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

Function create_predictor

src/sharp/models/__init__.py:23–73  ·  view source on GitHub ↗

Create gaussian predictor model specified by name.

(params: PredictorParams)

Source from the content-addressed store, hash-verified

21
22
23def create_predictor(params: PredictorParams) -> RGBGaussianPredictor:
24 """Create gaussian predictor model specified by name."""
25 if params.gaussian_decoder.stride < params.initializer.stride:
26 raise ValueError(
27 "We donot expected gaussian_decoder has higher resolution than initializer."
28 )
29
30 scale_factor = params.gaussian_decoder.stride // params.initializer.stride
31 gaussian_composer = GaussianComposer(
32 delta_factor=params.delta_factor,
33 min_scale=params.min_scale,
34 max_scale=params.max_scale,
35 color_activation_type=params.color_activation_type,
36 opacity_activation_type=params.opacity_activation_type,
37 color_space=params.color_space,
38 scale_factor=scale_factor,
39 base_scale_on_predicted_mean=params.base_scale_on_predicted_mean,
40 )
41 if params.num_monodepth_layers > 1 and params.initializer.num_layers != 2:
42 raise KeyError("We only support num_layers = 2 when num_monodepth_layers > 1.")
43
44 monodepth_model = create_monodepth_dpt(params.monodepth)
45 monodepth_adaptor = create_monodepth_adaptor(
46 monodepth_model,
47 params.monodepth_adaptor,
48 params.num_monodepth_layers,
49 params.sorting_monodepth,
50 )
51
52 if params.num_monodepth_layers == 2:
53 monodepth_adaptor.replicate_head(params.num_monodepth_layers)
54
55 gaussian_decoder = create_gaussian_decoder(
56 params.gaussian_decoder,
57 dims_depth_features=monodepth_adaptor.get_feature_dims(),
58 )
59 initializer = create_initializer(
60 params.initializer,
61 )
62 prediction_head = DirectPredictionHead(
63 feature_dim=gaussian_decoder.dim_out, num_layers=initializer.num_layers
64 )
65 decoder_dim = monodepth_model.decoder.dims_decoder[-1]
66 return RGBGaussianPredictor(
67 init_model=initializer,
68 feature_model=gaussian_decoder,
69 prediction_head=prediction_head,
70 monodepth_model=monodepth_adaptor,
71 gaussian_composer=gaussian_composer,
72 scale_map_estimator=create_alignment(params.depth_alignment, depth_decoder_dim=decoder_dim),
73 )
74
75
76__all__ = [

Callers 1

predict_cliFunction · 0.90

Calls 10

create_monodepth_dptFunction · 0.90
create_monodepth_adaptorFunction · 0.90
GaussianComposerClass · 0.85
create_gaussian_decoderFunction · 0.85
create_initializerFunction · 0.85
create_alignmentFunction · 0.85
replicate_headMethod · 0.80
get_feature_dimsMethod · 0.80

Tested by

no test coverage detected