Yolo-Fastestv2训练及部署自己的数据集

Yolo-Fastestv2训练及部署自己的数据集


训练流程

一、配置环境

1.下载代码

git clone https://github.com/dog-qiuqiu/Yolo-FastestV2.git

2.创建虚拟环境,在虚拟环境下安装相关python依赖包

pip install -r requirements.txt -i https://pypi.mirrors.ustc.edu.cn/simple #采用国内源,速度较快 

3.测试能否正常使用

python test.py --data data/coco.data --weights modelzoo/coco2017-0.241078ap-model.pth --img img/000139.jpg

二、数据集建立

1.数据集格式

数据集的格式是Yolo格式,每个图像对应一个.txt标签文件cx,cy,w,h。cx,cy是标签框的中心点的坐标,w,h是标签框的宽度和高度。示例如下:

0 0.410156 0.317708 0.807813 0.631250

2.图像与标签位置

数据集图像与对应的标签文件具有同样的名字,存储在同一目录中。结构如下:

 -train
   - 001.jpg
   - 001.txt
   - 002.jpg
   - 002.txt
 -val
   - 003.jpg
   - 003.txt
 -test
   - 004.jpg
   - 004.txt

3.生成数据集路径.txt文件

路径是图像的绝对路径,示例如下:

/home/dataset/train/001.jpg

python实现:

import os
images_path='/home/dataset/train/' 
txt_path='/home/dataset/train.txt'
with open(txt_path,'w') as f:
    files_name=os.listdir(images_path)
    f.truncate()
    for name in files_name:
        if name.endswith('.jpg'):
            f.write(images_path+name)
            f.write('\n')
f.close()

4.生成.names类别标签

./data/coco.names修改成自己数据集的类别。

5.最终构建的数据集目录结构

 -train
   - 001.jpg
   - 001.txt
   - 002.jpg
   - 002.txt
 -train.txt
 -val
   - 003.jpg
   - 003.txt
 -val.txt
 -test
   - 004.jpg
   - 004.txt
 -test.txt

三、训练

1.根据当前数据集生成锚点anchors

计算适应数据集的anchors,将输出值替换coco.data中的anchors

python genanchors.py --traintxt /home/dataset/train.txt

anchors6.txt文件将在当前目录中生成,anchors6.txt的示例内容如下:

12.64,19.39, 37.88,51.48, 55.71,138.31, 126.91,78.23, 131.57,214.55, 279.92,
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

欢天喜地小姐姐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值