MCPcopy Create free account
hub / github.com/DSL-Lab/StreamSplat / __init__

Method __init__

encoders/dinov2/layers/patch_embed.py:37–66  ·  view source on GitHub ↗
(
        self,
        img_size: Union[int, Tuple[int, int]] = 224,
        patch_size: Union[int, Tuple[int, int]] = 16,
        in_chans: int = 3,
        embed_dim: int = 768,
        norm_layer: Optional[Callable] = None,
        flatten_embedding: bool = True,
    )

Source from the content-addressed store, hash-verified

35 """
36
37 def __init__(
38 self,
39 img_size: Union[int, Tuple[int, int]] = 224,
40 patch_size: Union[int, Tuple[int, int]] = 16,
41 in_chans: int = 3,
42 embed_dim: int = 768,
43 norm_layer: Optional[Callable] = None,
44 flatten_embedding: bool = True,
45 ) -> None:
46 super().__init__()
47
48 image_HW = make_2tuple(img_size)
49 patch_HW = make_2tuple(patch_size)
50 patch_grid_size = (
51 image_HW[0] // patch_HW[0],
52 image_HW[1] // patch_HW[1],
53 )
54
55 self.img_size = image_HW
56 self.patch_size = patch_HW
57 self.patches_resolution = patch_grid_size
58 self.num_patches = patch_grid_size[0] * patch_grid_size[1]
59
60 self.in_chans = in_chans
61 self.embed_dim = embed_dim
62
63 self.flatten_embedding = flatten_embedding
64
65 self.proj = nn.Conv2d(in_chans, embed_dim, kernel_size=patch_HW, stride=patch_HW)
66 self.norm = norm_layer(embed_dim) if norm_layer else nn.Identity()
67
68 def forward(self, x: Tensor) -> Tensor:
69 _, _, H, W = x.shape

Callers

nothing calls this directly

Calls 1

make_2tupleFunction · 0.70

Tested by

no test coverage detected