heroku - AttributeError:“str”对象在heroku平台中没有属性“decode”
问题描述
我在 Heroku 中部署了我的模型,但下面提到的属性错误出现在 Web 应用程序中。heroku 和 streamlit 平台无法为分类目的解压我的 .h5 模型。 https://i.stack.imgur.com/WOCmH.png 我不知道要指定什么要求来避免此错误。
谢谢你。
import streamlit as st
import numpy as np
import cv2
from tensorflow.keras.preprocessing.image import img_to_array
from tensorflow.keras.models import load_model
st.header("Artificial Vision for indoor navigation")
st.subheader("Detecting doors,furnitures, stairs beforehand and prevent accidents")
loaded_model=load_model("vision1.h5")
FRAME_WINDOW = st.image([])
if st.checkbox("Run"):
webcam = cv2.VideoCapture(0)
classes = ['stairs','furniture',"door"]
# loop through frames
while webcam.isOpened():
status, frame = webcam.read()
face_crop=cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
face_crop = cv2.resize(face_crop, (300,300))
face_crop = face_crop.astype("float") / 255.0
face_crop = img_to_array(face_crop)
face_crop = np.expand_dims(face_crop, axis=0)
conf = loaded_model.predict(face_crop)[0] # model.predict return a 2D matrix, ex: [[9.9993384e-01 7.4850512e-05]]
idx = np.argmax(conf)
label = classes[idx]
label = "{}: {:.2f}%".format(label, conf[idx] * 100)
face_cropped=cv2.putText(frame, label, (140, 60), cv2.FONT_HERSHEY_SIMPLEX,0.7, (0, 255, 0), 2)
print("label: ",label,"probability: ", loaded_model.predict(face_crop)[0])
iml=face_cropped
FRAME_WINDOW.image(iml)
webcam.release()
cv2.destroyAllWindows()
解决方案
推荐阅读
- java - 错误:类 kotlin.reflect.jvm.internal.FunctionCaller$FieldSetter
- spring - Spring Mongo Repository - 在 mongo Repository 上实现软删除的最佳方法?
- c - 指针和指针位置的区别
- python - 在 Python 中调用函数进行测试时出现问题?
- c# - 为什么 HttpClient 不返回 302 代码?
- wpf - 在 MouseOver XAML (WPF) 上更改按钮上的图像
- r - 使用 plotly::api_create 和 ggplot2::geom_sf 函数时文件太大
- c - 数组的二维动态分配并将其作为参数传递的问题
- java - 如何在命令行上指定密钥库类型?
- php - 如何从具有多个输入的动态添加的行中存储数据