YOLOv7训练自己的数据集(超详细)

介绍

2022年7月,YOLOv7来临, 论文链接:https://arxiv.org/abs/2207.02696

代码链接:

GitHub – WongKinYiu/yolov7: Implementation of paper – YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors

废话不多说,赶紧上车!

文件配置

1、数据集

自己创建一个myself.yaml文件用来配置路径,路径格式与之前的V5、V6不同,只需要配置txt路径就可以

YOLOv7训练自己的数据集(超详细)

YOLOv7训练自己的数据集(超详细)

 train-list.txt和val-list.txt文件里存放的都是图片的绝对路径(也可以放入相对路径)

YOLOv7训练自己的数据集(超详细)

YOLOv7训练自己的数据集(超详细)

 如何获取图像的绝对路径,脚本写在下面了(也可以获取相对路径)

# From Mr. Dinosaur

import os


def listdir(path, list_name):  # 传入存储的list
    for file in os.listdir(path):
        file_path = os.path.join(path, file)
        if os.path.isdir(file_path):
            listdir(file_path, list_name)
        else:
            list_name.append(file_path)


list_name = []
path = 'D:/PythonProject/data/'  # 文件夹路径
listdir(path, list_name)
print(list_name)

with open('./list.txt', 'w') as f:  # 要存入的txt
    write = ''
    for i in list_name:
        write = write + str(i) + '\n'
    f.write(write)

2、train.py

官网下载模型文件,train.py文件只支持YOLOv7和YOLOv7-X模型

YOLOv7训练自己的数据集(超详细)

train文件还是和V5一样,为了方便,我将需要用到的文件放在了根目录下

YOLOv7训练自己的数据集(超详细)

路径修改完之后右击运行即可

YOLOv7训练自己的数据集(超详细)

3、train_aux.py

如果你想使用较大的预训练模型,请使用train_aux.py进行训练,否则效果会很差(本人亲测)

下面放上对比图:(上面V7,下面V5)

YOLOv7训练自己的数据集(超详细)

YOLOv7训练自己的数据集(超详细)

–weights

下载位置在官网的GitHub上(我是用的是yolov7-d6-training.pt)

YOLOv7训练自己的数据集(超详细)

–cfg

请使用cfg-training-中的模型文件

YOLOv7训练自己的数据集(超详细)

 –hyp

文件夹data-hyp.scratch.p6.yaml

YOLOv7训练自己的数据集(超详细)

 运行train_aux.py

YOLOv7训练自己的数据集(超详细)

效果对比

在此放上YOLOv7和YOLOv5的对比图:(左V7,右V5)

YOLOv7训练自己的数据集(超详细)

YOLOv7训练自己的数据集(超详细)

报错解决

YOLOv7 训练报错 IndexError: list index out of range_Mr Dinosaur的博客-CSDN博客YOLOv7训练自己的数据集(超详细)https://blog.csdn.net/qq_58355216/article/details/125842647?spm=1001.2014.3001.5501

 评价

无论是训练的速度、还是精度、召回和map的提升,V7的表现都是十分显著的,称得上是YOLO界的扛把子,期待作者之后的优化和更新。

YOLOv8发布

官网的YOLOv8最近开始发布,效果要比V7更快更准,训练和测试方法已写好,感兴趣的小伙伴快动手操作一下 

YOLOv8训练自己的数据集icon-default.png?t=MBR7https://blog.csdn.net/qq_58355216/article/details/128671030?spm=1001.2014.3001.5501

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
青葱年少的头像青葱年少普通用户
上一篇 2023年2月25日 下午6:36
下一篇 2023年2月25日 下午6:38

相关推荐