Skip to content

Commit

Permalink
Update rescale tests - cast to float after rescaling to reflect huggi…
Browse files Browse the repository at this point in the history
…ngface#25229 (huggingface#25259)

Rescale tests - cast to float after rescaling to reflect huggingface#25229
  • Loading branch information
amyeroberts authored and blbadger committed Nov 8, 2023
1 parent 9ad2ab6 commit 3489d22
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,9 @@ def test_rescale(self):
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))
4 changes: 2 additions & 2 deletions tests/models/vivit/test_image_processing_vivit.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ def test_rescale(self):
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))

0 comments on commit 3489d22

Please sign in to comment.