Skip to content

Commit 501f757

Browse files
format code with ufmt
1 parent 1e6682a commit 501f757

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

test/test_utils.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,27 +164,30 @@ def test_draw_boxes_with_coloured_label_backgrounds():
164164
)
165165
expected = torch.as_tensor(np.array(Image.open(path))).permute(2, 0, 1)
166166
assert_equal(result, expected)
167-
167+
168168

169169
@pytest.mark.skipif(PILLOW_VERSION < (10, 1), reason="The reference image is only valid for PIL >= 10.1")
170170
def test_draw_boxes_with_coloured_label_text_boxes():
171171
img = torch.full((3, 100, 100), 255, dtype=torch.uint8)
172172
labels = ["a", "b", "c", "d"]
173173
colors = ["green", "#FF00FF", (0, 255, 0), "red"]
174174
label_colors = ["green", "red", (0, 255, 0), "#FF00FF"]
175-
label_background_colors = ["white", "black", "yellow", "blue"]
175+
label_background_colors = ["white", "black", "yellow", "blue"]
176176
result = utils.draw_bounding_boxes(
177-
img,
178-
boxes,
179-
labels=labels,
180-
colors=colors,
181-
fill=True,
177+
img,
178+
boxes,
179+
labels=labels,
180+
colors=colors,
181+
fill=True,
182182
label_colors=label_colors,
183183
label_background_colors=label_background_colors,
184-
fill_labels=True
184+
fill_labels=True,
185185
)
186186
path = os.path.join(
187-
os.path.dirname(os.path.abspath(__file__)), "assets", "fakedata", "draw_boxes_different_label_background_colors.png"
187+
os.path.dirname(os.path.abspath(__file__)),
188+
"assets",
189+
"fakedata",
190+
"draw_boxes_different_label_background_colors.png",
188191
)
189192
expected = torch.as_tensor(np.array(Image.open(path))).permute(2, 0, 1)
190193
assert_equal(result, expected)

torchvision/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88

99
import numpy as np
1010
import torch
11-
from PIL import Image, ImageColor, ImageDraw, ImageFont
12-
from PIL import __version__ as PILLOW_VERSION_STRING
11+
from PIL import __version__ as PILLOW_VERSION_STRING, Image, ImageColor, ImageDraw, ImageFont
1312

1413
__all__ = [
1514
"_Image_fromarray",
@@ -366,7 +365,7 @@ def draw_bounding_boxes(
366365
label_colors = colors.copy() # type: ignore[assignment]
367366

368367
if fill_labels:
369-
label_background_colors = _parse_colors(label_background_colors, num_objects=num_boxes) if label_background_colors else colors.copy() # type: ignore[assignment]
368+
label_background_colors = _parse_colors(label_background_colors, num_objects=num_boxes) if label_background_colors else colors.copy() # type: ignore[assignment]
370369
else:
371370
label_background_colors = colors.copy() # type: ignore[assignment]
372371

0 commit comments

Comments
 (0)