属性错误:模块';keras.applications.mobilenet';没有属性';预处理';

属性错误:模块';keras.applications.mobilenet';没有属性';预处理';,keras,deep-learning,transfer-learning,image-preprocessing,Keras,Deep Learning,Transfer Learning,Image Preprocessing,我已经导入了预处理模块,但它一直显示相同的错误。我应该如何解决这个错误? 需要帮助来解决此错误 导入的库如下所示, import tensorflow as tf import keras from tensorflow.keras.preprocessing import image_dataset_from_directory from keras.preprocessing.image import ImageDataGenerator from keras.applications im

我已经导入了预处理模块,但它一直显示相同的错误。我应该如何解决这个错误? 需要帮助来解决此错误

导入的库如下所示,

import tensorflow as tf
import keras
from tensorflow.keras.preprocessing import image_dataset_from_directory
from keras.preprocessing.image import ImageDataGenerator
from keras.applications import MobileNet
from keras.applications.mobilenet import preprocess_input
train_path = 'eggplant/training'
test_path = 'eggplant/testing'
valid_path = 'eggplant/validation'

train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(train_path, target_size=(224,224), batch_size=10)
train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(valid_path, target_size=(224,224), batch_size=10)
train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(test_path, target_size=(224,224), batch_size=10, shuffle=False)
AttributeError                            Traceback (most recent call last)
<ipython-input-17-fc384b61e2b7> in <module>()
----> 1 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(train_path, target_size=(224,224), batch_size=10)
      2 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(valid_path, target_size=(224,224), batch_size=10)
      3 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(test_path, target_size=(224,224), batch_size=10, shuffle=False)

AttributeError: module 'keras.applications.mobilenet' has no attribute 'preprocess'
图像准备,

import tensorflow as tf
import keras
from tensorflow.keras.preprocessing import image_dataset_from_directory
from keras.preprocessing.image import ImageDataGenerator
from keras.applications import MobileNet
from keras.applications.mobilenet import preprocess_input
train_path = 'eggplant/training'
test_path = 'eggplant/testing'
valid_path = 'eggplant/validation'

train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(train_path, target_size=(224,224), batch_size=10)
train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(valid_path, target_size=(224,224), batch_size=10)
train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(test_path, target_size=(224,224), batch_size=10, shuffle=False)
AttributeError                            Traceback (most recent call last)
<ipython-input-17-fc384b61e2b7> in <module>()
----> 1 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(train_path, target_size=(224,224), batch_size=10)
      2 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(valid_path, target_size=(224,224), batch_size=10)
      3 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(test_path, target_size=(224,224), batch_size=10, shuffle=False)

AttributeError: module 'keras.applications.mobilenet' has no attribute 'preprocess'
错误如下所示,

import tensorflow as tf
import keras
from tensorflow.keras.preprocessing import image_dataset_from_directory
from keras.preprocessing.image import ImageDataGenerator
from keras.applications import MobileNet
from keras.applications.mobilenet import preprocess_input
train_path = 'eggplant/training'
test_path = 'eggplant/testing'
valid_path = 'eggplant/validation'

train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(train_path, target_size=(224,224), batch_size=10)
train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(valid_path, target_size=(224,224), batch_size=10)
train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(test_path, target_size=(224,224), batch_size=10, shuffle=False)
AttributeError                            Traceback (most recent call last)
<ipython-input-17-fc384b61e2b7> in <module>()
----> 1 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(train_path, target_size=(224,224), batch_size=10)
      2 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(valid_path, target_size=(224,224), batch_size=10)
      3 train_batches = ImageDataGenerator(preprocessing_function = keras.applications.mobilenet.preprocess.input).flow_from.directory(test_path, target_size=(224,224), batch_size=10, shuffle=False)

AttributeError: module 'keras.applications.mobilenet' has no attribute 'preprocess'
AttributeError回溯(最近一次调用)
在()
---->1个train_batches=ImageDataGenerator(预处理函数=keras.applications.mobilenet.preprocess.input)。flow_from.directory(train_路径,目标_大小=(224224),batch_大小=10)
2列\u批处理=ImageDataGenerator(预处理\u函数=keras.applications.mobilenet.preprocess.input)。从.directory(有效的\u路径,目标\u大小=(224224),批处理\u大小=10)
3列批处理=ImageDataGenerator(预处理函数=keras.applications.mobilenet.preprocess.input)。从.directory流出(测试路径,目标大小=(224224),批处理大小=10,随机播放=False)
AttributeError:模块“keras.applications.mobilenet”没有属性“preprocess”

您应该使用
preprocess\u input
而不是
preprocess.input
。此外,您还需要将
flow\u from.directory
更改为
flow\u from\u directory