【发布时间】:2022-01-22 03:52:44
【问题描述】:
我尝试使用此示例代码进行图像分类
def show_classify_button(file_path):
classify_btn = Button(top, text="Classify Image", command=lambda: classify(file_path), padx=10, pady=5)
classify_btn.configure(background="#364156", foreground="white", font=('arial',10,'bold'))
classify_btn.place(relx=0.79,rely=0.46)
def classify(file_path):
image = Image.open(file_path)
image = image.resize((32,32))
image = numpy.expand_dims(image, axis=0)
image = numpy.array(image)
pred = model.predict([image])[0]
sign = classes[pred]
print(sign)
label.configure(foreground='#011638')
终端弹出这个
Traceback (most recent call last):
line 39, in <lambda>
classify_btn = Button(top, text="Classify Image", command=lambda: classify(file_path), padx=10, pady=5)
line 49, in classify
sign = classes[pred]
TypeError: unhashable type: 'numpy.ndarray'
我尝试使用输出检查 pred 中的数据
[30990.06 46435.57 17636.973 16334.658 15860.342 16765.371 26879.748
14579.97 41989.523 34359.215]
我不知道为什么,因为数据来自一组数组
我是新手,我使用 python3.9 可以帮助我
【问题讨论】:
-
没有python 2.9 也许你的意思是3.9?
-
是的,很抱歉
标签: python tensorflow keras conv-neural-network artificial-intelligence