Spaces:
Sleeping
title: FitGenie CalorieCLIP
emoji: π
colorFrom: green
colorTo: blue
sdk: docker
app_port: 8000
pinned: false
license: mit
short_description: Instant food calorie estimate API for FitGenie (~51 MAE)
FitGenie CalorieCLIP
Free-to-host instant calorie estimate from food photos for the FitGenie nutrition app.
| Model | jc-builds/CalorieCLIP (CLIP ViT-B/32 + regression) |
| Output | Calories only (not protein/carbs/fat) |
| Speed | ~50β200 ms on CPU |
| Cost | $0 on Hugging Face Spaces free tier |
One-click deploy on Hugging Face (free)
Step 1 β Create the Space
- Go to huggingface.co/new-space
- Fill in:
- Owner: your username
- Space name:
fitgenie-calorie-clip(or any name) - License: MIT
- SDK: Docker
- Hardware: CPU basic (free β 16 GB RAM)
- Click Create Space
Step 2 β Upload these files
Upload the contents of fitgenie_calorie_clip/ to the Space repo:
app.py
model_core.py
gradio_app.py
Dockerfile
requirements.txt
README.md β this file (frontmatter configures the Space)
Or connect your GitHub repo and set the Space to sync from fitgenie_calorie_clip/.
Step 3 β Wait for build
First build takes 5β15 minutes (downloads CLIP + CalorieCLIP weights).
When status is Running, your API base URL is:
https://YOUR-USERNAME-fitgenie-calorie-clip.hf.space
Step 4 β Test
curl https://YOUR-USERNAME-fitgenie-calorie-clip.hf.space/health
# β {"status":"ok","model":"CalorieCLIP"}
curl -X POST https://YOUR-USERNAME-fitgenie-calorie-clip.hf.space/predict \
-H "Content-Type: application/json" \
-d '{"image":"'$(base64 -i food.jpg | tr -d '\n')'"}'
# β {"calories":342}
Step 5 β Wire to FitGenie backend
On Render β your fitgenie-backend service β Environment:
CALORIE_CLIP_URL=https://YOUR-USERNAME-fitgenie-calorie-clip.hf.space/predict
CALORIE_CLIP_API_KEY=choose-a-secret-string
FOOD_ANALYSIS_PROVIDER=gpt
OPENAI_API_KEY=sk-...
On the HF Space β Settings β Variables:
CALORIE_CLIP_API_KEY=same-secret-as-backend
Redeploy backend. Photo flow will show real kcal estimates instead of ~400 fallback.
Step 6 β Keep Space awake (optional, free)
Free Spaces sleep after 48 hours of no traffic.
- Sign up at uptimerobot.com (free)
- Add monitor: URL
https://YOUR-SPACE.hf.space/health, interval 30 min
Optional: Gradio demo Space (browser UI)
For a visual demo (no API), create a second Space:
| Setting | Value |
|---|---|
| SDK | Gradio |
| Hardware | CPU basic |
| App file | gradio_app.py |
Use this README frontmatter instead:
---
title: FitGenie CalorieCLIP Demo
sdk: gradio
sdk_version: 4.44.1
app_file: gradio_app.py
hardware: cpu-basic
---
API reference
| Endpoint | Method | Body | Response |
|---|---|---|---|
/health |
GET | β | { "status": "ok", "model": "CalorieCLIP" } |
/predict |
POST | { "image": "<base64>" } |
{ "calories": 342 } |
Optional header: X-API-Key: your-secret (when CALORIE_CLIP_API_KEY is set).
Environment variables
| Variable | Default | Description |
|---|---|---|
CALORIE_CLIP_API_KEY |
(empty) | Require X-API-Key header |
CALORIE_CLIP_MODEL_REPO |
jc-builds/CalorieCLIP |
HuggingFace weights repo |
MAX_IMAGE_BYTES |
8388608 |
Max upload size (8 MB) |
Limits (free tier)
| Topic | Detail |
|---|---|
| Indian food | Weak β trained on US cafeteria + 2 Indian Food-101 classes |
| Macros | Not supported β use GPT-4o or fitgenie_food_analysis for P/C/F |
| Thali / multi-item | Poor β single calorie number for whole image |
| Sleep | After 48h idle β use UptimeRobot |
Local dev
pip install -r requirements.txt
uvicorn app:app --reload --port 8000
# or visual demo:
python gradio_app.py
License
MIT (service code) Β· CalorieCLIP model MIT Β· FitGenie integration