Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 991cb4d

Browse files
author
Laurent
committed
loosen the tolerances for some sam tests (because of a recent pytorch upgrade)
1 parent a51d695 commit 991cb4d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

tests/foundationals/segment_anything/test_hq_sam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ def test_predictor(
256256
atol=4e-3,
257257
)
258258
assert (
259-
torch.abs(reference_high_res_mask_hq - refiners_high_res_mask_hq).flatten().sum() <= 1
260-
) # The diff on the logits above leads to an absolute diff of 1 pixel on the high res masks
259+
torch.abs(reference_high_res_mask_hq - refiners_high_res_mask_hq).flatten().sum() <= 2
260+
) # The diff on the logits above leads to an absolute diff of 2 pixel on the high res masks
261261
assert torch.allclose(
262262
iou_predictions_np,
263263
torch.max(iou_predictions),

tests/foundationals/segment_anything/test_sam.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def test_predictor_single_output(
422422
assert torch.allclose(
423423
low_res_masks[0, 0, ...],
424424
torch.as_tensor(facebook_low_res_masks[0], device=sam_h_single_output.device),
425-
atol=6e-3, # see test_predictor_resized_single_output for more explanation
425+
atol=5e-2, # see test_predictor_resized_single_output for more explanation
426426
)
427427
assert isclose(scores[0].item(), facebook_scores[0].item(), abs_tol=1e-05)
428428

@@ -497,7 +497,7 @@ def test_mask_encoder(
497497
dense_embeddings = sam_h.mask_encoder(mask_input)
498498

499499
assert facebook_mask_input.shape == mask_input.shape
500-
assert torch.allclose(dense_embeddings, fb_dense_embeddings, atol=1e-4, rtol=1e-4)
500+
assert torch.allclose(dense_embeddings, fb_dense_embeddings, atol=1e-3)
501501

502502

503503
@no_grad()

0 commit comments

Comments
 (0)