deploy.prototxt in Caffe model

huangapple go评论62阅读模式
英文:

deploy.prototxt in Caffe model

问题

我运行我的代码时遇到了这个问题:

    model = cv2.dnn.readNetFromCaffe("deploy.prototxt", "res10_300x300_ssd_iter_140000.caffemodel")
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1126: error: (-2:Unspecified error) FAILED: fs.is_open(). 无法打开 "deploy.prototxt",在函数 'cv::dnn::ReadProtoFromTextFile' 中

我认为这个问题出现在我运行以下代码行时,但不确定如何处理它。我认为问题是因为我没有将这个文件与代码保存在一起,但我不太确定这个文件是什么以及它的作用:

# 加载SSD模型
model = cv2.dnn.readNetFromCaffe("deploy.prototxt", "res10_300x300_ssd_iter_140000.caffemodel")
英文:

I am running into this problem when running my code:

    model = cv2.dnn.readNetFromCaffe("deploy.prototxt", "res10_300x300_ssd_iter_140000.caffemodel")
cv2.error: OpenCV(4.7.0) D:\a\opencv-python\opencv-python\opencv\modules\dnn\src\caffe\caffe_io.cpp:1126: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "deploy.prototxt" in function 'cv::dnn::ReadProtoFromTextFile'

I Believe it is coming from when I run this line of code and am not sure what to do about it. I thought it was because I didn't have this file saved with the code but I am not entirely sure what this file is and does:

# Load the SSD model
model = cv2.dnn.readNetFromCaffe("deploy.prototxt", "res10_300x300_ssd_iter_140000.caffemodel")

答案1

得分: 1

这是我在Stackoverflow上的第一次,所以对于如何使用它,我还不太了解,但根据我的理解,您想要使用OpenCV的Caffe模型进行人脸检测。为此,您需要下载以下两个文件:'res10_300x300_ssd_iter_140000.caffemodel' 和 'deploy.prototxt.txt'。您可以从这里下载这两个文件:https://github.com/Shiva486/facial_recognition。然后将这两个文件放到与您的Python脚本相同的文件夹中。您可以通过以下代码加载模型:

import cv2
from cv2 import dnn

prototxt = 'deploy.prototxt.txt'
caffemodel = 'res10_300x300_ssd_iter_140000.caffemodel'
model = cv2.dnn.readNetFromCaffe(prototxt, caffemodel)

或者您可以参考这里:https://www.geeksforgeeks.org/deep-learning-with-python-opencv/,它提供了一种直接导入模型的方法,使用以下代码:

cv2.dnn.createCaffeImporter

希望对您有所帮助。

英文:

it's my first time in Stackoverflow, so i'm sorry i still don't know how to use it. However, from my understanding you want to use the opencv Caffe model for face detection. To do this you need to download the the two files:
'res10_300x300_ssd_iter_140000.caffemodel' and 'deploy.prototxt.txt'. You can do that from here:
https://github.com/Shiva486/facial_recognition.
Then put those files in the same folder with your python script.
You can load the model by this:

import cv2    
from cv2 import dnn
prototxt = 'deploy.prototxt.txt'    
caffemodel='res10_300x300_ssd_iter_140000.caffemodel'     
model =  cv2.dnn.readNetFromCaffe( prototxt, caffemodel)     

Or you can check here:
https://www.geeksforgeeks.org/deep-learning-with-python-opencv/
it offers a way to to import the model directly, by using the

cv2.dnn.createCaffeImporter

Hope that helps.

huangapple
  • 本文由 发表于 2023年2月14日 03:58:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75440634.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定