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

│ ├─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/

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/
# 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-yolov3-tiny.cfg
# or yolov3-416
darknet detector train dota-yolov3-416.cfg
# more gpus
darknet detector train dota-yolov3-tiny.cfg -gpus 0,1,2

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

8. predict

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

# or 416
python --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



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