9. Data generator model in Keras
SSD requires a lot of labeled high-resolution images for object detection. Unlike the previous chapters where the dataset used can be loaded into memory to train the model, SSD implements a multi-threaded data generator. The task of the multi-threaded generator is to load multiple mini-batches of images and their corresponding labels. Because of multi-threading, the GPU can be kept busy as one thread feeds it with data while the rest of CPU threads are in the queue ready to feed another batch data or loading a batch of images from the filesystem and computing the ground truth values. Listing 11.9.1 shows the data generator model in Keras.
The DataGenerator
class inherits from the Sequence
class of Keras to ensure that it supports multi-processing. DataGenerator
guarantees that the entire dataset is used in one epoch.
The length of the entire epoch given a batch size is returned by the __len__()
method. Every request for a mini-batch of data...