yolov3-tiny训练自己的数据集(重在步骤,不究原理)

简介

YOLOv3是一种基于深度神经网络的对象识别和定位算法,其最大的特点是运行速度很快,可以用于实时系统。而YOLOv3-tiny是YOLOv3的简化版。

YOLOv3-tiny网络结构图

layer     filters    size              input                output
0 conv     16  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  16  0.150 BFLOPs
1 max          2 x 2 / 2   416 x 416 x  16   ->   208 x 208 x  16
2 conv     32  3 x 3 / 1   208 x 208 x  16   ->   208 x 208 x  32  0.399 BFLOPs
3 max          2 x 2 / 2   208 x 208 x  32   ->   104 x 104 x  32
4 conv     64  3 x 3 / 1   104 x 104 x  32   ->   104 x 104 x  64  0.399 BFLOPs
5 max          2 x 2 / 2   104 x 104 x  64   ->    52 x  52 x  64
6 conv    128  3 x 3 / 1    52 x  52 x  64   ->    52 x  52 x 128  0.399 BFLOPs
7 max          2 x 2 / 2    52 x  52 x 128   ->    26 x  26 x 128
8 conv    256  3 x 3 / 1    26 x  26 x 128   ->    26 x  26 x 256  0.399 BFLOPs
9 max          2 x 2 / 2    26 x  26 x 256   ->    13 x  13 x 256
10 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
11 max          2 x 2 / 1    13 x  13 x 512   ->    13 x  13 x 512
12 conv   1024  3 x 3 / 1    13 x  13 x 512   ->    13 x  13 x1024  1.595 BFLOPs
13 conv    256  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 256  0.089 BFLOPs
14 conv    512  3 x 3 / 1    13 x  13 x 256   ->    13 x  13 x 512  0.399 BFLOPs
15 conv    255  1 x 1 / 1    13 x  13 x 512   ->    13 x  13 x 255  0.044 BFLOPs
16 yolo
17 route  13
18 conv    128  1 x 1 / 1    13 x  13 x 256   ->    13 x  13 x 128  0.011 BFLOPs
19 upsample            2x    13 x  13 x 128   ->    26 x  26 x 128
20 route  19 8
21 conv    256  3 x 3 / 1    26 x  26 x 384   ->    26 x  26 x 256  1.196 BFLOPs
22 conv    255  1 x 1 / 1    26 x  26 x 256   ->    26 x  26 x 255  0.088 BFLOPs
23 yolo

环境条件

  • Window 10
  • GTX1050 2G
  • Python 3.6.7
  • Opencv 3.4.0
  • Tensorflow-gpu 1.14.0

源码获取

https://github.com/FreemanTang/yolov3_tiny_tensorflow
# 或者
https://gitee.com/freemantang/yolov3_tiny_tensorflow

项目结构

在这里插入图片描述

准备数据

将所有标注的图片放到VOCdevkit/VOC2007/JPEGImages目录下,如下图。
在这里插入图片描述
将所有标注的XML文件放到VOCdevkit/VOC2007/Annotations目录下,如下图。
在这里插入图片描述
运行VOCdevkit/VOC2007/ImageName_to_txt.py代码,如下图。
在这里插入图片描述
运行成功,会在VOCdevkit/VOC2007/ImageSets/Main目录下,生成4个TXT文件,如下图。
在这里插入图片描述
编辑yolov3_tiny_tensorflow/voc_annotation.py代码,将classes = []改成自己标注的类别名,如classes = [“head”,“car”,“cat”],如下图。
在这里插入图片描述
运行yolov3_tiny_tensorflow/voc_annotation.py代码,如下图。
在这里插入图片描述
运行成功,会在yolov3_tiny_tensorflow目录下生成3个TXT文件,如下图。
在这里插入图片描述
将其重命名为train.txt,test.txt,val.txt,如下图。
在这里插入图片描述
3个txt文件,内容格式,如下图。
在这里插入图片描述

相关配置

将/data/COCO.name用记事本打开,输入自己所标注的类名,如下图。
在这里插入图片描述

训练

运行yolov3_tiny_tensorflow/train.py代码,如下图。
在这里插入图片描述

python train.py --batch_size 1 --total_epoches 50

在这里插入图片描述
训练完成,在yolov3_tiny_tensorflow/checkpoint/yolov3_tiny_COCO已保存训练好的模型文件,如下图。
在这里插入图片描述
将最新保存的文件名改为yolov3_tiny_my.cpkt,如下图。
在这里插入图片描述

测试

Window系统下测试

图片测试

python test_single_image_yolov3_tiny.py --input_image ./imgs/test.jpg

视频测试

python camera_or_video_test_yolov3_tiny.py --input_video ./videos/test_video.mp4

摄像头测试

python camera_or_video_test_yolov3_tiny.py --input_video 0

在这里插入图片描述

Jetson Nano下测试

图片测试

python3 test_single_image_yolov3_tiny.py --input_image ./imgs/test.jpg

视频测试

python3 camera_or_video_test_yolov3_tiny.py --input_video ./videos/test_video.mp4

摄像头测试

python3 CSI_camera_test_yolov3_tiny.py

在这里插入图片描述

  • 4
    点赞
  • 54
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 8
    评论
要使用yolov7-tiny训练自己的数据集你需要按照以下步骤进行操作: 1. 首先,确保你已经安装了必要的环境。你可以使用conda创建一个新的环境,并安装Python 3.8版本。然后激活这个环境。 2. 下载yolov7-tiny的代码库。你可以从GitHub上的https://github.com/WongKinYiu/yolov7仓库中克隆代码到本地。 3. 进入yolov7代码库的目录,并使用pip安装所需的依赖项。你可以运行以下命令来安装依赖项: ``` pip install -r requirements.txt ``` 4. 准备你的数据集。将你的训练图像和相应的标签文件放在一个文件夹中。确保标签文件的格式符合YOLO的要求,每个标签文件应该与对应的图像文件具有相同的名称,但扩展名为txt。 5. 修改配置文件。在cfg/training文件夹中选择适合的模型配置文件,对于yolov7-tiny,你可以选择yolov7-tiny-silu.yaml。打开该文件并进行必要的修改,例如设置类别数量和路径等。 6. 开始训练。使用以下命令来启动训练过程: ``` python train.py --weights yolov7-tiny.pt --data data/your_dataset.yaml --epochs 300 --batch-size 8 --cfg cfg/training/yolov7-tiny-silu.yaml --workers 0 --device 0 --img-size 640 640 ``` 其中,--weights参数指定了预训练的权重文件,--data参数指定了你的数据集的配置文件,--epochs参数指定了训练的轮数,--batch-size参数指定了批量大小,--cfg参数指定了模型的配置文件,--workers参数指定了用于数据加载的工作线程数,--device参数指定了使用的GPU设备,--img-size参数指定了输入图像的尺寸。 通过按照以上步骤进行操作,你就可以使用yolov7-tiny训练自己的数据集了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

FriendshipT

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

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

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

打赏作者

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

抵扣说明:

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

余额充值