添加标准图像为None时候的判断

This commit is contained in:
2025-01-15 15:26:59 +08:00
parent 38d962cd59
commit 31db54fa37

View File

@ -112,7 +112,10 @@ def get_product_description(std_img, track_imgs):
} }
] ]
best_img = get_best_image(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) output_text = qwen_prompt(img_list, messages)
contrast_pair = ast.literal_eval(output_text.strip('```python\n')) contrast_pair = ast.literal_eval(output_text.strip('```python\n'))
@ -135,8 +138,10 @@ def main():
} }
track_imgs = stream_pipeline(stream_dict) track_imgs = stream_pipeline(stream_dict)
response = requests.get(stream_dict['goodsPic']) std_img = None
std_img = Image.open(BytesIO(response.content)) 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) description_dict = get_product_description(std_img, track_imgs)
print(description_dict) print(description_dict)