Get startedGet started for free

Bounding boxes prediction

You have trained an object recognition model. Now, you want to use to generate bounding boxes and classifications for a test image.

The model is available as model and it's already in the evaluation mode. The test_image is also available, and torch and torch.nn as nn have been imported.

This exercise is part of the course

Deep Learning for Images with PyTorch

View Course

Exercise instructions

  • Get the model's output for the test_image and assign it to output.
  • Extract the predicted bounding boxes from the output and assign them to boxes.
  • Extract the predicted scores from the output and assign them to scores.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Get model's prediction
with torch.no_grad():
    output = ____

# Extract boxes from the output
boxes = ____

# Extract scores from the output
scores = ____

print(boxes, scores)
Edit and Run Code