updates
This commit is contained in:
parent
9880dcd6cd
commit
45ce01f859
17
models.py
17
models.py
|
@ -67,9 +67,9 @@ def create_modules(module_defs, img_size, arc):
|
||||||
# modules = nn.Upsample(scale_factor=1/float(mdef[i+1]['stride']), mode='nearest') # reorg3d
|
# modules = nn.Upsample(scale_factor=1/float(mdef[i+1]['stride']), mode='nearest') # reorg3d
|
||||||
|
|
||||||
elif mdef['type'] == 'shortcut': # nn.Sequential() placeholder for 'shortcut' layer
|
elif mdef['type'] == 'shortcut': # nn.Sequential() placeholder for 'shortcut' layer
|
||||||
layer = int(mdef['from'])
|
layers = [int(x) for x in mdef['from'].split(',')]
|
||||||
filters = output_filters[layer]
|
filters = output_filters[layers[0]]
|
||||||
routs.extend([i + layer if layer < 0 else layer])
|
routs.extend([i + l if l < 0 else l for l in layers])
|
||||||
|
|
||||||
elif mdef['type'] == 'reorg3d': # yolov3-spp-pan-scale
|
elif mdef['type'] == 'reorg3d': # yolov3-spp-pan-scale
|
||||||
# torch.Size([16, 128, 104, 104])
|
# torch.Size([16, 128, 104, 104])
|
||||||
|
@ -239,10 +239,10 @@ class Darknet(nn.Module):
|
||||||
mtype = mdef['type']
|
mtype = mdef['type']
|
||||||
if mtype in ['convolutional', 'upsample', 'maxpool']:
|
if mtype in ['convolutional', 'upsample', 'maxpool']:
|
||||||
x = module(x)
|
x = module(x)
|
||||||
elif mtype == 'route':
|
elif mtype == 'route': # concat
|
||||||
layers = [int(x) for x in mdef['layers'].split(',')]
|
layers = [int(x) for x in mdef['layers'].split(',')]
|
||||||
if verbose:
|
if verbose:
|
||||||
print('route concatenating %s' % ([layer_outputs[i].shape for i in layers]))
|
print('route/concatenate %s' % ([layer_outputs[i].shape for i in layers]))
|
||||||
if len(layers) == 1:
|
if len(layers) == 1:
|
||||||
x = layer_outputs[layers[0]]
|
x = layer_outputs[layers[0]]
|
||||||
else:
|
else:
|
||||||
|
@ -252,10 +252,11 @@ class Darknet(nn.Module):
|
||||||
layer_outputs[layers[1]] = F.interpolate(layer_outputs[layers[1]], scale_factor=[0.5, 0.5])
|
layer_outputs[layers[1]] = F.interpolate(layer_outputs[layers[1]], scale_factor=[0.5, 0.5])
|
||||||
x = torch.cat([layer_outputs[i] for i in layers], 1)
|
x = torch.cat([layer_outputs[i] for i in layers], 1)
|
||||||
# print(''), [print(layer_outputs[i].shape) for i in layers], print(x.shape)
|
# print(''), [print(layer_outputs[i].shape) for i in layers], print(x.shape)
|
||||||
elif mtype == 'shortcut':
|
elif mtype == 'shortcut': # sum
|
||||||
j = int(mdef['from'])
|
layers = [int(x) for x in mdef['from'].split(',')]
|
||||||
if verbose:
|
if verbose:
|
||||||
print('shortcut adding layer %g-%s to %g-%s' % (j, layer_outputs[j].shape, i - 1, x.shape))
|
print('shortcut/add %s' % ([layer_outputs[i].shape for i in layers]))
|
||||||
|
for j in layers:
|
||||||
x = x + layer_outputs[j]
|
x = x + layer_outputs[j]
|
||||||
elif mtype == 'yolo':
|
elif mtype == 'yolo':
|
||||||
output.append(module(x, img_size))
|
output.append(module(x, img_size))
|
||||||
|
|
|
@ -33,7 +33,7 @@ def parse_model_cfg(path):
|
||||||
# Check all fields are supported
|
# Check all fields are supported
|
||||||
supported = ['type', 'batch_normalize', 'filters', 'size', 'stride', 'pad', 'activation', 'layers', 'groups',
|
supported = ['type', 'batch_normalize', 'filters', 'size', 'stride', 'pad', 'activation', 'layers', 'groups',
|
||||||
'from', 'mask', 'anchors', 'classes', 'num', 'jitter', 'ignore_thresh', 'truth_thresh', 'random',
|
'from', 'mask', 'anchors', 'classes', 'num', 'jitter', 'ignore_thresh', 'truth_thresh', 'random',
|
||||||
'stride_x', 'stride_y']
|
'stride_x', 'stride_y', 'weights_type', 'weights_normalization']
|
||||||
|
|
||||||
f = [] # fields
|
f = [] # fields
|
||||||
for x in mdefs[1:]:
|
for x in mdefs[1:]:
|
||||||
|
|
Loading…
Reference in New Issue