Aller au contenu
ModelPrésentéExterne
Télécharger

ConvNeXt Food CLF 75

512)->GELU->Dropout(0.3)->Linear(512->75)", "embeddingsize": 512, "activation": "GELU", "dropoutrate": 0.3 }, "dataset": { "name": "MM-Food-100K", "url": " "cleanedversion": "cleaned subset (75 classes, 88k images)",...

TypeOtherVersionRevision 5ab9d85BClasse

Source du modèle

Type
Other
Taille du fichier
108 MB
Version
vRevision 5ab9d85
Mis à jour
10 oct. 2026
Téléchargements
28
Source
Hugging Face

Description de la source

GitHub Repo License: Apache 2.0

F1 Macro mAP

HF Space

ConvNeXt-Food-CLF-75

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.


Model Description

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”).

  • Input: RGB image (any size, automatically resized to 640×640 and normalized with ImageNet statistics)
  • Output:
    • A list of ingredient names (default threshold 0.5)
    • Raw probability scores for each of the 75 classes
    • Optional: feature embedding from the penultimate layer (for transfer learning)

Supported Classes (75 ingredients)

almondcheese buttergrapeonionsauce
applechicken duckice creamorangesausage
asparaguschocolatejuicepastaseaweed
avocadocilantro mintkiwipeachshellfish
bananacoffeelambpeanutshrimp
beanscornlemonpearsoup
biscuitcrablettucepeasspring onion
breadcucumbermangopeppersprouts
broccolidatemeatpineapplesteak
cabbageeggmelonpizzastrawberry
cakeeggplantmilkporktea
carrotfishmushroompotatotofu
cashewfrench friesnoodlepumpkintomato
cauliflowergarlicokraricewatermelon
celery stickgingerolivessaladwonton dumplings

Intended Uses

  • Food ingredient classification into 75 categories independently or for downstream systems (calorie estimation, dietary logging, recipe retrieval).
  • Feature extraction: the embedding before the final layer can be fed into a segmentation network to condition mask prediction.
  • Research on multi‐label classification with long‐tail distributions and noisy training data.

Bias, Risks, and Limitations

  • Dataset bias: Trained on a cleaned subset of MM‐Food‐100K. It may underrepresent cuisines not well covered in that dataset.
  • Class imbalance: The smallest classes contain as few as ~100 training images; performance may be lower for those ingredients.
  • Ambiguity: Visually similar dishes (e.g., “apple” vs. “peach”) may be confused.
  • Hallucinations: The model can occasionally predict ingredients that are not visible, especially when cues are subtle or missing.

Recommendations

  • Always use the provided preprocessing pipeline (resize to 640×640, ImageNet normalization).
  • Consider using Test‐Time Augmentation (TTA) for critical applications.
  • Validate predictions against your own data distribution if you plan to deploy the model.

Out‐of‐Scope Use

  • Not intended for medical diagnosis or dietary prescription.
  • Not a zero‐shot classifier – it only covers the 75 classes listed above.

Training Procedure

Full training logs, hyperparameters, and stage‐by‐stage breakdown are in the GitHub model documentation.

Model Architecture

ComponentDetails
BackboneConvNeXt‐Tiny (pretrained on ImageNet‐1k)
AttentionCBAM (Channel + Spatial)
PoolingGeM (Generalized Mean) with learnable p
HeadLinear(1024 → 512) → GELU → Dropout(0.3) → Linear(512 → 75)
InputRGB image resized to 640×640
OutputMulti‐label logits (binary relevance per ingredient)

Training Configuration

ParameterValue
LossBCEWithLogitsLoss (class weights: background=1, others=30)
OptimizerAdamW (head LR=1e‐4, backbone LR=5e‐6)
SchedulerOneCycleLR (early stages), CosineAnnealingWarmRestarts (later)
Weight decay1e‐4
Batch size10
Input size640×640
MixUpp=0.5, α=0.2
Mixed precisionAMP (torch.amp)

Training Stages

  1. Feature Extraction (28 epochs): Only the classification head is trained, backbone frozen.
  2. Discriminative Fine‐Tuning (8 epochs): Head + stages 2‐3 of backbone unfrozen, lower LR for backbone.
  3. Staged Unfreezing (1 epoch): Head is trained again to adapt to newly unfrozen features.
  4. Final Feature Extraction (5 epochs): Only the classification head is trained at a low LR (5e‐5).

Stage‐by‐Stage Results

StageEpochF1 (macro)mAPVal Loss
Feature Extraction280.35330.50670.0637
Discriminative Fine‐Tuning360.61210.70170.0469
Staged Unfreezing370.64260.70970.0479
Final Feature Extraction400.65460.71420.0489

Evaluation Results (Final Model)

MetricValue
Macro F10.6546
mAP0.7142
Validation loss0.0489

Validation set: 2,000 fixed images, split before training.


Hardware and Training Time

ComponentDetail
GPUNVIDIA RTX 2060 (6 GB VRAM)
CPUIntel Xeon E5‐2660 v3
OSCachyOS (Arch‐based)
Python3.10+
PyTorch2.5
timm1.0.9
Training time≈1 hour per epoch
Batch size10
Mixed precisionAMP

Despite the limited 6 GB VRAM, the model trains comfortably with a batch size of 10 at 640×640 resolution.


Dataset

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:

  • Manually curated target class list (103 initial classes).
  • Extracted all matching ingredient names from the dataset.
  • Merged semantically identical ingredients (e.g., “enoki mushrooms” + “shiitake mushrooms” → “mushroom”).
  • Removed irrelevant matches (e.g., “cheesecake” for the “cheese” class).
  • Filtered out classes with fewer than 100 images.
  • Created multi‐hot label vectors and serialized the final dataset.

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


How to Use

👉 Try it live on Spaces - no installation required!

Quick inference using the provided script (recommended)

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...

Sources

1 source
Hugging FacePrincipalVersion 5ab9d85163f8a140b18d288dcec5a4e51b1328c0
huggingface.co/Alas-V/ConvNeXt-Food-CLF-75/tree/5ab9d85163f8a140b18d288dcec5a4e51b1328c0

Vérifié 10 oct.

Artefacts du modèle

2 artefacts

model.safetensors

safetensors · 108 MB · SHA-256 301c2942fe22…009d · Hugging Face

Télécharger

pytorch_model.bin

bin · 108 MB · SHA-256 9e077167143f…10eb · Hugging Face

Télécharger

Extraits de sources

3 extraits

--- license: apache-2.0 datasets: - Codatta/MM-Food-100K - Humanbased-AI/MM-Food-100K metrics: - f1 - map - precision - accuracy base_model: - timm/convnext_tiny pipeline_tag: image-classification tags: - machine-learning - computer-vision - architecture - cnn - pytorch - classification - image-classification - food-classification - f1-score - precision - convnext - convnext-tiny - food-ai - multi-class-classification - multi-label-classification - multi-label-image-classification - multi-label - food-recognition - fine-tuning - feature-extraction - embeddings - transfer-learning - transfer-learning-with-cnn - attention-mechanism - cbam - cbam-cnn - cbam-attention - gem-pooling - food-ingredients - food-dataset - dataset-preparation - mm-food-100k - dataset-cleaning - cpu-inference - gpu-inference - huggingface - huggingface-models - huggingface-hub - model-hub - ml - ml-model - ml-architecture - model-architecture - inference - model-optimization - backbone - pretrained-model - pretrained-weights - imagenet-pretrained - timm-library - torchvision - foodtech - benchmark - research - production - deployment - open-source language: - en library_name: timm model-index: - name: ConvNeXt-Food-CLF-75 results: - task: type: image-classification name: Multi-label Image Classification dataset: type: Codatta/MM-Food-100K name: MM-Food-100K (cleaned subset, 75 classes, ~88k images) metrics: - type: macro_f1 value: 0.6546 name: Macro F1-score - type: mAP value: 0.7142 name: Mean Average Precision - type: val_loss value: 0.0489 name: Validation Loss --- <!-- METRICS: Macro F1=0.6546, mAP=0.7142, Val Loss=0.0489 --> <!-- { "model_name": "ConvNeXt-Food-CLF-75", "version": "1.0.0", "author": "Artem V.", "license": "Apache-2.0", "date_created": "2026-06-12", "framework": "PyTorch 2.5", "task": "multi-label-image-classification", "classes_count": 75, "input_size": "640x640", "output_format": "ingredient names + probabilities (threshold 0.5)", "model_architecture": { "backbone": "ConvNeXt-Tiny (ImageNet-1k pretrained)", "attention": "CBAM (Channel + Spatial)", "pooling": "GeM (learnable p)", "head": "Linear(1024->512)->GELU->Dropout(0.3)->Linear(512->75)", "embedding_size": 512, "activation": "GELU", "dropout_rate": 0.3 }, "dataset": { "name": "MM-Food-100K", "url": "https://huggingface.co/datasets/Codatta/MM-Food-100K", "cleaned_ve...

Source context: 28 downloads · 1 likes · Pipeline image-classification · Library timm · Repo Alas-V/ConvNeXt-Food-CLF-75

Source context: 337 downloads · 1 likes · Pipeline image-classification · Library timm · Repo Alas-V/ConvNeXt-Food-CLF-75