• This repository has been archived on 15/Jun/2022
  • Stars
    star
    433
  • Rank 100,464 (Top 2 %)
  • Language
    Python
  • License
    Other
  • Created almost 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Implementation of YOLOv3 in PyTorch

YOLOv3 in Pytorch

Pytorch implementation of YOLOv3

What's New

  • 19/12/17 Now our repo exactly reproduces the train / eval performance of darknet!
  • 19/12/17 AP difference of evaluation between darknet and our repo has been eliminated by modifying the postprocess: one-hot class output to multiple-class output.
  • 19/05/05 We have verified that our repo exactly reproduces darknet's training using the default configuration, with COCO AP ~= 0.277 on train / val2017.
  • 19/02/12 verified inference COCO AP [IoU=0.50:0.95] = 0.297 with val2017, 416x416, batchsize = 8 and w/o random distortion
  • 18/11/27 COCO AP results of darknet (training) are reproduced with the same training conditions
  • 18/11/20 verified inference COCO AP [IoU=0.50:0.95] = 0.302 (paper: 0.310), val5k, 416x416
  • 18/11/20 verified inference COCO AP [IoU=0.50] = 0.544 (paper: 0.553), val5k, 416x416

Performance

Inference using yolov3.weights

Original (darknet) Ours (pytorch)
COCO AP[IoU=0.50:0.95], inference 0.310 0.311
COCO AP[IoU=0.50], inference 0.553 0.558

Training

The benchmark results below have been obtained by training models for 500k iterations on the COCO 2017 train dataset using darknet repo and our repo. The models have been evaluated on the COCO 2017 val dataset using our repo.

  • Our repo reproduces the results of the darknet repo exactly.
  • The AP of the pretrained weights (yolov3.weights) cannot be reproduced by the default setting of the darknet repo.
darknet weights darknet repo Ours (pytorch) Ours (pytorch)
batchsize ?? 4 4 8
speed [iter/min](*) ?? 19.2 19.4 21.0
COCO AP[IoU=0.50:0.95], training 0.311 0.284 0.283 0.298
COCO AP[IoU=0.50], training 0.558 0.488 0.491 0.511
(*) measured on Tesla V100

Installation

Requirements

  • Python 3.6.3+
  • Numpy (verified as operable: 1.15.2)
  • OpenCV
  • Matplotlib
  • Pytorch 1.0.0+ (verified as operable: v0.4.0, v1.0.0)
  • Cython (verified as operable: v0.29.1)
  • pycocotools (verified as operable: v2.0.0)
  • Cuda (verified as operable: v9.0)

