Hi,
There's an error when I try to put input to my opencv net. The net is imported onnx model, converted from pytorch model of easyocr(https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/model.py). Since the model works well in pytorch and onnx form, I guess there is something wrong with net. Below is my code:
import torch
import numpy as np
import cv2
x = torch.rand(1,1,64,256).float().cpu()
torch.onnx.export(model, (x, ''), "ocr0814_2.onnx", keep_initializers_as_inputs=True)
net = cv2.dnn.readNetFromONNX("ocr0814_2.onnx")
img = cv2.cvtColor(cv2.imread('5.png'), cv2.COLOR_BGR2GRAY)
blob= cv2.dnn.blobFromImage(img, size=(64,256))
net.setInput(blob)
net.forward() #where the error occurs
And here is the error message:
[ERROR:0] global ../modules/dnn/src/dnn.cpp (3444) getLayerShapesRecursively OPENCV/DNN: [Reshape]:(324): getMemoryShapes() throws exception. inputs=1 outputs=1/1 blobs=0
[ERROR:0] global ../modules/dnn/src/dnn.cpp (3447) getLayerShapesRecursively input[0] = [ 1 17 512 5 ]
[ERROR:0] global ../modules/dnn/src/dnn.cpp (3451) getLayerShapesRecursively output[0] = [ ]
[ERROR:0] global ../modules/dnn/src/dnn.cpp (3457) getLayerShapesRecursively Exception message: OpenCV(4.4.0) ../modules/dnn/src/layers/reshape_layer.cpp:113: error: (-215:Assertion failed) total(srcShape, srcRange.start, srcRange.end) == maskTotal in function 'computeShapeByReshapeMask'
Would you please help me? Thank you.