Train DOTA dataset with yolov3

1. clone the reop

git clone xxxx/dota-yolo
cd dota-yolo

2. download DOTA dataset

download link can be found here

DOTA-yolov3
|
├─dataset
│ ├─train
│ │ ├─images
│ │ └─labelTxt
│ └─val
│ ├─images
│ └─labelTxt

3. prerequisites

you need to have some lib/tool installed

4. split

beacuse the images in dataset are really huge, if you train directly, it likely will overflow your GPU memory, so we split images into small ones, as well as corresponding labels

python3 data_transform/split.py

5. transform label

the labels are not in yolo format yet, so we need to convert them to yolo format

mkdir dataset/trainsplit/labels
mkdir dataset/valsplit/labels
python3 data_transform/YOLO_Transform.py
# check labels
# cd dataset/trainsplit/labels
# awk -F" " '{col[$1]++} END {for (i in col) print i, col[i]}' *.txt

6. generate train.txt & val.txt

when we train, we need train set to train the weights, and validate set to check how accurate the weights are now

ls -1d $PWD/dataset/trainsplit/images/* > cfg/train.txt
ls -1d $PWD/dataset/valsplit/images/* > cfg/val.txt

7. train

cd cfg
mkdir backup
# yolo-tiny
darknet detector train dota.data dota-yolov3-tiny.cfg
# or yolov3-416
darknet detector train dota.data dota-yolov3-416.cfg
# more gpus
darknet detector train dota.data dota-yolov3-tiny.cfg -gpus 0,1,2

# resume from unexpected stop
darknet detector train dota.data dota-yolov3-tiny.cfg backup/dota-yolov3-tiny.backup

8. predict

# tiny
python test.py --image test.png --config cfg/dota-yolov3-tiny.cfg --weights cfg/backup/dota-yolov3-tiny_final.weights --classes cfg/dota.names

# or 416
python test.py --image test.png --config cfg/dota-yolov3-416.cfg --weights cfg/backup/dota-yolov3-416_final.weights --classes cfg/dota.names

9. pretrained weights

you can download my pretrained weights here

--

--

https://www.youtube.com/channel/UCuTKxK_2Q6EilN_rGk_JaeQ

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store