【发布时间】:2021-04-06 11:39:40
【问题描述】:
我想测试从这里下载的预训练模型以执行 ocr 任务。 Link to download,它的名字是CRNN_VGG_BiLSTM_CTC.onnx。此模型是从here 中提取的。 sample-image.png 可以从here 下载(见下面的代码)。
当我在 blob 中执行神经网络的前向预测 (ocr) 时,出现以下错误:
错误:OpenCV(4.4.0)/tmp/pip-req-build-xgme2194/opencv/modules/dnn/src/layers/convolution_layer.cpp:348:错误:(-215:断言失败)ngroups > 0 && inpCn % ngroups == 0 && outCn % ngroups == 0 在函数“getMemoryShapes”中
请随意阅读下面的代码。我尝试了很多东西,这很奇怪,因为这个模型不需要预先确定的输入形状。如果您知道任何方法来阅读此模型并进行转发,它也会有所帮助,但我宁愿使用 OpenCV 解决。
import cv2 as cv
# The model is downloaded from here https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr
# model path
modelRecognition = os.path.join(MODELS_PATH,'CRNN_VGG_BiLSTM_CTC.onnx')
# read net
recognizer = cv.dnn.readNetFromONNX(modelRecognition)
# Download sample_image.png from https://i.ibb.co/fMmCB7J/sample-image.png (image host website)
sample_image = cv.imread('sample-image.png')
# Height , Width and number of channels of the image
H, W, C = sample_image.shape
# Create a 4D blob from cropped image
blob = cv.dnn.blobFromImage(sample_image, size = (H, W))
recognizer.setInput(blob)
# Here is where i get the errror that I mentioned before
result = recognizer.forward()
非常感谢您。
【问题讨论】:
标签: python opencv conv-neural-network