)
基于深度學習YOLO26神經網絡實現紙板缺陷檢測和識別其能識別檢測出1種紙板缺陷檢測names: [defect]具體圖片見如下第一步YOLO26介紹YOLO26采用了端到端無NMS推理直接生成預測結果無需非極大值抑制NMS后處理。這種設計減少了延遲簡化了集成并提高了部署效率。此外YOLO26移除了分布焦點損失DFL從而增強了硬件兼容性特別是在邊緣設備上的表現。模型還引入了ProgLoss和小目標感知標簽分配STAL顯著提升了小目標檢測的精度。這對于物聯網、機器人技術和航空影像等應用至關重要。同時YOLO26采用了全新的MuSGD優化器結合了SGD和Muon優化技術提供更穩定的訓練和更快的收斂速度。第二步YOLO26網絡結構第三步代碼展示# 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, modelyolo11n.pt, taskNone, verboseFalse): 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, verboseverbose) self.__class__ type(new_instance) self.__dict__ new_instance.__dict__ else: # Continue with default YOLO initialization super().__init__(modelmodel, tasktask, verboseverbose) 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, modelyolov8s-world.pt, verboseFalse) - 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__(modelmodel, taskdetect, verboseverbose) # 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 its 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第四步統計訓練過程的一些指標相關指標都有?第五步運行預測代碼#coding:utf-8 from ultralytics import YOLO import cv2 # 所需加載的模型目錄 path models/best.pt # 需要檢測的圖片地址 img_path TestFiles/000353.jpg # 加載預訓練模型 # conf 0.25 object confidence threshold for detection # iou 0.7 intersection over union (IoU) threshold for NMS model YOLO(path, taskdetect) results model.predict(img_path, iou0.5) # 檢測圖片 res results[0].plot() cv2.imshow(YOLO26 Detection, res) cv2.waitKey(0)第六步整個工程的內容包含數據集、訓練代碼和預測代碼項目完整文件下載請見演示與介紹視頻的簡介處給出???https://www.bilibili.com/video/BV1fCuM67E2N/