MCPcopy Create free account
hub / github.com/apple/ml-4m / remove_tiny_instances

Method remove_tiny_instances

fourm/data/modality_transforms.py:495–505  ·  view source on GitHub ↗

Remove instances that have an area ratio smaller than `bbox_area_threshold`.

(self, sample, image_size)

Source from the content-addressed store, hash-verified

493 return resized_sample
494
495 def remove_tiny_instances(self, sample, image_size):
496 """ Remove instances that have an area ratio smaller than `bbox_area_threshold`.
497 """
498 filtered_sample = []
499 for instance in sample:
500 min_h, min_w, max_h, max_w = self.get_bbox(instance)
501 bbox_area_ratio = (max_h - min_h) * (max_w - min_w) / (image_size[0] * image_size[1])
502 if bbox_area_ratio < self.bbox_area_threshold:
503 continue
504 filtered_sample.append(instance)
505 return filtered_sample
506
507 def hflip(self, sample, width):
508 """ Horizontal flipping the instances in a sample.

Callers 1

image_augmentMethod · 0.95

Calls 1

get_bboxMethod · 0.95

Tested by

no test coverage detected