A comprehensive food waste tracking and management system that helps cafeterias, restaurants, and food service providers monitor, analyze, and reduce food waste through AI-powered insights and real-time tracking.
WasteWatch is a full-stack application that combines computer vision, data analytics, and an intuitive user interface to tackle food waste in institutional settings. The system uses YOLO (You Only Look Once) object detection to identify food items, tracks consumption patterns, and provides actionable insights through AI-generated reports.
- AI-Powered Food Recognition: Uses YOLOv8 model trained on 498+ food categories
- Camera Integration: Real-time food detection using Raspberry Pi camera or webcam
- Real-time Waste Tracking: Monitor leftover and wasted food items across different meal periods
- Menu Management: Create, edit, and manage daily menus with quantity tracking
- Interactive Dashboard: Visualize waste patterns with charts and analytics
- Smart Reports: AI-generated insights using Google Gemini API to identify waste patterns and provide recommendations
- Multi-Period Support: Track breakfast, lunch, dinner, and snacks separately
- Historical Analysis: View waste data by day, week, or month
- Individual item waste tracking (leftovers vs. explicitly wasted)
- Total waste calculations and percentages
- Menu-specific and time-based reporting
- AI recommendations for menu optimization
- React 19 with Vite for fast development
- React Router for navigation
- Bootstrap 5 for responsive UI
- Recharts & Chart.js for data visualization
- React Markdown for formatted reports
- FastAPI (Python) for REST API
- MongoDB for data persistence
- Google Gemini API for AI-powered insights
- PyMongo for database operations
- YOLOv8 (Ultralytics) for food detection
- PyTorch with CUDA support for GPU acceleration
- OpenCV for image processing
- Picamera2 for Raspberry Pi camera integration
- Custom training on food dataset with 498 classes
- Node.js/Express for alternative server implementation
- Python-dotenv for environment configuration
- CORS middleware for cross-origin requests
wastewatch/
βββ waste-watch/ # React frontend application
β βββ src/
β β βββ components/ # Reusable React components
β β βββ pages/ # Page-level components
β β βββ data/ # Static data and configurations
β β βββ App.jsx # Main application component
β βββ public/ # Static assets
β βββ package.json # Frontend dependencies
β
βββ waste-watch-server/ # FastAPI backend (main)
β βββ main.py # API endpoints and business logic
β βββ database.py # MongoDB connection
β βββ models.py # Pydantic models
β βββ requirements.txt # Backend dependencies
β
βββ waste_watch_server/ # Alternative server implementation
β βββ main.py # FastAPI endpoints
β βββ database.py # Database configuration
β βββ server.js # Node.js/Express server
β βββ start_cam.py # Camera integration script
β
βββ train_yolo.py # YOLO model training script
βββ best.pt # Trained YOLO model weights
βββ fooddataset.yaml # Dataset configuration (498 food classes)
βββ requirements.txt # Python dependencies
- Python 3.8-3.11 (3.11 recommended - provides best balance of PyTorch/CUDA support and performance)
- Node.js 18+ and npm
- MongoDB (local or MongoDB Atlas)
- CUDA-capable GPU (optional, for training)
- Git
-
Clone the repository
git clone https://github.com/Solanh/wastewatch.git cd wastewatch -
Set up Python environment
python -m venv env source env/bin/activate # On Windows: env\Scripts\activate pip install -r requirements.txt
-
Set up the backend
cd waste-watch-server pip install -r requirements.txt -
Configure environment variables Create a
.envfile in thewaste-watch-server/directory:GEMINI_API_KEY=your_gemini_api_key_here MONGODB_URI=your_mongodb_connection_string
-
Set up the frontend
cd ../waste-watch npm install
-
Start MongoDB (if running locally)
mongod
-
Start the backend server
cd waste-watch-server uvicorn main:app --reload --port 8000 -
Start the frontend development server
cd waste-watch npm run dev -
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Navigate to "Menus" from the dashboard
- Click "Add New Menu"
- Enter menu name, select meal period (1=Breakfast, 2=Lunch, 3=Dinner, 4=Snacks)
- Add food items with quantities
- Save the menu
- Select a menu from the menu list
- Update "Taken" and "Wasted" quantities for each item
- The system automatically calculates leftovers (Quantity - Taken)
- View real-time waste statistics on the dashboard
- Go to the "Reports" page
- Select a menu or time scope (day/week/month)
- View AI-generated insights and recommendations
- Analyze waste patterns through interactive charts
If you want to retrain the YOLO model:
python train_yolo.pyThe script will:
- Check for GPU availability
- Load YOLOv8n base model
- Train on the food dataset for specified epochs
- Save the best model weights
To use real-time camera detection (Raspberry Pi):
cd waste_watch_server
python start_cam.pyFeatures:
- Real-time food detection with configurable confidence threshold (default: 0.3)
- Note: The 0.3 threshold balances detection sensitivity and accuracy. Adjust in
start_cam.pyif needed for your use case
- Note: The 0.3 threshold balances detection sensitivity and accuracy. Adjust in
- Automatic waste tracking for detected items
- Visual feedback with annotated frames
- Press 'q' to quit and save detected items
POST /listing- Create a new food item listingGET /listing- Get all listingsGET /listing/{name}- Get listings by food namePUT /items/{item_id}- Increment waste count for an item
GET /api/menus- List all menusPOST /api/menus- Create a new menuGET /api/menus/{menu_id}- Get menu detailsPUT /api/menus/{menu_id}- Update a menuDELETE /api/menus/{menu_id}- Delete a menu
GET /api/summary- Get AI-generated waste summary with recommendations- Query params:
menu_id(optional),scope(menu/day/week/month)
- Query params:
GET /api/waste-summary- Get raw waste statistics- Query params:
menu_id(optional),scope(menu/day/week/month)
- Query params:
GET /health- Check API health status
The system recognizes 498+ food categories including:
- Fruits and vegetables
- Proteins (meat, fish, eggs)
- Dairy products
- Grains and pasta
- Breads and baked goods
- Beverages
- Prepared meals and dishes
- Condiments and sauces
See fooddataset.yaml for the complete list.
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow existing code style and conventions
- Test your changes thoroughly
- Update documentation as needed
- Keep commits focused and descriptive
This project is open source and available for educational and commercial use.
- Ultralytics YOLOv8 for object detection
- Google Gemini API for AI-powered insights
- Food dataset contributors
- Open source community
For questions, issues, or suggestions:
- Open an issue on GitHub
- Check existing documentation
- Review API docs at
/docsendpoint
Built with β€οΈ to reduce food waste and promote sustainability