You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing model from easyocr(https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/model.py) via ONNX shows an error. The model itself works well with torch and ONNX, but the error occurs when the ONNX version file is imported through openCV, and especially BiLSTM is the part where the error occurs.
error msg is cv2.error: OpenCV(4.4.0) ../modules/dnn/src/layers/permute_layer.cpp:134: error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'
Below is the simplified model I made which reproduces error:
@sjeongab I encountered the same problem as you.
And in my case, the following BiLSTM layer definition can work in OpenCV:
importtorch.nnasnnclassBidirectionalLSTM(nn.Module):
def__init__(self, input_size, hidden_size, output_size):
super(BidirectionalLSTM, self).__init__()
self.rnn=nn.LSTM(input_size, hidden_size, bidirectional=True, batch_first=True)
self.linear=nn.Linear(hidden_size*2, output_size)
defforward(self, input):
""" input : visual feature [batch_size x T x input_size] output : contextual feature [batch_size x T x output_size] """# self.rnn.flatten_parameters()recurrent, _=self.rnn(input) # batch_size x T x input_size -> batch_size x T x (2*hidden_size)b, T, h=recurrent.size()
recurrent=recurrent.view(b*T, h)
output=self.linear(recurrent) # batch_size x T x output_sizeoutput=output.view(b, T, -1)
returnoutput
System information (version)
Detailed description
Importing model from easyocr(https://github.com/JaidedAI/EasyOCR/blob/master/easyocr/model.py) via ONNX shows an error. The model itself works well with torch and ONNX, but the error occurs when the ONNX version file is imported through openCV, and especially BiLSTM is the part where the error occurs.
Also reported to openCV forum: https://answers.opencv.org/question/233370/importing-bidirectional-lstm-model-via-onnx-shows-an-error/
Below is the error code:
Below is the simplified model I made which reproduces error:
Steps to reproduce
Issue submission checklist
answers.opencv.org, Stack Overflow, etc and have not found solution
The text was updated successfully, but these errors were encountered: