基于深度学习YOLOv10神经网络PCB缺陷检测系统,其能识别六种PCB缺陷:names = {0:'missing_hole', 1:'mouse_bite', 2:'open_circuit', 3:'short', 4:'spur', 5:'spurious_copper'} CH_names = ['缺失孔','鼠标咬伤','开路','短路','杂散','伪铜']
具体图片见如下:
第一步:YOLOv10介绍
YOLOv10由Ao Wang等人于2024年提出,论文名为:《YOLOv10: Real-Time End-to-End Object Detection》,论文见:https://arxiv.org/pdf/2405.14458
YOLOv10的主要特点和改进包括:
无NMS训练:YOLOv10采用了一致的双重分配策略来进行无NMS(非最大抑制)训练,这显著减少了推理延迟。这种策略结合了一对多和一对一的标签分配,消除了在推理过程中对NMS的需求。
整体效率-精度驱动设计:YOLOv10全面优化了模型的各个组件,从效率和精度的角度减少了计算冗余,提高了参数的利用效率。
架构增强:YOLOv10使用了紧凑的倒置块(CIB)结构来增强特征提取,同时最小化计算成本。它还集成了空间-通道解耦降采样,提高了降采样的效率,同时保留了更多信息。
性能和效率:YOLOv10在速度和精度方面都超越了前代和其他最先进的模型。例如,YOLOv10-S的推理速度比RT-DETR-R18快1.8倍,同时保持了相似的精度。YOLOv10-B与YOLOv9-C相比,在相同性能下延迟减少了46%。
第二步:YOLOv10网络结构
第三步:代码展示
python
# Ultralytics YOLO 🚀, AGPL-3.0 license
from pathlib import Path
from ultralytics.engine.model import Model
from ultralytics.models import yolo
from ultralytics.nn.tasks import ClassificationModel, DetectionModel, OBBModel, PoseModel, SegmentationModel, WorldModel
from ultralytics.utils import ROOT, yaml_load
class YOLO(Model):
"""YOLO (You Only Look Once) object detection model."""
def __init__(self, model="yolo11n.pt", task=None, verbose=False):
"""Initialize YOLO model, switching to YOLOWorld if model filename contains '-world'."""
path = Path(model)
if "-world" in path.stem and path.suffix in {".pt", ".yaml", ".yml"}: # if YOLOWorld PyTorch model
new_instance = YOLOWorld(path, verbose=verbose)
self.__class__ = type(new_instance)
self.__dict__ = new_instance.__dict__
else:
# Continue with default YOLO initialization
super().__init__(model=model, task=task, verbose=verbose)
@property
def task_map(self):
"""Map head to model, trainer, validator, and predictor classes."""
return {
"classify": {
"model": ClassificationModel,
"trainer": yolo.classify.ClassificationTrainer,
"validator": yolo.classify.ClassificationValidator,
"predictor": yolo.classify.ClassificationPredictor,
},
"detect": {
"model": DetectionModel,
"trainer": yolo.detect.DetectionTrainer,
"validator": yolo.detect.DetectionValidator,
"predictor": yolo.detect.DetectionPredictor,
},
"segment": {
"model": SegmentationModel,
"trainer": yolo.segment.SegmentationTrainer,
"validator": yolo.segment.SegmentationValidator,
"predictor": yolo.segment.SegmentationPredictor,
},
"pose": {
"model": PoseModel,
"trainer": yolo.pose.PoseTrainer,
"validator": yolo.pose.PoseValidator,
"predictor": yolo.pose.PosePredictor,
},
"obb": {
"model": OBBModel,
"trainer": yolo.obb.OBBTrainer,
"validator": yolo.obb.OBBValidator,
"predictor": yolo.obb.OBBPredictor,
},
}
class YOLOWorld(Model):
"""YOLO-World object detection model."""
def __init__(self, model="yolov8s-world.pt", verbose=False) -> None:
"""
Initialize YOLOv8-World model with a pre-trained model file.
Loads a YOLOv8-World model for object detection. If no custom class names are provided, it assigns default
COCO class names.
Args:
model (str | Path): Path to the pre-trained model file. Supports *.pt and *.yaml formats.
verbose (bool): If True, prints additional information during initialization.
"""
super().__init__(model=model, task="detect", verbose=verbose)
# Assign default COCO class names when there are no custom names
if not hasattr(self.model, "names"):
self.model.names = yaml_load(ROOT / "cfg/datasets/coco8.yaml").get("names")
@property
def task_map(self):
"""Map head to model, validator, and predictor classes."""
return {
"detect": {
"model": WorldModel,
"validator": yolo.detect.DetectionValidator,
"predictor": yolo.detect.DetectionPredictor,
"trainer": yolo.world.WorldTrainer,
}
}
def set_classes(self, classes):
"""
Set classes.
Args:
classes (List(str)): A list of categories i.e. ["person"].
"""
self.model.set_classes(classes)
# Remove background if it's given
background = " "
if background in classes:
classes.remove(background)
self.model.names = classes
# Reset method class names
# self.predictor = None # reset predictor otherwise old names remain
if self.predictor:
self.predictor.model.names = classes
第四步:统计训练过程的一些指标,相关指标都有
第五步:运行(支持图片、文件夹、摄像头和视频功能)
第六步:整个工程的内容
有训练代码和训练好的模型以及训练过程,提供数据,提供GUI界面代码
项目完整文件下载请见演示与介绍视频的简介处给出:➷➷➷
工业缺陷检测实战------基于深度学习YOLOv10神经网络PCB缺陷检测系统_哔哩哔哩_bilibili