efficientnet_b4_cbam — Food-101
Food image classifier trained with food_recognition. efficientnet_b4_cbam is a torchvision backbone with a CBAM block (channel then spatial attention) between the features and the classification head.
Measured performance
| Metric | Value |
|---|---|
| Validation accuracy | 89.11% |
| Macro F1 | 0.8907 |
| Classes | 101 |
| Input resolution | 224px |
| Checkpoint epoch | 24 |
| Training wall clock | 671 min |
| Hardest / easiest class | steak (F1 0.636) / edamame (F1 0.994) |
These figures come from this run's own metrics.json, computed over the full validation split. The repository re-scores every published checkpoint through a separate evaluation path and requires the two to agree to six decimal places.
Usage
pip install git+https://github.com/linhongyu510/food_recognition.git
from huggingface_hub import hf_hub_download
from food_recognition import load_predictor
checkpoint = hf_hub_download("hylin16/food-recognition-food101-effnet-b4-cbam", "best.pt")
predictor = load_predictor(checkpoint)
prediction = predictor.predict("photo.jpg", topk=3)
print(prediction.label, prediction.topk)
The checkpoint embeds its architecture, input resolution and class names, so nothing needs to be specified again at load time.
To see which pixels drove a prediction:
food-recognition-gradcam --checkpoint best.pt --input photo.jpg --side-by-side
Training
- Architecture:
efficientnet_b4_cbam - Input: 224px
- Epochs: 30
- Batch size: 64
- Learning rate: 0.0003
- Scheduler: cosine
- Fully supervised (no pseudo-labelling)
- Source commit:
baf1b5e
Limitations
- Trained on Food-101 only. Accuracy on dishes, cuisines or photographic conditions outside that distribution is unmeasured, and the model will still return a confident label for an image containing no food at all.
- Predictions are not a nutrition, allergen or food-safety judgement. Do not use them where a misclassification carries a health risk.
- The reported figure is validation accuracy on a public benchmark split, which is an optimistic estimate of field performance.
Dataset licence
Food-101 consists of Foodspotting images that are not the property of ETH Zurich; the dataset terms allow scientific fair use, and any use beyond that must be negotiated with the picture owners. These weights are a derivative of that data and are released for research use under the same understanding.