YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
CalorieCLIP ONNX
ONNX export of CalorieCLIP for food calorie estimation.
Models
| File | Size | Precision | Use Case |
|---|---|---|---|
calorie_clip_fp16.onnx |
170 MB | FP16 | Mobile/Edge (recommended) |
calorie_clip.onnx |
354 MB | FP32 | Desktop/Server |
Quick Start
import onnxruntime as ort
import numpy as np
from PIL import Image
CLIP_MEAN = np.array([0.48145466, 0.4578275, 0.40821073], dtype=np.float32)
CLIP_STD = np.array([0.26862954, 0.26130258, 0.27577711], dtype=np.float32)
def preprocess(image_path):
img = Image.open(image_path).convert('RGB').resize((224, 224))
arr = np.array(img, dtype=np.float32) / 255.0
arr = (arr - CLIP_MEAN) / CLIP_STD
arr = np.transpose(arr, (2, 0, 1))
return np.expand_dims(arr, axis=0)
session = ort.InferenceSession("calorie_clip_fp16.onnx")
image = preprocess("food.jpg")
calories = session.run(None, {"image": image})[0][0]
print(f"Calories: {calories:.0f}")
Scripts
inference_onnx.py- Run inference on imagesexport_onnx.py- Export PyTorch to ONNXquantize_onnx.py- Quantize to FP16 or INT8final_comparison.py- Compare model versions
Performance
| Model | MAE (cal) | Size | Use Case |
|---|---|---|---|
| FP16 | ~13.6 | 170 MB | Mobile (recommended) |
| FP32 | ~13.7 | 354 MB | Desktop/Server |
| INT8 | ~20 | 86 MB | Maximum compression |
- Inference time: ~35ms on CPU
- Input: 224x224 RGB image
- Output: single float (estimated calories)
References
- Base model: jc-builds/CalorieCLIP
- Trained on Nutrition5k dataset
- MAE: 51.4 cal on full test set (1951 samples)
- Downloads last month
- 48
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support