tflite_model_maker.searcher.ImageDataLoader

DataLoader class for Image Searcher Task.

Inherits From: DataLoader

embedder Embedder to generate embedding from raw input image.
metadata_type Type of MetadataLoader to load metadata for each input data. By default, load the file name as metadata for each input data.

dataset Gets the dataset.

Due to performance consideration, we don't return a copy, but the returned self._dataset should never be changed.

embedder_path Gets the path to the TFLite Embedder model file.
metadata Gets the metadata.

Methods

append

View source

Appends the dataset.

Don't check if embedders from the two data loader are the same in this function. Users are responsible to keep the embedder identical.

Args
data_loader The data loader in which the data will be appended.

create

View source

Creates DataLoader for the Image Searcher task.

Args
image_embedder_path Path to the ".tflite" image embedder model.
metadata_type Type of MetadataLoader to load metadata for each input image based on image path. By default, load the file name as metadata for each input image.
l2_normalize Whether to normalize the returned feature vector with L2 norm. Use this option only if the model does not already contain a native L2_NORMALIZATION TF Lite Op. In most cases, this is already the case and L2 norm is thus achieved through TF Lite inference.

Returns
DataLoader object created for the Image Searcher task.

load_from_folder

View source

Loads image data from folder.

Users can load images from different folders one by one. For instance,

# Creates data_loader instance.
data_loader = image_searcher_dataloader.DataLoader.create(tflite_path)

# Loads images, first from `image_path1` and secondly from `image_path2`.
data_loader.load_from_folder(image_path1)
data_loader.load_from_folder(image_path2)

Args
path image directory to be loaded.
mode mode in which the file is opened, Used when metadata_type is FROM_DAT_FILE. Only 'r' and 'rb' are supported. 'r' means opening for reading, 'rb' means opening for reading binary.

__len__

View source