MCPcopy Create free account
hub / github.com/apple/ml-sharp / __init__

Method __init__

src/sharp/models/initializer.py:75–114  ·  view source on GitHub ↗

Initialize MultilayerInitializer. Args: stride: The downsample rate of output feature map. base_depth: The depth of the first layer (after the foreground layer if use_depth=True). scale_factor: Multiply scale of Gaussians by this factor.

(
        self,
        num_layers: int,
        stride: int,
        base_depth: float,
        scale_factor: float,
        disparity_factor: float,
        color_option: ColorInitOption = "first_layer",
        first_layer_depth_option: DepthInitOption = "surface_min",
        rest_layer_depth_option: DepthInitOption = "surface_min",
        normalize_depth: bool = True,
        feature_input_stop_grad: bool = True,
    )

Source from the content-addressed store, hash-verified

73 """
74
75 def __init__(
76 self,
77 num_layers: int,
78 stride: int,
79 base_depth: float,
80 scale_factor: float,
81 disparity_factor: float,
82 color_option: ColorInitOption = "first_layer",
83 first_layer_depth_option: DepthInitOption = "surface_min",
84 rest_layer_depth_option: DepthInitOption = "surface_min",
85 normalize_depth: bool = True,
86 feature_input_stop_grad: bool = True,
87 ) -> None:
88 """Initialize MultilayerInitializer.
89
90 Args:
91 stride: The downsample rate of output feature map.
92 base_depth: The depth of the first layer (after the foreground
93 layer if use_depth=True).
94 scale_factor: Multiply scale of Gaussians by this factor.
95 disparity_factor: Factor to convert inverse depth to disparity.
96 num_layers: How many layers of Gaussians to predict.
97 color_option: Which color option to initialize the multi-layer gaussians.
98 first_layer_depth_option: Which depth option to initialize the first layer of gaussians.
99 rest_layer_depth_option: Which depth option to initialize the rest layers of gaussians.
100 normalize_depth: # Whether to normalize depth to [DepthTransformParam.depth_min,
101 DepthTransformParam.depth_max).
102 feature_input_stop_grad: Whether to not propagate gradients through feature inputs.
103 """
104 super().__init__()
105 self.num_layers = num_layers
106 self.stride = stride
107 self.base_depth = base_depth
108 self.scale_factor = scale_factor
109 self.disparity_factor = disparity_factor
110 self.color_option = color_option
111 self.first_layer_depth_option = first_layer_depth_option
112 self.rest_layer_depth_option = rest_layer_depth_option
113 self.normalize_depth = normalize_depth
114 self.feature_input_stop_grad = feature_input_stop_grad
115
116 def prepare_feature_input(self, image: torch.Tensor, depth: torch.Tensor) -> torch.Tensor:
117 """Prepare the feature input to the Guassian predictor."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected