gpt4 book ai didi

opencv - 使用 DummyData 层 : "Can' t create layer "DummyData1" of type "DummyData1" in function 'getLayerInstance' "加载 Caffe 模型时出错

转载 作者:行者123 更新时间:2023-12-02 16:32:51 27 4
gpt4 key购买 nike

我将 Tensorflow 模型转换为 Caffe 模型( tf_resnet.prototxt ),现在我正在尝试运行对象检测计数算法( code )。但是,我收到以下错误:

[INFO] loading model...
[INFO] opening video file...
Traceback (most recent call last):
File "people_counter.py", line 132, in <module>
detections = net.forward()
cv2.error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/dnn.cpp:562: error: (-2:Unspecified error) Can't create layer "DummyData1" of type "DummyData" in function 'getLayerInstance'
This Stackoverflow 上的类似问题建议更改 type: "DummyData1"type: "Input"在以下代码中:
layer {
name: "DummyData1"
type: "DummyData1"
top: "DummyData1"
dummy_data_param {
shape {
dim: 1
dim: 64
dim: 150
dim: 150
}
}
}
但是,在执行此操作时,我收到另一个错误:
Traceback (most recent call last):
File "people_counter.py", line 132, in <module>
detections = net.forward()
cv2.error: OpenCV(4.2.0) /io/opencv/modules/dnn/src/dnn.cpp:2709: error: (-215:Assertion failed) inp.total() in function 'allocateLayers''
有关如何解决此问题的任何建议?

最佳答案

你可以试试这个方法;改变这个:

layer {
name: "DummyData1"
type: "DummyData1"
top: "DummyData1"
dummy_data_param {
shape {
dim: 1
dim: 64
dim: 150
dim: 150
}
}
}
有了这个:
layer {
name: "DummyData1"
type: "Input"
top: "DummyData1"
input_param {
shape {
dim: 1
dim: 64
dim: 150
dim: 150
}
}
}
然后在脚本中,而不是使用这些行:
blob = cv2.dnn.blobFromImage(frame, 0.007843, (W, H), 127.5)
net.setInput(blob)
detections = net.forward()
试试这些:
blob = cv2.dnn.blobFromImage(frame, 0.007843, (W, H), 127.5)
net.setInput(blob, "Placeholder")
net.setInput(np.zeros((1, 64, 150, 150)), "DummyData1")
detections = net.forward()
我不知道结果是否会好,但这至少应该解决异常。
为了获得良好的结果,您必须找出该层中的数据类型,因为在原始模型中,“DummyData1”可能是某种生成器或常量矩阵。

关于opencv - 使用 DummyData 层 : "Can' t create layer "DummyData1" of type "DummyData1" in function 'getLayerInstance' "加载 Caffe 模型时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62549599/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com