我想测试从此处下载的预训练模型来执行 OCR 任务。下载链接,其名称为 CRNN_VGG_BiLSTM_CTC.onnx。该模型是从此处提取的。Sample-image.png 可以从这里下载(参见下面的代码)。
当我在 blob 中进行神经网络的前向预测 (ocr) 时,出现以下错误:
错误:OpenCV(4.4.0) /tmp/pip-req-build-xgme2194/opencv/modules/dnn/src/layers/convolution_layer.cpp:348:错误:(-215:断言失败)ngroups > 0 && inpCn %函数“getMemoryShapes”中的 ngroups == 0 && outCn % ngroups == 0
请随意阅读下面的代码。我尝试了很多东西,这很奇怪,因为这个模型不需要预定的输入形状。如果你知道如何阅读这个模型并进行转发,它也会很有帮助,但我宁愿使用 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 …Run Code Online (Sandbox Code Playgroud)