Question: Obtain the model predictions on the test dataset. Create a list of computed IoUs for each class. Each list should have a length equal to

Obtain the model predictions on the test dataset. Create a list of computed IoUs for each class. Each list should have a length equal to the size of the test dataset. If there is no predicted bounding box on a particular image, put None instead of the IoU.
# Import compute_iou function from Keras CV
from keras_cv.bounding_box import compute_iou
# Get the model predictions. This will take some time.
# Save the model predictions to objdet_preds variable
### --YOUR CODE HERE-- ###
## I KEEP GETTING ERRORS HERE
# Extract the predicted and ground truth boxes for each object class
### --YOUR CODE HERE-- ###
class_banana_gt = ds_test_sample_batch[0,...].numpy()
#class_apple_gt = ds_test_sample_images["bounding_boxes"][1]
#class_orange_gt = ds_test_sample_images["bounding_boxes"][2]
# Compute the IoU of the bounding boxes for each object in each image
# Set the appropriate boxes parameters
# There should be three IoU lists
# Iterate through the prediction output of the model
# Save them to apple_ious, banana_ious, and orange_ious variables, respectively
### --YOUR CODE HERE-- ###
apple_ious =[]
banana_ious =[]
orange_ious =[]
for i in range(len(objdet_preds)):
pred_boxes = objdet_preds[i]["boxes"]
gt_boxes_apple = class_apple_gt[i]
gt_boxes_banana = class_banana_gt[i]
gt_boxes_orange = class_orange_gt[i]
apple_iou =[]
banana_iou =[]
orange_iou =[]
for j in range(len(pred_boxes)):
apple_iou.append(compute_iou(pred_boxes[j], gt_boxes_apple))
banana_iou.append(compute_iou(pred_boxes[j], gt_boxes_banana))
orange_iou.append(compute_iou(pred_boxes[j], gt_boxes_orange))
apple_ious.append(apple_iou)
banana_ious.append(banana_iou)
orange_ious.append(orange_iou)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!