From 12882db30fcedf89e852531ec452d7a5975881bb Mon Sep 17 00:00:00 2001 From: "pixeebot[bot]" <104101892+pixeebot[bot]@users.noreply.github.com> Date: Sun, 24 Mar 2024 18:25:20 +0000 Subject: [PATCH] Simplify Boolean Expressions Using `startswith` and `endswith` --- llava/eval/run_llava.py | 2 +- llava/eval/summarize_gpt_review.py | 2 +- llava/serve/cli.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/llava/eval/run_llava.py b/llava/eval/run_llava.py index 11bebda..d08f745 100644 --- a/llava/eval/run_llava.py +++ b/llava/eval/run_llava.py @@ -15,7 +15,7 @@ def load_image(image_file): - if image_file.startswith('http') or image_file.startswith('https'): + if image_file.startswith(('http', 'https')): response = requests.get(image_file) image = Image.open(BytesIO(response.content)).convert('RGB') else: diff --git a/llava/eval/summarize_gpt_review.py b/llava/eval/summarize_gpt_review.py index 0f796a3..bf07ab5 100644 --- a/llava/eval/summarize_gpt_review.py +++ b/llava/eval/summarize_gpt_review.py @@ -25,7 +25,7 @@ def parse_args(): if len(args.files) > 0: review_files = args.files else: - review_files = [x for x in os.listdir(args.dir) if x.endswith('.jsonl') and (x.startswith('gpt4_text') or x.startswith('reviews_') or x.startswith('review_') or 'review' in args.dir)] + review_files = [x for x in os.listdir(args.dir) if x.endswith('.jsonl') and (x.startswith(('gpt4_text', 'reviews_')) or x.startswith('review_') or 'review' in args.dir)] for review_file in sorted(review_files): config = os.path.basename(review_file).replace('gpt4_text_', '').replace('.jsonl', '') diff --git a/llava/serve/cli.py b/llava/serve/cli.py index 9898e77..818a506 100644 --- a/llava/serve/cli.py +++ b/llava/serve/cli.py @@ -16,7 +16,7 @@ def load_image(image_file): - if image_file.startswith('http://') or image_file.startswith('https://'): + if image_file.startswith(('http://', 'https://')): response = requests.get(image_file) image = Image.open(BytesIO(response.content)).convert('RGB') else: