Skip to content

Commit 821e9a3

Browse files
authored
Merge pull request #8 from BMW-InnovationLab/dev-yolov4
Yolov3-v4 Training automation
2 parents 7a5e42d + 647a3aa commit 821e9a3

22 files changed

Lines changed: 1925 additions & 92 deletions

README.md

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# YOLOv3 Training Automation API for Linux
2-
3-
This repository allows you to get started with training a state-of-the-art Deep Learning model with little to no configuration needed! You provide your labeled dataset and you can start the training right away and monitor it in many different ways like TensorBoard or a custom REST API and GUI. Training with YOLOv3 has never been so easy.
1+
# YOLOv4-v3 Training Automation API for Linux
42

3+
This repository allows you to get started with training a state-of-the-art Deep Learning model with little to no configuration needed! You provide your labeled dataset and you can start the training right away and monitor it in many different ways like TensorBoard or a custom REST API and GUI. Training with YOLOv4 has never been so easy.
4+
This repository has also cross compatibility with Yolov3 training
55
![](swagger_yolo_training.png)
66

77
## Prerequisites
@@ -22,7 +22,7 @@ chmod +x scripts/install_docker.sh && source scripts/install_docker.sh
2222
Prepare the docker image with all weights for GPU usage
2323

2424
```bash
25-
sudo docker build -f docker/Dockerfile -t darknet_yolo_gpu:1 --build-arg GPU=1 --build-arg CUDNN=1 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 --build-arg DOWNLOAD_ALL=1 .
25+
sudo docker build -f docker/Dockerfile -t darknet_yolov4_gpu:1 --build-arg GPU=1 --build-arg CUDNN=1 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 --build-arg DOWNLOAD_ALL=1 .
2626
```
2727
![terminal_example](gifs/1.gif)
2828

@@ -38,20 +38,35 @@ The environment is dockerized to run on GPU or CPU.
3838
For GPU, you need to build the image in the following way:
3939

4040
```bash
41-
sudo docker build -f docker/Dockerfile -t darknet_yolo_gpu:1 --build-arg GPU=1 --build-arg CUDNN=1 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 .
41+
sudo docker build -f docker/Dockerfile -t darknet_yolov4_gpu:1 --build-arg GPU=1 --build-arg CUDNN=1 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 .
4242
```
4343

44+
If you have a GPU: Volta, Xavier, Turing and higher
45+
46+
```bash
47+
sudo docker build -f docker/Dockerfile -t darknet_yolov4_gpu:1 --build-arg GPU=1 --build-arg CUDNN=1 --build-arg CUDNN_HALF=1 --build-arg OPENCV=1 .
48+
```
49+
If you are behind proxy
50+
```bash
51+
sudo docker build -f docker/Dockerfile -t darknet_yolov4_gpu:1 --build-arg GPU=1 --build-arg CUDNN=1 --build-arg CUDNN_HALF=1 --build-arg OPENCV=1 --build-arg http_proxy='' --build-arg https_proxy='' .
52+
```
4453
For CPU only, you can run the same command while setting GPU=0 CUDNN=0 and naming it darknet_yolo_cpu:1 for clarity.
4554

4655
```bash
47-
sudo docker build -f docker/Dockerfile -t darknet_yolo_cpu:1 --build-arg GPU=0 --build-arg CUDNN=0 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 .
56+
sudo docker build -f docker/Dockerfile -t darknet_yolov4_cpu:1 --build-arg GPU=0 --build-arg CUDNN=0 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 .
57+
```
58+
If you want multi-core cpu training you can add OPENMP=1 to the build
59+
60+
```bash
61+
sudo docker build -f docker/Dockerfile -t darknet_yolov4_cpu:1 --build-arg GPU=0 --build-arg CUDNN=0 --build-arg CUDNN_HALF=0 --build-arg OPENCV=1 --build-arg OPENMP=1 .
4862
```
4963

