【发布时间】:2020-05-12 11:36:06
【问题描述】:
我一直试图确定为什么,当我运行程序时,它说所选图像未定义,而当我查看代码时似乎已定义。
有问题的错误是:
NameError: name 'selectedimage' is not defined
我正在使用 streamlit,一个在线 GUI 生成器。
if st.sidebar.button("Identify"):
selectedimage = "./AI_TESTING_DATA/" + imageselect
selectedimage = Image.open(selectedimage).resize(IMAGE_SHAPE)
selectedimage = np.array(selectedimage) / 255.0
result = model.predict(selectedimage[np.newaxis, ...])
predicted_class = np.argmax(result[0], axis=-1)
labels_path = "./Product/labels.txt"
class_labels = np.array(open(labels_path).read().splitlines())
predicted_class_name = class_labels[predicted_class]
"It's a :" + predicted_class_name
【问题讨论】:
标签: python machine-learning streamlit