@@ -141,7 +141,7 @@ def draw_bounding_boxes(
141
141
image : torch .Tensor ,
142
142
boxes : torch .Tensor ,
143
143
labels : Optional [List [str ]] = None ,
144
- colors : Optional [List [Union [str , Tuple [int , int , int ]]]] = None ,
144
+ colors : Optional [Union [ List [Union [str , Tuple [int , int , int ]]], str , Tuple [ int , int , int ]]] = None ,
145
145
fill : Optional [bool ] = False ,
146
146
width : int = 1 ,
147
147
font : Optional [str ] = None ,
@@ -159,8 +159,9 @@ def draw_bounding_boxes(
159
159
the boxes are absolute coordinates with respect to the image. In other words: `0 <= xmin < xmax < W` and
160
160
`0 <= ymin < ymax < H`.
161
161
labels (List[str]): List containing the labels of bounding boxes.
162
- colors (List[Union[str, Tuple[int, int, int]]]): List containing the colors of bounding boxes. The colors can
163
- be represented as `str` or `Tuple[int, int, int]`.
162
+ colors (Union[List[Union[str, Tuple[int, int, int]]], str, Tuple[int, int, int]]): List containing the colors
163
+ or a single color for all of the bounding boxes. The colors can be represented as `str` or
164
+ `Tuple[int, int, int]`.
164
165
fill (bool): If `True` fills the bounding box with specified color.
165
166
width (int): Width of bounding box.
166
167
font (str): A filename containing a TrueType font. If the file is not found in this filename, the loader may
@@ -200,8 +201,10 @@ def draw_bounding_boxes(
200
201
for i , bbox in enumerate (img_boxes ):
201
202
if colors is None :
202
203
color = None
203
- else :
204
+ elif isinstance ( colors , list ) :
204
205
color = colors [i ]
206
+ else :
207
+ color = colors
205
208
206
209
if fill :
207
210
if color is None :
0 commit comments