Fix Fuyu image scaling bug (#26918)

* Fix Fuyu image scaling bug

It could produce negative padding and hence inference errors for certain
image sizes.

* Fix aspect ratio scaling test
This commit is contained in:
Pedro Cuenca
2023-10-20 13:46:06 +02:00
committed by GitHub
parent 9b1976697d
commit c030fc8913
2 changed files with 4 additions and 3 deletions

View File

@@ -50,9 +50,10 @@ class TestFuyuImageProcessor(unittest.TestCase):
), f"Expected {expected_num_patches} patches, got {patches_final.shape[1]}."
def test_scale_to_target_aspect_ratio(self):
# (h:450, w:210) fitting (160, 320) -> (160, 210*160/450)
scaled_image = self.processor._scale_to_target_aspect_ratio(self.sample_image)
self.assertEqual(scaled_image.shape[0], 74)
self.assertEqual(scaled_image.shape[1], 160)
self.assertEqual(scaled_image.shape[0], 160)
self.assertEqual(scaled_image.shape[1], 74)
def test_apply_transformation_numpy(self):
transformed_image = self.processor.apply_transformation(self.sample_image)