【问题标题】:How can I solve " cuda 2D conv problem "?如何解决“cuda 2D conv 问题”?
【发布时间】:2021-05-22 17:44:05
【问题描述】:

这是我的代码,但预测功能不起作用

错误:

from keras.applications.vgg16 import VGG16
from keras.utils.vis_utils import plot_model
#Keras will download the weight files from the Internet and store them in the ~/.keras/models directory.
model = VGG16()

from keras.preprocessing.image import load_img
from keras.preprocessing.image import img_to_array
from keras.applications.vgg16 import preprocess_input
# load an image from file
image = load_img('output.png', target_size=(224, 224))

# convert the image pixels to a numpy array
image = img_to_array(image)
# reshape data for the model
image = image.reshape((1, image.shape[0], image.shape[1], image.shape[2]))

# prepare the image for the VGG model
image = preprocess_input(image)


from keras.applications.vgg16 import decode_predictions
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
# predict the probability across all output classes
yhat = model.predict(image)
# convert the probabilities to class labels
label = decode_predictions(yhat)
# retrieve the most likely result, e.g. highest probability
label = label[0][0]
# print the classification
print('%s (%.2f%%)' % (label[1], label[2]*100))
img = Image.open('output.png')
plt.imshow(img)

我该怎么办?? wekfjeojocwjcopjcoekcopejcpoekcpwekcpejoejocijewjwrjwihujviruhviuhr

【问题讨论】:

  • 您可能希望将错误代码粘贴为纯文本(而不是屏幕截图),以便人们更轻松地为您提供帮助。

标签: python tensorflow keras


【解决方案1】:

错误是卷积算法失败。不确定可能导致此错误的所有事情,但是当我收到该错误时,这是​​因为我有多个正在运行的 python 实例使用 tensorflow。所以在你的 jupyter notebook 中禁用所有 python 打开 notebook 的内核,除了你要运行的 notebook。

【讨论】:

    猜你喜欢
    • 2020-09-24
    • 1970-01-01
    • 2020-04-18
    • 2020-02-02
    • 2012-10-03
    • 2016-11-15
    • 2011-01-04
    • 2012-03-22
    • 2021-12-22
    相关资源
    最近更新 更多