MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / interpolate

Method interpolate

timm/models/coat.py:274–290  ·  view source on GitHub ↗

Feature map interpolation.

(self, x, scale_factor: float, size: Tuple[int, int])

Source from the content-addressed store, hash-verified

272 return self.interpolate(x, scale_factor=1.0/factor, size=size)
273
274 def interpolate(self, x, scale_factor: float, size: Tuple[int, int]):
275 """ Feature map interpolation. """
276 B, N, C = x.shape
277 H, W = size
278 assert N == 1 + H * W
279
280 cls_token = x[:, :1, :]
281 img_tokens = x[:, 1:, :]
282
283 img_tokens = img_tokens.transpose(1, 2).reshape(B, C, H, W)
284 img_tokens = F.interpolate(
285 img_tokens, scale_factor=scale_factor, recompute_scale_factor=False, mode='bilinear', align_corners=False)
286 img_tokens = img_tokens.reshape(B, C, -1).transpose(1, 2)
287
288 out = torch.cat((cls_token, img_tokens), dim=1)
289
290 return out
291
292 def forward(self, x1, x2, x3, x4, sizes: List[Tuple[int, int]]):
293 _, S2, S3, S4 = sizes

Callers 15

upsampleMethod · 0.95
downsampleMethod · 0.95
trainFunction · 0.80
preprocessFunction · 0.80
trainFunction · 0.80
preprocessFunction · 0.80
trainFunction · 0.80
preprocessFunction · 0.80
trainFunction · 0.80
preprocessFunction · 0.80
preprocessFunction · 0.80
__init__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected