maia2000's picture
Upload README.md with huggingface_hub
831b2b6 verified
---
license: apache-2.0
tags: [image-classification, food, binary-classification, vit, mobile]
---
# Binary Healthy/Unhealthy Food Classifier — ViT-B/16
Frozen ViT-B/16 + linear head. Trained on [ethz/food101](https://huggingface.co/datasets/ethz/food101).
## Test metrics
- accuracy: **0.8088**
- macro F1: **0.8033**
- ROC-AUC: **0.8854**
## Files
| File | Format | Use |
|---|---|---|
| `best.pth` | PyTorch state dict | training / fine-tuning |
| `model.torchscript.pt` | TorchScript | server / LibTorch |
| `model_mobile.ptl` | TorchScript Lite | **iOS / Android** (PyTorch Mobile) |
| `model.onnx` | ONNX | Core ML, TFLite (via onnx2tf), ONNX Runtime Mobile |
## Inference (Python)
```python
import torch, torchvision.transforms as T
from PIL import Image
m = torch.jit.load("model.torchscript.pt").eval()
tf = T.Compose([T.Resize((224,224)), T.ToTensor(),
T.Normalize([0.485,0.456,0.406],[0.229,0.224,0.225])])
img = tf(Image.open("food.jpg").convert("RGB")).unsqueeze(0)
probs = torch.softmax(m(img), dim=-1)[0]
print({"healthy": probs[0].item(), "unhealthy": probs[1].item()})
```