改深度学习模型(适用于YOLOv5、YOLOv6、YOLOv7、YOLOv8、YOLOv9、YOLOX等YOLO架构的源代码)

我的配置

torch 1.12.1

python 3.9.18

编辑器:pycharm

# YOLOv5 requirements
# Usage: pip install -r requirements.txt

# Base ------------------------------------------------------------------------
gitpython>=3.1.30
matplotlib>=3.3
numpy>=1.23.5
opencv-python>=4.1.1
pillow==9.5.0
# pillow>=10.3.0
psutil  # system resources
PyYAML>=5.3.1
requests>=2.23.0
scipy>=1.4.1
thop>=0.1.1  # FLOPs computation
torch>=1.8.0  # see https://pytorch.org/get-started/locally (recommended)
torchvision>=0.9.0
tqdm>=4.64.0
ultralytics>=8.0.232
# protobuf<=3.20.1  # https://github.com/ultralytics/yolov5/issues/8012

# Logging ---------------------------------------------------------------------
# tensorboard>=2.4.1
# clearml>=1.2.0
# comet

# Plotting --------------------------------------------------------------------
pandas>=1.1.4
seaborn>=0.11.0

# Export ----------------------------------------------------------------------
# coremltools>=6.0  # CoreML export
# onnx>=1.10.0  # ONNX export
# onnx-simplifier>=0.4.1  # ONNX simplifier
# nvidia-pyindex  # TensorRT export
# nvidia-tensorrt  # TensorRT export
# scikit-learn<=1.1.2  # CoreML quantization
# tensorflow>=2.4.0,<=2.13.1  # TF exports (-cpu, -aarch64, -macos)
# tensorflowjs>=3.9.0  # TF.js export
# openvino-dev>=2023.0  # OpenVINO export

# Deploy ----------------------------------------------------------------------
setuptools>=65.5.1 # Snyk vulnerability fix
# tritonclient[all]~=2.24.0

# Extras ----------------------------------------------------------------------
# ipython  # interactive notebook
# mss  # screenshots
# albumentations>=1.0.3
# pycocotools>=2.0.6  # COCO mAP
wheel>=0.38.0 # not directly required, pinned by Snyk to avoid a vulnerability

# new module
timm
torchsummary

本篇博客主要分享各大企业和高校推出的源代码,并且集成在YOLOv5框架中。

源代码主要包括,主干网络、损失函数、检测头、注意力机制等模块。

GitHub仓库:https://github.com/Jie-Huangi/study_yolo,欢迎标星🔥🔥🔥。

当前仓库的代码还不够完整,后期会逐个添加相关代码。

我使用的数据是自行在B站上截屏获取的。经过数据增强,得到300张左右的训练集。

数据集下载地址:https://pan.baidu.com/s/1Zuroo7qpie-TFLQ93qvSsg?pwd=cqcc 提取码: cqcc

制作自己的数据集代码:https://github.com/Jie-Huangi/dataset_labelImg_To_yolo,欢迎标星🔥🔥🔥。

更新日志:

2024年5月21日

添加损失函数,注意力机制函数

GIoU (bool, optional): If True, calculate Generalized IoU. Defaults to False.
DIoU (bool, optional): If True, calculate Distance IoU. Defaults to False.
CIoU (bool, optional): If True, calculate Complete IoU. Defaults to False.

EIoU (bool, optional): If True, calculate Efficient IoU. Defaults to False.
SIoU (bool, optional): If True, calculate Scylla IoU. Defaults to False.
WIoU (bool, optional): 
ShapeIoU (bool, optional): 
mpdiou (bool, optional): 
from .CA import *
from .CBAM import *
from .ECA import *
from .GAM import *
from .DAT import *

2024年5月20日

添加基准模型,YOLOv3,YOLOv5,YOLOv6,YOLOv8,YOLOv9

2024年5月16日

添加 Ghostnetv1,Ghostnetv2,Ghostnetv3模块,以及ShuffleNetV1,ShuffleNetV2等15个模块。

15个主干网络,每个测试成功,可以跑通。

yaml 文件

在这里插入图片描述

from .FasterBlock import *

from .MobileNetV1 import *
from .MobileNetV2 import *
from .MobileNetV3 import *
from .MobileNetV4 import *
from .MobileViTv1 import *
from .MobileViTv2 import *

from .ShuffleNetV1 import *
from .ShuffleNetV2 import *

from .EfficientNetV1 import *
from .EfficientNetV2 import *
from .EfficientViT2 import *

from .GhostNetV1 import *
from .GhostNetV2 import *
from .GhostNetV3 import *

5个模块均可运行。

2024年5月15日

替换C3为 C2f_FasterBlock模块。yaml文件跑通,train文件跑通,detect文件可用。只展示yaml文件,其他核心代码自行去GitHub下载。

yaml文件

# YOLOv5 🚀 by Ultralytics, AGPL-3.0 license

# Parameters
nc: 80 # number of classes
depth_multiple: 0.33 # model depth multiple
width_multiple: 0.50 # layer channel multiple
anchors:
  - [10, 13, 16, 30, 33, 23] # P3/8
  - [30, 61, 62, 45, 59, 119] # P4/16
  - [116, 90, 156, 198, 373, 326] # P5/32

# YOLOv5 v6.0 backbone
backbone:
  # [from, number, module, args]
  [
    [-1, 1, Conv, [64, 6, 2, 2]], # 0-P1/2
    [-1, 1, Conv, [128, 3, 2]], # 1-P2/4
    [-1, 3, C2f_FasterBlock, [128]],
    [-1, 1, Conv, [256, 3, 2]], # 3-P3/8
    [-1, 6, C2f_FasterBlock, [256]],
    [-1, 1, Conv, [512, 3, 2]], # 5-P4/16
    [-1, 9, C2f_FasterBlock, [512]],
    [-1, 1, Conv, [1024, 3, 2]], # 7-P5/32
    [-1, 3, C2f_FasterBlock, [1024]],
    [-1, 1, SPPF, [1024, 5]], # 9
  ]

# YOLOv5 v6.0 head
head: [
    [-1, 1, Conv, [512, 1, 1]],
    [-1, 1, nn.Upsample, [None, 2, "nearest"]],
    [[-1, 6], 1, Concat, [1]], # cat backbone P4
    [-1, 3, C2f_FasterBlock, [512, False]], # 13

    [-1, 1, Conv, [256, 1, 1]],
    [-1, 1, nn.Upsample, [None, 2, "nearest"]],
    [[-1, 4], 1, Concat, [1]], # cat backbone P3
    [-1, 3, C2f_FasterBlock, [256, False]], # 17 (P3/8-small)

    [-1, 1, Conv, [256, 3, 2]],
    [[-1, 14], 1, Concat, [1]], # cat head P4
    [-1, 3, C2f_FasterBlock, [512, False]], # 20 (P4/16-medium)

    [-1, 1, Conv, [512, 3, 2]],
    [[-1, 10], 1, Concat, [1]], # cat head P5
    [-1, 3, C2f_FasterBlock, [1024, False]], # 23 (P5/32-large)

    [[17, 20, 23], 1, Detect, [nc, anchors]], # Detect(P3, P4, P5)
  ]

  • 8
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值