# YOLO-PCB **Repository Path**: thinkinapp/YOLO-PCB ## Basic Information - **Project Name**: YOLO-PCB - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-25 - **Last Updated**: 2026-03-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # YOLO-PCB πŸ”¬ **A Lightweight Multi-Scale Neural Network for Accurate and Real-Time PCB Defect Detection** [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE) [![Python 3.8+](https://img.shields.io/badge/Python-3.8%2B-blue.svg)](https://www.python.org/) [![PyTorch](https://img.shields.io/badge/PyTorch-1.13%2B-red.svg)](https://pytorch.org/) > **Paper**: Tang Jun, "YOLO-PCB: A Lightweight Multi-Scale Neural Network for Accurate and Real-Time PCB Defect Detection", IEEE Transactions on Industrial Informatics (under review) > **Author**: Tang Jun Β· Guangzhou Xinhua University Β· `tiger.tang@foxmail.com` --- ## Highlights | Model | mAP@0.5 | mAP@0.5:0.95 | FPS (RTX 3090) | Params | |-------|---------|--------------|----------------|--------| | YOLOv8s | 89.4 | 69.7 | 108 | 11.2M | | CDI-YOLO | 91.8 | 72.3 | 108 | 5.5M | | **YOLO-PCB (ours)** | **94.3** | **74.8** | **156** | **4.2M** | - **CSPPCoT backbone**: CoT self-attention inside CSP residual blocks β€” long-range context at < 5 M params - **MSFE neck**: PConv spatial detail + CSPSPPF multi-receptive-field context, dual-path FPN/PAN fusion - **PCB-SIoU loss**: Adaptive angular-cost with exponential decay for small objects β€” +4.4 pp AP on micro-defects (< 32Γ—32 px) - **Edge-ready**: 97 FPS (FP16) on NVIDIA Jetson AGX Orin --- ## Installation ```bash git clone https://github.com/tangjun-yolo/YOLO-PCB.git cd YOLO-PCB pip install -r requirements.txt ``` --- ## Quick Start ### Run Detection on an Image ```bash python detect.py \ --source path/to/pcb.jpg \ --weights weights/best.pt \ --conf 0.25 \ --save-dir runs/detect ``` ### Run on a Directory ```bash python detect.py --source data/images/test/ --weights weights/best.pt ``` ### Run Tests ```bash python tests/test_yolo_pcb.py # or with pytest pip install pytest pytest tests/ -v ``` --- ## Training ### 1. Prepare Dataset ```bash # DeepPCB (1386 images, 6 defect classes) python scripts/prepare_dataset.py ``` Expected layout: ``` data/DeepPCB/ images/ train/ *.jpg val/ *.jpg labels/ train/ *.txt # YOLO format: cls cx cy w h val/ *.txt ``` ### 2. Train ```bash python train.py \ --data data/configs/deeppcb.yaml \ --epochs 300 \ --batch 16 \ --img-size 640 \ --amp ``` Checkpoints are saved to `weights/`. Best model: `weights/best.pt`. --- ## Architecture ``` Input (640Γ—640Γ—3) β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ CSPPCoT Backbone β”‚ β”‚ Stem β†’ Stage1 (P3,80Γ—80,128ch) β”‚ β”‚ β†’ Stage2 (P4,40Γ—40,256ch) β”‚ β”‚ β†’ Stage3+SPPF (P5,20Γ—20,512ch)β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ P3, P4, P5 β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ MSFE Neck (FPN + PAN) β”‚ β”‚ MSFEBlock = PConv βŠ• CSPSPPF β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ N3, N4, N5 β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Decoupled Heads (stride 8 / 16 / 32) β”‚ β”‚ cls_branch (2Γ—Conv) | reg_branch (2Γ—Conv+obj) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό PCB-SIoU Loss ``` --- ## Defect Classes (DeepPCB) | ID | Class | Description | |----|-------|-------------| | 0 | missing_hole | Absence of through-hole | | 1 | mouse_bite | Edge notch on copper trace | | 2 | open_circuit | Broken copper trace | | 3 | short | Unintended copper bridge | | 4 | spur | Extra copper protrusion | | 5 | spurious_copper | Isolated copper residue | --- ## Repository Structure ``` YOLO-PCB/ β”œβ”€β”€ models/ β”‚ β”œβ”€β”€ modules.py # CSPPCoT, CoTAttention, PConv, CSPSPPF, PCB-SIoU β”‚ └── yolo_pcb.py # Full YOLOPCB model, backbone, neck β”œβ”€β”€ utils/ β”‚ β”œβ”€β”€ dataset.py # PCBDataset, augmentation, collate_fn β”‚ └── postprocess.py # NMS, decode_predictions, compute_map β”œβ”€β”€ tests/ β”‚ └── test_yolo_pcb.py # 17 unit & integration tests β”œβ”€β”€ data/ β”‚ └── configs/ β”‚ └── deeppcb.yaml β”œβ”€β”€ scripts/ β”‚ └── prepare_dataset.py β”œβ”€β”€ inference/ # (reserved for TensorRT / ONNX export) β”œβ”€β”€ train.py # Training script with AMP support β”œβ”€β”€ detect.py # Inference CLI (image / video / webcam) β”œβ”€β”€ requirements.txt └── README.md ``` --- ## Citation ```bibtex @article{tang2026yolopcb, title = {{YOLO-PCB}: A Lightweight Multi-Scale Neural Network for Accurate and Real-Time {PCB} Defect Detection}, author = {Tang, Jun}, journal = {IEEE Transactions on Industrial Informatics}, year = {2026}, note = {Under review} } ``` --- ## License MIT Β© Tang Jun, Guangzhou Xinhua University