How kadapalanikith/underwater-fish-classification-yolov8 works
1. Overall shape
- This repo is a two-tier computer-vision application: a React + Vite frontend in client/ and a FastAPI inference backend in server/.
- The core ML asset is the trained YOLOv8 weights file at models/best.pt, which both local and containerized deployments depend on.
2. Primary user-facing workflow
- The main flow is: user opens the web UI, uploads an underwater fish image, the frontend sends that image to the backend, and the backend returns detection/classification results with bounding boxes, labels, and confidence scores.
- The demo/inference experience is the central product path; the other pages are informational.
3. Frontend subsystem
- client/src/App.jsx acts as the app shell/router, switching between HomePage, DemoPage, ResearchPage, and ContactPage.
- DemoPage.jsx is the key interaction surface for inference; HomePage.jsx is the landing page; ResearchPage.jsx serves the paper and metrics; ContactPage.jsx provides team info.
- Styling is centralized in index.css and style.css, with shared layout pieces in Navbar.jsx and Footer.jsx.
4. Frontend-to-backend boundary
- The frontend is configured with a single backend base URL via VITE_API_URL in client/.env, so the UI is decoupled from the API host.
- This boundary is important for deployment: the frontend can be hosted separately from the model server as long as it knows the API URL.
5. Backend inference service
- server/main.py is the FastAPI service that loads the YOLOv8 model and exposes the prediction endpoint.
- The README indicates the service responds at / with a status payload and exposes /docs for interactive API exploration.
- The inference endpoint accepts uploaded image files and runs model prediction on them before returning structured detection output.
6. Model layer
- models/best.pt is the trained detector/classifier and is the only heavy ML artifact in the repo.
- The repository is organized around serving this artifact rather than training it at runtime; training appears to have been done offline, with notebooks retained in notebooks/ for experimentation and reproducibility.
7. Static assets and research content
- The client/public/research/ folder contains the research paper PDF used by the Research page, while client/src/assets/ also includes a paper copy used by the app.
- This content is served statically by the frontend build and does not pass through the backend.
8. Deployment modes
- There are three container entry points:
- Dockerfile for the unified self-hosted build,
- Dockerfile.render for backend-only deployment on Render,
- Dockerfile.huggingface for backend-only deployment on Hugging Face Spaces.
- This means the architecture supports both combined serving and split frontend/backend hosting depending on platform.
9. Serving topology
- In local development, the frontend runs on Vite dev server 5173 and the backend on FastAPI/Uvicorn 8000.
- In the all-in-one Docker mode, FastAPI also serves the built frontend, collapsing the system into a single exposed port.
10. External/runtime dependencies that matter architecturally
- The backend depends on Python, PyTorch, Ultralytics/YOLOv8, and FastAPI; these determine model loading, inference latency, and API shape.
- The frontend depends on React 19 and Vite, which makes the UI a static SPA that talks to the inference service over HTTP.
11. Legacy and auxiliary code
- server/archive/app_legacy.py suggests an older backend implementation kept for reference rather than active use.
- test_sample/ and the notebooks are supporting artifacts, not part of the primary request path.
12. Diagram-friendly summary
- The best architecture diagram should show:
- browser/user → React SPA (client)
- React SPA → FastAPI inference API (server/main.py)
- FastAPI API → YOLOv8 model weights (models/best.pt)
- FastAPI API → JSON/image-annotated prediction response back to the UI
- optional static delivery of research PDFs from the frontend build
- deployment variants via Docker, Render, and Hugging Face Spaces.
Main entry points: App.jsx App Shell · main.py FastAPI Server · DemoPage.jsx Demo · ResearchPage.jsx Research
Components 20
Frontend
React/Vite SPA, shared layout, and static content delivery.
- App Shell · Top-level React app that switches between the main pages.
client/src/App.jsx - Home · Landing page and overview content.
client/src/pages/HomePage.jsx - Demo · Primary upload-and-predict interaction surface.
client/src/pages/DemoPage.jsx - Research · Presents paper and results/metrics.
client/src/pages/ResearchPage.jsx - Contact · Team and contact information.
client/src/pages/ContactPage.jsx - Navbar · Shared top navigation.
client/src/Navbar.jsx - Footer · Shared bottom layout element.
client/src/Footer.jsx - Styles · Centralized app styling.
client/src/index.css - API URL · Backend base URL configured for the frontend build.
Inference API
FastAPI service that loads the model and serves predictions.
- FastAPI Server · Backend service exposing status and prediction endpoints.
server/main.py - Image Upload · Uploaded underwater fish image sent from the demo UI.
- Predictions · Detection results with boxes, labels, and confidence scores.
Model & Content
Trained weights and research artifacts used by the app.
- Paper PDF · Research paper served statically by the frontend build.
client/public/research/RE_Paper.pdf - YOLOv8 Weights · Trained detector/classifier used for inference.
models/best.pt
Deployment
Container and platform-specific serving entry points.
- Docker Build · Unified container entry point for self-hosted deployment.
Dockerfile - Render Build · Backend-only container variant for Render.
Dockerfile.render - HF Build · Backend-only container variant for Hugging Face Spaces.
Dockerfile.huggingface
Supporting
Legacy, notebooks, and sample artifacts around the core system.
- Legacy App · Older backend implementation kept for reference.
server/archive/app_legacy.py - Notebooks · Offline experimentation and reproducibility artifacts.
notebooks/MinorProject COLAB File.ipynb
Other components
- User Browser · End user opens the web UI and uploads fish images.
Connections 20
- User Browser → App Shell: loads UI · User opens the React SPA in the browser.
- App Shell → Home: routes to · App shell displays the landing page.
- App Shell → Demo: routes to · App shell displays the main inference workflow.
- App Shell → Research: routes to · App shell displays research content.
- App Shell → Contact: routes to · App shell displays contact information.
- App Shell → Navbar: uses · Shared navigation appears across pages.
- App Shell → Footer: uses · Shared footer appears across pages.
- App Shell → Styles: styled by · Global and shared CSS shape the UI.
- Demo → API URL: reads · Frontend uses the configured backend host.
- Demo → Image Upload: posts · Demo page uploads an image for inference.
- Image Upload → FastAPI Server: sent to · The uploaded image is submitted to the inference API.
- Research → Paper PDF: serves · Research page links to the statically hosted paper.
- FastAPI Server → YOLOv8 Weights: loads · Backend loads the trained YOLOv8 artifact at startup.
- FastAPI Server → Predictions: returns · Prediction endpoint responds with structured detections.
- FastAPI Server → User Browser: serves results to · Annotated predictions are ultimately shown in the UI.
- FastAPI Server → Legacy App: replaces · Legacy backend remains only as reference.
- Docker Build → FastAPI Server: packages · Unified container bundles the backend and built frontend.
- Render Build → FastAPI Server: packages · Render deployment targets the backend service.
- HF Build → FastAPI Server: packages · Hugging Face deployment targets the backend service.
- Notebooks → YOLOv8 Weights: produced offline · Notebooks represent experimentation that led to the trained weights.