工业缺陷检测实战——基于深度学习YOLOv10神经网络PCB缺陷检测系统

基于深度学习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

相关推荐
zxsz_com_cn25 分钟前
设备预测性维护模型构建详解与实例:中讯烛龙如何用“数据+算法”破解故障预测难题
人工智能·深度学习·机器学习
67X1 小时前
【论文研读】Deep learning improves prediction of drug–drug anddrug–food interactions
人工智能·深度学习
程序员Shawn2 小时前
【深度学习 | 第三篇】-卷积神经网络
人工智能·深度学习·cnn
光电的一只菜鸡3 小时前
《PyTorch深度学习建模与应用(参考用书)》(三)——深度神经网络
pytorch·深度学习·dnn
AI医影跨模态组学4 小时前
Ann Oncol(IF=65.4)广东省人民医院放射科刘再毅等团队:基于深度学习CT分类器与病理标志物增强II期结直肠癌风险分层以优化辅助治疗决策
人工智能·深度学习·论文·医学·医学影像
逻辑君5 小时前
认知神经科学研究报告【20260008】
人工智能·深度学习·神经网络·机器学习
弘弘弘弘~6 小时前
项目实战之评论情感分析模型——基于Bert(含任务头)
人工智能·深度学习·bert
小超同学你好6 小时前
Transformer 23. Qwen 3.5 架构介绍:混合线性/全注意力、MoE 与相对 Qwen 1 / 2 / 3 的演进
人工智能·深度学习·语言模型·架构·transformer
源码之屋7 小时前
计算机毕业设计:Python出行数据智能分析与预测平台 Django框架 可视化 数据分析 PyEcharts 交通 深度学习(建议收藏)✅
人工智能·python·深度学习·数据分析·django·汽车·课程设计
ForDreamMusk7 小时前
深度学习的计算环境
人工智能·深度学习