Skip to content

sarfraspc/object-detection-mlops

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLOv8-Nano Object Detection – MLOps Assignment

CI Status Docker Pulls Railway Deploy

A production-ready object detection API using YOLOv8-nano with 80 COCO classes, served with FastAPI, fully containerized with Docker, automatically tested with GitHub Actions, and deployed 24/7 on Railway cloud platform.

Live Demo

Try it now:
https://object-detection-mlops-production.up.railway.app/

Resources


Project Overview

This project implements a complete MLOps pipeline for an object detection service featuring:

  • YOLOv8-nano model detecting 80 COCO object classes
  • FastAPI backend with RESTful endpoints
  • Responsive web interface with real-time predictions
  • Docker containerization with optimized image
  • CI/CD pipeline using GitHub Actions
  • Cloud deployment on Railway with auto-scaling
  • Automated testing with pytest
  • Production-grade logging and monitoring

Works seamlessly both locally and in the cloud with zero configuration required.


Assignment Requirements

Step 1: Version Control

  • Public GitHub repository initialized
  • All code, Dockerfile, tests, and frontend committed
  • Clean commit history with meaningful messages
  • Comprehensive README documentation

Step 2: Docker Containerization

Dockerfile (optimized ~320 MB):

FROM ultralytics/ultralytics:latest-cpu

WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY src/ ./src
COPY frontend/ ./frontend

EXPOSE 8080
CMD ["uvicorn", "src.main:app", "--host", "0.0.0.0", "--port", "8080"]

Build & Run locally:

docker build -t yolo-app .
docker run -p 8080:8080 yolo-app

Public Docker Hub registry:
https://hub.docker.com/r/sarfras7/yolo-app

Anyone can run it instantly:

docker run -p 8080:8080 sarfras7/yolo-app:v1

Step 3: Cloud Deployment

Deployed on Railway.app – a production-grade cloud platform.

How it works:

  • Connected GitHub repository to Railway
  • Railway automatically detects and builds from Dockerfile
  • Deploys container with HTTPS, global CDN, and auto-scaling
  • Public URL generated instantly

Live Application:
https://object-detection-mlops-production.up.railway.app/

Features a beautiful, responsive web UI – just open the link and upload any image!

Step 4: Automated Testing & CI/CD

GitHub Actions CI runs on every push and pull request:

name: CI
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with: 
          python-version: '3.10'
      - uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: pip-${{ runner.os }}-${{ hashFiles('requirements.txt') }}
      - run: pip install -r requirements.txt
      - run: pytest -q

Testing features:

  • Mocked YOLO to avoid downloading weights in CI (fast & reliable)
  • Full API integration tests + health check
  • CI badge always green

Step 5: Monitoring & Logging

  • Structured logging in FastAPI (INFO level)
  • Real-time logs visible in Railway dashboard
  • Request timing and object count logged per inference
  • Production-ready error handling

Features (Above & Beyond)

Responsive Web Interface

  • Modern HTML + CSS + JavaScript frontend (no framework bloat)
  • Drag-and-drop file upload with live preview
  • Real-time detection results with confidence percentages
  • Comprehensive error handling & loading states
  • Works seamlessly on mobile and desktop devices

Production Quality

  • Zero-cost deployment running 24/7
  • Global CDN for fast access worldwide
  • Automatic HTTPS encryption
  • Auto-scaling based on traffic

How to Run

Option 1: Cloud (Recommended)

Simply visit the live demo:
https://object-detection-mlops-production.up.railway.app/

Option 2: Docker (Local or Any Server)

Pull and run the pre-built image from Docker Hub:

docker run -p 8080:8080 sarfras7/yolo-app:v1

Then open: http://localhost:8080

Option 3: From Source

Clone the repository and build locally:

# Clone repository
git clone https://github.com/sarfraspc/object-detection-mlops.git
cd object-detection-mlops

# Build Docker image
docker build -t yolo-local .

# Run container
docker run -p 8080:8080 yolo-app

Then open: http://localhost:8080


Tech Stack

Component Technology
Model YOLOv8-nano (Ultralytics)
Backend FastAPI + Uvicorn
Frontend HTML5 + CSS3 + JavaScript
Containerization Docker
CI/CD GitHub Actions
Testing pytest
Deployment Railway.app
Registry Docker Hub

API Endpoints

GET /

Serves the web interface

POST /predict

Accepts an image file and returns detection results

Request:

  • Content-Type: multipart/form-data
  • Body: Image file (jpg, png, jpeg)

Response:

{
  "predictions": [
    {
      "class_name": "person",
      "class_id": 0,
      "confidence": 0.95,
      "bbox": [100.0, 200.0, 300.0, 400.0]
    }
  ],
  "inference_time_s": 0.015,
  "model": "yolov8n.pt"
}

GET /health

Health check endpoint for monitoring

Response:

{
  "status": "healthy"
}

Testing

Run tests locally:

pip install -r requirements.txt
pytest -v

Tests include:

  • API endpoint validation
  • Health check verification
  • Image processing pipeline
  • Error handling scenarios

Project Structure

object-detection-mlops/
├── .github/
│   └── workflows/
│       └── ci.yml          # GitHub Actions CI/CD
├── src/
│   └── main.py             # FastAPI application
├── frontend/
│   └── index.html          # Web interface
├── tests/
│   └── test_api.py         # Pytest test suite
├── Dockerfile              # Container configuration
├── requirements.txt        # Python dependencies
└── README.md              # This file

Summary

This project demonstrates a complete MLOps pipeline with:

Version Control – Clean Git history and documentation
Containerization – Optimized Docker image on public registry
Cloud Deployment – 24/7 availability with auto-scaling
CI/CD Pipeline – Automated testing on every commit
Production Quality – Monitoring, logging, and error handling
User Experience – Beautiful, responsive web interface

All assignment requirements fully satisfied and exceeded.


License

MIT License - feel free to use this project for learning and portfolio purposes.


Acknowledgments

  • Ultralytics for the YOLOv8 model
  • FastAPI for the excellent web framework
  • Railway for seamless deployment
  • GitHub Actions for CI/CD automation

About

YOLOv8-Nano object detection API with FastAPI + beautiful web UI. Fully Dockerized, CI-tested, deployed 24/7 on Railway.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages