工业缺陷检测实战——基于深度学习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

相关推荐
湘美书院--湘美谈教育22 分钟前
AI时代的奥德赛:算法星空,寻找精神归航
大数据·人工智能·深度学习·机器学习·生活
搞科研的小刘选手39 分钟前
【昌吉学院主办】第三届大数据、神经网络与深度学习研讨会(BDNNDL 2026)
大数据·深度学习·神经网络·学术会议·会议推荐
FriendshipT1 小时前
Ubuntu 20.04 下使用 Ollama 本地部署 AI 大模型
linux·人工智能·python·深度学习·ubuntu
m沐沐3 小时前
【机器学习】朴素贝叶斯算法:从贝叶斯定理到手写数字识别实战
人工智能·深度学习·算法·机器学习·计算机视觉·手写数字·数字识别
大鱼>3 小时前
DSPy:LLM程序自动编译与提示词优化
开发语言·人工智能·python·深度学习
DogDaoDao3 小时前
VVC 帧间编码分区加速方法
深度学习·音视频·视频编解码·h266·vvc·预测编码·帧间编码
Lee_jerome4 小时前
python神经网络编程入门(二十)——RNN LSTM 数学原理与结构拆解
深度学习·numpy·lstm·参数量·sigmoid·tanh·门控机制
梦想三三4 小时前
YOLOv5口罩检测完整实战(二):从现成数据集到训练、评估与摄像头识别
人工智能·yolo·计算机视觉·目标跟踪
满怀冰雪5 小时前
15-Paddle 高层 API 入门:paddle.Model 的训练与评估流程
人工智能·python·深度学习·机器学习·paddle
妍妍爱学习18 小时前
自动编码器与变分自动编码器:同一脉络下的进化
深度学习·无监督学习·概率模型·自动编码器·变分自动编码器