Skip to content

Commit

Permalink
fix: update barcode range check during insight import
Browse files Browse the repository at this point in the history
Don't check barcode range for insights generated from logos
(universal-logo-detector model) that were annotated manually
  • Loading branch information
raphael0202 committed Dec 6, 2022
1 parent 4229c94 commit 090c746
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions robotoff/insights/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,7 @@ def is_conflicting_insight(
return candidate.value_tag == reference.value_tag

@staticmethod
def is_valid(barcode: str, tag: str) -> bool:
def is_in_barcode_range(barcode: str, tag: str) -> bool:
brand_prefix: Set[Tuple[str, str]] = BRAND_PREFIX_STORE.get()

if not in_barcode_range(brand_prefix, tag, barcode):
Expand All @@ -875,7 +875,14 @@ def generate_candidates(
return

for prediction in predictions:
if not cls.is_valid(product.barcode, prediction.value_tag): # type: ignore
if not (
prediction.predictor == "universal-logo-detector"
and "username" in prediction.data
) and not cls.is_in_barcode_range(
product.barcode, prediction.value_tag # type: ignore
):
# Check barcode range for all predictors except logos detected using
# universal-logo-detector model and annotated manually
continue
insight = ProductInsight(**prediction.to_dict())
if insight.automatic_processing is None:
Expand Down

0 comments on commit 090c746

Please sign in to comment.