Skip to content

kadapalanikith/Underwater-Fish-Classification-YOLOv8

Repository files navigation

🌊 DeepSea AI β€” Underwater Fish Classification

YOLOv8 Β· FastAPI Β· React 19 Β· Docker

Model Frontend Backend License

DeepSea AI is an end-to-end computer vision web application that detects and classifies 13 underwater fish species in real time using a custom-trained YOLOv8 model (best.pt).


πŸ—‚οΈ Project Structure

fish_offline_app/
β”œβ”€β”€ client/                  # React 19 + Vite Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx           # Router β€” Home | Demo | Research | Contact
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ DemoPage.jsx  ← AI inference UI (main feature)
β”‚   β”‚   β”‚   β”œβ”€β”€ HomePage.jsx  ← Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ ResearchPage.jsx ← Paper + metrics
β”‚   β”‚   β”‚   └── ContactPage.jsx  ← Team info
β”‚   β”‚   └── index.css        # Design system
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   └── research/
β”‚   β”‚       └── RE_Paper.pdf  # Research paper (served statically)
β”‚   └── .env                 # Frontend environment variables
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ main.py              # FastAPI inference server
β”‚   └── requirements.txt     # Python dependencies
β”œβ”€β”€ models/
β”‚   └── best.pt              # YOLOv8 trained weights (mAP@50: 0.91)
β”œβ”€β”€ Dockerfile               # Unified build (for self-hosted)
β”œβ”€β”€ Dockerfile.render        # Backend-only β€” Render.com
β”œβ”€β”€ Dockerfile.huggingface   # Backend-only β€” Hugging Face Spaces
β”œβ”€β”€ explanation.md           # Project explanation for review committee
└── code_explanation.md      # Code walkthrough for review committee

🐟 Fish Species (13 Classes)

AngelFish Β· BlueTang Β· ButterflyFish Β· ClownFish Β· GoldFish Β· Gourami Β· MorishIdol Β· PlatyFish Β· RibbonedSweetlips Β· ThreeStripedDamselfish Β· YellowCichlid Β· YellowTang Β· ZebraFish


πŸ’» How to Run Locally (Step-by-Step)

Prerequisites

Make sure you have these installed before starting:

Tool Version Check with
Python 3.10+ python --version
Node.js 18+ node --version
npm 9+ npm --version
Git Any git --version

Step 1 β€” Clone the Repository

git clone https://github.com/kadapalanikith/Underwater-Fish-Classification-YOLOv8.git
cd Underwater-Fish-Classification-YOLOv8

Step 2 β€” Start the Backend (Python / FastAPI)

Open a terminal and run:

cd server
pip install -r requirements.txt
python main.py

βœ… You should see:

INFO:     Uvicorn running on http://0.0.0.0:8000
INFO:HF-Backend:βœ… YOLOv8 Model Loaded

The backend is now running at: http://localhost:8000

  • Visit http://localhost:8000 β†’ should return {"status":"running","model":"YOLOv8-Fish-Classifier"}
  • Visit http://localhost:8000/docs β†’ interactive API documentation

Note: First run may take a few minutes to download PyTorch and Ultralytics.


Step 3 β€” Configure Frontend Environment

The frontend needs to know where the backend is. Open client/.env:

VITE_API_URL=http://localhost:8000

This is already set correctly for local development. βœ… No changes needed.


Step 4 β€” Start the Frontend (React / Vite)

Open a new terminal (keep the backend running):

cd client
npm install
npm run dev

βœ… You should see:

  VITE v5.x ready in 300ms
  ➜  Local:   http://localhost:5173/

The frontend is now running at: http://localhost:5173


Step 5 β€” Use the App

  1. Open http://localhost:5173 in your browser
  2. Click "Try the Model" or navigate to Demo
  3. Upload any underwater fish photo (JPEG/PNG, max 10 MB)
  4. Click "Process with YOLOv8"
  5. View annotated image with bounding boxes, species names, and confidence scores

🐳 Docker (All-in-One)

If you have Docker Desktop installed:

# Build the unified image
docker build -t deepsea-ai .

# Run it
docker run -p 8000:8000 deepsea-ai

Open http://localhost:8000 β€” the React build is served by FastAPI in this mode.


πŸ§ͺ Test the API Directly

You can test the backend without the frontend using curl:

curl -X POST http://localhost:8000/api/predict \
  -F "file=@/path/to/your/fish.jpg"

Or use the interactive docs at http://localhost:8000/docs.


πŸ“Š Model Performance

Metric Value
mAP@50 0.91
Precision 0.86
Recall 0.87
mAP@50–95 0.66
Inference Time ≀ 45ms (CPU)
Input Size 640 Γ— 640 px
Confidence Threshold 0.25 (default)

πŸš€ Production Deployment

Frontend β†’ Vercel

  1. Push this repo to GitHub
  2. Connect repo to vercel.com
  3. Set Root Directory to client
  4. Add Environment Variable: VITE_API_URL β†’ your backend URL
  5. Deploy βœ…

Backend β†’ Hugging Face Spaces

  1. Create a new Space at huggingface.co/spaces
  2. Choose Docker as the SDK
  3. Upload Dockerfile.huggingface (rename to Dockerfile) and server/ contents
  4. Upload models/best.pt to the Space files
  5. Space will build and run automatically βœ…

Backend β†’ Render.com

  1. Create a new Web Service at render.com
  2. Connect GitHub repo, set Root Directory to . (repo root)
  3. Set Dockerfile Path to Dockerfile.render
  4. Deploy βœ…

πŸ”§ Troubleshooting

Problem Fix
ModuleNotFoundError: ultralytics Run pip install -r server/requirements.txt
Backend shows ❌ Failed to load model Check that models/best.pt exists
Frontend shows "Connection error" Make sure backend is running on port 8000
CORS error in browser Backend allows * origins by default β€” check it's running
npm install fails Ensure Node.js 18+ is installed
Port 8000 already in use Kill the process: npx kill-port 8000

πŸ“„ Documents

File Purpose
explanation.md Project explanation for review committee (problem β†’ solution β†’ results)
code_explanation.md Code walkthrough for review committee (architecture β†’ functions β†’ design decisions)

πŸ‘¨β€πŸ”¬ Team

Nikith Kadapalaneni β€” Computer Vision & Full-Stack Development GitHub: kadapalanikith


πŸ“œ License

Academic/Educational use only. No unauthorized commercial redistribution.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors