simple Pytorch implementation of YOLOv3 / YOLOv3-tiny.
- [x]: Support darknet format weights
- [x]: Sample code for infering image and video
- [x]: Sample code for training
-
Install dependent libraries.
pip install -r requirements.txt
If you have already installed older version of Pytorch, update it.
pip install -U torch torchvision torchaudio
-
Download the official weights.
./weights/download_weights.sh
python detect_image.py \
--input data/dog.png \
--output output \
--weights weights/yolov3.weights \
--config config/yolov3_coco.yaml
python detect_image.py \
--input data \
--output output \
--weights weights/yolov3.weights \
--config config/yolov3_coco.yaml
python detect_video.py \
--input data/sample.avi \
--output output \
--weights weights/yolov3.weights \
--config config/yolov3_coco.yaml
YOLOv3 - 自作データセットで学習する方法について - pystyle
python train_custom.py \
--dataset_dir custom_dataset \
--weights weights/darknet53.conv.74 \
--config config/yolov3_custom.yaml
python evaluate_custom.py \
--dataset_dir custom_dataset \
--weights train_output/yolov3_final.pth \
--config config/yolov3_custom.yaml
python detect_image.py \
--input data/dog.png \
--output output \
--weights weights/yolov3-tiny.weights \
--config config/yolov3tiny_coco.yaml
python detect_image.py \
--input data \
--output output \
--weights weights/yolov3-tiny.weights \
--config config/yolov3tiny_coco.yaml
python detect_video.py \
--input data/sample.avi \
--output output \
--weights weights/yolov3-tiny.weights \
--config config/yolov3tiny_coco.yaml
Download YOLOv3-tiny pretrained weights.
YOLOv3 - 自作データセットで学習する方法について - pystyle
python train_custom.py \
--dataset_dir custom_dataset \
--weights weights/yolov3-tiny.conv.15 \
--config config/yolov3tiny_custom.yaml
-
Download MSCOC 2017 dataset and unzip them.
wget http://images.cocodataset.org/annotations/annotations_trainval2017.zip wget http://images.cocodataset.org/zips/train2017.zip wget http://images.cocodataset.org/zips/val2017.zip unzip train2017.zip unzip val2017.zip unzip annotations_trainval2017.zip
After unzipping, the directory structure should look like
<dataset_dir> |-- annotations |-- train2017 `-- val2017
-
Install pycocotools (Cython is required to build pycocotools)
pip install Cython pip install pycocotools
python train_coco.py \
--dataset_dir /data/COCO \
--anno_path /data/COCO/annotations/instances_train2017.json \
--weights weights/darknet53.conv.74 \
--config config/yolov3_coco.yaml
python evaluate_coco.py \
--dataset_dir /data/COCO \
--anno_path config/instances_val5k.json \
--weights weights/yolov3.weights \
--config config/yolov3_coco.yaml
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.311
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=100 ] = 0.558
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=100 ] = 0.313
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.141
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.339
Average Precision (AP) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.457
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 1 ] = 0.275
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets= 10 ] = 0.416
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.437
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=100 ] = 0.238
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=100 ] = 0.477
Average Recall (AR) @[ IoU=0.50:0.95 | area= large | maxDets=100 ] = 0.603
0.31082299897937926 0.5579624636166972