和識(shí)別2:基于深度學(xué)習(xí)YOLO26神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)昆蟲檢測(cè)和識(shí)別(含訓(xùn)練代碼和數(shù)據(jù)集))
基于深度學(xué)習(xí)YOLO26神經(jīng)網(wǎng)絡(luò)實(shí)現(xiàn)昆蟲檢測(cè)和識(shí)別其能識(shí)別檢測(cè)出6種昆蟲檢測(cè)names {0:Leconte, 1:acuminatus, 2:Boerner, 3:Linnaeus, 4:armandi, 5:coleoptera}具體圖片見如下第一步Y(jié)OLO26介紹YOLO26采用了端到端無NMS推理直接生成預(yù)測(cè)結(jié)果無需非極大值抑制NMS后處理。這種設(shè)計(jì)減少了延遲簡(jiǎn)化了集成并提高了部署效率。此外YOLO26移除了分布焦點(diǎn)損失DFL從而增強(qiáng)了硬件兼容性特別是在邊緣設(shè)備上的表現(xiàn)。模型還引入了ProgLoss和小目標(biāo)感知標(biāo)簽分配STAL顯著提升了小目標(biāo)檢測(cè)的精度。這對(duì)于物聯(lián)網(wǎng)、機(jī)器人技術(shù)和航空影像等應(yīng)用至關(guān)重要。同時(shí)YOLO26采用了全新的MuSGD優(yōu)化器結(jié)合了SGD和Muon優(yōu)化技術(shù)提供更穩(wěn)定的訓(xùn)練和更快的收斂速度。第二步Y(jié)OLO26網(wǎng)絡(luò)結(jié)構(gòu)第三步代碼展示# 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第四步統(tǒng)計(jì)訓(xùn)練過程的一些指標(biāo)相關(guān)指標(biāo)都有?第五步運(yùn)行預(yù)測(cè)代碼#coding:utf-8 from ultralytics import YOLO import cv2 # 所需加載的模型目錄 path models/best.pt # 需要檢測(cè)的圖片地址 img_path TestFiles/000353.jpg # 加載預(yù)訓(xùn)練模型 # 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) # 檢測(cè)圖片 res results[0].plot() cv2.imshow(YOLO26 Detection, res) cv2.waitKey(0)第六步整個(gè)工程的內(nèi)容包含數(shù)據(jù)集、訓(xùn)練代碼和預(yù)測(cè)代碼項(xiàng)目完整文件下載請(qǐng)見演示與介紹視頻的簡(jiǎn)介處給出???https://www.bilibili.com/video/BV1G48y6tEdZ/