MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / __call__

Method __call__

detrsmpl/data/datasets/pipelines/hybrik_transforms.py:377–428  ·  view source on GitHub ↗
(self, results)

Source from the content-addressed store, hash-verified

375 self.dpg_prob = dpg_prob
376
377 def __call__(self, results):
378 if np.random.rand() > self.dpg_prob:
379 return results
380
381 bbox = results['bbox']
382 imgwidth = results['ann_info']['width']
383 imgheight = results['ann_info']['height']
384
385 PatchScale = random.uniform(0, 1)
386 width = bbox[2] - bbox[0]
387 ht = bbox[3] - bbox[1]
388
389 if PatchScale > 0.85:
390 ratio = ht / width
391 if (width < ht):
392 patchWidth = PatchScale * width
393 patchHt = patchWidth * ratio
394 else:
395 patchHt = PatchScale * ht
396 patchWidth = patchHt / ratio
397
398 xmin = bbox[0] + random.uniform(0, 1) * (width - patchWidth)
399 ymin = bbox[1] + random.uniform(0, 1) * (ht - patchHt)
400 xmax = xmin + patchWidth + 1
401 ymax = ymin + patchHt + 1
402 else:
403 xmin = max(
404 1,
405 min(bbox[0] + np.random.normal(-0.0142, 0.1158) * width,
406 imgwidth - 3))
407 ymin = max(
408 1,
409 min(bbox[1] + np.random.normal(0.0043, 0.068) * ht,
410 imgheight - 3))
411 xmax = min(
412 max(xmin + 2,
413 bbox[2] + np.random.normal(0.0154, 0.1337) * width),
414 imgwidth - 3)
415 ymax = min(
416 max(ymin + 2,
417 bbox[3] + np.random.normal(-0.0013, 0.0711) * ht),
418 imgheight - 3)
419 bbox_xyxy = np.array([xmin, ymin, xmax, ymax])
420 bbox_xywh = xyxy2xywh(bbox_xyxy)
421 center, scale = box2cs(bbox_xywh,
422 aspect_ratio=1.0,
423 bbox_scale_factor=1.0)
424 results['bbox'] = bbox_xyxy
425 results['center'] = center
426 results['scale'] = scale
427
428 return results
429
430
431@PIPELINES.register_module()

Callers

nothing calls this directly

Calls 2

xyxy2xywhFunction · 0.90
box2csFunction · 0.90

Tested by

no test coverage detected