Lab build

Guns object detection API

Detects guns in images with a fine-tuned Faster R-CNN served through a FastAPI endpoint.

Role
Builder, end to end
Group
MLOps
Services
AI & LLM systems · MLOps & cloud

What it does

A Kaggle guns object-detection dataset is downloaded with kagglehub and organised into images and labels. A torchvision Faster R-CNN ResNet-50 FPN model is fine-tuned with Adam, losses are logged to TensorBoard, and a two-stage DVC pipeline reproduces ingestion and training. A FastAPI /predict endpoint returns the uploaded image with boxes drawn for detections scoring above 0.7, tested through Swagger UI and Postman.

What was built

  1. 01

    Ingestion pulls issaisasank/guns-object-detection via kagglehub and copies images and labels into artifacts/raw.

  2. 02

    Pre-trained fasterrcnn_resnet50_fpn gets a new box predictor head and trains with Adam at a 1e-4 learning rate.

  3. 03

    Training losses are written to timestamped TensorBoard log directories.

  4. 04

    dvc.yaml defines data_ingestion and model_training stages with tracked outputs, including fasterrcnn.pth.

  5. 05

    FastAPI /predict draws red boxes for scores above 0.7 and streams the annotated image back.

The pipeline, layer by layer

Four layers, one pipeline.

  1. L1Data

    • Kaggle dataset
    • kagglehub ingestion
  2. L2Training

    • Faster R-CNN fine-tuning
    • TensorBoard logs
  3. L3Pipeline

    • DVC stages
  4. L4Serving

    • FastAPI /predict
    • Swagger UI and Postman

Stack

  • PyTorch
  • torchvision
  • Faster R-CNN
  • OpenCV
  • kagglehub
  • TensorBoard
  • DVC
  • FastAPI
  • Uvicorn
  • Pillow
  • Postman

Next lab build · 19 / 46

Student performance prediction on AWS and Azure

Predicts student maths scores and deploys the Flask app to Elastic Beanstalk, EC2 and Azure Web App.

Previous: Smart manufacturing efficiency prediction with GitOps

Need a system like this in production? Tell us about it.