Skip to content

AI-powered recycling assistant built with YOLOv8 and optimized for AMD NPU acceleration. Provides real-time object detection and disposal guidance through a gamified interface.

connergroth/EcoVision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EcoVision

🌱 EcoVision: Smart Recycling Detection App

Project for the AMD AI track at HackCU11

My Skills
EcoVision is an intelligent recycling assistant that uses computer vision and AI to help users identify recyclable items, learn proper disposal methods, and track their environmental impact.

πŸ”² AMD AI PC Implementation

Much of the code is based on AMD AI Software for NPU utilization.

EcoVision leverages AMD Ryzenβ„’ AI PC technology to optimize our object detection pipeline. We've specifically engineered our YOLOv8 model to utilize the Neural Processing Unit (NPU) on AMD hardware, providing significant performance improvements while reducing power consumption.

To enhance real-time object detection efficiency, we retrained a pre-trained AMD/YOLOv8m COCO model from Hugging Face, utilizing cloud resources to fine-tune the model on custom datasets sourced from Roboflow. By leveraging NPU technology, we achieved superior efficiency and performance, enabling real-time recyclable item detection directly on-device with minimal latency. This implementation ensures a more responsive and energy-efficient experience for everyday use.

Demo

EcoVision Demo

πŸš€ Problem Statement

Improper waste disposal and low recycling rates remain significant environmental challenges:

  • Many people are unsure about which items can be recycled
  • Recycling rules vary by location and can be confusing
  • Lack of immediate feedback makes it difficult to build good recycling habits
  • Limited knowledge about the environmental impact of individual actions

EcoVision addresses these challenges by providing real-time identification, personalized guidance, and gamification elements to make recycling more accessible and engaging.

πŸ”₯ AMD Ryzen AI Integration

We leveraged Xilinx's MLIR-AIE framework for model optimization and NPU acceleration:

  1. MLIR-AIE Compilation Pipeline:

    • Used Xilinx MLIR-AIE compiler infrastructure
    • Implemented MLIR (Multi-Level Intermediate Representation) to target AMD's AI Engine architecture
    • Applied specialized graph optimizations for AMD NPU execution
  2. Quantization Process:

    • Performed post-training quantization to reduce model precision from FP32 to INT8
    • Applied per-channel quantization to minimize accuracy loss
    • Calibrated quantization parameters using representative dataset samples
    • Generated quantized model variants optimized specifically for AMD NPU execution

πŸ“± App Design

original original-2

πŸ–ΌοΈ Sample Training Images

✨ Key Features

  • Real-time object detection: Identify recyclable items using your device's camera
  • AI-enhanced information: Get detailed, contextual information about each item powered by the ChatGPT API
  • Environmental impact tracking: Earn points for proper recycling and see your cumulative positive impact
  • User history: Review past scans and track your recycling progress over time
  • Leaderboard: Compete with others in your community to promote sustainable behaviors
  • Educational content: Learn facts and proper disposal methods for various materials

πŸ’» Tech Stack

Backend

  • Framework: FastAPI (Python)
  • Authentication: Firebase Authentication
  • Database: Firebase Firestore
  • Storage: Firebase Storage
  • Object Detection: YOLOv8 model with ChatGPT classification
  • AI Text Generation: ChatGPT custom text generation

Frontend

  • Framework: Next.js with TypeScript
  • Styling: Tailwind CSS
  • State Management: React Hooks
  • Authentication: Firebase SDK

🌎 Environmental Impact

By using EcoVision, users can:

  • Reduce contamination in recycling streams
  • Increase recycling rates
  • Learn sustainable practices through engaging feedback
  • Track their personal environmental impact over time

The application itself is designed to be environmentally friendly:

  • Optimized for low power consumption with edge ML
  • Efficient API design to minimize data transfer

πŸ–₯️ System Architecture

