jc-builds / CalorieCLIP

huggingface.co
Total runs: 50
24-hour runs: 1
7-day runs: -11
30-day runs: -2
Model's Last Updated: March 20 2026
image-to-text

Introduction of CalorieCLIP

Model Details of CalorieCLIP

๐ŸŽ CalorieCLIP: Accurate Food Calorie Estimation

CalorieCLIP vs Other Models

CalorieCLIP is a fine-tuned CLIP model that estimates calories from food images with state-of-the-art accuracy. It outperforms all tested VLMs (including GPT-4o and Claude) while running entirely on-device.

๐ŸŽฏ Key Results
Metric Value
Mean Absolute Error 51.4 calories
Within 50 calories 67.6%
Within 100 calories 90.5%
Inference Speed <50ms on M1 Mac

Accuracy Breakdown

๐Ÿฝ๏ธ Example Predictions

Real predictions from our validation set across multiple datasets:

Image Food Dataset Actual Predicted Error
Example 1 Hamburger Food-101 558 555 3
Example 2 Ramen Food-101 431 437 6
Example 3 Greek Salad Food-101 144 143 1
Example 4 Sashimi Food-101 156 156 0
Example 5 Cafeteria Meal Nutrition5k 88 88 0
Example 6 Cafeteria Meal Nutrition5k 138 138 0
Example 7 Cafeteria Meal Nutrition5k 330 334 3
Example 8 Cafeteria Meal Nutrition5k 214 217 4
๐Ÿš€ Quick Start
Installation
pip install open-clip-torch torch pillow
Python Usage
# Clone or download this repo first, then:
from calorie_clip import CalorieCLIP

# Load model from local directory
model = CalorieCLIP.from_pretrained(".")

# Predict calories
calories = model.predict("food_photo.jpg")
print(f"Estimated: {calories:.0f} calories")

# Batch prediction
images = ["breakfast.jpg", "lunch.jpg", "dinner.jpg"]
results = model.predict_batch(images)
Direct Usage (no wrapper)
import torch
import open_clip
from PIL import Image

# Load CLIP
clip, _, preprocess = open_clip.create_model_and_transforms('ViT-B-32', pretrained='openai')
checkpoint = torch.load('calorie_clip.pt', map_location='cpu', weights_only=False)
clip.load_state_dict(checkpoint['clip_state'], strict=False)

# Load regression head
import torch.nn as nn
class RegressionHead(nn.Module):
    def __init__(self):
        super().__init__()
        self.net = nn.Sequential(
            nn.Linear(512, 512), nn.BatchNorm1d(512), nn.ReLU(), nn.Dropout(0.4),
            nn.Linear(512, 256), nn.BatchNorm1d(256), nn.ReLU(), nn.Dropout(0.3),
            nn.Linear(256, 64), nn.ReLU(), nn.Linear(64, 1)
        )
    def forward(self, x): return self.net(x)

head = RegressionHead()
head.load_state_dict(checkpoint['regressor_state'])
clip.eval(); head.eval()

# Predict
img = preprocess(Image.open('food.jpg')).unsqueeze(0)
with torch.no_grad():
    features = clip.encode_image(img)
    calories = head(features).item()
print(f"{calories:.0f} calories")
Command Line
python calorie_clip.py my_food_image.jpg
# Output: my_food_image.jpg: 342 calories
๐Ÿ“Š Training Progress

Training Progress

The model was trained for 30 epochs on the Nutrition5k dataset with:

  • Huber Loss for robustness to outliers
  • Strong augmentation (rotation, color jitter, flips)
  • Fine-tuning last 2 CLIP transformer blocks (9.4% of parameters)
  • Differential learning rates (1e-5 for CLIP, 1e-3 for regression head)
๐Ÿ”ฌ Technical Details
Architecture
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Food Image    โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  CLIP ViT-B  โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚  Regression โ”‚โ”€โ”€โ”€โ”€โ–ถ Calories
โ”‚   (224ร—224)     โ”‚     โ”‚   Encoder    โ”‚     โ”‚    Head     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  (fine-tuned)โ”‚     โ”‚  (4 layers) โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                              โ–ผ
                        512-dim features
Model Specs
  • Base Model : OpenAI CLIP ViT-B/32
  • Fine-tuned Layers : Last 2 transformer blocks + regression head
  • Trainable Parameters : 9.4% (8.5M of 90M)
  • Input Size : 224ร—224 RGB
  • Output : Single float (calories)
Comparison to VLMs

We tested multiple Vision-Language Models on the same test set:

Error Distribution

Model MAE Notes
CalorieCLIP (Ours) 51.4 Local, fast, accurate
Claude 3.5 Sonnet 71.7 API required
GPT-4o 80.2 API required
Gemini 1.5 Pro 86.7 API required
GPT-4o-mini 88.7 API required
Qwen2-VL-7B (Local) 160.7 Mode collapse issues

Key Finding : All tested local VLMs (Qwen, Pixtral) suffered from mode collapse, outputting the same calorie value for all images. CalorieCLIP's regression approach avoids this entirely.

๐Ÿ“ Files
CalorieCLIP/
โ”œโ”€โ”€ config.json           # Model configuration
โ”œโ”€โ”€ calorie_clip.pt       # Model weights (PyTorch)
โ”œโ”€โ”€ calorie_clip.py       # Inference code
โ”œโ”€โ”€ requirements.txt      # Dependencies
โ””โ”€โ”€ assets/
    โ”œโ”€โ”€ training_progress.png
    โ”œโ”€โ”€ model_comparison.png
    โ”œโ”€โ”€ accuracy_breakdown.png
    โ””โ”€โ”€ error_distribution.png
๐Ÿ“‹ Training Data

Trained on a combined dataset of:

  • Nutrition5k : 5,006 real cafeteria food images with professional calorie measurements
  • Food-101 subset : 8,000+ food images with estimated calories
  • Total: 13,004 samples (11,053 train / 1,951 validation)
  • Diverse foods : beignets, prime rib, ramen, hamburgers, bruschetta, chicken wings, pork chops, greek salads, sashimi, and more
โš ๏ธ Limitations
  • Trained on cafeteria food; may be less accurate for restaurant/home-cooked meals
  • Single-dish focused; complex multi-item plates may have higher error
  • Portion size estimation is inherently challenging from 2D images
  • Not a replacement for professional nutrition advice
๐Ÿ™ Citation
@software{calorieclip2024,
  author = {Haplo LLC},
  title = {CalorieCLIP: Accurate Food Calorie Estimation from Images},
  year = {2024},
  url = {https://huggingface.co/jc-builds/CalorieCLIP}
}
๐Ÿ“„ License

MIT License - free for commercial and personal use.


Made with โค๏ธ by Haplo LLC

Runs of jc-builds CalorieCLIP on huggingface.co

50
Total runs
1
24-hour runs
1
3-day runs
-11
7-day runs
-2
30-day runs

More Information About CalorieCLIP huggingface.co Model

More CalorieCLIP license Visit here:

https://choosealicense.com/licenses/mit

CalorieCLIP huggingface.co

CalorieCLIP huggingface.co is an AI model on huggingface.co that provides CalorieCLIP's model effect (), which can be used instantly with this jc-builds CalorieCLIP model. huggingface.co supports a free trial of the CalorieCLIP model, and also provides paid use of the CalorieCLIP. Support call CalorieCLIP model through api, including Node.js, Python, http.

jc-builds CalorieCLIP online free

CalorieCLIP huggingface.co is an online trial and call api platform, which integrates CalorieCLIP's modeling effects, including api services, and provides a free online trial of CalorieCLIP, you can try CalorieCLIP online for free by clicking the link below.

jc-builds CalorieCLIP online free url in huggingface.co:

https://huggingface.co/jc-builds/CalorieCLIP

CalorieCLIP install

CalorieCLIP is an open source model from GitHub that offers a free installation service, and any user can find CalorieCLIP on GitHub to install. At the same time, huggingface.co provides the effect of CalorieCLIP install, users can directly use CalorieCLIP installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

CalorieCLIP install url in huggingface.co:

https://huggingface.co/jc-builds/CalorieCLIP

Url of CalorieCLIP

CalorieCLIP huggingface.co Url

Provider of CalorieCLIP huggingface.co

jc-builds
ORGANIZATIONS

Other API from jc-builds

huggingface.co

Total runs: 16
Run Growth: 5
Growth Rate: 31.25%
Updated:July 03 2026