Skip to content
thlasagnaPublic

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Dieta — AI Fitness & Nutrition Coach

An AI-powered coaching platform that analyzes workout form in real time using computer vision, and estimates a meal's nutrition from a single photo.

Features

Live Workout Form Analysis

  • Real-time pose detection (17 body joints) via YOLOv8, with a live skeleton overlay
  • Supports Lunges and Push-ups, with exercise-specific angle and alignment checks
  • AI coaching feedback generated by Claude 3.5 Sonnet (via OpenRouter), based on live form metrics
  • Form score and status updates every 500ms–2s
  • GPU-accelerated inference (CUDA), with automatic CPU fallback
  • Multi-threaded pipeline — camera capture, inference, and AI calls run independently and never block each other

Meal Photo Analysis

  • Upload a photo (or text description) of a meal
  • Gemini 2.5 Flash identifies the foods and returns estimated calories, macros (protein / carbs / fat / fiber), and an eight-nutrient vitamin and mineral breakdown
  • A 1–10 health score, plus a plain-language explanation of what's good, neutral, or a concern about the meal
  • Weekly nutrient-category tracking (leafy greens, fatty fish, legumes, red meat) against target ranges, to encourage variety over time

Tech Stack

Layer Stack
Frontend Next.js 14, TypeScript, Tailwind CSS
Workout backend Flask (port 5000), OpenCV, YOLOv8 Nano, PyTorch
Workout AI Railtracks agent (port 5001) → OpenRouter → Claude 3.5 Sonnet
Meal analysis Next.js API route → Google Generative AI SDK → Gemini 2.5 Flash

Architecture

Next.js Frontend (Browser)
        │
        ├──────────────────────────────┐
        │                              │
Exercise Feed Server            Meal Analysis
(Flask, port 5000)               (Next.js API route)
+ Fitness Agent API                    │
(port 5001, OpenRouter)                │
        │                              │
   YOLO pose detection          Gemini 2.5 Flash
   + Claude coaching            (image or text → JSON)

Workout analysis runs on a local Flask + YOLO pipeline with a separate AI coaching service. Meal analysis is a single Next.js API route that sends the photo directly to Gemini and returns structured JSON — no local inference needed.

Setup

Prerequisites

  • Python 3.10+, Node.js 16+
  • Webcam (for workout analysis)
  • CUDA-capable GPU (optional — falls back to CPU)
  • OpenRouter API key (workout coaching) and Gemini API key (meal analysis)

Environment Variables

fitness_agent/.env.local:

OPENROUTER_API_KEY=your_openrouter_api_key_here

Project root .env.local:

GEMINI_API_KEY=your_gemini_api_key_here

Meal analysis returns a clear error if this key is missing.

Install & Run

# Python backends
cd exercise_feed && pip install -r requirements.txt
cd ../fitness_agent && pip install -r requirements.txt

# Node frontend
cd .. && npm install

Three terminals:

# Terminal 1 — workout pose/vision server
cd exercise_feed && python app.py        # http://127.0.0.1:5000

# Terminal 2 — workout AI coaching
cd fitness_agent && python api_server.py # http://127.0.0.1:5001

# Terminal 3 — frontend
npm run dev                              # http://localhost:3000

Project Structure

Dieta/
├── app/
│   ├── api/
│   │   ├── analyze-food/       # Meal photo analysis (Gemini)
│   │   ├── generate-workout/
│   │   └── suggest/
│   ├── lib/
│   │   ├── achievements.ts
│   │   ├── foodCategories.ts
│   │   ├── nutrientTargets.ts
│   │   ├── storage.ts
│   │   └── userProfile.ts
│   └── ...
├── components/                  # React components
├── exercise_feed/                # Flask backend — pose detection (port 5000)
│   └── app.py
├── fitness_agent/                 # AI coaching agent (port 5001)
│   ├── api_server.py
│   └── railtracks_agent.py
├── .railtracks/
└── README.md

Troubleshooting

Camera not working — check permissions, restart exercise_feed, confirm the webcam works in other apps.

No workout AI feedback — confirm fitness_agent is running on port 5001 and OPENROUTER_API_KEY is set.

Meal analysis failing — confirm GEMINI_API_KEY is set; the API returns "GEMINI_API_KEY not configured" if it's missing.

API Costs

  • Workout coaching: Claude 3.5 Sonnet via OpenRouter, ~$0.003/call, roughly 1 call every 1–2s during a session
  • Meal analysis: Gemini 2.5 Flash, billed per request through Google's API

Future Enhancements

  • More exercises (squats, deadlifts, pull-ups)
  • Rep/set counting
  • Meal history and trends over time
  • Mobile app version

Acknowledgments

YOLOv8 (Ultralytics) · OpenRouter · Google Generative AI (Gemini) · Railtracks · Next.js · Flask


Created by: GenAI Genesis Team

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages