Skip to content

Commit

Permalink
Merge pull request #9 from sjain-stanford/master
Browse files Browse the repository at this point in the history
SAME padding for maxpool to match with Darknet (tested on yolov3-tiny)
  • Loading branch information
jinyu121 authored Jan 30, 2019
2 parents 9ccd692 + 402e973 commit 772aca0
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 3 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Provide optional argument `--training` to generate training graph (uses batch no

### Object Detection Networks

#### yolo-v2
#### yolov2
```
python3 main.py \
--cfg 'data/yolov2.cfg' \
Expand All @@ -25,7 +25,17 @@ python3 main.py \
--gpu 0
```

#### yolo-v3
#### yolov2-tiny
```
python3 main.py \
--cfg 'data/yolov2-tiny.cfg' \
--weights 'data/yolov2-tiny.weights' \
--output 'data/' \
--prefix 'yolov2-tiny/' \
--gpu 0
```

#### yolov3
```
python3 main.py \
--cfg 'data/yolov3.cfg' \
Expand All @@ -35,6 +45,16 @@ python3 main.py \
--gpu 0
```

#### yolov3-tiny
```
python3 main.py \
--cfg 'data/yolov3-tiny.cfg' \
--weights 'data/yolov3-tiny.weights' \
--output 'data/' \
--prefix 'yolov3-tiny/' \
--gpu 0
```

### Image Classification Networks

#### darknet19
Expand Down
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def parse_net(num_layers, cfg, weights, training=False, const_inits=True, verbos
cfg_walker = CFGReader(cfg)
weights_walker = WeightsReader(weights)
output_index = []
num_layers = int(num_layers)

for ith, layer in enumerate(cfg_walker):
if ith > num_layers and num_layers > 0:
Expand Down
139 changes: 139 additions & 0 deletions models/yolov2-tiny.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
[net]
# Testing
batch=1
subdivisions=1
# Training
# batch=64
# subdivisions=2
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=16
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=1

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

###########

[convolutional]
batch_normalize=1
size=3
stride=1
pad=1
filters=512
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=425
activation=linear

[region]
anchors = 0.57273, 0.677385, 1.87446, 2.06253, 3.33843, 5.47434, 7.88282, 3.52778, 9.77052, 9.16828
bias_match=1
classes=80
coords=4
num=5
softmax=1
jitter=.2
rescore=0

object_scale=5
noobject_scale=1
class_scale=1
coord_scale=1

absolute=1
thresh = .6
random=1
3 changes: 3 additions & 0 deletions models/yolov2-tiny.weights.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://pjreddie.com/media/files/yolov2-tiny.weights
(or)
https://drive.google.com/uc?export=view&id=1qzPVXk_ZXcqdllbaLMPeCEB0scEFX2cN
182 changes: 182 additions & 0 deletions models/yolov3-tiny.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
[net]
# Testing
batch=1
subdivisions=1
# Training
# batch=64
# subdivisions=2
width=416
height=416
channels=3
momentum=0.9
decay=0.0005
angle=0
saturation = 1.5
exposure = 1.5
hue=.1

learning_rate=0.001
burn_in=1000
max_batches = 500200
policy=steps
steps=400000,450000
scales=.1,.1

[convolutional]
batch_normalize=1
filters=16
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=32
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=64
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=128
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=2

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[maxpool]
size=2
stride=1

[convolutional]
batch_normalize=1
filters=1024
size=3
stride=1
pad=1
activation=leaky

###########

[convolutional]
batch_normalize=1
filters=256
size=1
stride=1
pad=1
activation=leaky

[convolutional]
batch_normalize=1
filters=512
size=3
stride=1
pad=1
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear



[yolo]
mask = 3,4,5
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
classes=80
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1

[route]
layers = -4

[convolutional]
batch_normalize=1
filters=128
size=1
stride=1
pad=1
activation=leaky

[upsample]
stride=2

[route]
layers = -1, 8

[convolutional]
batch_normalize=1
filters=256
size=3
stride=1
pad=1
activation=leaky

[convolutional]
size=1
stride=1
pad=1
filters=255
activation=linear

[yolo]
mask = 0,1,2
anchors = 10,14, 23,27, 37,58, 81,82, 135,169, 344,319
classes=80
num=6
jitter=.3
ignore_thresh = .7
truth_thresh = 1
random=1
3 changes: 3 additions & 0 deletions models/yolov3-tiny.weights.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://pjreddie.com/media/files/yolov3-tiny.weights
(or)
https://drive.google.com/uc?export=view&id=1V4gI_vA2kvWrwELRA8RbuXJGMDjrWz1N
3 changes: 2 additions & 1 deletion util/cfg_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ def cfg_convolutional(B, H, W, C, net, param, weights_walker, stack, output_inde
def cfg_maxpool(B, H, W, C, net, param, weights_walker, stack, output_index, scope, training, const_inits, verbose):
pool_args = {
"pool_size": int(param['size']),
"strides": int(param['stride'])
"strides": int(param['stride']),
"padding": 'same'
}

net = tf.layers.max_pooling2d(net, name=scope, **pool_args)
Expand Down

0 comments on commit 772aca0

Please sign in to comment.