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.
- 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
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- GET
/– HTML UI. - POST
/detect/– Detect on uploaded file.- Body: multipart form-data with
file - Query:
model_typein {n,s,m} (defaults ton) - Returns:
- Image: JPEG of annotated result
- Video:
{ "stream_url": "/video_stream/{uid}?model_type=..." }
- Body: multipart form-data with
- GET
/video_stream/{uid}– MJPEG video stream (querymodel_typeas above)
Example (image):
curl -X POST "http://127.0.0.1:8000/detect/?model_type=s" ^
-F "file=@sample.jpg" --output result.jpgYOLO-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
- Weights: Replace the provided
.ptfiles with your preferred YOLOv11 variants if needed. - GPU: Install the appropriate PyTorch build with CUDA before
ultralyticsif you want GPU acceleration. See https://pytorch.org/get-started/locally/ - Video formats: OpenCV decoding depends on your system codecs/ffmpeg.
- FastAPI, Uvicorn
- Ultralytics YOLO
- NumPy, OpenCV
- HTML/CSS/JS
The included Procfile runs:
web: uvicorn app.main:app --host 0.0.0.0 --port $PORT
Suitable for platforms like Heroku or Render.
MIT