Skip to content

mzayan-bit/SentinelOps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

90 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SentinelOps

Production-grade MLOps pipeline for PPE (Personal Protective Equipment) detection using YOLO object detection.


Problem Statement

SentinelOps aims to provide a robust, scalable, and automated MLOps pipeline for computer vision models. Moving from isolated Jupyter notebooks to a structured, reproducible environment is crucial for bringing AI models reliably into production.

Architecture Diagram

graph TD
    A[Raw Data] -->|DVC| B[Versioned Dataset]
    B --> C[Training Pipeline]
    C -->|MLflow| D[Experiment Tracking & Model Registry]
    D --> E[FastAPI Inference]
    E -->|Evidently| F[Monitoring]
Loading

Tech Stack

Layer Technology
Data Versioning DVC
Experiment Tracking MLflow + DagsHub
Modeling Ultralytics YOLO11
Inference API FastAPI, Uvicorn
Frontend App Next.js, React, Tailwind CSS
Monitoring Evidently
Testing & Formatting Pytest, Black, Flake8

PPE Detection Model

Model: YOLO11s (Fine-Tuned)

Classes:

  • 🦺 Reflective Jacket
  • ⛑️ Safety Helmet

Dataset:

  • 4,864 labeled instances
  • 1,427 validation images

Performance

Metric Value
Precision 93.3%
Recall 91.4%
mAP50 96.4%
mAP50-95 77.9%

The model achieves near-production accuracy with a precision–recall balance above 90%, making it suitable for real-time safety monitoring.


Training Artifacts

Training Curves

Training Results

Precision–Recall & F1

Precision–Recall Curve F1 Curve
BoxPR Curve BoxF1 Curve

Precision Curve

BoxP Curve

Confusion Matrices

Standard Normalised
Confusion Matrix Normalised Confusion Matrix

Label Distribution

Labels

πŸ“– For detailed explanations of each chart, see docs/training/README.md.


Training Summary

Parameter Value
Architecture YOLO11s
Framework Ultralytics
Tracking MLflow + DagsHub
Training Time 2.44 hours
GPU NVIDIA Tesla T4
Input Size 640Γ—640
Epochs 50

Model Weights

The models/ppe_detector/best.pt file contains the best-performing checkpoint selected by validation mAP during training. It can be loaded directly with the Ultralytics library:

from ultralytics import YOLO

model = YOLO("models/ppe_detector/best.pt")

Example Inference

from ultralytics import YOLO

model = YOLO("models/ppe_detector/best.pt")

results = model.predict(
    source="video.mp4",
    conf=0.25,
    show=True,
    show=True,
    save=True
)

How to Run Locally

You can run SentinelOps locally by starting both the FastAPI backend and the Next.js frontend.

1. Start the Backend (FastAPI)

Open a terminal, activate your virtual environment, and run the FastAPI server:

# From the root of the SentinelOps project
source venv/bin/activate
uvicorn app.api.app:app --port 8001

The API will be available at http://localhost:8001.

2. Start the Frontend (Next.js)

Open a new terminal, navigate to the frontend directory, and start the Next.js development server:

cd frontend
npm install
npm run dev

The web application will be available at http://localhost:3000.


Docker Deployment

SentinelOps includes a production-ready multi-stage Dockerfile that runs the API as a non-root user.

Build the Image

docker build -t sentinelops:latest .

Run the Container

docker run -d \
  --name sentinelops \
  -p 8000:8000 \
  -e HOST=0.0.0.0 \
  -e PORT=8000 \
  -v $(pwd)/artifacts:/app/artifacts \
  -v $(pwd)/config:/app/config \
  sentinelops:latest

This maps port 8000, provides required environment variables, and mounts the artifacts and config directories so persistent data is retained outside the container.


Configuration Management

SentinelOps uses pydantic-settings for robust, type-checked centralized configuration.

All settings are managed via the ENVIRONMENT variable (defaults to dev). This variable automatically loads the corresponding .env file from the config/environments/ directory.

  • Development (ENVIRONMENT=dev): Loads config/environments/.env.dev. Uses local artifacts/ directories.
  • Production (ENVIRONMENT=prod): Loads config/environments/.env.prod. Connects to external databases (postgres/redis) and mounted volume paths.

If you are running the system outside of Docker Compose, ensure you copy .env.example to .env and set ENVIRONMENT=dev or your desired target.


Docker Compose Deployment (Recommended)

SentinelOps includes a docker-compose.yml for standing up the full infrastructure stack (Backend API, PostgreSQL, Redis) simultaneously.

  1. Ensure you have populated your environment variables (see .env.example).
  2. Bring up the stack in detached mode:
docker-compose up -d

The services are configured with health checks and persistent volumes for databases and application artifacts.

To view logs:

docker-compose logs -f backend

To tear down the stack:

docker-compose down

Repository Structure

.
β”œβ”€β”€ app/                # Alert management system (API + service)
β”œβ”€β”€ config/             # Centralised settings
β”œβ”€β”€ frontend/           # Next.js web application (Dashboard & Live Streams)
β”œβ”€β”€ docs/               # Documentation & training artifacts
β”‚   └── training/       # Evaluation curves & confusion matrices
β”œβ”€β”€ inference/          # Model loader, predictor, tracker, compliance
β”‚   └── api/            # FastAPI inference service
β”œβ”€β”€ models/
β”‚   └── ppe_detector/   # Production model weights
β”œβ”€β”€ monitoring/         # Data drift monitoring
β”œβ”€β”€ schemas/            # Typed data schemas
β”œβ”€β”€ scripts/            # Utility scripts
β”œβ”€β”€ src/                # Dataset validation, model registry
β”œβ”€β”€ tests/              # Unit & structural tests
β”œβ”€β”€ training/           # Training configs & presets
β”œβ”€β”€ utils/              # Logger, image validator
β”œβ”€β”€ .gitignore
β”œβ”€β”€ Makefile
β”œβ”€β”€ README.md
└── requirements.txt

Project Roadmap

  • Phase 0: Project Foundation (Setup, Environments, Boilerplate)
  • Phase 1: Dataset Versioning & Preparation
  • Phase 2: Model Training & Experiment Tracking
  • Phase 3: Inference API (FastAPI)
  • Phase 4: Monitoring Dashboard (Streamlit & Evidently)
  • Phase 5: CI/CD and Cloud Deployment

Future Improvements

  • Cloud integration (AWS S3 / GCP Cloud Storage) for DVC remotes.
  • Automated CI/CD pipelines with GitHub Actions.
  • Dockerization of the inference and dashboard services.
  • Advanced monitoring alerts and drift-triggered retraining.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors