Skip to content

Commit a65d219

Browse files
authored
Merge pull request #417 from pshah0086/patch-1
Translated to English for better reachout
2 parents 47483be + 48c5e88 commit a65d219

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed
Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,63 @@
1-
yolov4的发布引起了不少的关注,但由于darknet是大佬c语言写的,对代码的阅读有诸多不变,所以周末的时候写了个pytorch版的(蹭一波热度)。虽然pytorch——yolov4写好已经有一段时间了,但是由于种种原因一直没有进行验证(主要就是懒),大家提出了诸多问题帮助修复很多bug,还有大佬一起增加新的功能,感谢大家的帮助。这些天呼声最高的就是如何如何使用自己的数据进行训练,昨天又是周末,就把这件拖了很久的事做了。并不像使用很多数据,于是自己制作了一个简单的数据集。
1+
The release of yolov4 has attracted a lot of attention, but because darknet is written in big brother c language, there are many unchanged reading of the code, so the weekend wrote a pytorch version (to rub a wave of heat). Although pytorch - yolov4 write good has been a while, but for a variety of reasons have not been validated (mainly lazy), people raised many questions to help fix many bugs, there are big brothers together to add new features, thank you for your help. These days the highest call is how to how to use their own data for training, and yesterday was the weekend, so the thing that has dragged on for a long time to do. It is not like using a lot of data, so I made a simple dataset myself
22

3-
# 1. 代码准备
43

5-
github 克隆代码
4+
# 1. Code Preparation
5+
6+
github Cloning Code
67
```
78
git clone https://github.com/Tianxiaomo/pytorch-YOLOv4.git
89
```
9-
# 2. 数据准备
10+
# 2. Data Preparation
1011

11-
准备train.txt,内容是图片名和box。格式如下
12+
Prepare train.txt, which contains the image name and box in the following format
1213

1314
```
1415
image_path1 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ...
1516
image_path2 x1,y1,x2,y2,id x1,y1,x2,y2,id x1,y1,x2,y2,id ...
1617
...
1718
```
18-
- image_path : 图片名
19-
- x1,y1 : 左上角坐标
20-
- x2,y2 : 右下角坐标
21-
- id : 物体类别
19+
- image_path : Image Name
20+
- x1,y1 : Coordinates of the upper left corner
21+
- x2,y2 : Coordinates of the lower right corner
22+
- id : Object Class
2223

23-
我自己用的数据是自己制作的了一个小数据集,检测各种各样的硬币(也就1元,5角,1角三种),为什么不使用其他的东西制作数据集呢,没有啊,手边只有这些硬币感觉比较合适,相对其他的东西也比较简单
24+
I use their own data is their own production of a small data set to detect a variety of coins (also 1 yuan, 50 cents, 10 cents three), why not use other things to produce data sets, no ah, only these coins on hand feel more appropriate, relatively simple compared to other things
2425

2526
![UTOOLS1590383513325.png](https://user-gold-cdn.xitu.io/2020/5/25/1724a3e953909b1b?w=1649&h=791&f=png&s=1290382)
2627

27-
一共准备了没几张
28+
A total of a few prepared
2829

29-
# 3. 参数设置
30+
# 3. Parameter Setting
3031

31-
开始训练的时候我直接用原来的参数,batch size设为64,跑了几个epoch发现不对,我数据一共才二十多个。后修改网络更新策略,不是按照每个epoch的step更新,使用总的steps更新,观察loss貌似可以训练了,于是睡觉,明天再看训练如何(鬼知道我又改了啥)。
32+
When I started training, I directly used the original parameters, batch size set to 64, ran a few epochs found that it is not right, my data is only a total of more than 20. After modifying the network update strategy, not in accordance with the step of each epoch update, using the total steps update, observe the loss seems to be able to train, so sleep, tomorrow to see how the training (the ghost knows what I changed)
3233

33-
今天打开电脑一看,what xx,loss收敛到2.e+4下不去了,此种必又蹊跷,遂kill了。于是把batch size直接设为4,可以正常训练了
34+
Today, I opened my computer and saw that what xx,loss converged to 2.e+4, which must be strange again, so I killed it. So I set the batch size to 4 directly, and can train normally
3435

3536
```
3637
Cfg.batch = 4
3738
Cfg.subdivisions = 1
3839
```
3940

40-
# 4. 开始训练
41+
# 4. Start training
4142

4243
```
4344
python train.py -l 0.001 -g 4 -pretrained ./yolov4.conv.137.pth -classes 3 -dir /home/OCR/coins
4445
45-
-l 学习率
46+
-l learning rate
4647
-g gpu id
47-
-pretrained 预训练的主干网络,从AlexeyAB给的darknet的yolov4.conv.137转换过来的
48-
-classes 类别种类
49-
-dir 图片所在文件夹
48+
-pretrained Pre-trained backbone network, converted from yolov4.conv.137 of darknet given by AlexeyAB
49+
-classes NO. of classes
50+
-dir Training image dir
5051
```
5152

5253

53-
看下loss曲线
54+
Look at the loss curve
5455
```
5556
tensorboard --logdir log --host 192.168.212.75 --port 6008
5657
```
5758
![UTOOLS1590386319240.png](https://user-gold-cdn.xitu.io/2020/5/25/1724a696148d13f3?w=1357&h=795&f=png&s=151465)
5859

59-
# 5. 验证
60+
# 5. Inference
6061

6162
```
6263
python model.py 3 weight/Yolov4_epoch166_coins.pth data/coin2.jpg data/coins.names
@@ -73,10 +74,10 @@ coins.names
7374

7475
![UTOOLS1590386705468.png](https://user-gold-cdn.xitu.io/2020/5/25/1724a6f46e826bb8?w=774&h=1377&f=png&s=1191048)
7576

76-
效果差强人意(训练数据只有3种类型硬币)。
77+
The results were poor (only 3 types of coins were available for the training data).
7778

78-
#
79+
# Attachment
7980

80-
- coins数据集 (链接:https://pan.baidu.com/s/1y701NRKSdpj6UKDIH-GpqA
81-
提取码:j09s
82-
- yolov4.conv.137.pth (链接:https://pan.baidu.com/s/1ovBie4YyVQQoUrC3AY0joA 提取码:kcel)
81+
- coins dataset (link: https://pan.baidu.com/s/1y701NRKSdpj6UKDIH-GpqA)
82+
(Extraction code: j09s)
83+
- yolov4.conv.137.pth (Link: https://pan.baidu.com/s/1ovBie4YyVQQoUrC3AY0joA Extraction code: kcel)

0 commit comments

Comments
 (0)