Giter Club home page Giter Club logo

pytorch-yolo2's Introduction

pytorch-yolo2

Convert https://pjreddie.com/darknet/yolo/ into pytorch. This repository is trying to achieve the following goals.

  • implement RegionLoss, MaxPoolStride1, Reorg, GolbalAvgPool2d
  • implement route layer
  • detect, partial, valid functions
  • load darknet cfg
  • load darknet saved weights
  • save as darknet weights
  • fast evaluation
  • pascal voc validation
  • train pascal voc
  • LMDB data set
  • Data augmentation
  • train resnet
  • load/save caffe prototxt and weights

Detection Using A Pre-Trained Model

wget http://pjreddie.com/media/files/yolo.weights
python detect.py cfg/yolo.cfg yolo.weights data/dog.jpg

You will see some output like this:

layer     filters    size              input                output
    0 conv     32  3 x 3 / 1   416 x 416 x   3   ->   416 x 416 x  32
    1 max          2 x 2 / 2   416 x 416 x  32   ->   208 x 208 x  32
    ......
   30 conv    425  1 x 1 / 1    13 x  13 x1024   ->    13 x  13 x 425
   31 detection
Loading weights from yolo.weights... Done!
data/dog.jpg: Predicted in 0.014079 seconds.
truck: 0.934711
bicycle: 0.998013
dog: 0.990524

Real-Time Detection on a Webcam


Training YOLO on VOC

Get The Pascal VOC Data
wget https://pjreddie.com/media/files/VOCtrainval_11-May-2012.tar
wget https://pjreddie.com/media/files/VOCtrainval_06-Nov-2007.tar
wget https://pjreddie.com/media/files/VOCtest_06-Nov-2007.tar
tar xf VOCtrainval_11-May-2012.tar
tar xf VOCtrainval_06-Nov-2007.tar
tar xf VOCtest_06-Nov-2007.tar
Generate Labels for VOC
wget http://pjreddie.com/media/files/voc_label.py
python voc_label.py
cat 2007_train.txt 2007_val.txt 2012_*.txt > voc_train.txt
Modify Cfg for Pascal Data

Change the cfg/voc.data config file

train  = train.txt
valid  = 2007_test.txt
names = data/voc.names
backup = backup
Download Pretrained Convolutional Weights

Download weights from the convolutional layers

wget http://pjreddie.com/media/files/darknet19_448.conv.23

or run the following command:

python partial.py cfg/darknet19_448.cfg darknet19_448.weights darknet19_448.conv.23 23
Train The Model
python train.py cfg/voc.data cfg/yolo-voc.cfg darknet19_448.conv.23
Evaluate The Model
python valid.py cfg/voc.data cfg/yolo-voc.cfg yolo-voc.weights
python scripts/voc_eval.py results/comp4_det_test_

mAP

YOLOv2 544 0.7682 (paper: 78.6)
YOLOv2 416 0.7513 (paper: 76.8)
TinyYolo 416 0.5410 (paper: 57.1)

Problems

1. Running variance difference between darknet and pytorch

Change the code in normalize_cpu to make the same result

normalize_cpu:
x[index] = (x[index] - mean[f])/(sqrt(variance[f] + .00001f));

pytorch-yolo2's People

Contributors

marvis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.