Fix tests for vision models (#35654)
* Trigger tests * [run-slow] beit, detr, dinov2, vit, textnet * Fix BEiT interpolate_pos_encoding * Fix DETR test * Update DINOv2 test * Fix textnet * Fix vit * Fix DPT * fix data2vec test * Fix textnet test * Update interpolation check * Fix ZoeDepth tests * Update interpolate embeddings for BEiT * Apply suggestions from code review
This commit is contained in:
committed by
GitHub
parent
e60ae0d078
commit
d419862889
@@ -301,8 +301,8 @@ class ZoeDepthModelIntegrationTest(unittest.TestCase):
|
||||
out_l_reduced = torch.nn.functional.interpolate(
|
||||
out_l.unsqueeze(0).unsqueeze(1), size=img.size[::-1], mode="bicubic", align_corners=False
|
||||
)
|
||||
self.assertTrue((np.array(out_l.shape)[::-1] == np.array(img.size) * 2).all())
|
||||
torch.testing.assert_close(out, out_l_reduced, rtol=2e-2)
|
||||
out_l_reduced = out_l_reduced.squeeze(0).squeeze(0)
|
||||
torch.testing.assert_close(out, out_l_reduced, rtol=2e-2, atol=2e-2)
|
||||
|
||||
def check_post_processing_test(self, image_processor, images, model, pad_input=True, flip_aug=True):
|
||||
inputs = image_processor(images=images, return_tensors="pt", do_pad=pad_input).to(torch_device)
|
||||
@@ -324,7 +324,7 @@ class ZoeDepthModelIntegrationTest(unittest.TestCase):
|
||||
for img, out, expected_slice in zip(images, outputs, expected_slices):
|
||||
out = out["predicted_depth"]
|
||||
self.assertTrue(img.size == out.shape[::-1])
|
||||
torch.testing.assert_close(expected_slice, out[:3, :3], atol=1e-3, rtol=1e-3)
|
||||
torch.testing.assert_close(expected_slice, out[:3, :3], rtol=1e-3, atol=1e-3)
|
||||
|
||||
self.check_target_size(image_processor, pad_input, images, outputs, raw_outputs, raw_outputs_flipped)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user