def paths_and_labels_to_dataset(file_paths, labels, label_mode, num_classes, max_length): """Constructs a dataset of text strings and labels.""" path_ds = tf.data.Dataset.from_tensor_slices(file_paths) string_ds = path_ds.map(lambda x: path_to_string_content(x, max_length)) if label_mode: label_ds = dataset_utils.labels_to_dataset(labels, label_mode, num_classes) string_ds = tf.data.Dataset.zip((string_ds, label_ds)) return string_ds
def paths_and_labels_to_dataset(image_paths, image_size, num_channels, labels, label_mode, num_classes, interpolation): """Constructs a dataset of images and labels.""" # TODO(fchollet): consider making num_parallel_calls settable path_ds = tf.data.Dataset.from_tensor_slices(image_paths) img_ds = path_ds.map( lambda x: path_to_image(x, image_size, num_channels, interpolation)) if label_mode: label_ds = dataset_utils.labels_to_dataset(labels, label_mode, num_classes) img_ds = tf.data.Dataset.zip((img_ds, label_ds)) return img_ds
def paths_and_labels_to_dataset(image_paths, image_size, num_channels, labels, label_mode, num_classes, interpolation, crop_to_aspect_ratio=False): """Constructs a dataset of images and labels.""" # TODO(fchollet): consider making num_parallel_calls settable path_ds = tf.data.Dataset.from_tensor_slices(image_paths) args = (image_size, num_channels, interpolation, crop_to_aspect_ratio) img_ds = path_ds.map( lambda x: load_image(x, *args), num_parallel_calls=tf.data.AUTOTUNE) if label_mode: label_ds = dataset_utils.labels_to_dataset(labels, label_mode, num_classes) img_ds = tf.data.Dataset.zip((img_ds, label_ds)) return img_ds