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

Method resize_sample

fourm/data/modality_transforms.py:482–493  ·  view source on GitHub ↗

Resize the sample

(self, sample, original_size, target_size)

Source from the content-addressed store, hash-verified

480 return cropped_sample
481
482 def resize_sample(self, sample, original_size, target_size):
483 """ Resize the sample
484 """
485 width_scale = target_size[1] / original_size[1]
486 height_scale = target_size[0] / original_size[0]
487 resized_sample = []
488 for instance in sample:
489 instance_copy = instance.copy()
490 instance_copy[:, :, 0] = np.round(width_scale * instance_copy[:, :, 0])
491 instance_copy[:, :, 1] = np.round(height_scale * instance_copy[:, :, 1])
492 resized_sample.append(instance_copy)
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`.

Callers 1

image_augmentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected