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)