@@ -116,15 +116,16 @@ def test_draw_boxes():
116
116
assert_equal (img , img_cp )
117
117
118
118
119
- def test_draw_boxes_dtypes ():
119
+ @pytest .mark .parametrize ("fill" , [True , False ])
120
+ def test_draw_boxes_dtypes (fill ):
120
121
img_uint8 = torch .full ((3 , 100 , 100 ), 255 , dtype = torch .uint8 )
121
- out_uint8 = utils .draw_bounding_boxes (img_uint8 , boxes )
122
+ out_uint8 = utils .draw_bounding_boxes (img_uint8 , boxes , fill = fill )
122
123
123
124
assert img_uint8 is not out_uint8
124
125
assert out_uint8 .dtype == torch .uint8
125
126
126
127
img_float = to_dtype (img_uint8 , torch .float , scale = True )
127
- out_float = utils .draw_bounding_boxes (img_float , boxes )
128
+ out_float = utils .draw_bounding_boxes (img_float , boxes , fill = fill )
128
129
129
130
assert img_float is not out_float
130
131
assert out_float .is_floating_point ()
@@ -168,7 +169,6 @@ def test_draw_boxes_grayscale():
168
169
169
170
def test_draw_invalid_boxes ():
170
171
img_tp = ((1 , 1 , 1 ), (1 , 2 , 3 ))
171
- img_wrong1 = torch .full ((3 , 5 , 5 ), 255 , dtype = torch .float )
172
172
img_wrong2 = torch .full ((1 , 3 , 5 , 5 ), 255 , dtype = torch .uint8 )
173
173
img_correct = torch .zeros ((3 , 10 , 10 ), dtype = torch .uint8 )
174
174
boxes = torch .tensor ([[0 , 0 , 20 , 20 ], [0 , 0 , 0 , 0 ], [10 , 15 , 30 , 35 ], [23 , 35 , 93 , 95 ]], dtype = torch .float )
@@ -178,8 +178,6 @@ def test_draw_invalid_boxes():
178
178
179
179
with pytest .raises (TypeError , match = "Tensor expected" ):
180
180
utils .draw_bounding_boxes (img_tp , boxes )
181
- with pytest .raises (ValueError , match = "Tensor uint8 expected" ):
182
- utils .draw_bounding_boxes (img_wrong1 , boxes )
183
181
with pytest .raises (ValueError , match = "Pass individual images, not batches" ):
184
182
utils .draw_bounding_boxes (img_wrong2 , boxes )
185
183
with pytest .raises (ValueError , match = "Only grayscale and RGB images are supported" ):
0 commit comments