当前位置: 首页 > news >正文

菌落微生物检测和识别2:基于深度学习YOLO26神经网络实现菌落微生物检测和识别(含训练代码和数据集)

基于深度学习YOLO26神经网络实现菌落微生物检测和识别,其能识别检测出5种菌落微生物检测:names: ['S.aureus', 'E.coli', 'P.aeruginosa', 'C.albicans', 'B.subtilis']

具体图片见如下:

第一步: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, 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

第四步:统计训练过程的一些指标,相关指标都有

第五步:运行预测代码

#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, task='detect') results = model.predict(img_path, iou=0.5) # 检测图片 res = results[0].plot() cv2.imshow("YOLO26 Detection", res) cv2.waitKey(0)

第六步:整个工程的内容

包含数据集、训练代码和预测代码

项目完整文件下载请见演示与介绍视频的简介处给出:➷➷➷

https://www.bilibili.com/video/BV1WJGu6eEBV/

http://www.jsqmd.com/news/1311054/

相关文章:

  • AI反蒸馏机制误触解析:开发者如何规避Claude模型“降智”风险
  • Expo SDK 54 下 React Native 新老架构选型与低配设备内存优化指南
  • 单片机毕设选题推荐:基于单片机射频刷卡充电桩智能计费装置开发 基于硬件传感器的充电桩连接状态检测系统设计(017001)
  • 数控机床数据采集实战:从Fanuc/西门子协议到OneNet上云全解析
  • 树状数组:二进制索引树原理、实现与工程应用指南
  • 基于SpringBoot的全栈Java博客系统开发实践
  • 宝塔面板Nginx文件存在却报404错误:从端口监听到权限配置的完整排查指南
  • 第一篇:AI安全工作流搭建实战——从告警降噪到威胁狩猎,安全工程师的工作流重构教程
  • 白嫖党福音!阿贝云免费云服务器+免费虚拟主机真实体验
  • Apple Watch蜂窝网络开通失败?一文详解eSIM一号双终端报错与解决方案
  • 深度解析so-vits-svc架构:NSF-HIFIGAN声码器如何实现高质量歌唱语音转换
  • HDMI电子墨水屏原理、连接配置与创意应用全解析
  • 利用旧电脑与家庭宽带搭建24小时运行的家庭服务器:从Minecraft私服到个人网站
  • 干货分享:程序员如何避免退化成程序猿
  • 后门攻击和手段
  • GCP 4层 外部网络负载均衡器深度解析
  • 5分钟极速备份:GetQzonehistory教你永久保存QQ空间所有历史说说
  • 深入解决NotepadNext在Windows 7系统上的兼容性挑战
  • RBF网络在时序预测中的三大应用场景
  • 半导体温差发电片专业测试指南:从原理到实战,解锁稳定电源方案
  • 支持向量机(SVM)原理与实现:从最大间隔到梯度下降实战
  • 本地大语言模型开发指南:llama-cpp-python从入门到精通
  • 机器学习交叉验证全解析:从K折到对抗验证的实战指南
  • 0.49英寸OLED屏幕开发全攻略:从硬件连接到ESP32网络时钟实战
  • 机器码你也看不懂,为什么 AI 代码必须逐行看懂?
  • ConcurrentHashMap 深度解析:从分段锁到 CAS 的进化之路
  • 告别拼音文件名:3分钟掌握Calibre中文路径保护插件
  • 基于机器学习模型的缺失值填补:从MICE原理到scikit-learn实战
  • 苹果M5 Max芯片深度实测:专业用户如何评估MacBook Pro极限性能
  • 如何设计移动类型清单:从状态机到智能工作流的核心实践