Skip to content

devsk18/foodsnap-ai

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FoodSnap.ai

FoodSnap.ai is a complete AI-powered food analysis platform that delivers a seamless pipeline — from data collection and intelligent inference to real-time visualization. It combines food image classification, weight estimation, and nutritional analysis into a unified experience with a rich, user-friendly interface.

  1. Food Classification Model — Classifies Indian food images into predefined categories.
  2. Weight Prediction Model — Predicts the total weight (mass in grams) of food items from images.
  3. Inference Server — REST API for real-time predictions using both models.
  4. FoodSnap Web App — Provides a user-friendly interface and seamless experience.
  5. Data Scrapper — Python script that executes API calls to extract nutritional data and store it as CSV.

🎬 Demo Preview

demo


1. Food Classification Model

Dataset

Indian Food Classification (Kaggle)

Overview

  • Uses MobileNetV2 as a base model with transfer learning.
  • Can classify below food items

["burger", "butter_naan", "chai", "chapati", "chole_bhature", "dal_makhani", "dhokla", "fried_rice", "idli", "jalebi", "kaathi_rolls", "kadai_paneer", "kulfi", "masala_dosa", "momos", "paani_puri", "pakode", "pav_bhaji", "pizza", "samosa"].

Evaluation

  • Test accuracy : 87.39%

2. Food Weight Prediction Model

Dataset

Food Nutrients Dataset (HuggingFace)

Overview

  • Model is a CNN-based regression network.
  • Predicts food weight (total mass in grams) from images.

Evaluation

  • RMSE (Root Mean Squared Error) : 131.78434
  • R² Score : 0.29374
  • Null/Baseline Model Test RMSE : 156.81286

3. Inference Server (Flask)

A simple REST API server that takes an image and returns:

  • Predicted food name
  • Class code
  • Estimated weight (grams)
  • Confidence score (%)
  • Time taken (seconds)

Endpoint

POST /predict

Request

  • multipart/form-data
  • Key: foodImage
  • Value: food image file (.jpg, .png, etc.)

Response

{
  "food_name": "Masala Dosa",
  "food_code": "masala_dosa",
  "weight": 322.45,
  "confidence": 94.38,
  "time_taken": "0.86 seconds"
}

Setup & Installation

If you encounter any version-related issues with Python & tensorflow, switch to Python 3.11

  1. Clone the repository
git clone <repo url>
cd Food_Classification_Model
  1. Install dependencies
pip install -r req.txt
  1. Run script
python3.11 server/app.py

4. FoodSnap Web App — Laravel + FilamentPHP

A powerful and modern web application built using Laravel and FilamentPHP to manage, visualize, and interact with AI-powered food classification and weight estimation models.

This panel acts as the front-end interface for:

  • Uploading food images for inference*
  • Displaying classification results and estimated weight
  • Showing food nutrition details
  • Presenting charts and statistical overviews
  • Managing user-submitted entries and food records
* Only food items with a confidence level of 60% or higher are displayed.

Requirements

  • PHP >= 8.2
  • Composer
  • MySQL or SQLite
  • Node.js & npm

Installation Guide

  1. Clone the Repository
git clone <repo url>
cd FoodSnap_App
  1. Install PHP Dependencies
composer install

  1. Create and Configure .env
cp .env.example .env
php artisan key:generate

Update your .env file with the correct DB and app settings:

DB_CONNECTION=mysql         # or sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database
DB_USERNAME=your_username
DB_PASSWORD=your_password


FOOD_DETECTION_API_URL='http://localhost:5000/predict'

  1. Run Migrations
php artisan migrate

  1. Seed Initial Data
php artisan db:seed

  1. Create Storage Link
php artisan storage:link
  1. Serve the App
php artisan serve

Your app will now be accessible at: http://localhost:8000


5. Nutrition Info Scraper

This Python script mimics an API request made by a food website to fetch nutritional data for a list of specified foods. It extracts structured nutritional details and saves them to a CSV file for further analysis or integration.

What It Does

  • Performs API call to a food website.
  • Sends food names via POST request to the nutrition endpoint.
  • Parses the response to extract:
    • Food Name
    • Serving Size
    • Calories
    • Protein
    • Carbohydrates
    • Fats
    • Sugar
    • Fibre
  • Saves all data to a .csv file.

Installation

  1. Clone the repository
git clone <repo url>
cd Data_Scrapper
  1. Install dependencies
pip install -r req.txt
  1. Run script
python scrapper.py

About

Find your calories just from a snap

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors