Dataset Loader for classification models.
Inherits From: Dataset
View aliases
Main aliases
`mediapipe_model_maker.gesture_recognizer.gesture_recognizer.classification_ds.ClassificationDataset`, `mediapipe_model_maker.gesture_recognizer.gesture_recognizer.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.image_classifier.dataset.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.image_classifier.image_classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.image_classifier.image_classifier.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.python.core.data.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.core.tasks.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.python.text.text_classifier.dataset.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.text.text_classifier.preprocessor.text_classifier_ds.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.text.text_classifier.text_classifier.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.python.text.text_classifier.text_classifier.preprocessor.text_classifier_ds.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.text.text_classifier.text_classifier.text_ds.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.vision.gesture_recognizer.dataset.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.vision.gesture_recognizer.gesture_recognizer.classification_ds.ClassificationDataset`, `mediapipe_model_maker.python.vision.gesture_recognizer.gesture_recognizer.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.python.vision.image_classifier.dataset.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.python.vision.image_classifier.image_classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.python.vision.image_classifier.image_classifier.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.text_classifier.dataset.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.text_classifier.preprocessor.text_classifier_ds.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.text_classifier.text_classifier.classifier.classification_ds.ClassificationDataset`, `mediapipe_model_maker.text_classifier.text_classifier.preprocessor.text_classifier_ds.classification_dataset.ClassificationDataset`, `mediapipe_model_maker.text_classifier.text_classifier.text_ds.classification_dataset.ClassificationDataset`
mediapipe_model_maker.gesture_recognizer.dataset.classification_dataset.ClassificationDataset(
dataset: tf.data.Dataset, size: int, label_names: List[str]
)
Args |
tf_dataset
|
A tf.data.Dataset object that contains a potentially large set
of elements, where each element is a pair of (input_data, target). The
input_data means the raw input data, like an image, a text etc., while
the target means the ground truth of the raw input data, e.g. the
classification label of the image etc.
|
size
|
The size of the dataset. tf.data.Dataset donesn't support a function
to get the length directly since it's lazy-loaded and may be infinite.
|
Attributes |
label_names
|
|
num_classes
|
|
size
|
Returns the size of the dataset.
Note that this function may return None becuase the exact size of the
dataset isn't a necessary parameter to create an instance of this class,
and tf.data.Dataset donesn't support a function to get the length directly
since it's lazy-loaded and may be infinite.
In most cases, however, when an instance of this class is created by helper
functions like 'from_folder', the size of the dataset will be preprocessed,
and this function can return an int representing the size of the dataset.
|
Methods
gen_tf_dataset
View source
gen_tf_dataset(
batch_size: int = 1,
is_training: bool = False,
shuffle: bool = False,
preprocess: Optional[Callable[..., bool]] = None,
drop_remainder: bool = False
) -> tf.data.Dataset
Generates a batched tf.data.Dataset for training/evaluation.
Args |
batch_size
|
An integer, the returned dataset will be batched by this size.
|
is_training
|
A boolean, when True, the returned dataset will be optionally
shuffled and repeated as an endless dataset.
|
shuffle
|
A boolean, when True, the returned dataset will be shuffled to
create randomness during model training.
|
preprocess
|
A function taking three arguments in order, feature, label and
boolean is_training.
|
drop_remainder
|
boolean, whether the finaly batch drops remainder.
|
Returns |
A TF dataset ready to be consumed by Keras model.
|
split
View source
split(
fraction: float
) -> Tuple[ds._DatasetT, ds._DatasetT]
Splits dataset into two sub-datasets with the given fraction.
Primarily used for splitting the data set into training and testing sets.
Args |
fraction
|
float, demonstrates the fraction of the first returned
subdataset in the original data.
|
Returns |
The splitted two sub datasets.
|
__len__
View source
__len__()
Returns the number of element of the dataset.