in detection/backbone/xcit.py [0:0]
def forward_features(self, x):
B, C, H, W = x.shape
x, (Hp, Wp) = self.patch_embed(x)
pos_encoding = self.pos_embeder(B, Hp, Wp).reshape(B, -1, x.shape[1]).permute(0, 2, 1)
if self.use_pos:
x = x + pos_encoding
x = self.pos_drop(x)
features = []
for i, blk in enumerate(self.blocks):
x = blk(x, Hp, Wp)
if i in self.out_indices:
xp = x.permute(0, 2, 1).reshape(B, -1, Hp, Wp)
features.append(xp)
ops = [self.fpn1, self.fpn2, self.fpn3, self.fpn4]
for i in range(len(features)):
features[i] = ops[i](features[i])
return tuple(features)