Resize the sample
(self, sample, original_size, target_size)
| 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`. |