無法在函數“cv::dnn::ReadProtoFromTextFile”中打開“face_detector\deploy.prototxt”

穆罕默德·法赫米

我正在嘗試學習 python,以檢測是否有人使用過面具。

當我運行這段代碼時

prototxtPath = r"face_detector\deploy.prototxt"
weightsPath = r"face_detector\res10_300x300_ssd_iter_140000.caffemodel"
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)

maskNet = load_model("mask_detector.model")

print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()

我有錯誤

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_13672/2145281415.py in <module>
     34 prototxtPath = r"face_detector\deploy.prototxt"
     35 weightsPath = r"face_detector\res10_300x300_ssd_iter_140000.caffemodel"
---> 36 faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
     37 
     38 maskNet = load_model("mask_detector.model")

error: OpenCV(4.5.4) 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 "face_detector\deploy.prototxt" in function 'cv::dnn::ReadProtoFromTextFile'

我試著用同樣的問題在谷歌上搜索,但我在某些文件中遇到了問題。我的 python 項目文件在C:\Users\mfahm\anaconda3\Test 中我得到了錯誤的文件名嗎?

H。德維爾弗萊徹

 你必須確保文件deploy.prototxtres10_300x300_ssd_iter_140000.caffemodel在正確的目錄,然後使用os.path.join

import os

prototxtPath = os.path.join(os.getcwd(), 'face_detector', 'deploy.prototxt')
weightsPath = os.path.join(os.getcwd(), 'face_detector', 'res10_300x300_ssd_iter_140000.caffemodel')

faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)

print("[INFO] starting video stream...")
vs = VideoStream(src=0).start()

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在python中定义caffe prototxt

無法修改函數中的矩陣

無法在類的函數中模擬變量

在GoogLeNet中修改Deploy.prototxt

如何在prototxt文件中写注释?

無法從返回函數的函數原型中獲取屬性

無法獲取 postgres 函數中輸入參數的值

R中的函數內部無法識別數據

無法將二維數組傳遞給 C++ 中的函數

無法在 C 中打印返回數組指針的函數的輸出

在 golang 函數中測試無法訪問的執行路徑

腳本無法與 Qlik Sense 中的 STARTS WITH 函數一起使用

無法讓 += 在 python 中的函數之間正常工作

無法從 onclick 函數 javascript 中獲取價值

Map 函數或 lambda 在 Python 中無法按預期工作

在caffe prototxt中没有从hdf5读取数据

caffe SqueezeNet:prototxt中全连接FC层在哪里

在caffe prototxt文件中。TRAIN和TEST阶段做什么?

从Caffe .prototxt模型定义中读取网络参数

如何使用 Python 从 caffe 中的 .prototxt 按名称删除图层

無法將“Null”類型的值分配給 const 構造函數中“int”類型的參數

错误:(-215:声明失败)cv :: dnn中的函数'FormattedImpl'中的m.dims <= 2

函数'cv :: dnn :: ConvolutionLayerImpl :: getMemoryShapes'中的OpenCV深度学习面部检测断言错误

我無法在按鈕(onClick())上的函數調用中訪問地圖函數的索引,這是在地圖()的範圍內,代碼如下

儘管 console.log() 顯示了正確的值,但無法訪問另一個函數中函數的返回

當 defconstant 使用同一文件中的函數時無法編譯文件

If-Else 在函數下無法在 Tkinter 中工作,請解決這個問題:

無法使用 vba 函數中的索引結果進行進一步計算

如何修復錯誤“無法將參數類型‘動態函數()’分配給參數類型‘類名’”在 Flutter 中