Skip to content

Repository files navigation

🏭 Inspection Engine

CI

high-precision Real-Time PCB Defect Detection System

License: MIT Python 3.13+ PyTorch Nightly CUDA 12.8 React 19 FastAPI mAP50: 97.8% Inference: ~12ms

A high-performance computer vision pipeline for high-speed Printed Circuit Board (PCB) quality control.
Powered by a custom-trained YOLOv11s model, a FastAPI WebSocket backend, and a React 19 industrial dashboard.
Delivering real-time defect detection at 80+ FPS on NVIDIA Blackwell hardware.


✨ Features

Feature Description
πŸŽ₯ Live Sensor Feed Real-time webcam streaming with zero-latency YOLO bounding box overlays
πŸ” Static Analysis Mode Upload any PCB image β€” get back a fully annotated result from the model
⚑ TensorRT Acceleration GPU-compiled .engine file for maximum Blackwell SM 12.0 throughput
πŸ“Š Real-Time Anomaly Log Live defect feed with timestamps, auto-scrolling, and persistent session history
πŸ“„ PDF Report Generation One-click official inspection reports with timestamped anomaly timelog
🎨 Industrial Themes Four dark-mode color profiles: Carbon · Cobalt · Emerald · Crimson
πŸ”Œ Full-Duplex WebSockets Zero-copy frame streaming between the AI engine and the React dashboard
πŸ–±οΈ One-Click Deployment Single .bat launch β€” backend + frontend + browser open, fully automated
πŸ“¦ One-Click Install/Uninstall Save ~8 GB of disk space when not in use; restore the full stack in minutes

πŸ“Š Performance

Metric Value
Model Architecture YOLOv11s (Small)
Training Dataset DeepPCB v5 Β· 3,000+ Annotated Images Β· CC BY 4.0
mAP50 97.8%
Inference Backend NVIDIA TensorRT (.engine)
Inference Latency ~10–13 ms / frame
Live Throughput 80+ FPS
Target GPU NVIDIA RTX 5060 (Blackwell SM 12.0)

πŸ—οΈ Architecture

The system is split into three fully asynchronous layers communicating over WebSockets:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  FACE β€” Vite + React 19  (localhost:5173)                   β”‚
β”‚  Industrial dark-mode dashboard                             β”‚
β”‚  Live feed Β· Anomaly log Β· Theme switcher Β· PDF export      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚  ws://127.0.0.1:8000/ws
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  HEART β€” FastAPI  (127.0.0.1:8000)                          β”‚
β”‚  /ws          β†’ Frontend WebSocket (broadcaster)            β”‚
β”‚  /ws_internal β†’ Internal AI pipe (receiver)                 β”‚
β”‚  POST /analyze β†’ Static image analysis endpoint             β”‚
β”‚  GET  /health  β†’ Liveness + model status check             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β”‚  ws://127.0.0.1:8000/ws_internal
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  BRAIN β€” AI Inference Engine  (multiprocessing.Process)     β”‚
β”‚  DirectShow webcam capture β†’ YOLO11s TensorRT               β”‚
β”‚  Annotated JPEG (Base64) β†’ JSON {image, defects[]}          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”¬ Defect Classes

Trained to detect 6 PCB defect categories from the DeepPCB dataset:

Class Description
copper Excess or missing copper on the PCB surface
mousebite Partial break along the edge of the board
open Broken trace causing an open circuit
pin-hole Pinhole void drilled through the copper layer
short Unintended conductive connection between traces
spur Spurious copper protrusion from a trace

πŸš€ Quick Start

Prerequisites

Requirement Minimum Version
OS Windows 10 / 11
Python 3.13+
Node.js v18+
GPU NVIDIA RTX (Blackwell recommended)
CUDA Toolkit 12.8+

Step 1 β€” Clone

git clone https://github.com/Ares19v/Inspection-Engine.git
cd "Inspection Engine"

Step 2 β€” One-Click Install

Double-click INSTALL.bat (or run from a terminal):

.\INSTALL.bat

This automatically:

  • Creates a Python venv
  • Installs PyTorch Nightly with CUDA 12.8 (Blackwell SM 12.0 support)
  • Installs all backend dependencies from backend/requirements.txt
  • Installs all frontend packages via npm install

Disk usage: ~7–10 GB Β· Time: ~5–15 min depending on internet speed

Step 3 β€” Launch

Double-click Run_Inspection_Engine.bat:

.\Run_Inspection_Engine.bat

The full stack starts automatically and your browser opens to http://localhost:5173.


πŸ—‘οΈ Uninstall / Free Disk Space

When you don't need the project running, free up ~8 GB instantly:

.\UNINSTALL.bat

This removes venv/ and frontend/node_modules/ β€” your code, model weights, and configs are completely safe.
Run INSTALL.bat again to restore the full environment in minutes.


πŸ“‘ API Reference

WebSocket Endpoints

