Skip to content

Commit

Permalink
fix: fix issue with max() call on empty sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Oct 25, 2024
1 parent 253d0b7 commit 5410b30
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions robotoff/workers/tasks/import_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,14 +842,15 @@ def extract_nutrition_job(
return

output = nutrition_extraction.predict(image, ocr_result, triton_uri=triton_uri)
max_confidence = None

if output is None:
data: JSONType = {"error": "missing_text"}
max_confidence = None
else:
max_confidence = max(
entity["score"] for entity in output.entities.aggregated
)
if output.entities.aggregated:
max_confidence = max(
entity["score"] for entity in output.entities.aggregated
)
data = {
"nutrients": {
entity: dataclasses.asdict(nutrient)
Expand Down

0 comments on commit 5410b30

Please sign in to comment.