MCPcopy Create free account
hub / github.com/UX-Decoder/Semantic-SAM / Backbone

Class Backbone

semantic_sam/backbone/backbone.py:11–53  ·  view source on GitHub ↗

Abstract base class for network backbones.

Source from the content-addressed store, hash-verified

9
10
11class Backbone(nn.Module):
12 """
13 Abstract base class for network backbones.
14 """
15
16 def __init__(self):
17 """
18 The `__init__` method of any subclass can specify its own set of arguments.
19 """
20 super().__init__()
21
22 def forward(self):
23 """
24 Subclasses must override this method, but adhere to the same return type.
25
26 Returns:
27 dict[str->Tensor]: mapping from feature name (e.g., "res2") to tensor
28 """
29 pass
30
31 @property
32 def size_divisibility(self) -> int:
33 """
34 Some backbones require the input height and width to be divisible by a
35 specific integer. This is typically true for encoder / decoder type networks
36 with lateral connection (e.g., FPN) for which feature maps need to match
37 dimension in the "bottom up" and "top down" paths. Set to 0 if no specific
38 input size divisibility is required.
39 """
40 return 0
41
42 def output_shape(self):
43 """
44 Returns:
45 dict[str->ShapeSpec]
46 """
47 # this is a backward-compatible default
48 return {
49 name: ShapeSpec(
50 channels=self._out_feature_channels[name], stride=self._out_feature_strides[name]
51 )
52 for name in self._out_features
53 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected