Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tests/models/rt_detr/test_image_processing_rt_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@

import requests

from transformers.testing_utils import require_torch, require_torch_gpu, require_torchvision, require_vision, slow
from transformers.testing_utils import (
is_flaky,
require_torch,
require_torch_gpu,
require_torchvision,
require_vision,
slow,
)
from transformers.utils import is_torch_available, is_torchvision_available, is_vision_available

from ...test_image_processing_common import ImageProcessingTestMixin, prepare_image_inputs
Expand Down Expand Up @@ -427,3 +434,9 @@ def test_fast_processor_equivalence_cpu_gpu_coco_detection_annotations(self):
)
# verify size
torch.testing.assert_close(encoding_cpu["labels"][0]["size"], encoding_gpu["labels"][0]["size"].to("cpu"))

@is_flaky(
description="Still flaky with a failing ratio of ~0.6% after #36240",
)
def test_fast_is_faster_than_slow(self):
super().test_fast_is_faster_than_slow()
11 changes: 8 additions & 3 deletions tests/test_image_processing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,14 @@ def measure_time(image_processor, image):
# Warmup
for _ in range(5):
_ = image_processor(image, return_tensors="pt")
start = time.time()
_ = image_processor(image, return_tensors="pt")
return time.time() - start
all_times = []
for _ in range(10):
start = time.time()
_ = image_processor(image, return_tensors="pt")
all_times.append(time.time() - start)
# Take the average of the fastest 3 runs
avg_time = sum(sorted(all_times[:3])) / 3.0
return avg_time

dummy_images = torch.randint(0, 255, (4, 3, 224, 224), dtype=torch.uint8)
image_processor_slow = self.image_processing_class(**self.image_processor_dict)
Expand Down