如何修复使用dnn时出现的此打开cv库错误?

2024-09-28 05:22:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用opencvdnn加载yolov3权重并进行预测

这条线出错了

    outs = self.net.forward(self.get_outputs_names(self.net))

enter image description here

这完全是个错误

推理和预测代码

def get_outputs_names(self, net):
        layersNames = self.net.getLayerNames()
        return [layersNames[i[0] - 1] for i in net.getUnconnectedOutLayers()]


def predict(self, image):
    blob = cv.dnn.blobFromImage(image, 1/255.0, (inpWidth, inpHeight), [0,0,0], 1, crop=False)
    self.net.setInput(blob)
    outs = self.net.forward(self.get_outputs_names(self.net))
    return outs


def infer_image(self, image):
    image = cv.cvtColor(image, cv.COLOR_BGR2RGB)
    outs = self.predict(image)
    return self.postprocess(image, outs)

是什么导致了这个错误?你知道吗


Tags: imageselfgetnetreturnnamesdef错误

热门问题