Skip to content

Commit

Permalink
feat(nutrisight): add a demo that can be run as-it
Browse files Browse the repository at this point in the history
  • Loading branch information
raphael0202 committed Dec 27, 2024
1 parent 09fda19 commit 610d4fd
Show file tree
Hide file tree
Showing 3 changed files with 842 additions and 122 deletions.
36 changes: 36 additions & 0 deletions nutrisight/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,42 @@ Then, we analyzed where the model predictions differed from the annotations, to

The model is also available on [Hugging Face](https://huggingface.co/openfoodfacts/nutrition-extractor).

You can easily test the model by running the `demo.py` script. The requirements are described as metadata at the top of the file, and
the script can be run using [uv](https://docs.astral.sh/uv/) in a single step:

```bash
$ uv run demo.py https://images.openfoodfacts.org/images/products/406/826/203/8564/2.jpg

Reading inline script metadata from `demo.py`
Running nutrition extraction model on:
image URL: https://images.openfoodfacts.org/images/products/406/826/203/8564/2.jpg
OCR URL: https://images.openfoodfacts.org/images/products/406/826/203/8564/2.json

Nutrient predictions
--------------------
serving_size 45 g (score: 0.999)
energy-kj_100g 1928 kj (score: 0.999)
energy-kj_serving 868 kj (score: 0.998)
energy-kcal_100g 460 kcal (score: 0.999)
energy-kcal_serving 207 kcal (score: 0.998)
fat_100g 18 g (score: 0.999)
fat_serving 8.0 g (score: 0.998)
saturated-fat_100g 5.3 g (score: 0.999)
saturated-fat_serving 2.4 g (score: 0.998)
carbohydrates_100g 62 g (score: 0.999)
carbohydrates_serving 28 g (score: 0.998)
sugars_100g 22 g (score: 0.999)
sugars_serving 9.8 g (score: 0.998)
fiber_100g 7.3 g (score: 0.998)
fiber_serving 3.3 g (score: 0.997)
proteins_100g 9.3 g (score: 0.999)
proteins_serving 4.2 g (score: 0.997)
salt_100g 0.08 g (score: 0.999)
salt_serving 0.04 g (score: 0.998)
```

If you don't provide an Open Food Facts image, you should also provide the URL of the OCR result generated by Google Cloud Vision.

## Dataset management

Every script related to dataset management and generation is located in the `dataset` directory:
Expand Down
122 changes: 0 additions & 122 deletions nutrisight/cli.py

This file was deleted.

Loading

0 comments on commit 610d4fd

Please sign in to comment.