Я использую API-интерфейс tenorflow 2.0, в котором я создал набор данных из всех путей к изображениям, как в примере ниже
X_train, X_test, y_train, y_test = train_test_split(all_image_paths, all_image_labels, test_size=0.20, random_state=32)
path_train_ds = tf.data.Dataset.from_tensor_slices(X_train)
image_train_ds = path_train_ds.map(load_and_preprocess_image, num_parallel_calls=AUTOTUNE)
Тем не менее, я получаю сообщение об ошибке, когда я запускаю этот код для применения некоторого агментирования с использованием keras ImageDataGenerator
datagen=tf.keras.preprocessing.image.ImageDataGenerator(featurewise_center=True,
featurewise_std_normalization=True,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True)
datagen.fit(image_train_ds)
Ошибка:
/usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/image_data_generator.py in fit(self, x, augment, rounds, seed)
907 seed: Int (default: None). Random seed.
908 """
--> 909 x = np.asarray(x, dtype=self.dtype)
910 if x.ndim != 4:
911 raise ValueError('Input to `.fit()` should have rank 4. '
/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py in asarray(a, dtype, order)
499
500 """
--> 501 return array(a, dtype, copy=False, order=order)
502
503
TypeError: float() argument must be a string or a number, not 'ParallelMapDataset'