View source on GitHub |
DataLoader class for Image Searcher Task.
Inherits From: DataLoader
tflite_model_maker.searcher.ImageDataLoader(
embedder: image_embedder.ImageEmbedder,
metadata_type: tflite_model_maker.searcher.MetadataType
= tflite_model_maker.searcher.MetadataType.FROM_FILE_NAME
) -> None
Methods
append
append(
data_loader: 'DataLoader'
) -> None
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
@classmethod
create( image_embedder_path: str, metadata_type:
tflite_model_maker.searcher.MetadataType
=tflite_model_maker.searcher.MetadataType.FROM_FILE_NAME
, l2_normalize: bool = False ) -> 'DataLoader'
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
load_from_folder(
path: str, mode: str = 'r'
) -> None
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__
__len__()