mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Rescale tests - cast to float after rescaling to reflect #25229
This commit is contained in:
parent
904e7e0f3c
commit
1b35409768
@ -201,9 +201,9 @@ class EfficientNetImageProcessorTest(ImageProcessingSavingTestMixin, unittest.Te
|
||||
image_processor = self.image_processing_class(**self.image_processor_dict)
|
||||
|
||||
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))
|
||||
|
||||
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))
|
||||
|
@ -220,9 +220,9 @@ class VivitImageProcessingTest(ImageProcessingSavingTestMixin, unittest.TestCase
|
||||
image_processor = self.image_processing_class(**self.image_processor_dict)
|
||||
|
||||
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))
|
||||
|
||||
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))
|
||||
|
Loading…
Reference in New Issue
Block a user