|
Download README.md from emiloetting/FoodCLS: direct link, hf CLI and curl.
- Browser
- Download file 2.62 kB
-
https://huggingface.co/emiloetting/FoodCLS/resolve/main/README.md
- Command line
-
hf download hf://emiloetting/FoodCLS/README.md
-
curl -L -o README.md https://huggingface.co/emiloetting/FoodCLS/resolve/main/README.md
2.62 kB
| pipeline_tag: text-classification | |
| language: | |
| - de | |
| - en | |
| tags: | |
| - food-classification | |
| - openfoodfacts | |
| - product-categorization | |
| - class-mapping | |
| # FoodCLS | |
| **FoodCLS** is to map product category tags from [OpenFoodFacts](https://world.openfoodfacts.org/) to a set of predefined, user-friendly food categories. | |
| The model uses the `categories_tags` attribute from the OpenFoodFacts product database to classify products into **12 broader food categories**. | |
| This allows for simplified product categorization, easier data aggregation, and more intuitive overviews of food products. | |
| ### Dataset | |
| The model is based on the [OpenFoodFacts Product Database](https://huggingface.co/datasets/openfoodfacts/product-database), using the state from **November 9, 2026**. | |
| ## Target Classes | |
| The model predicts one of 12 predefined categories. Each category is assigned a numeric class ID. | |
| | Class ID | German Category | English Equivalent | | |
| |:---:|---|---| | |
| | 0 | Obst & Gemüse | Fruits & Vegetables | | |
| | 1 | Fleisch, Fisch & Alternativen | Meat, Fish & Alternatives | | |
| | 2 | Milchprodukte & Eier | Dairy Products & Eggs | | |
| | 3 | Brot & Backwaren | Bread & Bakery Products | | |
| | 4 | Nudeln, Reis & Getreide | Pasta, Rice & Grains | | |
| | 5 | Fertigprodukte | Ready-Made Meals & Convenience Foods | | |
| | 6 | Backzutaten | Baking Ingredients | | |
| | 7 | Getränke | Beverages | | |
| | 8 | Snacks & Süßigkeiten | Snacks & Sweets | | |
| | 9 | Öle, Gewürze & Saucen | Oils, Spices & Sauces | | |
| | 10 | Brotaufstriche | Spreads | | |
| | 11 | Sonstiges | Other | | |
| ## Usage | |
| ### 1. Grab files | |
| First, download the `food_classifier.py` and `requirements.txt`. | |
| If you want to use only local files (and not rely on internet connection in ordedr to load weights), ensure to download all files and explicitly setting the `local_file_only` parameter when calling the `from_pretrained()`method! | |
| <br> | |
| ### 2. Install prerequisites | |
| Next, install the libraries required for running the model: | |
| ``` | |
| pip install -r requirements.txt | |
| ``` | |
| ### 3. Enjoy usage | |
| For example, like this: | |
| ```python | |
| from food_classifier import FoodClassifier | |
| classifier = FoodClassifier.from_pretrained("emiloetting/FoodCLS") | |
| category = classifier.predict( | |
| {"categories_tags": ["en:milks", "en:dairies"]}, | |
| string_classes=True) | |
| print(category) | |
| ``` | |
| When setting `string_classes`, the ouput will not be the integer class encoding but the respective string stored in the model's attribute `self.class_mapping` (a dictionary containing the integer-string mapping) | |
| ## About | |
| This model was made for use in a student project, aiming at providing an intuitive overview over food products. |