Exercise: Download a Pretrained Object Detection CNN

Use your skills to download a pretrained object detection CNN, and test it with images of natural scenes.

Problem statement

In this lesson, we’ll download a pretrained CNN for object detection. We’ll test it with some images and filter the results by comparing the confidence level with a preset threshold.

Launch the Jupyter Notebook below and follow the instructions.

Instructions:

  • The comment lines starting with # >>> indicate that you must edit the cell.

  • Replace the None values with the correct function calls.

The main steps that you’ll have to complete are:

  1. Download the pretrained weights for a Faster-RCNN neural network.

  2. Create the transform pipeline associated with the pretrained weights and the list of categories.

  3. Optionally, add image URLs to the list.

  4. Pass the list of image tensors through the CNN.

  5. Annotate the images with the bounding boxes of the objects that are detected.

  6. Filter the detected objects whose confidence level is above a fixed threshold.

Expected output

If everything works as expected, you should obtain annotated images showing bounding boxes of everyday objects and animals. The precision and recall should be reasonable, don’t expect all detected objects to be accurate, nor that all the objects are detected.

Get hands-on with 1400+ tech skills courses.