【发布时间】:2022-01-08 09:27:20
【问题描述】:
这是我的代码:
dic = test_dataset.class_indices
idc = {k:v for v, k in dic.items()}
img = load_img( r'C:\Users\sreep\Downloads\Alzheimer_s Dataset\test\NonDemented\26 (62).jpg', target_size = (224,224,3))
img = img_to_array(img)
img = img/255
imshow(img)
plt.axis('off')
img = np.expand_dims(img,axis=0)
answer = model.predict(img)
probability = round(np.max(model.predict(img)*100),2)
print(probability, '% chances are there that the image is',idc[answer[0]])
错误:
TypeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17688/2364562646.py in <module>
13 probability = round(np.max(model.predict(img)*100),2)
14
---> 15 print(probability, '% chances are there that the image is',idc[answer[0]])
TypeError: unhashable type: 'numpy.ndarray'
【问题讨论】:
-
你能分享一个最小的工作示例吗?当我们无法访问存储在您计算机上的内容时,我们无法运行您的代码。
-
请编辑问题以将其限制为具有足够详细信息的特定问题,以确定适当的答案。
标签: python anaconda junit-jupiter