Skip to content

PyTorch implmenetation of YOLO v3, including training and testing, and can be adapted for user-defined dataset

Notifications You must be signed in to change notification settings

ecr23xx/yolov3.pytorch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yolov3.pytorch

This repository is used for object detection. The algorithm is based on YOLOv3: An Incremental Improvement, implemented in PyTorch v0.4. Thanks to ayooshkathuria/pytorch-yolo-v3 and ultralytics/yolov3, based on their work, I re-implemented YOLO v3 in PyTorch for better readability and re-useablity.

News

Full version of update logs could be seen in issue #2

  • (2018/10/10) Support training on VOC dataset.

Environments

  • Python 3.6
  • PyTorch 0.4.1
  • CUDA (CPU is not supported)
  • pycocoapi

Train

How to train on COCO

  1. Download COCO detection dataset and annotions and provide full path to your downloaded dataset in config.py like below
    'coco': {
        'train_imgs': '/home/data/coco/2017/train2017',
        'train_anno': '/home/data/coco/2017/annotations/instances_train2017.json'
    }
  2. Download official pre-trained Darknet53 weights on ImageNet here, and move it to checkpoint/darknet/darknet53.conv.74.weights
  3. Transform the weights to PyTorch readable file 0.ckpt by running
    $ python transfer.py --dataset=coco --weights=darknet53.conv.74.weights
  4. Run
    $ python train.py

How to train on custom dataset

  1. Implement your own dataset loading function in dataset.py. You should keep the interfaces similar to that in dataset.py.
  2. Add your dataset in prepare_dataset function in dataset.py
  3. Details can be viewed in dataset.py. This part requires some coding, and need to be imporved later.

Training visualization

Logging directory will be displayed when you run training scripts. You can visualize the training process by running

$ tensorboard --logdir path-to-your-logs

tensorboard

Evaluation

How to evaluate on COCO

  1. Download COCO detection dataset and annotions and provide full path to your downloaded dataset in config.py like below
    'coco': {
        'val_imgs': '/home/data/coco/2017/val2017',
        'val_anno': '/home/data/coco/2017/annotations/instances_val2017.json',
    }
  2. Download official pretrained YOLO v3 weights here and move it to checkpoint/darknet/yolov3-coco.weights
  3. Transform the weights to PyTorch readable file checkpoint/coco/-1.-1.ckpt by running
    $ python transfer.py --dataset=coco --weights=yolov3-coco.weights
  4. Evaluate on validation sets you specify in config.py and compute the mAP by running. Some validation detection examples will be save to assets/results
    $ python evaluate.py

How to detect COCO objects

  1. Download official pretrained YOLO v3 weights here and move it to checkpoint/darknet/yolov3-coco.weights
  2. Transform the weights to PyTorch readable file checkpoint/coco/-1.-1.ckpt by running
    $ python transfer.py --dataset=coco --weights=yolov3-coco.weights
  3. Specify the images folder in config.py
    demo = {
      'images_dir': opj(ROOT, 'assets/imgs'),
      'result_dir': opj(ROOT, 'assets/dets')
    }
  4. Detect your own images by running
    $ python demo.py

Evaluation results

mAP computation seems not very accruate

Test datasets Training datasets Resolution Notes mAP FPS
COCO 2017 416 official pretrained YOLO v3 weights 63.4
COCO 2017 608 paper results 57.9

Evaluation demo

TODO

  • Evaluation
    • Draw right bounding box
    • mAP re-implementated
      • VOC mAP implemented
      • COCO mAP implemented
  • Training
    • Loss function implementation
    • Visualize training process
    • Use pre trained Darknet model to train on custom datasets
    • Validation
    • Train COCO from scratch
    • Train custom datasets from scratch
    • Learning rate scheduler
    • Data augumentation
  • General
    • Generalize annotation format to VOC for every dataset
    • Multi-GPU support
    • Memory use imporvements

Reference

About

PyTorch implmenetation of YOLO v3, including training and testing, and can be adapted for user-defined dataset

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages