How abijith-vs/fridge-ammachi works
What this project is (type + purpose)
Fridge_Whisperer Ammachi is a small full-stack web app:
• Frontend: static HTML/CSS/JS in /static (UI, mood selection, animations, speech bubbles).
• Backend: Python FastAPI (main.py) served by Uvicorn.
• AI/ML inference: YOLOv8 (PyTorch) for ingredient detection (yolov8m.pt) + an additional grocery classifier (Keras .h5 + MobileNet runner) under /classifier.
• Business logic: “recipe suggestion” generation in recipe_gen.py based on detected ingredients.
• Supporting scripts: image preprocessing (image_procc.py), entrypoints (run.py, main.py).
How to read the file tree into architectural components
Use the tree to split into runtime containers vs offline tooling:
Runtime (what runs when user uses the app)
• Frontend (static site)
• static/index.html
• static/style.css
• static/fallingVeggies.js
• Backend API (FastAPI)
• main.py (FastAPI app; likely defines endpoints for upload / ingredient input / recipe response)
• run.py (helper to start/serve)
• Image + ML inference pipeline
• image_procc.py (image loading, resizing, normalization, etc. via Pillow)
• yolov8m.pt (YOLO model weights)
• classifier/predict.py (inference wrapper for grocery classifier)
• classifier/model/grocery_classifier.h5
• classifier/model/classes.txt
• classifier/model/run_mobilenet.py (MobileNet-based inference runner)
• Recipe generation
• recipe_gen.py (turn ingredients into recipe suggestions / text)
Offline / development workflows (don’t confuse with runtime)
• classifier/train_classify.py (training pipeline)
• classifier/train/* (training image dataset by category: curd/juice/milk/sauce)
• requirements.txt (runtime dependencies)
• .env (config; can imply API keys, env toggles, etc.)
Static Frontend (HTML/CSS/JS)
• Runs in browser
• Handles: mood selection UI, upload form, animations, rendering results
ML Inference Module (YOLOv8 + Grocery Classifier)
• YOLOv8 weights: yolov8m.pt
• Keras classifier: grocery_classifier.h5
Recipe Generator (recipe_gen.py)
• Converts ingredient list → recipe suggestions + “Ammachi” dialogue text
Data stores:
• There’s no explicit database in the tree. Represent storage as:
• In-memory processing (default)
• Optional “local temp files” if upload is saved (unknown—call it out as assumption)
Inside “Backend API,” show components mapped to files:
• main.py → API Router / Controllers
• image_procc.py → Image Preprocessor
• YOLO wrapper (wherever implemented; likely in main.py or helper) → Object Detection Service
• classifier/predict.py → Grocery Classification Service
• recipe_gen.py → Recipe + Dialogue Generator
At least two flows:
Flow 1: Image upload
Browser: renders recipe + mood-based Ammachi speech
Flow 2: Manual ingredients
FastAPI → Browser: recipes + dialogue
• Local dev: Browser + Uvicorn on localhost + models on local filesystem
• Hosted (HF Spaces): Browser → HF Spaces app container (FastAPI) → model files in container image/storage
• Browser → FastAPI
• Protocol: HTTP (JSON + multipart file upload)
• FastAPI → Image preprocessing
• Library: Pillow (per README)
• FastAPI → YOLOv8 inference
• Library: PyTorch/Ultralytics (implied by YOLOv8)
• Artifact: yolov8m.pt
• FastAPI → Grocery classifier
• Artifact: grocery_classifier.h5, classes.txt
• This is a second-stage classifier; show it as “optional refinement” if YOLO already detects items.
• FastAPI → Recipe generator
• Input: ingredient list (+ mood)
• Output: recipe suggestions + text
• FastAPI → Browser
• Output: response payload
offline training:
• Training images classifier/train/* → train_classify.py → outputs .h5 + classes.txt
Architectural patterns to highlight (based on structure)
• Thin frontend, API-driven backend: static UI calls FastAPI.
• Pipeline architecture for inference: preprocess → detect → (optional classify/refine) → generate recipe.
• Separation of concerns by file/module: API entry (main.py), CV (image_procc.py + model weights), classification (classifier/), recipe logic (recipe_gen.py).
• Offline training vs online inference separation: /classifier/train_* vs /classifier/predict.py.