Rescale tests - cast to float after rescaling to reflect #25229
This commit is contained in:
@@ -201,9 +201,9 @@ class EfficientNetImageProcessorTest(ImageProcessingSavingTestMixin, unittest.Te
|
|||||||
image_processor = self.image_processing_class(**self.image_processor_dict)
|
image_processor = self.image_processing_class(**self.image_processor_dict)
|
||||||
|
|
||||||
rescaled_image = image_processor.rescale(image, scale=1 / 255)
|
rescaled_image = image_processor.rescale(image, scale=1 / 255)
|
||||||
expected_image = image.astype(np.float32) * (2 / 255.0) - 1
|
expected_image = (image * (2 / 255.0)).astype(np.float32) - 1
|
||||||
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
||||||
|
|
||||||
rescaled_image = image_processor.rescale(image, scale=1 / 255, offset=False)
|
rescaled_image = image_processor.rescale(image, scale=1 / 255, offset=False)
|
||||||
expected_image = image.astype(np.float32) / 255.0
|
expected_image = (image / 255.0).astype(np.float32)
|
||||||
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
||||||
|
|||||||
@@ -220,9 +220,9 @@ class VivitImageProcessingTest(ImageProcessingSavingTestMixin, unittest.TestCase
|
|||||||
image_processor = self.image_processing_class(**self.image_processor_dict)
|
image_processor = self.image_processing_class(**self.image_processor_dict)
|
||||||
|
|
||||||
rescaled_image = image_processor.rescale(image, scale=1 / 255)
|
rescaled_image = image_processor.rescale(image, scale=1 / 255)
|
||||||
expected_image = image.astype(np.float32) * (2 / 255.0) - 1
|
expected_image = (image * (2 / 255.0)).astype(np.float32) - 1
|
||||||
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
||||||
|
|
||||||
rescaled_image = image_processor.rescale(image, scale=1 / 255, offset=False)
|
rescaled_image = image_processor.rescale(image, scale=1 / 255, offset=False)
|
||||||
expected_image = image.astype(np.float32) / 255.0
|
expected_image = (image / 255.0).astype(np.float32)
|
||||||
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
self.assertTrue(np.allclose(rescaled_image, expected_image))
|
||||||
|
|||||||
Reference in New Issue
Block a user