Skip to content

Commit 2e72bbb

Browse files
Let user specify label_color
1 parent 69a320e commit 2e72bbb

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

torchvision/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ def draw_bounding_boxes(
225225
)
226226

227227
colors = _parse_colors(colors, num_objects=num_boxes)
228-
if label_colors:
229-
label_colors = _parse_colors(label_colors, num_objects=num_boxes) # type: ignore[assignment]
228+
if label_colors or fill_labels:
229+
label_colors = _parse_colors(label_colors if label_colors else "black", num_objects=num_boxes) # type: ignore[assignment]
230230
else:
231231
label_colors = colors.copy() # type: ignore[assignment]
232232

@@ -268,7 +268,6 @@ def draw_bounding_boxes(
268268
draw.rectangle(
269269
(left - box_margin, top - box_margin, right + box_margin, bottom + box_margin), fill=color
270270
)
271-
label_color = "black"
272271
draw.text((bbox[0] + margin, bbox[1] + margin), label, fill=label_color, font=txt_font) # type: ignore[arg-type]
273272

274273
out = F.pil_to_tensor(img_to_draw)

0 commit comments

Comments
 (0)