@@ -230,10 +230,13 @@ def wrapper(idx, sample):
230
230
batched_target ["image_id" ] = image_id
231
231
232
232
spatial_size = tuple (F .get_spatial_size (image ))
233
- batched_target ["boxes" ] = datapoints .BoundingBox (
234
- batched_target ["bbox" ],
235
- format = datapoints .BoundingBoxFormat .XYWH ,
236
- spatial_size = spatial_size ,
233
+ batched_target ["boxes" ] = F .convert_format_bounding_box (
234
+ datapoints .BoundingBox (
235
+ batched_target ["bbox" ],
236
+ format = datapoints .BoundingBoxFormat .XYWH ,
237
+ spatial_size = spatial_size ,
238
+ ),
239
+ new_format = datapoints .BoundingBoxFormat .XYXY ,
237
240
)
238
241
batched_target ["masks" ] = datapoints .Mask (
239
242
torch .stack (
@@ -323,8 +326,13 @@ def wrapper(idx, sample):
323
326
target ,
324
327
target_types = dataset .target_type ,
325
328
type_wrappers = {
326
- "bbox" : lambda item : datapoints .BoundingBox (
327
- item , format = datapoints .BoundingBoxFormat .XYWH , spatial_size = (image .height , image .width )
329
+ "bbox" : lambda item : F .convert_format_bounding_box (
330
+ datapoints .BoundingBox (
331
+ item ,
332
+ format = datapoints .BoundingBoxFormat .XYWH ,
333
+ spatial_size = (image .height , image .width ),
334
+ ),
335
+ new_format = datapoints .BoundingBoxFormat .XYXY ,
328
336
),
329
337
},
330
338
)
@@ -416,8 +424,11 @@ def wrapper(idx, sample):
416
424
image , target = sample
417
425
418
426
if target is not None :
419
- target ["bbox" ] = datapoints .BoundingBox (
420
- target ["bbox" ], format = datapoints .BoundingBoxFormat .XYWH , spatial_size = (image .height , image .width )
427
+ target ["bbox" ] = F .convert_format_bounding_box (
428
+ datapoints .BoundingBox (
429
+ target ["bbox" ], format = datapoints .BoundingBoxFormat .XYWH , spatial_size = (image .height , image .width )
430
+ ),
431
+ new_format = datapoints .BoundingBoxFormat .XYXY ,
421
432
)
422
433
423
434
return image , target
0 commit comments