小编Sat*_*wat的帖子

无法从“keras.preprocessing.image”导入名称“load_img”

为什么我会遇到这个问题?我可以从 导入图像模块kera.preprocessing。但无法导入image_dataset_from_directory。我的 TensorFlow 版本是 2.9.1,所以我不处理旧版本,例如ImportError: Cannot import name 'image_dataset_from_directory' from 'tensorflow.keras.preprocessing' (unknown location)

# make a prediction for a new image.
from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.models import load_model

# load and prepare the image
def load_image(filename):
    # load the image
    img = load_img(filename, target_size=(224, 224))
    # convert to array
    img = img_to_array(img)
    # reshape into a single sample with 3 channels
    img = img.reshape(1, 224, 224, 3)
    # center pixel …
Run Code Online (Sandbox Code Playgroud)

python tensorflow tensorflow2.0

9
推荐指数
3
解决办法
8万
查看次数

标签 统计

python ×1

tensorflow ×1

tensorflow2.0 ×1