MCPcopy Create free account
hub / github.com/InternRobotics/G2VLM / __init__

Method __init__

eval_code/recons/models/moge/model/v1.py:149–204  ·  view source on GitHub ↗
(self, 
        encoder: str = 'dinov2_vitb14', 
        intermediate_layers: Union[int, List[int]] = 4,
        dim_proj: int = 512,
        dim_upsample: List[int] = [256, 128, 128],
        dim_times_res_block_hidden: int = 1,
        num_res_blocks: int = 1,
        remap_output: Literal[False, True, 'linear', 'sinh', 'exp', 'sinh_exp'] = 'linear',
        res_block_norm: Literal['group_norm', 'layer_norm'] = 'group_norm',
        num_tokens_range: Tuple[Number, Number] = [1200, 2500],
        last_res_blocks: int = 0,
        last_conv_channels: int = 32,
        last_conv_size: int = 1,
        mask_threshold: float = 0.5,
        **deprecated_kwargs
    )

Source from the content-addressed store, hash-verified

147 image_std: torch.Tensor
148
149 def __init__(self,
150 encoder: str = 'dinov2_vitb14',
151 intermediate_layers: Union[int, List[int]] = 4,
152 dim_proj: int = 512,
153 dim_upsample: List[int] = [256, 128, 128],
154 dim_times_res_block_hidden: int = 1,
155 num_res_blocks: int = 1,
156 remap_output: Literal[False, True, 'linear', 'sinh', 'exp', 'sinh_exp'] = 'linear',
157 res_block_norm: Literal['group_norm', 'layer_norm'] = 'group_norm',
158 num_tokens_range: Tuple[Number, Number] = [1200, 2500],
159 last_res_blocks: int = 0,
160 last_conv_channels: int = 32,
161 last_conv_size: int = 1,
162 mask_threshold: float = 0.5,
163 **deprecated_kwargs
164 ):
165 super(MoGeModel, self).__init__()
166
167 if deprecated_kwargs:
168 # Process legacy arguments
169 if 'trained_area_range' in deprecated_kwargs:
170 num_tokens_range = [deprecated_kwargs['trained_area_range'][0] // 14 ** 2, deprecated_kwargs['trained_area_range'][1] // 14 ** 2]
171 del deprecated_kwargs['trained_area_range']
172 warnings.warn(f"The following deprecated/invalid arguments are ignored: {deprecated_kwargs}")
173
174 self.encoder = encoder
175 self.remap_output = remap_output
176 self.intermediate_layers = intermediate_layers
177 self.num_tokens_range = num_tokens_range
178 self.mask_threshold = mask_threshold
179
180 # NOTE: We have copied the DINOv2 code in torchhub to this repository.
181 # Minimal modifications have been made: removing irrelevant code, unnecessary warnings and fixing importing issues.
182 hub_loader = getattr(importlib.import_module(".dinov2.hub.backbones", __package__), encoder)
183 self.backbone = hub_loader(pretrained=False)
184 dim_feature = self.backbone.blocks[0].attn.qkv.in_features
185
186 self.head = Head(
187 num_features=intermediate_layers if isinstance(intermediate_layers, int) else len(intermediate_layers),
188 dim_in=dim_feature,
189 dim_out=[3, 1],
190 dim_proj=dim_proj,
191 dim_upsample=dim_upsample,
192 dim_times_res_block_hidden=dim_times_res_block_hidden,
193 num_res_blocks=num_res_blocks,
194 res_block_norm=res_block_norm,
195 last_res_blocks=last_res_blocks,
196 last_conv_channels=last_conv_channels,
197 last_conv_size=last_conv_size
198 )
199
200 image_mean = torch.tensor([0.485, 0.456, 0.406]).view(1, 3, 1, 1)
201 image_std = torch.tensor([0.229, 0.224, 0.225]).view(1, 3, 1, 1)
202
203 self.register_buffer("image_mean", image_mean)
204 self.register_buffer("image_std", image_std)
205
206 @property

Callers

nothing calls this directly

Calls 2

HeadClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected