AI Powered Recipe Generator
Turn a fridge photo into smart recipe suggestions using YOLOv8, FastAPI, and Google Gemini.
Fridge Mate is an AI-based web app that:
- Detects ingredients from fridge images using YOLOv8n
- Generates recipes using Google Gemini LLM
- Shows step-by-step cooking instructions
- Uses FastAPI backend + React frontend for a smooth workflow
- Smart Ingredient Detection
- Upload a fridge/pantry image
- YOLOv8n detects common food items (vegetables, fruits, dairy, jars, bottles)
- Optimized for quick inference and low compute
- AI Recipe Generation
- Uses Google Gemini LLM
- Converts detected items into:
- Simple everyday recipes
- Detailed step-by-step instructions
- Fully Automated Pipeline
- Image β Preprocessing β Detection β Prompt β Recipe β Frontend display
- All integrated inside FastAPI.
- Beginner-Friendly Meal Assistance
- Generates easy-to-follow instructions, perfect for new cooks.
- Modern, Fast UI
- Built using React + TypeScript + Tailwind
- Real-time image previews
- Smooth display of detected ingredients & recipes
- React (Vite)
- TypeScript
- TailwindCSS
- FastAPI (Python)
- YOLOv8n (Ultralytics)
- Google Gemini API
- OpenCV
- Pillow
- YOLOv8n β Lightweight + fastest version, ideal for quick inference in a web project
- FastAPI β Faster than Flask, async, auto-docs, perfect for ML APIs
- React (Vite) β Fast dev environment, smooth UI, instant hot reload
- Pillow β Format conversion + dimension prep for ML models
- OpenCV β Pixel-level operations (resizing, color channels, etc.)
- Gemini API β Strong reasoning + natural recipe generation
[Frontend: React + Vite]
|
Image Upload (JPG/PNG)
|
v
[FastAPI Backend (Python)]
ββββββββββββββββββββββββββββββββββββββββββ
β 1. Preprocess Image (Pillow, OpenCV) β
β 2. Ingredient Detection (YOLOv8n) β
β 3. Prompt Engineering β
β 4. Gemini API Recipe Generation β
ββββββββββββββββββββββββββββββββββββββββββ
|
v
JSON Response (Ingredients + Recipe)
|
v
Recipe UI Display (Frontend)
π§ͺ Core Functional Workflow 1οΈβ£ User uploads image
- Frontend sends image β FastAPI receives file.
2οΈβ£ Image Processing
- Pillow normalizes image format
- OpenCV handles resizing, color channels, and drawing (if needed)
3οΈβ£ YOLOv8n Detection
- Model infers bounding boxes + labels
- Extracts ingredients list
4οΈβ£ LLM Recipe Generation
A custom prompt sends:
- Ingredient list
- User preferences (optional)
- Required style (simple/stepwise/healthy)
- Gemini returns the final recipe text.
5οΈβ£ Response to Frontend
Frontend displays:
- Detected items
- Recipe title
- Steps -Tips or variations
RecipeGenerator/
βββ requirements.txt # Backend dependencies
βββ Frontend/ # React application
βββ Backend/ # FastAPI backend
This project contains a FastAPI backend for image-based ingredient detection and recipe generation, and a React (Vite) frontend for user interaction.
Run all backend commands inside:
RecipeGenerator/Backend
cd RecipeGenerator/Backend
python -m venv .venv
PowerShell:
.\.venv\Scripts\Activate.ps1
Requirements file is in the project root, so install using:
pip install -r ../requirements.txt
uvicorn app:app --reload --port 8000
Backend will now run at:
http://localhost:8000
API Endpoint:
POST /detect_and_generate
Run all frontend commands inside:
RecipeGenerator/Frontend
cd RecipeGenerator/Frontend
npm install
npm run dev
React will run on a port such as:
http://localhost:5173
Make sure your React API calls point to:
http://localhost:8000/detect_and_generate
Ensure both are running:
- Backend β
http://localhost:8000 - Frontend β
http://localhost:5173
If the backend port is different, update the frontend fetch URL accordingly.
You can test the backend using curl, Postman, or a file upload client.
Example (PowerShell):
curl -X POST -F "file=@image.jpg" http://localhost:8000/detect_and_generate
- venv not activated OR uvicorn not installed.
.\.venv\Scripts\Activate.ps1
pip install -r ../requirements.txt
Then run:
uvicorn app:app --reload --port 8000
- React is trying to call the backend but the backend is not running on the expected port.
- Ensure backend is running on port 8000
- If backend runs on a different port, update frontend API URL.
- Frontend is on a different port.
CORS is already enabled with:
allow_origins=["*"]
If needed, restart backend.
Use the correct command:
.\.venv\Scripts\Activate.ps1
If permission error:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
- Running uvicorn from the wrong directory.
Run from inside Backend:
cd RecipeGenerator/Backend
uvicorn app:app --reload --port 8000