Skip to content

kuennethgroup/EcoVision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

66 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌱 EcoVision AI

AI-Powered Food Recognition & Carbon Footprint Calculator

EcoVision AI is an advanced computer vision application that uses YOLO models to detect food items in images and calculate their carbon footprint. The application supports both bounding box detection and segmentation modes, with sophisticated weight estimation for accurate COβ‚‚ emissions calculation.

EcoVision AI Streamlit Python YOLO

🎯 Features

πŸ” Dual Detection Modes

  • Bounding Box Detection: Fast food recognition using average weight database
  • Segmentation Mode: Advanced pixel-level detection with AI-powered weight estimation

πŸ“Š Advanced Weight Estimation

  • Standard Mode: Uses pre-calculated average weights from comprehensive food database
  • Segmentation Mode: Implements depth estimation + area calculation + density-based volume estimation for precise weight calculation

πŸŽ₯ Multiple Input Methods

  • Image Upload: Analyze food images from your device
  • Live Detection: Real-time food detection using WebRTC for detailed analysis

🌍 Carbon Footprint Analysis

  • Calculate COβ‚‚ emissions for 45+ food categories
  • Comprehensive emissions database with per-kg COβ‚‚ factors
  • Export results to CSV or Excel with detection mode indicators

☁️ Cloud Deployment Ready

  • WebRTC-based camera access (no server-side camera required)
  • Compatible with Streamlit Community Cloud, Heroku, AWS, GCP, Azure
  • Optimized for production deployment

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • CUDA-compatible GPU (optional, for faster inference)

Installation

  1. Clone the repository
git clone https://github.com/kuennethgroup/EcoVision.git
cd EcoVision
  1. Install dependencies
pip install -r requirements.txt
  1. Run the application
streamlit run app.py
  1. Access the app Open your browser and navigate to http://localhost:8501

πŸ“ Project Structure

EcoVision/
β”œβ”€β”€ πŸ“ .streamlit/
β”‚   └── config.toml              # Streamlit configuration
β”œβ”€β”€ πŸ“ data/
β”‚   └── data_all.xlsx           # Food COβ‚‚ database (45+ items)
β”œβ”€β”€ πŸ“ src/
β”‚   β”œβ”€β”€ πŸ“ components/
β”‚   β”‚   β”œβ”€β”€ camera_controls.py   # Camera management
β”‚   β”‚   β”œβ”€β”€ input_live.py       # Live input handling  
β”‚   β”‚   └── sidebar.py          # UI sidebar components
β”‚   β”œβ”€β”€ πŸ“ logic/
β”‚   β”‚   β”œβ”€β”€ emissions_calculator.py  # COβ‚‚ calculations
β”‚   β”‚   β”œβ”€β”€ image_processing.py      # YOLO inference
β”‚   β”‚   β”œβ”€β”€ model_loader.py          # Model management
β”‚   β”‚   β”œβ”€β”€ data_loader.py           # Data loading
β”‚   β”‚   └── weight_estimation.py    # Advanced weight estimation
β”‚   └── config.py               # Configuration constants
β”œβ”€β”€ πŸ“ pages/
β”‚   β”œβ”€β”€ image_analysis.py       # Image upload analysis
β”‚   └── live_detection.py       # Live camera detection
β”œβ”€β”€ πŸ“ training_pipeline/
β”‚   β”œβ”€β”€ πŸ“ data_processing        # Dataset generation and processing
β”‚   └── πŸ“ model_training         # Training and Evaluation of YOLO model
β”œβ”€β”€ app.py                      # Main application entry
β”œβ”€β”€ requirements.txt            # Python dependencies
└── README.md                   # This file

πŸ“ˆ Dataset and Training Pipeline

For information and code, click here

Project Architecture

img.png

🧠 Technical Details

Detection Modes

🎯 Bounding Box Detection

  • Model Type: YOLO detection models (standard .pt files)
  • Weight Estimation: Database average weights
  • Speed: ⚑ Fast processing
  • Use Case: Quick analysis, real-time detection

