Skip to content

Commit

Permalink
fix: fix category predictions
Browse files Browse the repository at this point in the history
- the nutriment properties were not the right one in schema.py
- we have to use V2 of Product Opener API to get nested ingredients,
  otherwise 3.0 models underperform
  • Loading branch information
raphael0202 committed Feb 28, 2023
1 parent f86c098 commit 347c72c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions robotoff/app/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@
"nutriments": {
"type": "object",
"properties": {
"fat": {"type": "number"},
"saturated_fat": {"type": "number"},
"carbohydrates": {"type": "number"},
"sugars": {"type": "number"},
"fiber": {"type": "number"},
"proteins": {"type": "number"},
"salt": {"type": "number"},
"energy_kcal": {"type": "number"},
"fruits_vegetables_nuts": {"type": "number"},
"fat_100g": {"type": "number"},
"saturated-fat_100g": {"type": "number"},
"carbohydrates_100g": {"type": "number"},
"sugars_100g": {"type": "number"},
"fiber_100g": {"type": "number"},
"proteins_100g": {"type": "number"},
"salt_100g": {"type": "number"},
"energy-kcal_100g": {"type": "number"},
"fruits-vegetables-nuts_100g": {"type": "number"},
},
"additionalProperties": False,
},
Expand Down
4 changes: 3 additions & 1 deletion robotoff/off.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@ def get_product_image_select_url(server: Union[ServerType, str]) -> str:


def get_api_product_url(server: Union[ServerType, str]) -> str:
return "{}/api/v0/product".format(get_base_url(server))
# V2 of API is required to have proper ingredient nesting
# for product categorization
return "{}/api/v2/product".format(get_base_url(server))


def get_base_url(server: Union[ServerType, str]) -> str:
Expand Down

0 comments on commit 347c72c

Please sign in to comment.