Binary Healthy/Unhealthy Food Classifier โ ViT-B/16
Frozen ViT-B/16 + linear head. Trained on 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)
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()})