我一直试图确定为什么,当我运行程序时,它说未定义所选图像,而当我查看代码时似乎已定义。
有问题的错误是:
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