Skip to content

ODevStudio/NutriLens

Repository files navigation

🥗 NutriLens - AI Powered Nutrition Assistant

Python Flask AI License

NutriLens is a cutting-edge web application that transforms simple food photos into comprehensive nutritional reports. By leveraging the power of modern Vision Language Models (VLMs), it provides detailed calorie counts, macronutrient breakdowns, and health evaluations in seconds.

Whether you prioritize privacy with local models or crave the precision of state-of-the-art cloud APIs, NutriLens adapts to your needs.


✨ Key Features

  • 📷 Instant Analysis: Upload a photo of your meal and get immediate feedback.
  • 🧠 Multi-Model Intelligence: Built to be model-agnostic. Switch seamlessly between:
    • Google Gemini: High speed and accuracy.
    • OpenAI GPT: Industry-leading reasoning and detail.
    • Anthropic: Excellent nuance and safety.
    • Ollama (Local): Run models like llama3.2-vision entirely on your machine for complete privacy and zero cost.
  • 📊 Structured Reports:
    • Identification: Recognizes distinct food items on the plate.
    • Portion & Calories: Estimates serving sizes and energy content.
    • Macro Breakdown: Calculates Protein, Carbs, and Fats.
    • Health Score: Provides a qualitative health assessment of the meal.
  • 🛠 Flexible Configuration: Simple YAML-based setup for API keys and model preferences.

🚀 Getting Started

Prerequisites

  • Python 3.8+ installed on your system.
  • (Optional) Ollama installed if you plan to use local models.

Installation

  1. Clone the Repository

    git clone https://github.com/yourusername/nutrilens.git
    cd nutrilens
  2. Install Dependencies It is recommended to use a virtual environment.

    python -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
  3. Configuration Copy the example configuration file to create your local config.

    cp config.example.yaml config.yaml
    # On Windows: copy config.example.yaml config.yaml
  4. Add API Keys Open config.yaml and add your API keys. You can paste them directly or reference environment variables (e.g., ${OPENAI_API_KEY}).

    providers:
      openai:
        api_key: "sk-..."
      gemini:
        api_key: "AIza..."
      # ... other providers

Running the App

Start the Flask development server:

python app.py

Visit http://localhost:5000 in your browser to start analyzing meals!


⚙️ Configuration Guide

The config.yaml file allows you to define which AI models are available in the UI.

Using Local Models (Ollama)

To use a local model like Llama 3.2 Vision:

  1. Run ollama serve in your terminal.
  2. Pull the model: ollama pull llama3.2-vision.
  3. Ensure your config.yaml matches the default:
    ollama:
      name: "Ollama (Local)"
      type: ollama
      model: "llama3.2-vision"
      base_url: "http://localhost:11434"

Using Cloud APIs

Simply populate the api_key field for your desired provider. If a provider is missing an API key, it will automatically be hidden from the UI.


🛡️ Medical Disclaimer

Important: The nutritional information and calorie estimates provided by this application are generated by AI and are approximate. Actual values may vary based on ingredients, preparation methods, and portion sizes.

This tool is for educational and informational purposes only. It is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or qualified health provider with any questions you may have regarding a medical condition or dietary changes.


🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project.
  2. Create your feature branch (git checkout -b feature/AmazingFeature).
  3. Commit your changes (git commit -m 'Add some AmazingFeature').
  4. Push to the branch (git push origin feature/AmazingFeature).
  5. Open a Pull Request.

📄 License

Distributed under the MIT License. See LICENSE for more information.

About

Check meal calories and macros from a photo upload.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors