HW

hari8749/waste_analysis

Developer tools
0 stars Quality 45 Trend 8

A full-stack web application that classifies waste from images using deep learning (SegFormer + ResNet18), generates recycling guidance via a RAG pipeline (FAISS + Groq LLM), and plots reports on an...

Overview

A full-stack web application that classifies waste from images using deep learning (SegFormer + ResNet18), generates recycling guidance via a RAG pipeline (FAISS + Groq LLM), and plots reports on an interactive map. - Image upload with drag-and-drop - Waste classification (plastic, metal, glass, paper, other) - AI-generated segmentation overlay - RAG recycling guide from a PDF knowledge base (FAISS + Groq) - Interactive map with historical waste reports (MongoDB Atlas) - AI chat assistant for follow-up questions - Manual location entry with geocoding fallback The segment-anything package installs from GitHub. Requires git to be on your PATH. Edit .env and fill in: - MONGO_URI — your MongoDB Atlas connection string - MONGO_DB_NAME — database name (default: waste_classification) - GROQ_API_KEY — your Groq API key Download SAM weights from: https://github.

README

EcoVision — Waste Classification & Mapping

A full-stack web application that classifies waste from images using deep learning (SegFormer + ResNet18), generates recycling guidance via a RAG pipeline (FAISS + Groq LLM), and plots reports on an interactive map.


Features

  • Image upload with drag-and-drop
  • Waste classification (plastic, metal, glass, paper, other)
  • AI-generated segmentation overlay
  • RAG recycling guide from a PDF knowledge base (FAISS + Groq)
  • Interactive map with historical waste reports (MongoDB Atlas)
  • AI chat assistant for follow-up questions
  • Manual location entry with geocoding fallback

Prerequisites

Requirement Version
Python 3.10 or 3.11
pip latest
MongoDB Atlas free tier is fine
Groq API key free at console.groq.com

Local Setup

1. Clone / unzip the project

cd ecovision

2. Create a virtual environment

python -m venv venv
source venv/bin/activate      # Linux / Mac
venv\Scripts\activate         # Windows

3. Install dependencies

pip install -r requirements.txt

Note: The segment-anything package installs from GitHub. Requires git to be on your PATH.

4. Configure environment variables

cp .env.example .env

Edit .env and fill in:

  • MONGO_URI — your MongoDB Atlas connection string
  • MONGO_DB_NAME — database name (default: waste_classification)
  • GROQ_API_KEY — your Groq API key

5. Add model weights

Place the following files in the project root:

File Description
resnet_best.pth ResNet18 waste classifier
segformer_best.pth SegFormer segmentation model
sam_vit_b_01ec64.pth SAM (optional — for segmentation masks)

Download SAM weights from: https://github.com/facebookresearch/segment-anything#model-checkpoints

6. Add RAG knowledge base PDFs (optional)

Place recycling-related PDF files in:

backend/rag/data/

The app will automatically index them on first startup and cache the FAISS index to backend/rag/cache/.

7. Run the server

python -m uvicorn backend.main:app --host 0.0.0.0 --port 5000 --reload

Open your browser at: http://localhost:5000


Project Structure

ecovision/
├── backend/
│   ├── main.py                  # FastAPI app & routes
│   ├── db/
│   │   └── database.py          # MongoDB connection
│   ├── models/
│   │   └── inference.py         # SegFormer + ResNet18 + SAM pipeline
│   ├── services/
│   │   ├── processing.py        # Recyclability & cleanliness scoring
│   │   └── rag_service.py       # FAISS retrieval + Groq generation
│   └── rag/
│       ├── data/                # PDF knowledge base files
│       └── cache/               # FAISS index cache (auto-generated)
├── frontend/
│   ├── index.html
│   ├── css/
│   │   ├── style.css
│   │   └── components.css
│   └── js/
│       ├── api.js               # API calls
│       ├── app.js               # Main app logic
│       ├── map.js               # Leaflet map
│       └── ui.js                # UI helpers
├── uploads/                     # Saved images (auto-created)
├── requirements.txt
├── .env.example
└── README.md

Environment Variables Reference

Variable Description
MONGO_URI MongoDB Atlas connection string
MONGO_DB_NAME Database name
GROQ_API_KEY Groq LLM API key

Tech Stack

  • Backend: FastAPI, Python 3.11
  • ML Models: SegFormer (HuggingFace Transformers), ResNet18 (PyTorch), SAM (Meta)
  • RAG: FAISS vector store, sentence-transformers (all-MiniLM-L6-v2), Groq (llama-3.1-8b-instant)
  • Database: MongoDB Atlas
  • Frontend: Vanilla HTML/CSS/JS, Leaflet.js
  • Geocoding: OpenStreetMap Nominatim (no API key required)
View this README on GitHub

Recommended Tools

Try a different keyword or remove a filter.

Install

npx skillfish add hari8749/waste_analysis