Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
amyeroberts committed Jun 24, 2024
1 parent e9568bb commit 90c9584
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
scale = size / min(w, h)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
2 changes: 1 addition & 1 deletion tests/models/detr/test_image_processing_detr.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
2 changes: 1 addition & 1 deletion tests/models/idefics/test_image_processing_idefics.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
scale = size / min(w, h)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
2 changes: 1 addition & 1 deletion tests/models/oneformer/test_image_processing_oneformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
2 changes: 1 addition & 1 deletion tests/models/oneformer/test_processor_oneformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
if w < h:
Expand Down
2 changes: 1 addition & 1 deletion tests/models/vilt/test_image_processing_vilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_expected_values(self, image_inputs, batched=False):
if isinstance(image, Image.Image):
w, h = image.size
elif isinstance(image, np.ndarray):
h, w = image.shape[:2]
h, w = image.shape[0], image.shape[1]
else:
h, w = image.shape[1], image.shape[2]
scale = size / min(w, h)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_image_processing_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,12 @@ def measure_time(image_processor, image):
return time.time() - start

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

fast_time = measure_time(image_processor_fast, dummy_images)
slow_time = measure_time(image_processor_slow, dummy_images)

# We take an average
self.assertLessEqual(fast_time, slow_time)

def test_image_processor_to_json_string(self):
Expand Down

0 comments on commit 90c9584

Please sign in to comment.