Skip to content

vera-codes6/yolo-object-detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLO Object Detection App

Modern web app for real‑time object detection in images and videos using Ultralytics YOLOv11. Backend is FastAPI; frontend is a simple HTML/CSS/JS UI with drag‑and‑drop uploads and live video streaming.


Features

  • Image and video object detection (YOLOv11 n/s/m)
  • Drag & drop or file picker
  • Model selector: Fast (n) / Balanced (s) / Accurate (m)
  • Live MJPEG stream for videos
  • Clean, responsive UI with reset

Quickstart (Windows PowerShell)

Requires Python 3.10+.

git clone https://github.com/vera-codes6/yolo-object-detection.git
cd yolo-object-detection

python -m venv .venv; .\.venv\Scripts\Activate.ps1
pip install -r requirements.txt

# Place YOLO weights in models/ (already included here as examples)
# yolo11n.pt, yolo11s.pt, yolo11m.pt

uvicorn app.main:app --reload

Open http://127.0.0.1:8000


API

  • GET / – HTML UI.
  • POST /detect/ – Detect on uploaded file.
    • Body: multipart form-data with file
    • Query: model_type in {n,s,m} (defaults to n)
    • Returns:
      • Image: JPEG of annotated result
      • Video: { "stream_url": "/video_stream/{uid}?model_type=..." }
  • GET /video_stream/{uid} – MJPEG video stream (query model_type as above)

Example (image):

curl -X POST "http://127.0.0.1:8000/detect/?model_type=s" ^
  -F "file=@sample.jpg" --output result.jpg

Project structure

YOLO-Object-Detection-App/
├─ app/                  # FastAPI backend
│  ├─ main.py
│  ├─ model_loader.py
│  ├─ image_processor.py
│  └─ stream_processor.py
├─ templates/            # Jinja2 HTML
│  └─ index.html
├─ static/               # Frontend assets
│  ├─ script.js
│  └─ style.css
├─ models/               # YOLO weights (.pt)
│  ├─ yolo11n.pt
│  ├─ yolo11s.pt
│  └─ yolo11m.pt
├─ requirements.txt
├─ Procfile              # For deployment (e.g., Heroku/Render)
└─ README.md

Notes

  • Weights: Replace the provided .pt files with your preferred YOLOv11 variants if needed.
  • GPU: Install the appropriate PyTorch build with CUDA before ultralytics if you want GPU acceleration. See https://pytorch.org/get-started/locally/
  • Video formats: OpenCV decoding depends on your system codecs/ffmpeg.

Tech stack

  • FastAPI, Uvicorn
  • Ultralytics YOLO
  • NumPy, OpenCV
  • HTML/CSS/JS

Deployment

The included Procfile runs:

web: uvicorn app.main:app --host 0.0.0.0 --port $PORT

Suitable for platforms like Heroku or Render.


License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published