Downloading and parsing the dataset

In this section, we first download the dataset from the official website and then parse it into a convenient format. During this stage, we will leave out the images, which occupy quite a lot of memory. We cover this procedure in the following steps:

  1. Define where we want to store our pets dataset and download it using a convenient get_file function in Keras:

DATASET_DIR = "dataset"for type in ("annotations", "images"):    tf.keras.utils.get_file(        type,        f"{type}.tar.gz",        untar=True,        cache_dir=".",        cache_subdir=DATASET_DIR)

As our dataset resides in an archive, we have also extracted it by passing untar=True. We also pointed cache_dir to the current directory. ...

Get OpenCV 4 with Python Blueprints - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.