Jupyter notebook 如何导入一个谷歌";“可教机器”;用python编写的Anaconda Jupyter笔记本

Jupyter notebook 如何导入一个谷歌";“可教机器”;用python编写的Anaconda Jupyter笔记本,jupyter-notebook,tensor,h5py,Jupyter Notebook,Tensor,H5py,我的问题是将Google“可教机器”(Teachable machine)导入到Python的Jupyter笔记本中。 为了进行测试,我制作了一台易于教学的机器,并将其导出到以下张量代码: import tensorflow.keras from PIL import Image import numpy as np # Disable scientific notation for clarity np.set_printoptions(suppress=True) # Load the

我的问题是将Google“可教机器”(Teachable machine)导入到Python的Jupyter笔记本中。 为了进行测试,我制作了一台易于教学的机器,并将其导出到以下张量代码:

import tensorflow.keras
from PIL import Image
import numpy as np

# Disable scientific notation for clarity
np.set_printoptions(suppress=True)

# Load the model
model = tensorflow.keras.models.load_model('keras_model.h5')

# Create the array of the right shape to feed into the keras model
# The 'length' or number of images you can put into the array is
# determined by the first position in the shape tuple, in this case 1.
data = np.ndarray(shape=(1, 224, 224, 3), dtype=np.float32)

# Replace this with the path to your image
image = Image.open('Path to your image')

# Make sure to resize all images to 224, 224 otherwise they won't fit in the array
image = image.resize((224, 224))
image_array = np.asarray(image)

# Normalize the image
normalized_image_array = (image_array.astype(np.float32) / 127.0) - 1

# Load the image into the array
data[0] = normalized_image_array

# run the inference
prediction = model.predict(data)
print(prediction)
是否有可能在具有相同功能的jupyter笔记本中直接运行此代码?
非常感谢

是的,但要确保依赖项的版本是否相同。因为我有问题,因为我有一个较低版本的TensorFlow和Keras。 这是运行Google可教机器的首选版本

Keras==2.2.4
tensorflow==2.1.0
pillow==7.0.0