5064
## Preparing your dataset
5165

5266
We provided a `sample_dataset` to show how your data should be structured in order to start the training seemlesly.
5367
The `train_config.json` file found in `sample_dataset` is a copy of the template `config/train_config.json.template` with needed modifications. The template can as well be copied as is while making sure to remove the '.template' from the name.
54-
You can also provide your own `train.txt` and `test.txt` to specify which images will be used for training and which ones are for testing. If not provided, the dataset will be split according to the `data/train_ratio` (by default 80% train 20% test)
68+
You can also provide your own `train.txt` and `test.txt` to specify which images will be used for training and which ones are for testing. If not provided, the dataset will be split according to the `data/train_ratio` (by default 80% train 20% test).
69+
If you are using **Yolov4** training please make sure to choose your `yolov4` instead of **yolov3** in `train_config.json` `model/model-name` **Yolov4** specific hyperparams ("mosaic","blur")
5570

5671
## Starting the training
5772

@@ -78,23 +93,23 @@ dogs-dataset_20191110_14:21:41
7893
├── config
7994
│ ├── obj.data
8095
│ ├── obj.names
81-
│ └── yolov3.cfg
96+
│ └── yolov4.cfg
8297
├── test.txt
8398
├── train.txt
8499
├── weights
85100
│ ├── initial.weights
86-
│ ├── yolov3_10000.weights
87-
│ ├── yolov3_1000.weights
88-
│ ├── yolov3_2000.weights
89-
│ ├── yolov3_3000.weights
90-
│ ├── yolov3_4000.weights
91-
│ ├── yolov3_5000.weights
92-
│ ├── yolov3_6000.weights
93-
│ ├── yolov3_7000.weights
94-
│ ├── yolov3_8000.weights
95-
│ ├── yolov3_9000.weights
96-
│ ├── yolov3_best.weights
97-
│ └── yolov3_last.weights
101+
│ ├── yolov4_10000.weights
102+
│ ├── yolov4_1000.weights
103+
│ ├── yolov4_2000.weights
104+
│ ├── yolov4_3000.weights
105+
│ ├── yolov4_4000.weights
106+
│ ├── yolov4_5000.weights
107+
│ ├── yolov4_6000.weights
108+
│ ├── yolov4_7000.weights
109+
│ ├── yolov4_8000.weights
110+
│ ├── yolov4_9000.weights
111+
│ ├── yolov4_best.weights
112+
│ └── yolov4_last.weights
98113
├── yolo_events.log
99114
└── yolo_events.log.1
100115
```
@@ -132,38 +147,30 @@ Some of the elements are specific to YOLO itself like saturation, hue, rotation,
132147
## Benchmark
133148

134149
<table>
135-
<tr>
136-
<th></th>
137-
<th colspan="4">OS</th>
138-
</tr>
139-
<tr>
140-
<td></td>
141-
<td>Windows</td>
142-
<td colspan="3">Ubuntu</td>
143-
</tr>
144-
<tr>
145-
<td></td>
146-
<td>CPU</td>
147-
<td colspan="2">CPU</td>
148-
<td>GPU</td>
149-
</tr>
150-
<tr>
151-
<td></td>
152-
<td>Intel Xeon CPU 2.3 GHz</td>
153-
<td>Intel Xeon CPU 2.3 GHz</td>
154-
<td>Intel Core i9-7900 3.3 GHz</td>
155-
<td>GeForce GTX 1080</td>
156-
</tr>
157-
<tr>
158-
<td>pascalvoc_dataset</td>
159-
<td>0.793 second/image</td>
160-
<td>0.885 second/image</td>
161-
<td>0.295 second/image</td>
162-
<td>0.0592 second/image</td>
163-
</tr>
150+
<thead align="center">
151+
<tr>
152+
<th></th>
153+
<th colspan=3>Ubuntu</th>
154+
</tr>
155+
</thead>
156+
<thead align="center">
157+
<tr>
158+
<th>Network\Hardware</th>
159+
<th>Intel Xeon CPU 2.3 GHz</th>
160+
<th>Intel Core i9-7900 3.3 GHZ</th>
161+
<th>Tesla V100</th>
162+
</tr>
163+
</thead>
164+
<tbody align="center">
165+
<tr>
166+
<td>COCO Dataset</td>
167+
<td>0.259 seconds/image</td>
168+
<td>0.281 seconds/image</td>
169+
<td>0.0691 seconds/image</td>
170+
</tr>
171+
</tbody>
164172
</table>
165173

166-
167174
## Preparing weights
168175

169176
Default yolo weights are provided on the [official website](https://pjreddie.com/darknet/yolo/).
@@ -174,7 +181,7 @@ Change your current working directory to be inside the repo. The following steps
174181
yolov3.weights
175182

176183
```bash
177-
wget https://pjreddie.com/media/files/yolov3.weights -P config/darknet/yolo_default_weights
184+
wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov3.weights -P config/darknet/yolo_default_weights
178185
```
179186

180187
yolov3-tiny.weights
@@ -189,6 +196,13 @@ darknet53.conv.74
189196
wget https://pjreddie.com/media/files/darknet53.conv.74 -P config/darknet/yolo_default_weights
190197
```
191198

