An AI-powered underwater trash detection application that uses advanced computer vision to identify marine debris in images and videos. The system includes a modern React frontend and Python FastAPI backend.
- Single Image Processing: Upload and analyze individual underwater images to detect trash
- Multiple Frame Processing: Convert a series of images into a video with trash detection
- Visualization: View detection results with bounding boxes and confidence scores
- Analytics: Review detection statistics and categorization of marine debris
- Media Gallery: Browse and download previously processed videos
- React with TypeScript
- TailwindCSS for styling
- ShadCN UI components
- Framer Motion for animations
- Python FastAPI
- YOLO for object detection
- OpenCV for image processing
- Ultralytics ML framework
Before installation, make sure you have the following installed:
- Node.js (v14+)
- npm or yarn
- Python (v3.8+)
- pip (Python package manager)
- Git
git clone https://github.com/yourusername/sea-trash-detection.git
cd sea-trash-detection# Create and activate a virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install required packages
pip install ultralytics fastapi python-multipart uvicorn pillow opencv-python imageioThe system requires the YOLO model file (best.pt) to be in the root directory. If you don't have it yet:
- Download the model from this link (replace with actual link)
- Place it in the project root directory
Alternatively, if you have your own trained model, make sure it's named best.pt and place it in the root directory.
Install npm dependencies:
npm installThe backend server runs on port 8000 by default. You can modify this in main.py if needed.
The frontend connects to the backend API at http://localhost:8000 by default. If you need to change this:
- Edit
src/lib/api.ts - Update the
API_BASE_URLconstant to your desired URL
You have multiple options to run the application:
This starts both frontend and backend simultaneously:
node server.js# Activate virtual environment if you created one
source venv/bin/activate # On Windows: venv\Scripts\activate
# Start the FastAPI server
uvicorn main:app --reloadnpm run devFor a production-ready frontend build:
npm run buildThis creates optimized files in the dist directory that can be served by any static file server.
- Open your browser and navigate to http://localhost:5173 (frontend) or the port shown in your terminal
- Click "Get Started" on the homepage to access the detection tool
- Choose the detection method:
- Single Image: Upload one image for immediate analysis
- Multiple Frames: Upload multiple images to create a video
- Adjust the confidence threshold to filter detections
- For video creation, set the desired frames per second (FPS)
- View results with bounding boxes indicating detected objects
- Processed videos appear in the "Recent Processed Videos" section
- Download or share processed media using the available controls
sea-trash-detection/
├── src/ # Frontend source code
│ ├── components/ # React components
│ ├── lib/ # Utilities and API client
│ └── pages/ # Application pages
├── videos/ # Processed video storage
├── main.py # FastAPI backend
├── server.js # Combined dev server
├── setup_server.js # Setup script
└── best.pt # YOLO model file
- Check if Python dependencies are installed correctly
- Verify that the
best.ptmodel file exists in the root directory - Make sure port 8000 is not already in use by another application
- Check the browser console for errors
- Make sure the
videosdirectory exists and is writable - Verify that the CORS settings in
main.pyallow your frontend origin
- Check if the uploaded image format is supported
- Verify that the YOLO model is loaded correctly
- Increase timeout settings if processing large images
This project is licensed under the MIT License - see the LICENSE file for details.
- YOLO model: Ultralytics
- Ocean images: Unsplash


