【发布时间】:2021-10-11 03:39:14
【问题描述】:
我正在做一个暴力检测项目,我已经使用 resnet 训练了我的模型,但是当我只是打印概率时,它会出现一些错误。
# import packages done
#load model
model = load_model('E:\Docs & Other\C-VS\ViolenceDetection\Resources\VDresnet152v2.h5')
img_width, img_hight = 224, 224
#start web cam
cap = cv2.VideoCapture(0)
#sart reading images and prediction
while True:
#read image from webcam
responce, color_img = cap.read()
#if respoce False the break the loop
if responce == False:
break
#resize image with 50 % ratio
color_img = cv2.resize(color_img,(224,224))
color_img = color_img.reshape(1,224,224,3)
pred_prob = model.predict(color_img)
print(pred_prob[0][0].round(2))
pred=np.argmax(pred_prob)
# display image
cv2.imshow('LIVE', color_img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the VideoCapture object
cap.release()
cv2.destroyAllWindows()
我做错了什么?当我运行这段代码时,它给出了一个错误。
【问题讨论】:
标签: python tensorflow opencv keras