Instructions to use Janani-V/pcb-defect-yolov8s-deeppcb with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use Janani-V/pcb-defect-yolov8s-deeppcb with ultralytics:
from ultralytics import YOLOvv8 model = YOLOvv8.from_pretrained("Janani-V/pcb-defect-yolov8s-deeppcb") source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
YOLOv8s β DeepPCB Defect Detection
Model Summary
- Model: YOLOv8s
- Task: PCB defect detection (object detection)
- Dataset: DeepPCB (via Roboflow export)
- Classes: 6 defect categories
- Framework: Ultralytics YOLOv8
- Input size: 640 Γ 640
- Training hardware: Google Colab, Tesla T4 GPU
- Best validation mAP@0.5: 0.985
- Best validation mAP@0.5:0.95: 0.734
- Companion module:
inspector.pyβ adds severity, root cause, impact, and recommended action per detection
π Try it live: PCB Defect Detector Space
Model Description
This repository hosts a YOLOv8s object detection model fine-tuned on the DeepPCB PCB defect dataset for automated visual inspection of printed circuit boards. The model detects and localizes six common manufacturing defects from grayscale PCB imagery, making it suitable as a lightweight baseline for automated optical inspection (AOI), defect benchmarking, and industrial vision research.
Alongside the detection weights, this repository includes a companion knowledge-base module (inspector.py) that wraps the raw YOLO output with structured, defect-specific information β explanation, severity, likely root cause, potential impact, and recommended action β for each detected instance. This is a deterministic rules layer bundled with the model, not the neural network itself generating text; the detection weights (best.pt) only output class, bounding box, and confidence, exactly as a standard YOLOv8 model does.
Architecture: YOLOv8s (Ultralytics), single-stage anchor-free object detector
Base weights: yolov8s.pt (COCO-pretrained, then fine-tuned)
Parameters: ~11.1M
GFLOPs: ~28.4
Defect Classes
| Class ID | Name | Description |
|---|---|---|
| 0 | copper |
Excess/spurious copper residue on the board |
| 1 | mousebite |
Small irregular notches along conductor edges |
| 2 | open |
Break in a conductor path (broken circuit) |
| 3 | pin-hole |
Small void/hole defect in the copper trace |
| 4 | short |
Unintended connection between two conductors |
| 5 | spur |
Unwanted protruding copper extension |
Evaluation Results
Dataset Split
| Split | Images | Used For |
|---|---|---|
| Train | 1,050 | Model fine-tuning |
| Validation | 150 | Metric reporting (below) |
| Test | 300 | Qualitative inference / sample predictions |
All metrics below are computed on the validation split (150 images, 1,003 annotated instances). The test split (300 images) was used only for qualitative inference β the sample detections shown further down are drawn from it.
Overall Metrics
Per-Class Breakdown
| Class | Images | Instances | Precision | Recall | mAP50 | mAP50-95 |
|---|---|---|---|---|---|---|
| copper | 118 | 141 | 0.993 | 0.975 | 0.994 | 0.849 |
| mousebite | 123 | 193 | 0.989 | 0.945 | 0.982 | 0.723 |
| open | 136 | 195 | 0.955 | 0.987 | 0.983 | 0.655 |
| pin-hole | 138 | 154 | 0.991 | 0.968 | 0.993 | 0.829 |
| short | 114 | 151 | 0.890 | 0.934 | 0.970 | 0.639 |
| spur | 120 | 169 | 0.948 | 0.969 | 0.988 | 0.711 |
Performance Chart
Inference speed: ~12.0ms preprocess, ~10.1ms inference, ~4.9ms postprocess per image (Tesla T4, batch size 1, 640Γ640).
Sample Detections
Each pair shows the raw input image (left) and the model's predicted output with bounding boxes and confidence scores (right). Samples are drawn from the test split.
Sample 1
| Input | Prediction |
|---|---|
![]() |
![]() |
Sample 2
| Input | Prediction |
|---|---|
![]() |
![]() |
Sample 3
| Input | Prediction |
|---|---|
![]() |
![]() |
Training Configuration
| Parameter | Value |
|---|---|
| Base model | yolov8s.pt (COCO-pretrained) |
| Framework | Ultralytics YOLOv8 |
| Dataset | DeepPCB (6 classes), via Roboflow export |
| Epochs | 50 |
| Image size | 640 Γ 640 |
| Batch size | 16 |
| Optimizer | Default (SGD, Ultralytics auto-config) |
| Hardware | Google Colab, Tesla T4 GPU (16GB) |
| Train / Val / Test split | 1,050 / 150 / 300 images |
Usage
Option A β Detection only (raw YOLO output)
pip install ultralytics huggingface_hub
from huggingface_hub import hf_hub_download
from ultralytics import YOLO
weights_path = hf_hub_download(
repo_id="Janani-V/pcb-defect-yolov8s-deeppcb",
filename="best.pt"
)
model = YOLO(weights_path)
results = model.predict("your_pcb_image.jpg", conf=0.25)
results[0].show() # visualize
print(results[0].boxes) # raw bounding box data
Batch inference on a folder:
results = model.predict(source="path/to/image_folder/", conf=0.25, save=True)
Option B β Detection + structured explanation, severity, root cause, impact, action
from huggingface_hub import snapshot_download
import sys
local_dir = snapshot_download(repo_id="Janani-V/pcb-defect-yolov8s-deeppcb")
sys.path.append(local_dir)
from inspector import PCBDefectInspector
inspector = PCBDefectInspector(weights_path=f"{local_dir}/best.pt")
result = inspector.inspect("your_pcb_image.jpg")
print(result["summary"])
for finding in result["findings"]:
print(finding["class"], "-", finding["severity"])
print("Explanation:", finding["explanation"])
print("Root cause:", finding["root_cause"])
print("Impact:", finding["impact"])
print("Action:", finding["action"])
print()
Applications
- Automated Optical Inspection (AOI) integration for PCB manufacturing lines
- Pre-screening boards before manual QA review, reducing inspector workload
- Defect-rate tracking and analytics across production batches
- Research baseline for PCB defect detection benchmarking
- Educational/demo use for object detection in industrial inspection contexts
- Generating structured, actionable inspection reports (via
inspector.py) for non-expert reviewers
Limitations
- This model was trained on DeepPCB grayscale linear-scan images and has not been validated on RGB PCB images or other imaging modalities.
- Performance may degrade under distribution shifts such as different board layouts, camera setups, illumination conditions, or image resolutions.
- Localization performance at stricter IoU thresholds is weaker for thin, elongated defects such as open and short, as reflected in their lower mAP@0.5:0.95 scores.
- The
inspector.pyexplanations, severities, root causes, impacts, and actions are drawn from a static, hand-curated knowledge base per defect class β they are general guidance, not image-specific diagnosis, and do not account for defect size, position, or board context. - The model should be treated as a research / baseline AOI model, not a production-ready inspection system, unless further validated on real manufacturing data.
Repository Contents
best.ptβ best fine-tuned YOLOv8s weightsinspector.pyβ companion module providing severity, root cause, impact, and recommended action per detected defectmetrics_chart.pngβ per-class validation performance chartsample*_input.jpg/sample*_predicted.jpgβ example qualitative detections (from test split)README.mdβ model documentation and usage instructions
Intended Role in Project
This model is Stage 1 of a two-stage PCB defect detection effort:
- Stage 1 (this repo): YOLOv8s fine-tuned on DeepPCB β 6 defect classes, clean grayscale images, used as a baseline and pipeline validation stage.
- Stage 2 (in progress): YOLOv8m fine-tuned on DSPCBSD+ β 9 defect classes, larger and more challenging dataset with smaller, imbalanced defect instances.
The two models are intended to be used together or compared, with this repo serving as the simpler, faster baseline.
Author
Fine-tuned and maintained by Janani-V.
Citation
This model was fine-tuned on the DeepPCB dataset, accessed via a Roboflow-hosted version of the dataset.
Original dataset: Tang, S. et al. β DeepPCB: https://github.com/tangsanli5201/DeepPCB
Dataset access (Roboflow project used for this fine-tuning):
janani-v-sdspd/deeppcb-4dhir-failw on Roboflow Universe
Model architecture: Jocher, G., Chaurasia, A., Qiu, J. β Ultralytics YOLOv8: https://github.com/ultralytics/ultralytics
- Downloads last month
- 261
Space using Janani-V/pcb-defect-yolov8s-deeppcb 1
Evaluation results
- mAP50 on DeepPCBvalidation set self-reported0.985
- mAP50-95 on DeepPCBvalidation set self-reported0.734






