Implementation of YOLOv3 in PyTorch
Switch branches/tags
Nothing to show
Clone or download
Latest commit 386c5d2 Dec 5, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
config initial commit Dec 5, 2018
data initial commit Dec 5, 2018
dataset initial commit Dec 5, 2018
docker initial commit Dec 5, 2018
models initial commit Dec 5, 2018
requirements initial commit Dec 5, 2018
utils initial commit Dec 5, 2018
LICENSE initial commit Dec 5, 2018 initial commit Dec 5, 2018 initial commit Dec 5, 2018 initial commit Dec 5, 2018

YOLOv3 in Pytorch

Pytorch implementation of YOLOv3

What's New


Original (darknet) Ours (pytorch)
COCO AP[IoU=0.50:0.95], inference 0.310 0.302
COCO AP[IoU=0.50], inference 0.553 0.544
COCO AP[IoU=0.50:0.95], training 0.310 to be updated
COCO AP[IoU=0.50], training 0.553 to be updated

We have verified that COCO val results of darknet are reproduced in the condition where only random resizing is used:



  • Python 3.6+
  • Numpy (verified as operable: 1.15.2)
  • OpenCV
  • Matplotlib
  • Pytorch (verified as operable: v0.4.0)
  • Cython (verified as operable: v0.29.1)
  • pycocotools (verified as operable: v2.0.0)


Docker Environment

We provide a Dockerfile to build an environment that meets the above requirements.

# build docker image
$ nvidia-docker build -t yolov3-in-pytorch-image --build-arg UID=`id -u` -f docker/Dockerfile .
# create docker container and login bash
$ nvidia-docker run -it -v `pwd`:/work --name yolov3-in-pytorch-container yolov3-in-pytorch-image
docker@4d69df209f4a:/work$ python --help

Download pretrained weights

download the pretrained file from the author's project page:

$ mkdir weights
$ cd weights/
$ bash ../requirements/

COCO 2017 dataset:

the COCO dataset is downloaded and unzipped by:

$ bash requirements/

Inference with Pretrained Weights

To detect objects in the sample image, just run:

$ python --image data/mountain.png --detect_thresh 0.5 --weights_path weights/yolov3.weights


$ python --help
usage: [-h] [--cfg CFG] [--weights_path WEIGHTS_PATH] [--n_cpu N_CPU]
                [--checkpoint_interval CHECKPOINT_INTERVAL]
                [--eval_interval EVAL_INTERVAL] [--checkpoint CHECKPOINT]
                [--checkpoint_dir CHECKPOINT_DIR] [--use_cuda USE_CUDA]
                [--debug] [--tfboard TFBOARD]

optional arguments:
  -h, --help            show this help message and exit
  --cfg CFG             config file. see readme
  --weights_path WEIGHTS_PATH
                        darknet weights file
  --n_cpu N_CPU         number of workers
  --checkpoint_interval CHECKPOINT_INTERVAL
                        interval between saving checkpoints
  --eval_interval EVAL_INTERVAL
                        interval between evaluations
  --checkpoint CHECKPOINT
                        pytorch checkpoint file path
  --checkpoint_dir CHECKPOINT_DIR
                        directory where checkpoint files are saved
  --use_cuda USE_CUDA
  --debug               debug mode where only one image is trained
  --tfboard TFBOARD     tensorboard path for logging


$ python --weights_path weights/darknet53.conv.74 --tfboard log

The train configuration is written in yaml files located in config folder. We use the following format:

  BACKBONE: darknet53
  LR: 0.001
  DECAY: 0.0005
  BURN_IN: 1000 # duration (iters) for learning rate burn-in
  MAXITER: 500000
  STEPS: (400000, 450000) # lr-drop iter points
  SUBDIVISION: 16 # num of minibatch inner-iterations
  IMGSIZE: 608 # initial image size
  CONFWEIGHT: 1 # not used
  LOSSTYPE: l2 # loss type for w, h
  IGNORETHRE: 0.7 # IoU threshold for learning conf
  RANDRESIZE: True # enable random resizing
  CONFTHRE: 0.8 # not used
  NMSTHRE: 0.45 # same as official darknet
  IMGSIZE: 416 # this can be changed to measure acc-speed tradeoff

Evaluate COCO AP

$ python --cfg config/yolov3_eval.cfg --eval_interval 1 [--ckpt ckpt_path] [--weights_path weights_path]


  • Precision Evaluator (bbox, COCO metric)
  • Modify the target builder
  • Modify loss calculation
  • Training Scheduler
  • Weight initialization
  • Augmentation : Resizing
  • Augmentation : Random Distortion
  • Augmentation : Jitter
  • Augmentation : Flip


YOLOv3: An Incremental Improvement

Joseph Redmon, Ali Farhadi

[Paper] [Original Implementation] [Author's Project Page]


  title={YOLOv3: An Incremental Improvement},
  author={Redmon, Joseph and Farhadi, Ali},
  journal = {arXiv},