From 68cc43dbc8156892264187e8f6a4f96f5f8f554f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bournhonesque?= Date: Mon, 24 Jun 2024 10:19:51 +0200 Subject: [PATCH] fix: don't select nutrition image if one has already been selected (#1348) --- robotoff/insights/annotate.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/robotoff/insights/annotate.py b/robotoff/insights/annotate.py index c75a6617c4..f403f97591 100644 --- a/robotoff/insights/annotate.py +++ b/robotoff/insights/annotate.py @@ -623,6 +623,12 @@ def process_annotation( description="the image is invalid", ) + image_key = f"nutrition_{insight.value_tag}" + # We don't want to select the nutrition image if one has already been + # selected + if image_key in images: + return ALREADY_ANNOTATED_RESULT + rotation = insight.data.get("rotation", 0) crop_bounding_box: Optional[tuple[float, float, float, float]] = None if "bounding_box" in insight.data: @@ -635,7 +641,6 @@ def process_annotation( insight.data["bounding_box"], width, height, rotation ) - image_key = f"nutrition_{insight.value_tag}" select_rotate_image( product_id=product_id, image_id=image_id,