Skip to content

Commit d31c3e9

Browse files
Fix _ImageDrawTV (#9137)
1 parent 646341d commit d31c3e9

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed
3.05 KB
Loading

test/test_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,17 @@ def test_draw_rotated_boxes():
177177
assert_equal(result, expected)
178178

179179

180+
@pytest.mark.skipif(PILLOW_VERSION < (10, 1), reason="The reference image is only valid for PIL >= 10.1")
181+
def test_draw_rotated_boxes_fill():
182+
img = torch.full((3, 500, 500), 255, dtype=torch.uint8)
183+
colors = ["blue", "yellow", (0, 255, 0), "black"]
184+
185+
result = utils.draw_bounding_boxes(img, rotated_boxes, colors=colors, fill=True)
186+
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "fakedata", "draw_rotated_boxes_fill.png")
187+
expected = torch.as_tensor(np.array(Image.open(path))).permute(2, 0, 1)
188+
assert_equal(result, expected)
189+
190+
180191
@pytest.mark.parametrize("fill", [True, False])
181192
def test_draw_boxes_dtypes(fill):
182193
img_uint8 = torch.full((3, 100, 100), 255, dtype=torch.uint8)

torchvision/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def oriented_rectangle(self, xy, fill=None, outline=None, width=1):
136136
width=width,
137137
fill=outline,
138138
)
139-
self.rectangle(xy, fill=fill, outline=None, width=0)
139+
self.polygon(xy, fill=fill, outline=None, width=0)
140140

141141
def dashed_line(self, xy, fill=None, width=0, joint=None, dash_length=5, space_length=5):
142142
# Calculate the total length of the line

0 commit comments

Comments
 (0)