Complete the code to create a bounding box tensor for an object detection model.
bbox = torch.tensor([[1], 50, 150, 200])
The bounding box coordinates must be numeric values, so 30 without quotes is correct.
Complete the code to calculate the Intersection over Union (IoU) between two boxes.
iou = intersection_area / [1]IoU is the ratio of intersection area over union area of two boxes.
Fix the error in the code that extracts predicted bounding boxes from model output.
pred_boxes = outputs['boxes'][1]
To index a tensor in PyTorch, square brackets [] are used, so [0] is correct.
Fill both blanks to complete the code that filters detections by confidence score.
filtered = [box for box in detections if box['score'] [1] [2]]
We keep boxes with score greater than 0.5 to filter confident detections.
Fill all three blanks to complete the code that creates a dictionary of detected object labels and their bounding boxes.
results = [1]((label, [2]) for label, box in zip(labels, [3]))
We use dict() to create a dictionary mapping each label to its bounding box from the boxes list.