optional:

  • tensorboard (>1.7.0)
  • tensorboardX
  • CuDNN (verified as operable: v7.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 train.py --help

Download pretrained weights

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

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

COCO 2017 dataset:

the COCO dataset is downloaded and unzipped by:

$ bash requirements/getcoco.sh

Inference with Pretrained Weights

To detect objects in the sample image, just run:

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

To run the demo using the non-interactive backend, add --background .

Train

$ python train.py --help
usage: train.py [-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

example:

$ python train.py --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:

MODEL:
  TYPE: YOLOv3
  BACKBONE: darknet53
  ANCHORS: [[10, 13], [16, 30], [33, 23],
            [30, 61], [62, 45], [59, 119],
            [116, 90], [156, 198], [373, 326]] # the anchors used in the YOLO layers
  ANCH_MASK: [[6, 7, 8], [3, 4, 5], [0, 1, 2]] # anchor filter for each YOLO layer
  N_CLASSES: 80 # number of object classes
TRAIN:
  LR: 0.001
  MOMENTUM: 0.9
  DECAY: 0.0005
  BURN_IN: 1000 # duration (iters) for learning rate burn-in
  MAXITER: 500000
  STEPS: (400000, 450000) # lr-drop iter points
  BATCHSIZE: 4 
  SUBDIVISION: 16 # num of minibatch inner-iterations
  IMGSIZE: 608 # initial image size
  LOSSTYPE: l2 # loss type for w, h
  IGNORETHRE: 0.7 # IoU threshold for learning conf
AUGMENTATION: # data augmentation section only for training
  RANDRESIZE: True # enable random resizing
  JITTER: 0.3 # amplitude of jitter for resizing
  RANDOM_PLACING: True # enable random placing
  HUE: 0.1 # random distortion parameter
  SATURATION: 1.5 # random distortion parameter
  EXPOSURE: 1.5 # random distortion parameter
  LRFLIP: True # enable horizontal flip
  RANDOM_DISTORT: False # enable random distortion in HSV space
TEST:
  CONFTHRE: 0.8 # not used
  NMSTHRE: 0.45 # same as official darknet
  IMGSIZE: 416 # this can be changed to measure acc-speed tradeoff
NUM_GPUS: 1

Evaluate COCO AP

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

TODOs

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

Paper

YOLOv3: An Incremental Improvement

Joseph Redmon, Ali Farhadi

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

Credit

@article{yolov3,
  title={YOLOv3: An Incremental Improvement},
  author={Redmon, Joseph and Farhadi, Ali},
  journal = {arXiv},
  year={2018}
}

More Repositories

1

HandlerSocket-Plugin-for-MySQL

HandlerSocket is a NoSQL plugin for MySQL, working as a daemon inside the mysqld process, to accept tcp connections, and execute requests from clients. HandlerSocket does not support SQL queries; instead it supports simple CRUD operations on tables.
C++
1,132
star
2

Chainer_Realtime_Multi-Person_Pose_Estimation

Chainer version of Realtime Multi-Person Pose Estiamtion
Python
431
star
3

PacketProxy

A local proxy written in Java
Java
429
star
4

SRCNNKit

CoreML and Keras implementation of Super-Resolution Convolutional Neural Network (SRCNN)
Python
387
star
5

DeClang

An anti-hacking compiler forked from the ollvm (https://github.com/obfuscator-llvm/obfuscator)
379
star
6

HandyRL

HandyRL is a handy and simple framework based on Python and PyTorch for distributed reinforcement learning that is applicable to your own environments.
Python
282
star
7

Chainer_Mask_R-CNN

Implementation of Mask R-CNN in Chainer
Python
140
star
8

nota

Web application for image and video labeling and annotation
JavaScript
112
star
9

Anjin

Autopilot tool for games made with Unity
C#
99
star
10

unity-meta-check

A tool to check problems about meta files of Unity
Go
81
star
11

techcon_app

TechCon App
Dart
57
star
12

HEVCPlayerView

C++
46
star
13

android-modern-architecture-test-handson

Kotlin
30
star
14

codelabs

DeNAγŒδ½œζˆγƒ»ε…¬ι–‹γ—γ¦γ„γ‚‹γ‚³γƒΌγƒ‰γƒ©γƒœγ§γ™γ€‚
Kotlin
28
star
15

cocoa-checker

COCOA(Covid-19 Exposure Notification System in Japan) Signal Checker / COCOA(Covid-19ζŽ₯触璺θͺγ‚’γƒ—γƒͺ)ε‹•δ½œγƒγ‚§γƒƒγ‚«γƒΌ
HTML
25
star
16

aelog

App Engine Logger
Go
24
star
17

ChainerPruner

ChainerPruner: Channel Pruning framework for Chainer
Python
21
star
18

devfarm

Tools to control iOS and Android mobile apps across several device farms
Go
20
star
19

Face2Speech

20
star
20

setup-job-workspace-action

An action creating a virtual workspace directory for each job
TypeScript
20
star
21

tflite-runtime-builder

Build TensorFlow Lite runtime with GitHub Actions
20
star
22

thrush

Some useful additions to bluebird for Node.js
JavaScript
16
star
23

punctual

Redis-backed Node.js task queue for delayed job processing
JavaScript
15
star
24

dworker

Distributed worker system.
JavaScript
11
star
25

capistrano-net_storage

Capistrano Plugin for Fast Deployment via Remote Storage
Ruby
10
star
26

cloud-datastore-interceptor

Interceptors for Cloud Datastore
Go
10
star
27

Dena.CodeAnalysis.Testing

TDD friendly test helpers for Microsoft.CodeAnalysis.Diagnostics.DiagnosticAnalyzer
C#
9
star
28

mysql_rewinder

Ruby
8
star
29

aehcl

App Engine Http Client
Go
7
star
30

mobilize-server

Mobilize-Server includes deployment scripts via Capistrano and scheduling via whenever.
Shell
7
star
31

FBStackableURLCache

A more pluggable version of Apple's NSURLCache. Implement a filtering webbrowser, or even your own version of Amazon Silk…
Objective-C
6
star
32

digdag-operator-bq-wait

Java
6
star
33

m_logger

Ruby
6
star
34

FBFramedScrollableView

UIView subclass that manages any type of UIKit scrollable view, automatically animating a header and footer as you scroll.
Objective-C
6
star
35

mobilize-base

Mobilize is a script deployment and data visualization framework with a Google Spreadsheets UI. Mobilize uses Resque for parallelization and queueuing, MongoDB for caching, and Google Drive for hosting, user input and display.
Ruby
6
star
36

rubycf

Ruby bindings for native Property List read/writing using Core Foundation or CFLite
C
5
star
37

asyncgraph

asyncgraph is a very simply module for controlling flow between asynchronous code.
JavaScript
5
star
38

IsarTutorial

Isabelle
4
star
39

PacketProxyPlugin

Plugins for PacketProxy
Java
4
star
40

ommonitor

Open Match Ticket Monitor
Go
4
star
41

mobilize-ssh

Mobilize-Ssh adds the power of ssh to mobilize-base.
Ruby
4
star
42

ubuntu22-mysql-q4m

Dockerfile
4
star
43

RoslynAnalyzerTemplate

C#
3
star
44

capistrano-deploy_locker

Capistrano Plugin to Lock Deployment
Ruby
3
star
45

redis_info

A Scout plugin to monitor redis by using the redis-cli info command
3
star
46

PacketProxyHub

Web service for sharing configs of PacketProxy
Java
3
star
47

Login-Toboggan-Android

Java
2
star
48

mobilize-hdfs

Adds hdfs support for mobilize-ssh
Ruby
2
star
49

kobold_ruby

Tools for working with and writing tests in Ruby, Rails and Sinatra
Ruby
2
star
50

capistrano-net_storage_demo

Example application for Capistrano::NetStorage
Ruby
1
star
51

aemw

App Engine Middleware
1
star
52

mobilize-hive

adds hive support to mobilize-hdfs
Ruby
1
star
53

unity-meta-check-bins

Pre-built binaries of unity-meta-check for Windows/Linux/macOS
Shell
1
star
54

capistrano-net_storage-s3

Capistrano::NetStorage Plugin for Deployment via Amazon S3
Ruby
1
star
55

Login-Toboggan-iOS

Objective-C
1
star
56

mono-login-sample

C#
1
star
57

mempatch

Memory tampering tool for security assessment
C++
1
star