Training Faster R-CNN on a custom dataset
In the following code, we will train the Faster R-CNN algorithm to detect the bounding boxes around objects present in images. For this, we will work on the same truck versus bus detection exercise from the previous chapter:
Find the following code in the Training_Faster_RCNN.ipynb
file in the Chapter08
folder on GitHub at https://bit.ly/mcvp-2e.
- Download the dataset:
!pip install -qU torch_snippets import os %%writefile kaggle.json {"username":"XXX", "key":"XXX"} !mkdir -p ~/.kaggle !cp kaggle.json ~/.kaggle/ !chmod 600 /root/.kaggle/kaggle.json !kaggle datasets download -d sixhky/open-images-bus-trucks/ !unzip -qq open-images-bus-trucks.zip !rm open-images-bus-trucks.zip
- Read the DataFrame containing metadata of information about images and their bounding box, and classes:
from torch_snippets import * from PIL import Image IMAGE_ROOT ...