MCPcopy Create free account
hub / github.com/NVIDIA/semantic-segmentation / Basic

Class Basic

network/basic.py:38–64  ·  view source on GitHub ↗

Basic segmentation network, no ASPP, no Mscale

Source from the content-addressed store, hash-verified

36
37
38class Basic(nn.Module):
39 """
40 Basic segmentation network, no ASPP, no Mscale
41 """
42 def __init__(self, num_classes, trunk='hrnetv2', criterion=None):
43 super(Basic, self).__init__()
44 self.criterion = criterion
45 self.backbone, _, _, high_level_ch = get_trunk(
46 trunk_name=trunk, output_stride=8)
47 self.seg_head = make_seg_head(in_ch=high_level_ch,
48 out_ch=num_classes)
49 initialize_weights(self.seg_head)
50
51 def forward(self, inputs):
52 x = inputs['images']
53 _, _, final_features = self.backbone(x)
54 pred = self.seg_head(final_features)
55 pred = scale_as(pred, x)
56
57 if self.training:
58 assert 'gts' in inputs
59 gts = inputs['gts']
60 loss = self.criterion(pred, gts)
61 return loss
62 else:
63 output_dict = {'pred': pred}
64 return output_dict
65
66
67class ASPP(nn.Module):

Callers 1

HRNetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected