news 2026/8/23 19:15:09

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

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
船只检测和识别2:基于深度学习YOLO26神经网络实现船只检测和识别(含训练代码和数据集)

基于深度学习YOLO26神经网络实现船只检测和识别,其能识别检测出6种船只检测:names: ['ore carrier', 'passenger ship', 'container ship', 'bulk cargo carrier', 'general cargo ship', 'fishing boat']

具体图片见如下:

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

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/8/23 19:11:42

DeepSeek破甲实战:高级提示工程与AI协作效率提升指南

你是不是经常遇到这样的场景:当你向AI助手提出一个稍微复杂或敏感的问题时,得到的回复往往是“抱歉,我无法回答这个问题”或“作为AI助手,我不能……”?这种被“规则”或“护栏”限制的感觉,就像面对一个固…

作者头像 李华
网站建设 2026/8/23 19:10:06

基于QingLedger项目三级锁并发控制机制详解

基于QingLedger项目三级锁并发控制机制详解目录一.项目背景二.为什么是"三级锁",而不是一把锁三.核心概念四. 第 1 级Session Lock(会话级锁)1 锁放在哪2 抢锁:一个原子 UPDATE 搞定"三种场景"3 续租与释放五.第 2 级:Request Lock(请求级锁)1 锁放在哪2 幂…

作者头像 李华
网站建设 2026/8/23 19:04:58

Claude Code实战指南:AI应用开发平台部署与多模型集成

这次我们来看一个名为 Claude Code 的项目。它不是一个新的AI模型,而是一个功能强大的AI应用开发与集成平台,可以让你在本地或云端快速搭建、管理和调用各种AI模型,实现智能应用的快速构建。简单来说,它就像一个“AI应用的操作系…

作者头像 李华
网站建设 2026/8/23 19:03:07

数学建模实战:DEA与Tobit模型在银行效率与风险分析中的应用

1. 从一道赛题到一套方法论:银行效率与风险分析的实战拆解 如果你关注过近几年的数学建模竞赛,无论是国赛、美赛还是像数维杯这样的区域性赛事,会发现一个明显的趋势:赛题越来越“接地气”,越来越贴近真实的产业问题。…

作者头像 李华
网站建设 2026/8/23 19:02:50

小宇宙APP:如何通过时间戳评论与社区运营重塑播客体验

1. 从“听”到“场”:小宇宙的破局点在哪?聊播客,这几年绕不开“小宇宙”这个名字。作为一个在内容行业摸爬滚打了十来年的老编辑,我见证了太多产品从风口上起飞,又悄无声息地落下。播客这个赛道,看似门槛低…

作者头像 李华