This project aims to detect and classify different types of trash using YOLOv8 for potential integration with robotic systems.
data/
: Contains training and testing dataimages/
: Image files for training and testinglabels/
: Annotation files for trainingdatasets/
: Organized datasets
models/
: Saved model files and weightsscripts/
: Python scripts for training, evaluation, and inferencenotebooks/
: Jupyter notebooks for experimentation and visualizationutils/
: Utility functions and helper scriptsapp/
: Web application for demo purposesstatic/
: Static files (CSS, JS)templates/
: HTML templates
frontend/
: React frontend application
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
Note: We don't push virtual environments (venv, trash_env) to GitHub because they contain large binary files and are system-specific. Instead, we use requirements.txt to specify dependencies that can be installed in a fresh environment.
-
Download YOLOv8 model:
python scripts/download_models.py
-
Run the detection:
python scripts/detect.py --source data/images/test.jpg
-
Navigate to the frontend directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm start
See requirements.txt
for a complete list of Python dependencies.
This project uses TensorFlow and PyTorch, which include large binary files. Instead of pushing these to GitHub:
- We specify these as dependencies in requirements.txt
- The setup process will download the appropriate versions for your system
- We've added virtual environments (venv/, trash_env/) to .gitignore to avoid pushing large binaries
If you encounter issues with large files when pushing to GitHub, make sure you're not pushing any virtual environment directories, and use .gitignore to exclude them.
cd app
python app.py
cd frontend
npm start
Your application should now be running at http://localhost:3000
If the camera feed is not displaying properly in the application, follow these steps to fix common issues:
We've created a script to automatically fix common camera issues:
-
From the project root, run:
./fix_camera.sh
-
After the script completes, start the backend with the proper environment variables:
cd backend OPENCV_FFMPEG_CAPTURE_OPTIONS="video_codec;h264_videotoolbox" PYTHONUNBUFFERED=1 python app.py
-
Camera shows as connected but no image appears
- This is often an environment variable or terminal issue
- Run the fix_camera.sh script to reset the camera system
- Ensure you're using the correct environment variables when starting the backend
-
Multiple cameras detected (phone and computer)
- The application is configured to use the first camera (index 0)
- Disconnect or disable other camera devices if needed
- You can modify the
initialize_camera()
function in app.py to explicitly use a different camera index
-
Permission issues with the camera
- Make sure your application has camera permissions in system settings
- The Info.plist file contains macOS camera permission requirements
- Try restarting your computer if permissions appear stuck
If the fix_camera.sh script doesn't solve your issue:
-
Kill any Python processes that might be using the camera:
pkill -f python
-
Reset the macOS camera system:
sudo killall VDCAssistant sudo killall AppleCameraAssistant
-
Clear any Python cache:
find ./backend -name "*.pyc" -delete find ./backend -name "__pycache__" -type d -exec rm -rf {} +
-
Start the backend with proper environment variables:
export OPENCV_FFMPEG_CAPTURE_OPTIONS="video_codec;h264_videotoolbox" export OPENCV_VIDEOIO_DEBUG=1 export PYTHONUNBUFFERED=1 cd backend python app.py
The camera detection system is vulnerable to environment variables and terminal session issues because:
- OpenCV's camera handling is sensitive to environment variables
- WebSocket connections can be interrupted by terminal state changes
- Camera access permissions can get stuck between sessions
- Multiple processes trying to access the camera can cause conflicts
Always make sure to properly shut down the application when you're done to avoid camera resource conflicts in future sessions.