CLIPFeatureExtractor should resize images with kept aspect ratio (#11994)

* Resize with kept aspect ratio

* Fixed failed test

* Overload center_crop and resize methods instead

* resize should handle non-PIL images

* update slow test

* Tensor => tensor

Co-authored-by: patil-suraj <surajp815@gmail.com>
This commit is contained in:
Tobias Norlund
2021-06-10 15:10:41 +02:00
committed by GitHub
parent 472a867626
commit 9d2cee8b48
2 changed files with 56 additions and 2 deletions

View File

@@ -544,7 +544,8 @@ class CLIPModelIntegrationTest(unittest.TestCase):
).to(torch_device)
# forward pass
outputs = model(**inputs)
with torch.no_grad():
outputs = model(**inputs)
# verify the logits
self.assertEqual(
@@ -556,6 +557,6 @@ class CLIPModelIntegrationTest(unittest.TestCase):
torch.Size((inputs.input_ids.shape[0], inputs.pixel_values.shape[0])),
)
expected_logits = torch.tensor([[24.5056, 18.8076]], device=torch_device)
expected_logits = torch.tensor([[24.5701, 19.3049]], device=torch_device)
self.assertTrue(torch.allclose(outputs.logits_per_image, expected_logits, atol=1e-3))