Directory structure:
└── connergroth-ecovision/
    β”œβ”€β”€ README.md
    β”œβ”€β”€ yolov8m.pt
    β”œβ”€β”€ backend/
    β”‚   β”œβ”€β”€ Dockerfile
    β”‚   β”œβ”€β”€ docker-compose.yml
    β”‚   β”œβ”€β”€ requirements.txt
    β”‚   └── app/
    β”‚       β”œβ”€β”€ requirements.txt
    β”‚       β”œβ”€β”€ .gitignore
    β”‚       β”œβ”€β”€ endpoints/
    β”‚       β”‚   β”œβ”€β”€ __init__.py
    β”‚       β”‚   β”œβ”€β”€ detection.py
    β”‚       β”‚   β”œβ”€β”€ leaderboard.py
    β”‚       β”‚   β”œβ”€β”€ scans.py
    β”‚       β”‚   └── websocket.py
    β”‚       β”œβ”€β”€ models/
    β”‚       β”‚   └── yolov8.ipynb
    β”‚       β”œβ”€β”€ services/
    β”‚       β”‚   β”œβ”€β”€ __init__.py
    β”‚       β”‚   β”œβ”€β”€ detection_service.py
    β”‚       β”‚   β”œβ”€β”€ firebase_service.py
    β”‚       β”‚   └── npu_service.py
    β”‚       β”œβ”€β”€ training/
    β”‚       β”‚   β”œβ”€β”€ annotation_setup.py
    β”‚       β”‚   β”œβ”€β”€ data_augmentation.py
    β”‚       β”‚   β”œβ”€β”€ hyperparameter_tuning.py
    β”‚       β”‚   β”œβ”€β”€ prepare_trashnet.py
    β”‚       β”‚   β”œβ”€β”€ test_model.py
    β”‚       β”‚   β”œβ”€β”€ train_yolov8.py
    β”‚       β”‚   └── training_pipeline.py
    β”‚       └── utils/
    β”‚           β”œβ”€β”€ __init__.py
    β”‚           β”œβ”€β”€ enviroment.py
    β”‚           β”œβ”€β”€ firebase_check.py
    β”‚           └── logger.py
    β”œβ”€β”€ frontend/
    β”‚   β”œβ”€β”€ README.md
    β”‚   β”œβ”€β”€ Dockerfile
    β”‚   β”œβ”€β”€ eslint.config.mjs
    β”‚   β”œβ”€β”€ next.config.ts
    β”‚   β”œβ”€β”€ package-lock.json
    β”‚   β”œβ”€β”€ package.json
    β”‚   β”œβ”€β”€ postcss.config.mjs
    β”‚   β”œβ”€β”€ tsconfig.json
    β”‚   β”œβ”€β”€ .dockerignore
    β”‚   β”œβ”€β”€ .gitignore
    β”‚   β”œβ”€β”€ public/
    β”‚   └── src/
    β”‚       β”œβ”€β”€ app/
    β”‚       β”‚   β”œβ”€β”€ globals.css
    β”‚       β”‚   β”œβ”€β”€ layout.tsx
    β”‚       β”‚   β”œβ”€β”€ (protected)/
    β”‚       β”‚   β”‚   β”œβ”€β”€ layout.tsx
    β”‚       β”‚   β”‚   β”œβ”€β”€ page.tsx
    β”‚       β”‚   β”‚   β”œβ”€β”€ history/
    β”‚       β”‚   β”‚   β”‚   └── page.tsx
    β”‚       β”‚   β”‚   β”œβ”€β”€ image/
    β”‚       β”‚   β”‚   β”‚   └── page.tsx
    β”‚       β”‚   β”‚   └── leaderboard/
    β”‚       β”‚   β”‚       └── page.tsx
    β”‚       β”‚   β”œβ”€β”€ api/
    β”‚       β”‚   β”‚   β”œβ”€β”€ apiClient.ts
    β”‚       β”‚   β”‚   β”œβ”€β”€ chat/
    β”‚       β”‚   β”‚   β”‚   └── route.ts
    β”‚       β”‚   β”‚   β”œβ”€β”€ classify/
    β”‚       β”‚   β”‚   β”‚   └── route.ts
    β”‚       β”‚   β”‚   β”œβ”€β”€ image/
    β”‚       β”‚   β”‚   β”‚   └── route.ts
    β”‚       β”‚   β”‚   β”œβ”€β”€ leaderboard/
    β”‚       β”‚   β”‚   β”‚   └── route.ts
    β”‚       β”‚   β”‚   └── user-trash/
    β”‚       β”‚   β”‚       └── route.ts
    β”‚       β”‚   β”œβ”€β”€ auth/
    β”‚       β”‚   β”‚   └── page.tsx
    β”‚       β”‚   β”œβ”€β”€ components/
    β”‚       β”‚   β”‚   β”œβ”€β”€ LoadingPage.tsx
    β”‚       β”‚   β”‚   β”œβ”€β”€ NavBar.tsx
    β”‚       β”‚   β”‚   β”œβ”€β”€ SignIn.tsx
    β”‚       β”‚   β”‚   β”œβ”€β”€ WebSocketDetector.tsx
    β”‚       β”‚   β”‚   └── WebcamDetection.tsx
    β”‚       β”‚   └── hooks/
    β”‚       β”‚       └── AuthHook.jsx
    β”‚       β”œβ”€β”€ firebase/
    β”‚       β”‚   β”œβ”€β”€ firebaseAdminConfig.ts
    β”‚       β”‚   └── firebaseConfig.ts
    β”‚       └── utils/
    β”‚           β”œβ”€β”€ gpt-image-analysis.ts
    β”‚           └── gpt-image-classifier.ts

The application follows a microservices architecture:

  • Frontend Service: Next.js application serving the UI and handling all routes. Also performs image processing and ML inference directly in the browser.

  • Detection Service: FastAPI backend providing additional ML capabilities for more complex image analysis tasks. Optimized for AMD GPU/NPU acceleration when deployed on compatible hardware.

  • User Service: Manages user data, history, and statistics.

  • OpenAI Integration Service: Communicates with ChatGPT APIs for enhanced content generation and advanced image analysis.

About

AI-powered recycling assistant built with YOLOv8 and optimized for AMD NPU acceleration. Provides real-time object detection and disposal guidance through a gamified interface.

Topics

Resources

Stars

Watchers

Forks

Contributors 5