Skip to content

Commit

Permalink
Merge pull request Hzzone#21 from RizkyWellyanto/master
Browse files Browse the repository at this point in the history
changed OrderedDict usage to fix runtime error of expected channels
  • Loading branch information
Hzzone authored Nov 30, 2019
2 parents f6dda44 + c988c38 commit dac6b08
Showing 1 changed file with 85 additions and 75 deletions.
160 changes: 85 additions & 75 deletions python/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,59 +31,67 @@ def __init__(self):
'Mconv7_stage4_L1', 'Mconv7_stage4_L2', 'Mconv7_stage5_L1',\
'Mconv7_stage5_L2', 'Mconv7_stage6_L1', 'Mconv7_stage6_L1']
blocks = {}
block0 = OrderedDict({'conv1_1': [3, 64, 3, 1, 1],
'conv1_2': [64, 64, 3, 1, 1],
'pool1_stage1': [2, 2, 0],
'conv2_1': [64, 128, 3, 1, 1],
'conv2_2': [128, 128, 3, 1, 1],
'pool2_stage1': [2, 2, 0],
'conv3_1': [128, 256, 3, 1, 1],
'conv3_2': [256, 256, 3, 1, 1],
'conv3_3': [256, 256, 3, 1, 1],
'conv3_4': [256, 256, 3, 1, 1],
'pool3_stage1': [2, 2, 0],
'conv4_1': [256, 512, 3, 1, 1],
'conv4_2': [512, 512, 3, 1, 1],
'conv4_3_CPM': [512, 256, 3, 1, 1],
'conv4_4_CPM': [256, 128, 3, 1, 1]})
block0 = OrderedDict([
('conv1_1', [3, 64, 3, 1, 1]),
('conv1_2', [64, 64, 3, 1, 1]),
('pool1_stage1', [2, 2, 0]),
('conv2_1', [64, 128, 3, 1, 1]),
('conv2_2', [128, 128, 3, 1, 1]),
('pool2_stage1', [2, 2, 0]),
('conv3_1', [128, 256, 3, 1, 1]),
('conv3_2', [256, 256, 3, 1, 1]),
('conv3_3', [256, 256, 3, 1, 1]),
('conv3_4', [256, 256, 3, 1, 1]),
('pool3_stage1', [2, 2, 0]),
('conv4_1', [256, 512, 3, 1, 1]),
('conv4_2', [512, 512, 3, 1, 1]),
('conv4_3_CPM', [512, 256, 3, 1, 1]),
('conv4_4_CPM', [256, 128, 3, 1, 1])
])


# Stage 1
block1_1 = OrderedDict({'conv5_1_CPM_L1': [128, 128, 3, 1, 1],
'conv5_2_CPM_L1': [128, 128, 3, 1, 1],
'conv5_3_CPM_L1': [128, 128, 3, 1, 1],
'conv5_4_CPM_L1': [128, 512, 1, 1, 0],
'conv5_5_CPM_L1': [512, 38, 1, 1, 0]})

block1_2 = OrderedDict({'conv5_1_CPM_L2': [128, 128, 3, 1, 1],
'conv5_2_CPM_L2': [128, 128, 3, 1, 1],
'conv5_3_CPM_L2': [128, 128, 3, 1, 1],
'conv5_4_CPM_L2': [128, 512, 1, 1, 0],
'conv5_5_CPM_L2': [512, 19, 1, 1, 0]})
block1_1 = OrderedDict([
('conv5_1_CPM_L1', [128, 128, 3, 1, 1]),
('conv5_2_CPM_L1', [128, 128, 3, 1, 1]),
('conv5_3_CPM_L1', [128, 128, 3, 1, 1]),
('conv5_4_CPM_L1', [128, 512, 1, 1, 0]),
('conv5_5_CPM_L1', [512, 38, 1, 1, 0])
])

block1_2 = OrderedDict([
('conv5_1_CPM_L2', [128, 128, 3, 1, 1]),
('conv5_2_CPM_L2', [128, 128, 3, 1, 1]),
('conv5_3_CPM_L2', [128, 128, 3, 1, 1]),
('conv5_4_CPM_L2', [128, 512, 1, 1, 0]),
('conv5_5_CPM_L2', [512, 19, 1, 1, 0])
])
blocks['block1_1'] = block1_1
blocks['block1_2'] = block1_2

self.model0 = make_layers(block0, no_relu_layers)

# Stages 2 - 6
for i in range(2, 7):
blocks['block%d_1' % i] = OrderedDict({
'Mconv1_stage%d_L1' % i: [185, 128, 7, 1, 3],
'Mconv2_stage%d_L1' % i: [128, 128, 7, 1, 3],
'Mconv3_stage%d_L1' % i: [128, 128, 7, 1, 3],
'Mconv4_stage%d_L1' % i: [128, 128, 7, 1, 3],
'Mconv5_stage%d_L1' % i: [128, 128, 7, 1, 3],
'Mconv6_stage%d_L1' % i: [128, 128, 1, 1, 0],
'Mconv7_stage%d_L1' % i: [128, 38, 1, 1, 0]})

blocks['block%d_2' % i] = OrderedDict({
'Mconv1_stage%d_L2' % i: [185, 128, 7, 1, 3],
'Mconv2_stage%d_L2' % i: [128, 128, 7, 1, 3],
'Mconv3_stage%d_L2' % i: [128, 128, 7, 1, 3],
'Mconv4_stage%d_L2' % i: [128, 128, 7, 1, 3],
'Mconv5_stage%d_L2' % i: [128, 128, 7, 1, 3],
'Mconv6_stage%d_L2' % i: [128, 128, 1, 1, 0],
'Mconv7_stage%d_L2' % i: [128, 19, 1, 1, 0]})
blocks['block%d_1' % i] = OrderedDict([
('Mconv1_stage%d_L1' % i, [185, 128, 7, 1, 3]),
('Mconv2_stage%d_L1' % i, [128, 128, 7, 1, 3]),
('Mconv3_stage%d_L1' % i, [128, 128, 7, 1, 3]),
('Mconv4_stage%d_L1' % i, [128, 128, 7, 1, 3]),
('Mconv5_stage%d_L1' % i, [128, 128, 7, 1, 3]),
('Mconv6_stage%d_L1' % i, [128, 128, 1, 1, 0]),
('Mconv7_stage%d_L1' % i, [128, 38, 1, 1, 0])
])

blocks['block%d_2' % i] = OrderedDict([
('Mconv1_stage%d_L2' % i, [185, 128, 7, 1, 3]),
('Mconv2_stage%d_L2' % i, [128, 128, 7, 1, 3]),
('Mconv3_stage%d_L2' % i, [128, 128, 7, 1, 3]),
('Mconv4_stage%d_L2' % i, [128, 128, 7, 1, 3]),
('Mconv5_stage%d_L2' % i, [128, 128, 7, 1, 3]),
('Mconv6_stage%d_L2' % i, [128, 128, 1, 1, 0]),
('Mconv7_stage%d_L2' % i, [128, 19, 1, 1, 0])
])

for k in blocks.keys():
blocks[k] = make_layers(blocks[k], no_relu_layers)
Expand Down Expand Up @@ -140,45 +148,47 @@ def __init__(self):
no_relu_layers = ['conv6_2_CPM', 'Mconv7_stage2', 'Mconv7_stage3',\
'Mconv7_stage4', 'Mconv7_stage5', 'Mconv7_stage6']
# stage 1
block1_0 = OrderedDict({
'conv1_1': [3, 64, 3, 1, 1],
'conv1_2': [64, 64, 3, 1, 1],
'pool1_stage1': [2, 2, 0],
'conv2_1': [64, 128, 3, 1, 1],
'conv2_2': [128, 128, 3, 1, 1],
'pool2_stage1': [2, 2, 0],
'conv3_1': [128, 256, 3, 1, 1],
'conv3_2': [256, 256, 3, 1, 1],
'conv3_3': [256, 256, 3, 1, 1],
'conv3_4': [256, 256, 3, 1, 1],
'pool3_stage1': [2, 2, 0],
'conv4_1': [256, 512, 3, 1, 1],
'conv4_2': [512, 512, 3, 1, 1],
'conv4_3': [512, 512, 3, 1, 1],
'conv4_4': [512, 512, 3, 1, 1],
'conv5_1': [512, 512, 3, 1, 1],
'conv5_2': [512, 512, 3, 1, 1],
'conv5_3_CPM': [512, 128, 3, 1, 1]})

block1_1 = OrderedDict({
'conv6_1_CPM': [128, 512, 1, 1, 0],
'conv6_2_CPM': [512, 22, 1, 1, 0]
})
block1_0 = OrderedDict([
('conv1_1', [3, 64, 3, 1, 1]),
('conv1_2', [64, 64, 3, 1, 1]),
('pool1_stage1', [2, 2, 0]),
('conv2_1', [64, 128, 3, 1, 1]),
('conv2_2', [128, 128, 3, 1, 1]),
('pool2_stage1', [2, 2, 0]),
('conv3_1', [128, 256, 3, 1, 1]),
('conv3_2', [256, 256, 3, 1, 1]),
('conv3_3', [256, 256, 3, 1, 1]),
('conv3_4', [256, 256, 3, 1, 1]),
('pool3_stage1', [2, 2, 0]),
('conv4_1', [256, 512, 3, 1, 1]),
('conv4_2', [512, 512, 3, 1, 1]),
('conv4_3', [512, 512, 3, 1, 1]),
('conv4_4', [512, 512, 3, 1, 1]),
('conv5_1', [512, 512, 3, 1, 1]),
('conv5_2', [512, 512, 3, 1, 1]),
('conv5_3_CPM', [512, 128, 3, 1, 1])
])

block1_1 = OrderedDict([
('conv6_1_CPM', [128, 512, 1, 1, 0]),
('conv6_2_CPM', [512, 22, 1, 1, 0])
])

blocks = {}
blocks['block1_0'] = block1_0
blocks['block1_1'] = block1_1

# stage 2-6
for i in range(2, 7):
blocks['block%d' % i] = OrderedDict({
'Mconv1_stage%d' % i: [150, 128, 7, 1, 3],
'Mconv2_stage%d' % i: [128, 128, 7, 1, 3],
'Mconv3_stage%d' % i: [128, 128, 7, 1, 3],
'Mconv4_stage%d' % i: [128, 128, 7, 1, 3],
'Mconv5_stage%d' % i: [128, 128, 7, 1, 3],
'Mconv6_stage%d' % i: [128, 128, 1, 1, 0],
'Mconv7_stage%d' % i: [128, 22, 1, 1, 0]})
blocks['block%d' % i] = OrderedDict([
('Mconv1_stage%d' % i, [150, 128, 7, 1, 3]),
('Mconv2_stage%d' % i, [128, 128, 7, 1, 3]),
('Mconv3_stage%d' % i, [128, 128, 7, 1, 3]),
('Mconv4_stage%d' % i, [128, 128, 7, 1, 3]),
('Mconv5_stage%d' % i, [128, 128, 7, 1, 3]),
('Mconv6_stage%d' % i, [128, 128, 1, 1, 0]),
('Mconv7_stage%d' % i, [128, 22, 1, 1, 0])
])

for k in blocks.keys():
blocks[k] = make_layers(blocks[k], no_relu_layers)
Expand Down

0 comments on commit dac6b08

Please sign in to comment.