πŸ”¬ Segmentation Mode

  • Model Type: YOLO segmentation models (-seg.pt files)
  • Weight Estimation: Advanced AI-powered calculation
    • Depth Estimation: Depth-Anything-V2-Small-hf model
    • Area Calculation: Pixel-level segmentation area
    • Volume Calculation: Area Γ— estimated thickness
    • Weight Calculation: Volume Γ— food density
  • Speed: 🐌 Slower but more accurate
  • Use Case: Precise analysis, research applications

AI Models

  • Object Detection: Ultralytics YOLO models from Hugging Face Hub
  • Depth Estimation: Depth-Anything-V2-Small-hf (Hugging Face Transformers)
  • Segmentation: Custom trained YOLO segmentation models

Data

  • Food Database: 45 food categories with COβ‚‚ factors, average weights, and densities
  • COβ‚‚ Factors: Scientific literature-based emission factors (kg COβ‚‚ eq/kg food)
  • Densities: Physical density values for volume-to-weight conversion

πŸ’‘ Usage

1. Select Detection Mode

Choose between "Bounding boxes" or "Segmentation" in the sidebar

2. Configure Settings

  • Model: Automatically filtered based on detection mode
  • Confidence: Adjust detection threshold (0.0-1.0)
  • Class Filter: Select specific food categories (optional)

3. Analyze Food

Image Analysis

  1. Upload image (JPG, PNG, JPEG)
  2. View detection results
  3. Review COβ‚‚ emissions report
  4. Export results

Live Detection

  1. Start camera feed
  2. Capture frame when ready
  3. Process with selected detection mode
  4. Download results and processed image

4. Export Results

  • Formats: CSV or Excel
  • Filenames: Automatic mode detection (_bb for bounding boxes, _seg for segmentation)
  • Data: Complete emissions analysis with methodology tracking

πŸ› οΈ Deployment

Streamlit Community Cloud

  1. Fork this repository
  2. Connect to Streamlit Community Cloud
  3. Deploy directly (WebRTC works out of the box)

Other Platforms

The application is compatible with:

  • Heroku: Add setup.sh and Procfile
  • AWS/GCP/Azure: Use container deployment
  • Local Network: Run with --server.address 0.0.0.0

Environment Variables

# Optional: Hugging Face token for private models
HUGGING_FACE_TOKEN=your_token_here

πŸ“Š Supported Foods

The application recognizes 45+ food categories including:

🍎 Fruits: Apple, Avocado, Banana, Grapes, Orange, etc.
πŸ₯• Vegetables: Carrot, Broccoli, Tomato, Cucumber, etc.
πŸ«› Legumes: Beans, Peas, etc.
πŸ„ Others: Mushroom, Garlic, Ginger, etc.

Complete list available in data/data_all.xlsx

πŸ”§ Configuration

Model Configuration

Models are automatically downloaded from Hugging Face Hub:

  • Repository: nagasaiteja999/EcoVision
  • Detection Models: Standard YOLO .pt files
  • Segmentation Models: Files containing "-seg" in filename

Theme Customization

Edit .streamlit/config.toml to customize the UI theme:

[theme]
primaryColor = "#2E86AB"
backgroundColor = '#0E1117'
secondaryBackgroundColor = "#262730"
textColor = "#FAFAFA"
font = "sans serif"

Development Setup

# Install development dependencies
pip install -r requirements.txt

# Run with debug mode
streamlit run app.py 

πŸ›οΈ Citation

If you use EcoVision AI in your research, please cite:

@software{ecovision_ai_2025,
  title={EcoVision AI: AI-Powered Food Recognition and Carbon Footprint Calculator},
  author={Kolakaleti, Naga Sai Teja},
  year={2025},
  organization={Kuenneth Research Group, University of Bayreuth},
  url={https://github.com/kuennethgroup/EcoVision}
}

πŸ‘₯ Credits

Created by: Naga Sai Teja Kolakaleti
Organization: Kuenneth Research Group, University of Bayreuth
Copyright: Β© 2025 Kuenneth Research Group, University of Bayreuth. All rights reserved.

πŸ”— Related Projects


⭐ Star this repository if you find it useful!

Made with ❀️ for a sustainable future 🌍

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors