MCPcopy Create free account
hub / github.com/FoundationVision/ByteTrack / __call__

Method __call__

tutorials/motr/transforms.py:349–369  ·  view source on GitHub ↗
(self, imgs: list, targets: list)

Source from the content-addressed store, hash-verified

347 self.bs = bs
348
349 def __call__(self, imgs: list, targets: list):
350 ret_imgs = copy.deepcopy(imgs)
351 ret_targets = copy.deepcopy(targets)
352
353 n_frames = len(imgs)
354 select_i = random.choice(list(range(n_frames)))
355 w, h = imgs[select_i].size
356
357 xshift = (100 * torch.rand(self.bs)).int()
358 xshift *= (torch.randn(self.bs) > 0.0).int() * 2 - 1
359 yshift = (100 * torch.rand(self.bs)).int()
360 yshift *= (torch.randn(self.bs) > 0.0).int() * 2 - 1
361 ymin = max(0, -yshift[0])
362 ymax = min(h, h - yshift[0])
363 xmin = max(0, -xshift[0])
364 xmax = min(w, w - xshift[0])
365
366 region = (int(ymin), int(xmin), int(ymax-ymin), int(xmax-xmin))
367 ret_imgs[select_i], ret_targets[select_i] = random_shift(imgs[select_i], targets[select_i], region, (h,w))
368
369 return ret_imgs, ret_targets
370
371
372class FixedMotRandomShift(object):

Callers

nothing calls this directly

Calls 1

random_shiftFunction · 0.85

Tested by

no test coverage detected