MCPcopy
hub / github.com/magicleap/Atlas / build_backbone2d

Function build_backbone2d

atlas/backbone2d.py:14–30  ·  view source on GitHub ↗

Builds 2D feature extractor backbone network from Detectron2.

(cfg)

Source from the content-addressed store, hash-verified

12
13
14def build_backbone2d(cfg):
15 """ Builds 2D feature extractor backbone network from Detectron2."""
16
17 output_dim = cfg.MODEL.BACKBONE3D.CHANNELS[0]
18 norm = cfg.MODEL.FPN.NORM
19 output_stride = 4 # TODO: make configurable
20
21 backbone = d2_build_backbone(cfg)
22 feature_extractor = FPNFeature(
23 backbone.output_shape(), output_dim, output_stride, norm)
24
25 # load pretrained backbone
26 if cfg.MODEL.BACKBONE.WEIGHTS:
27 state_dict = torch.load(cfg.MODEL.BACKBONE.WEIGHTS)
28 backbone.load_state_dict(state_dict)
29
30 return nn.Sequential(backbone, feature_extractor), output_stride
31
32
33class FPNFeature(nn.Module):

Callers 1

__init__Method · 0.90

Calls 2

FPNFeatureClass · 0.85
loadMethod · 0.80

Tested by

no test coverage detected