加载中…
加载中…
Multi‑label food ingredient classifier (75 classes) based on ConvNeXt‑Tiny with CBAM attention and GeM pooling.
Trained on a heavily cleaned subset of MM‑Food‑100K.
The model serves as a semantic guide for a downstream segmentation pipeline, but can also be used standalone for ingredient recognition.
📊 Key Metrics: Macro F1 = 0.6546 | mAP = 0.7142 | Validation Loss = 0.0489
💡 Full source code, training scripts, and detailed dataset preparation are available in the GitHub repository.
This model card focuses on how to use the model. For deeper technical details, see the links throughout or visit the GitHub repo.
ConvNeXt-Food-CLF-75 takes an RGB food image and predicts which of 75 ingredients it contains.
Each prediction is a multi‑label probability – a dish can contain multiple ingredients simultaneously (e.g., “rice” and “chicken”).
| almond | cheese butter | grape | onion | sauce |
| apple | chicken duck | ice cream | orange | sausage |
| asparagus | chocolate | juice | pasta | seaweed |
| avocado | cilantro mint | kiwi | peach | shellfish |
| banana | coffee | lamb | peanut | shrimp |
| beans | corn | lemon | pear | soup |
| biscuit | crab | lettuce | peas | spring onion |
| bread | cucumber | mango | pepper | sprouts |
| broccoli | date | meat | pineapple | steak |
| cabbage | egg | melon | pizza | strawberry |
| cake | eggplant | milk | pork | tea |
| carrot | fish | mushroom | potato | tofu |
| cashew | french fries | noodle | pumpkin | tomato |
| cauliflower | garlic | okra | rice | watermelon |
| celery stick | ginger | olives | salad | wonton dumplings |
Full training logs, hyperparameters, and stage‑by‑stage breakdown are in the GitHub model documentation.
| Component | Details |
|---|---|
| Backbone | ConvNeXt‑Tiny (pretrained on ImageNet‑1k) |
| Attention | CBAM (Channel + Spatial) |
| Pooling | GeM (Generalized Mean) with learnable p |
| Head | Linear(1024 → 512) → GELU → Dropout(0.3) → Linear(512 → 75) |
| Input | RGB image resized to 640×640 |
| Output | Multi‑label logits (binary relevance per ingredient) |
| Parameter | Value |
|---|---|
| Loss | BCEWithLogitsLoss (class weights: background=1, others=30) |
| Optimizer | AdamW (head LR=1e‑4, backbone LR=5e‑6) |
| Scheduler | OneCycleLR (early stages), CosineAnnealingWarmRestarts (later) |
| Weight decay | 1e‑4 |
| Batch size | 10 |
| Input size | 640×640 |
| MixUp | p=0.5, α=0.2 |
| Mixed precision | AMP (torch.amp) |
| Stage | Epoch | F1 (macro) | mAP | Val Loss |
|---|---|---|---|---|
| Feature Extraction | 28 | 0.3533 | 0.5067 | 0.0637 |
| Discriminative Fine‑Tuning | 36 | 0.6121 | 0.7017 | 0.0469 |
| Staged Unfreezing | 37 | 0.6426 | 0.7097 | 0.0479 |
| Final Feature Extraction | 40 | 0.6546 | 0.7142 | 0.0489 |
| Metric | Value |
|---|---|
| Macro F1 | 0.6546 |
| mAP | 0.7142 |
| Validation loss | 0.0489 |
Validation set: 2,000 fixed images, split before training.
| Component | Detail |
|---|---|
| GPU | NVIDIA RTX 2060 (6 GB VRAM) |
| CPU | Intel Xeon E5‑2660 v3 |
| OS | CachyOS (Arch‑based) |
| Python | 3.10+ |
| PyTorch | 2.5 |
| timm | 1.0.9 |
| Training time | ≈1 hour per epoch |
| Batch size | 10 |
| Mixed precision | AMP |
Despite the limited 6 GB VRAM, the model trains comfortably with a batch size of 10 at 640×640 resolution.
The model was trained on a cleaned subset of MM‑Food‑100K, a large‑scale food dataset with noisy 4,000+ ingredient labels.
A rigorous multi‑step cleaning pipeline reduced the original chaos to 75 balanced classes:
Result: ~88k images (86.3k train, 2k validation), 75 classes.
🔗 The complete cleaning pipeline with all scripts and documentation is here:dataset_preparation/ on GitHub
👉 Try it live on Spaces - no installation required!
The repository includes a self‑contained inference.py script. First, clone this HF repo or download the files, then:
Linux / MacOS:
git clone https://huggingface.co/Alas-V/ConvNeXt-Food-CLF-75
cd ConvNeXt-Food-CLF-75
python -m venv venv
source venv/bin/activate
pip install -r requirements-inference.txt
python -m model.inference --image path/to/meal.jpg --checkpoint pytorch_model.bin --mode text
for Windows
git clone https://huggingface.co/Alas-V/ConvNeXt-Food-CLF-75
cd ConvNeXt-Food-CLF-75
python -m venv venv
.\venv\Scripts\Activate
pip install -r requirements-inference.txt
python -m model.inference --image path/to/photo.jpg --checkpoint checkpoint.pth.tar
| Argument | Description | Default |
|---|---|---|
| --image | Path to an image or a folder | required |
| --checkpoint | Path to the model checkpoint | required |
| --threshold | Confidence threshold (0.0–1.0) | 0.5 |
| --mode | text prints ingredients, image saves annotated photo | text |
| --output_dir | Folder for annotated images (only with --mode image) | predictions |
| --device | cuda or cpu | cuda if available, else cpu |
MM‑Food‑100K for the original dataset.
timm for the ConvNeXt backbone.
Albumentations for image augmentations.
If you use this model or the cleaned dataset in your work, please cite it as follows:
@misc{alasv2026convnextfoodclf75,
author = {Artem V.},
title = {ConvNeXt-Food-CLF-75: A Multi-Label Food Ingredient Classifier},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Alas-V/ConvNeXt-Food-CLF-75}},
note = {Model trained on a cleaned subset of MM-Food-100K}
}
This project is licensed under the Apache 2.0 License. See the LICENSE file for details.