Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
6.3.0
metadata
title: AI Diet Planner & Nutrition Assistant
emoji: π½οΈ
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: mit
short_description: AI-powered diet planning with nutrition analysis
π½οΈ AI Diet Planner & Nutrition Assistant
An intelligent diet planning application that uses RAG (Retrieval-Augmented Generation) technology to provide personalized nutrition advice, meal planning, and dietary recommendations.
β¨ Features
π― Personalized Diet Planning
- Weekly Meal Plans: Complete 7-day diet plans with detailed meal breakdowns
- Daily Nutrition: Individual day meal planning with macro and micronutrient analysis
- Customizable Parameters: Age, weight, height, activity level, and dietary preferences
π Nutrition Analysis
- Comprehensive Nutrition Facts: Detailed breakdown of calories, macronutrients, vitamins, and minerals
- USDA Food Database: Access to extensive food nutrition information
- BMR & TDEE Calculations: Accurate metabolic rate calculations using Mifflin-St Jeor formula
π€ AI-Powered Recommendations
- Smart Suggestions: Personalized dietary recommendations based on your profile
- Goal-Oriented Planning: Weight loss, muscle gain, or maintenance-focused plans
- Interactive Chat: Natural language interface for easy interaction
π Advanced Features
- JSON Export: All plans and analyses saved as structured JSON files
- Table Formatting: Beautiful markdown tables for easy reading
- Multi-language Support: English interface with comprehensive food database
π How to Use
1. Create a Diet Plan
"Create a weekly diet plan for a 25-year-old male, 70kg, 175cm, moderate activity"
2. Calculate Nutrition
"Calculate nutrition for 200g chicken breast and 150g rice"
3. Get Recommendations
"Get diet recommendations for weight loss"
4. Vegetarian Options
"Create a vegetarian meal plan for 7 days"
π§ Technical Details
Architecture
- RAG System: Retrieval-Augmented Generation for intelligent responses
- Groq API: Fast LLM inference for real-time responses
- Sentence Transformers: Semantic search for relevant nutrition data
- Gradio: Modern web interface for easy interaction
Data Sources
- USDA FoodData Central: Comprehensive nutrition database
- Custom Food Database: Curated collection of common foods
- Nutritional Algorithms: BMR, TDEE, and macro distribution calculations
Output Formats
- JSON Files: Structured data for all plans and analyses
- Markdown Tables: Human-readable formatted output
- Interactive Chat: Real-time conversation interface
π File Structure
βββ app.py # Main Gradio application
βββ main3.py # RAG system and tool router
βββ diet_tool.py # Diet planning algorithms
βββ usda_provider.py # USDA API integration
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ outputs/ # Generated JSON files
βββ diet_plan_weekly_*.json
βββ diet_plan_daily_*.json
βββ diet_recommendations_*.json
π οΈ Setup Instructions
For Hugging Face Spaces
- Create a new Space on Hugging Face
- Upload all files to your Space repository
- Set Environment Variables:
- Go to Settings β Secrets
- Add
GROQ_API_KEYwith your Groq API key
- Deploy - The Space will automatically build and deploy
For Local Development
Install Dependencies:
pip install -r requirements.txtSet Environment Variable:
export GROQ_API_KEY="your_groq_api_key_here"Run the Application:
python app.py
π API Keys Required
- Groq API Key: Get your free API key from console.groq.com
π Example Outputs
Weekly Diet Plan
- 7-day meal breakdown
- Daily calorie and macro targets
- Detailed food lists with portions
- Nutritional analysis per meal
Nutrition Analysis
- Complete macronutrient breakdown
- Vitamin and mineral content
- Calorie calculations
- Serving size recommendations
Dietary Recommendations
- Personalized advice based on profile
- Goal-specific suggestions
- Macro distribution guidance
- Lifestyle integration tips
π€ Contributing
Feel free to contribute to this project by:
- Adding new food items to the database
- Improving nutrition calculation algorithms
- Enhancing the user interface
- Adding new dietary patterns (keto, paleo, etc.)
π License
This project is licensed under the MIT License - see the LICENSE file for details.
π Acknowledgments
- USDA FoodData Central for comprehensive nutrition data
- Groq for fast LLM inference
- Gradio for the beautiful web interface
- Sentence Transformers for semantic search capabilities
Made with β€οΈ for better nutrition and healthier living!