199+
yolov4.weights
200+
201+
```bash
202+
wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov4.weights -P config/darknet/yolov4_default_weights
203+
```
204+
205+
192206

193207
## Known Issues
194208

@@ -198,6 +212,8 @@ Issue related to darknet itself can be filed in [the correct repo](https://githu
198212
- If during training you see nan values for avg (loss) field - then training goes wrong, but if nan is in some other lines - then training goes well.
199213
- If error Out of memory occurs then you should try increasing subdivisions to 16, 32 or 64 or have a smaller image size.
200214
- If training finishes immediately without any error you should decrease batch size and subdivisions.
215+
- if training on multiple GPU produce nan try decreasing the learning rate to 0,00065
216+
201217

202218
## Acknowledgements
203219

@@ -208,3 +224,5 @@ Issue related to darknet itself can be filed in [the correct repo](https://githu
208224
Lynn Nassif, Beirut, Lebanon
209225

210226
Nour Azzi, Beirut, Lebanon
227+
228+
Hadi Koubeissy , Beirut, Lebanon

config/darknet/yolo_default_cfgs/yolov3-tiny.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ saturation = 1.5
1515
exposure = 1.5
1616
hue=.1
1717

18+
letter_box=1
1819
learning_rate=0.001
1920
burn_in=1000
2021
max_batches = 500200

config/darknet/yolo_default_cfgs/yolov3.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ saturation=1.5
1515
exposure=1.5
1616
hue=.1
1717

18+
letter_box=1
1819
learning_rate=0.001
1920
burn_in=1000
2021
max_batches=500200

config/darknet/yolo_default_weights/download_weights.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ else
66
if test $1 -eq 1; then
77
echo "Downloading Weights"
88
echo "Downloading yolov3.weights"
9-
wget https://pjreddie.com/media/files/yolov3.weights -P $2
9+
wget https://github.com/AlexeyAB/darknet/releases/download/darknet_yolo_v3_optimal/yolov3.weights -P $2 -4
1010
echo "Downloading yolov3-tiny.weights"
11-
wget https://pjreddie.com/media/files/yolov3-tiny.weights -P $2
11+
wget https://pjreddie.com/media/files/yolov3-tiny.weights -P $2 -4
1212
echo "Downloading darknet53.conv.74"
13-
wget https://pjreddie.com/media/files/darknet53.conv.74 -P $2
13+
wget https://pjreddie.com/media/files/darknet53.conv.74 -P $2 -4
1414
echo "All weights downloaded!"
1515
fi
1616
fi

0 commit comments

Comments
 (0)