如何在Tensorflow中创建自定义图像数据集

时间:2019-04-13 08:41:14

标签: python tensorflow keras

我正在尝试使用Estimators和或Keras创建图像分类器。

我一直在遵循此页面上的教程:https://www.tensorflow.org/tutorials/load_data/images

我使用以下代码构建了图像和标签的数据集:

ds = tf.data.Dataset.from_tensor_slices((all_image_paths, all_image_labels))

image_label_ds = ds.map(load_and_preprocess_from_path_label)

image_label_ds输出如下:

<DatasetV1Adapter shapes: ((180, 360, 3), ()), types: (tf.float32, tf.int32)>

由于本教程使用的MobileNetV2可以接受大小为(192,192,3)的图像,所以我不再遵循本教程。

有人可以向我解释如何对数据集进行所有必要的准备,然后将其馈入DNNClassifier预制估算器吗?

1 个答案:

答案 0 :(得分:0)

问题尚不清楚,为什么您不能继续学习本教程?

无论如何,如果问题是输入大小不同,那么在本教程中,您将定义网络的输入形状:

mobile_net = tf.keras.applications.MobileNetV2(input_shape=(192, 192, 3), include_top=False)

尝试将网络的input_shape定义为您使用的图像大小-(180,360,3)

相关问题