MCPcopy Create free account
hub / github.com/Ropedia/SpatialBench / __init__

Method __init__

benchmark/models/streamvggt/layers/patch_embed.py:28–57  ·  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

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

Callers

nothing calls this directly

Calls 1

make_2tupleFunction · 0.70

Tested by

no test coverage detected