trainingdata = keras.utils.image_dataset_from_directory(
directory='archive/chest_xray/train/',
labels='inferred',
label_mode='int',
batch_size=32,
image_size=(512,512)
)
validationdata = keras.utils.image_dataset_from_directory(
directory='archive/chest_xray/test/',
labels='inferred',
label_mode='int',
batch_size=32,
image_size=(512,512)
)
td = keras.applications.resnet_v2.preprocess_input(trainingdata)
vd = keras.applications.resnet_v2.preprocess_input(validationdata)
input = keras.Input(shape=(512, 512, 3))
Traceback (most recent call last):
File "C:UsersYouDocumentskeras modelsPNEUMONIA.PY", line 25, in <module>
td = keras.applications.resnet_v2.preprocess_input(trainingdata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersYouDocumentskeras models.venvLibsite-packageskerassrcapplicationsresnet_v2.py", line 134, in preprocess_input
return imagenet_utils.preprocess_input(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersYouDocumentskeras models.venvLibsite-packageskerassrcapplicationsimagenet_utils.py", line 106, in preprocess_input
return _preprocess_tensor_input(x, data_format=data_format, mode=mode)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersYouDocumentskeras models.venvLibsite-packageskerassrcapplicationsimagenet_utils.py", line 254, in _preprocess_tensor_input
ndim = len(x.shape)
^^^^^^^
AttributeError: '_PrefetchDataset' object has no attribute 'shape'. Did you mean: 'save'?
I keep running into this error when trying to preprocess my datasets. The code above is for ResNet, but I’ve also tried the preprocess functions for MobileNet and NasNet. It almost looks like it’s an issue with imagenet_utils.py, but I assume that’s not the case. Is there any way I can fix this other than switching to a new application?