Endpoint Direction Payload
ws://127.0.0.1:8000/ws Server β†’ Client { image: string (base64 JPEG), defects: string[] }
ws://127.0.0.1:8000/ws_internal AI Engine β†’ Server Same as above (internal pipe)

HTTP Endpoints

Method Endpoint Description
GET /health Liveness check + model file status
POST /analyze Static PCB image analysis

GET /health β€” Response

{
  "status": "ok",
  "model_dir": "...\\runs\\detect\\inspection_engine_final3\\weights",
  "engine_ready": true,
  "pt_ready": true
}

POST /analyze β€” Request

multipart/form-data with field file (JPEG or PNG image of a PCB)

POST /analyze β€” Response

{
  "image": "<base64-encoded annotated JPEG>",
  "defects": ["open", "short"]
}

πŸ§ͺ Running Model Tests

# Activate the virtual environment
.\venv\Scripts\activate

# Run batch inference on 25 random validation images
python test_model.py

Sample output:

============================================================
IMAGE NAME                     | DEFECT          | CONFIDENCE
------------------------------------------------------------
00041003_test.jpg              | open            | 94.21%
00041015_test.jpg              | CLEAN           | N/A
00041028_test.jpg              | short           | 89.47%
00041044_test.jpg              | mousebite       | 96.83%
============================================================
TEST COMPLETE: Processed 25 images.

🧠 Training Your Own Model

The full training pipeline is included in model_training/:

.\venv\Scripts\activate
cd model_training
python train.py

This downloads the DeepPCB v5 dataset from Roboflow and fine-tunes yolo11s.pt for 50 epochs with early stopping. Results are saved to runs/detect/.

Exporting to TensorRT

The .engine file is machine-specific (compiled for your exact GPU) and is not included in this repository. After training, export it from the .pt weights:

from ultralytics import YOLO
model = YOLO("runs/detect/inspection_engine_final3/weights/best.pt")
model.export(format="engine", device=0)

The backend automatically falls back to the .pt file if no .engine is present β€” no extra configuration needed.


πŸ“ Project Structure

Inspection Engine/
β”‚
β”œβ”€β”€ πŸ“‚ backend/
β”‚   β”œβ”€β”€ requirements.txt         # Pinned Python dependencies
β”‚   └── πŸ“‚ app/
β”‚       β”œβ”€β”€ main.py              # FastAPI server, WebSocket routing, AI spawn
β”‚       β”œβ”€β”€ config.py            # Centralized config (ports, paths, thresholds)
β”‚       β”œβ”€β”€ πŸ“‚ api/              # Route handlers (extensible)
β”‚       └── πŸ“‚ services/         # Business logic layer (extensible)
β”‚
β”œβ”€β”€ πŸ“‚ frontend/
β”‚   └── πŸ“‚ src/
β”‚       └── App.jsx              # Full React 19 industrial dashboard
β”‚
β”œβ”€β”€ πŸ“‚ model_training/
β”‚   β”œβ”€β”€ train.py                 # YOLO fine-tuning script (Roboflow + GPU)
β”‚   └── download_data.py         # Dataset download helper
β”‚
β”œβ”€β”€ πŸ“‚ runs/detect/
β”‚   └── inspection_engine_final3/
β”‚       └── weights/
β”‚           β”œβ”€β”€ best.pt          # βœ… Trained PyTorch weights (in repo)
β”‚           └── best.engine      # ⚑ TensorRT engine (gitignored, generate locally)
β”‚
β”œβ”€β”€ test_model.py                # Batch validation CLI
β”‚
β”œβ”€β”€ INSTALL.bat                  # ⬇️  One-click full installation
β”œβ”€β”€ UNINSTALL.bat                # πŸ—‘οΈ  One-click dependency cleanup
β”œβ”€β”€ Run_Inspection_Engine.bat    # πŸš€  One-click launcher (full stack)
β”‚
β”œβ”€β”€ LICENSE
└── README.md

πŸ—ΊοΈ Roadmap

  • Real-time live webcam inference
  • Static image upload + analysis
  • TensorRT acceleration (Blackwell SM 12.0)
  • WebSocket full-duplex streaming
  • PDF inspection report generation
  • Multi-theme industrial dashboard
  • One-click install / uninstall
  • Multi-camera channel switching
  • Historical analytics with trend graphs
  • Docker containerization
  • REST API for programmatic batch submission
  • ONNX export for cross-platform deployment

Developed as a Final Year B.Tech Computer Science Project by Devansh Tyagi

πŸ€— Model on Hugging Face

The trained model is available on Hugging Face: devanshty/Inspection-Engine

Download

from huggingface_hub import hf_hub_download
model_path = hf_hub_download(repo_id='devanshty/Inspection-Engine', filename='best.pt')

Β© 2026 Devansh Tyagi (Ares19v). All Rights Reserved.

About

Real-time PCB defect detection system powered by YOLOv11 and optimized for NVIDIA RTX 50-Series (Blackwell) edge inference.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages