| 79 | |
| 80 | @staticmethod |
| 81 | def build_decoder(arch='ppm', |
| 82 | fc_dim=512, num_class=150, |
| 83 | weights='', use_softmax=False): |
| 84 | arch = arch.lower() |
| 85 | if arch == 'ppm': |
| 86 | net_decoder = PPM( |
| 87 | num_class=num_class, |
| 88 | fc_dim=fc_dim, |
| 89 | use_softmax=use_softmax) |
| 90 | else: |
| 91 | raise Exception('Architecture undefined!') |
| 92 | |
| 93 | net_decoder.apply(ModelBuilder.weights_init) |
| 94 | if len(weights) > 0: |
| 95 | print('Loading weights for net_decoder') |
| 96 | net_decoder.load_state_dict( |
| 97 | torch.load(weights, map_location=lambda storage, loc: storage), strict=False) |
| 98 | return net_decoder |
| 99 | |
| 100 | |
| 101 | def conv3x3_bn_relu(in_planes, out_planes, stride=1): |