In the exercise of residual networks, please tell me how to use your own pictures for prediction

All parts of the exercise have been completed.

Here’s the code

my_ image = “images/my_image.jpg”

fname = my_ image

image = np. array(matplotlib.pyplot.imread(fname))

my_ image = np. array(Image.fromarray(image). resize(size=(64,64))). reshape((1, 64643)). T

my_ image=my_ image/255

What should I do next to predict a picture

canyou write sample code


Your implementation reshapes to 64643 in the last dimension.

Why not use this snippet from the assignment starter code?

img_path = 'images/my_image.jpg'
img = image.load_img(img_path, target_size=(64, 64))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = x/255.0
print('Input image shape:', x.shape)
prediction = pre_trained_model.predict(x)
print("Class prediction vector [p(0), p(1), p(2), p(3), p(4), p(5)] = ", prediction)
print("Class:", np.argmax(prediction))

It worked,thanks~~~~~~~~