Hey there! Check out this AI Plastic Waste Detector! So, this project is all about using cool computer vision and AI to spot plastic waste. We're hoping it can really help with keeping an eye on our environment and cleaning things up! At its heart, we've got a special YOLOv5 model that's been trained just for this, doing real-time detection, plus another script for checking out images and even making maps. Pretty neat, huh?
What it can do! See Plastic Live! This uses our special YOLOv5 model to find plastic waste as it happens. Perfect for hooking up to cameras or video feeds!
Upload an Image, Get Results! Just pop in an image, and it'll tell you where the plastic waste is hiding.
Map It Out! It can even whip up a simple map showing where all that detected plastic waste is. Super helpful for planning cleanups!
What's under the hood? YOLOv5: That's our go-to for spotting objects, whether it's live or in pictures.
Gradio: This helps us make a super easy-to-use web interface for the live detection part.
Python: Our main language for all the coding magic.
OpenCV (probably!): Great for all those image-related tasks.
Other cool libraries: Like NumPy and Matplotlib, for handling data and making pretty visuals.
How it's all put together yolov5_gradiotrash.py: This is the script that handles all the real-time plastic spotting with YOLOv5 and the Gradio interface.
trash_detection.py: This one takes care of uploading images, recognizing the plastic, and generating those helpful maps.
README.md: Yep, that's this file right here!
(You'd usually find other important stuff here too, like a requirements.txt file, the actual model brains, and some example data!)
Let's get it running! Wanna give this project a whirl? Just follow these simple steps:
Grab the code:
git clone cd "AI Powered Plastic Detection"
(Don't forget to swap with where you actually keep the code!)
Set up a cozy virtual environment (totally recommended!):
python -m venv venv .\venv\Scripts\activate # If you're on Windows source venv/bin/activate # If you're on macOS or Linux
Install all the bits and bobs it needs:
pip install -r requirements.txt
(You'll definitely want a requirements.txt file with all your Python library names like torch, ultralytics, gradio, opencv-python, etc. If you don't have one, you'll have to install them one by one, like pip install torch torchvision opencv-python ultralytics gradio)
Get those YOLOv5 brains:
You'll need the standard YOLOv5 weights (like yolov5s.pt) and the special ones we trained for plastic. Just pop them into the right spot (maybe a weights/ folder?).
How to use it! For the live action (yolov5_gradiotrash.py) To fire up the real-time detection:
python yolov5_gradiotrash.py
This will usually open up a Gradio web page in your browser. Then you can use your webcam or upload a video to see it in action!
For images and maps (trash_detection.py) To get started with image uploads and map making:
python trash_detection.py
This script probably has its own way of letting you upload images and process them for data and maps. Just peek inside the script or check its arguments for the nitty-gritty details!
A little heads-up about the model... Just so you know, our current AI model was trained with only about 5000 images. Because the dataset is a bit on the smaller side, the accuracy isn't super high right now. So, you might see a few things like:
Oops, that's not plastic! Sometimes it might think something is plastic when it's not.
Missed one! It might occasionally miss some actual plastic waste.
Not quite perfect in different places or tricky lighting.
What's next for this project? We've got some exciting ideas for the future!
More Data! We really want to get way more diverse images of plastic waste to train the model better.
Smarter Model! We'll look into cooler ways to fine-tune the YOLOv5 model or even try out different versions.
Awesome Maps! We want to make the maps even better, maybe with more interactive stuff and super precise location info.
Easy Access! Thinking about making it super easy for everyone to use by deploying the application somewhere!
License stuff This project is open-source, which means it's free to use and share under the MIT License. (Psst! If you haven't already, it's a good idea to add a LICENSE file to your repository!)