I wanted to use MobileNet to obtain features of all images present in a dataset. But the error mentioned keeps popping up.
The full code that produced the error is:
`
from keras.applications import MobileNet
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Model
from keras.applications.mobilenet import preprocess_input
# Load the MobileNet model
base_model = MobileNet(weights='imagenet', include_top=False)
# Define the data generator
data_generator = ImageDataGenerator(preprocessing_function=preprocess_input)
# Create the data generator for the custom dataset
image_generator = data_generator.flow_from_directory(
'C:/Users/mahit/OneDrive/Pictures/Desktop/DATA AND VIDEOS//16k_images',
target_size=(224, 224),
batch_size=1,
class_mode=None,
shuffle=False)
# Obtain the image features
image_features = base_model.predict(image_generator, 16042)
# Save the image features to a file
np.save('mobilenet_image_features.npy', image_features)
`
The full error is as follows:
I wanted to obtain the image features and save it in a .npy file. But this error keeps coming up.