MCPcopy Create free account
hub / github.com/Kitware/COAT / xpatch_square

Method xpatch_square

utils/mask.py:204–218  ·  view source on GitHub ↗

(self, features, mask_size)

Source from the content-addressed store, hash-verified

202
203
204 def xpatch_square(self, features, mask_size):
205 """
206 """
207 # square
208 x1_max = features.shape[2] - mask_size
209 y1_max = features.shape[3] - mask_size
210 num_masks = 1
211 for i in range(num_masks):
212 mask_x1 = torch.randint(x1_max, (1,))
213 mask_y1 = torch.randint(y1_max, (1,))
214 mask_x2 = mask_x1 + mask_size
215 mask_y2 = mask_y1 + mask_size
216 new_idx = torch.randperm(features.shape[0])
217 features[:, :, mask_x1 : mask_x2, mask_y1 : mask_y2] = features[new_idx, :, mask_x1 : mask_x2, mask_y1 : mask_y2]
218 return features
219
220
221class cutout_patch:

Callers 1

__call__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected