我已经导入了一张图片,一切都很好,但我在运行net.setInput(blob)时得到了AttributeError。第一个
net.setInput(blob)
AttributeError
kx7yvsdv1#
正如@Dan Mašek在他的评论中提到的,临界线是
net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt"),("E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel")
逗号使net成为一个元组,其中包含函数calll cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt")的返回值和字符串"E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel"。
net
cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt")
"E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel"
>>> a = 4, "abc" >>> a (4, 'abc') >>> type(a) tuple
在最后一行中,您调用了net.setInput(blob),但元组没有属性或方法setInput,这就是您得到错误的原因。您可能想写net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt", "E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel")或简单地写net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt")(我不知道readNetFromCaffe方法,所以我不知道它需要什么作为输入)。
setInput
net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt", "E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel")
net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt")
readNetFromCaffe
1条答案
按热度按时间kx7yvsdv1#
正如@Dan Mašek在他的评论中提到的,临界线是
逗号使
net
成为一个元组,其中包含函数calllcv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt")
的返回值和字符串"E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel"
。在最后一行中,您调用了
net.setInput(blob)
,但元组没有属性或方法setInput
,这就是您得到错误的原因。您可能想写
net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt", "E:/Face recognition/Models/res10_300x300_ssd_iter_140000_fp16.caffemodel")
或简单地写net = cv2.dnn.readNetFromCaffe("E:/Face recognition/Models/deploy.prototxt.txt")
(我不知道readNetFromCaffe
方法,所以我不知道它需要什么作为输入)。