From 31db54fa3715e6ed4735d585bbbb692eff713251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=8F=88=E7=BB=B4?= <591343188@qq.com> Date: Wed, 15 Jan 2025 15:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=87=E5=87=86=E5=9B=BE?= =?UTF-8?q?=E5=83=8F=E4=B8=BANone=E6=97=B6=E5=80=99=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Qwen_agent.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Qwen_agent.py b/Qwen_agent.py index 7b168af..8d57792 100644 --- a/Qwen_agent.py +++ b/Qwen_agent.py @@ -112,7 +112,10 @@ def get_product_description(std_img, track_imgs): } ] best_img = get_best_image(track_imgs) - img_list = [std_img, best_img] + if std_img is not None: + img_list = [std_img, best_img] + else: + img_list = [best_img, best_img] output_text = qwen_prompt(img_list, messages) contrast_pair = ast.literal_eval(output_text.strip('```python\n')) @@ -135,8 +138,10 @@ def main(): } track_imgs = stream_pipeline(stream_dict) - response = requests.get(stream_dict['goodsPic']) - std_img = Image.open(BytesIO(response.content)) + std_img = None + if stream_dict['goodsPic'] is not None: + response = requests.get(stream_dict['goodsPic']) + std_img = Image.open(BytesIO(response.content)) description_dict = get_product_description(std_img, track_imgs) print(description_dict)