Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR(https://github.com/JaidedAI/EasyOCR) to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1 x = torch.rand(batch_size,1,64,256).float().cpu() torch.onnx.export(model, (x,''), "ocr0807_0.onnx") net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM: """ Sequence modeling""" self.SequenceModeling = nn.Sequential( BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size), BidirectionalLSTM(hidden_size, hidden_size, hidden_size)) self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR(https://github.com/JaidedAI/EasyOCR) easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1 x = torch.rand(batch_size,1,64,256).float().cpu() torch.onnx.export(model, (x,''), "ocr0807_0.onnx") net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM: """ Sequence modeling""" self.SequenceModeling = nn.Sequential( BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size), BidirectionalLSTM(hidden_size, hidden_size, hidden_size)) self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

click to hide/show revision 3
None

updated 2020-08-07 07:55:52 -0600

berak gravatar image

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

occurs error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM: LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

hidden_size

Would you please help me with this problem? Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

'''python import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx') '''

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

'''python '''python

import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx') cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

'''

Thank you.

click to hide/show revision 7
None

updated 2020-08-11 02:57:56 -0600

berak gravatar image

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

'''python

import torch.nn as nn
import torch

torch class BidirectionalLSTM(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)

output_size)

    def forward(self, input):
     self.rnn.flatten_parameters()
     recurrent, _ = self.rnn(input)
     output = self.linear(recurrent)
     return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

512))

    def forward(self, input, text):
     contextual_feature = self.SequenceModeling(input)
     return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

"ocr0811_1.onnx") import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

'''

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

'''python

'''python
import torch.nn as nn
import torch


torch

class BidirectionalLSTM(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) output_size)

def forward(self, input):
     self.rnn.flatten_parameters()
     recurrent, _ = self.rnn(input)
     output = self.linear(recurrent)
     return output
 

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512)) 512))

def forward(self, input, text):
     contextual_feature = self.SequenceModeling(input)
     return contextual_feature
 

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx") "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

'''

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

'''python ₩₩₩python import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

'''₩₩₩

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

₩₩₩python ```python import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

₩₩₩```

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

```python import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

```

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

```python ```python

import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

```

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

```python```

import torch.nn as nn import torch

class BidirectionalLSTM(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)

def forward(self, input):
    self.rnn.flatten_parameters()
    recurrent, _ = self.rnn(input)
    output = self.linear(recurrent)
    return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

```

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

``````python

import torch.nn as nn import torch

class BidirectionalLSTM(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)

 def forward(self, input):
     self.rnn.flatten_parameters()
     recurrent, _ = self.rnn(input)
     output = self.linear(recurrent)
     return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

def forward(self, input, text):
    contextual_feature = self.SequenceModeling(input)
    return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

```

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

```python

import torch.nn as nn
 import torch

torch class BidirectionalLSTM(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)

output_size)

   def forward(self, input):
       self.rnn.flatten_parameters()
       recurrent, _ = self.rnn(input)
       output = self.linear(recurrent)
       return output

class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.SequenceModeling = nn.Sequential( BidirectionalLSTM(512, 512, 512), BidirectionalLSTM(512, 512, 512))

512))

   def forward(self, input, text):
     contextual_feature = self.SequenceModeling(input)
     return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

```

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

import torch.nn as nn
import torch

class BidirectionalLSTM(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)

   def forward(self, input):
       self.rnn.flatten_parameters()
       recurrent, _ = self.rnn(input)
       output = self.linear(recurrent)
       return output


class Model(nn.Module):
   def __init__(self):
       super(Model, self).__init__()
       self.SequenceModeling = nn.Sequential(
           BidirectionalLSTM(512, 512, 512),
           BidirectionalLSTM(512, 512, 512))

   def forward(self, input, text):
       contextual_feature = self.SequenceModeling(input)
       return contextual_feature

x = torch.rand(1, 65, 512).float().cpu() model = Model() model.eval() torch.onnx.export(model, x, "ocr0811_1.onnx")

"ocr0811_1.onnx") import cv2 net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: 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'

Also, here is the error reproducing minimal test case code:

import torch.nn as nn
import torch

class BidirectionalLSTM(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)

   def forward(self, input):
       self.rnn.flatten_parameters()
       recurrent, _ = self.rnn(input)
       output = self.linear(recurrent)
       return output


class Model(nn.Module):
   def __init__(self):
       super(Model, self).__init__()
       self.SequenceModeling = nn.Sequential(
           BidirectionalLSTM(512, 512, 512),
           BidirectionalLSTM(512, 512, 512))

   def forward(self, input, text):
       contextual_feature = self.SequenceModeling(input)
       return contextual_feature


x = torch.rand(1, 65, 512).float().cpu()
model = Model()
model.eval()
torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2
net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

Thank you.

Importing Bidirectional LSTM model via onnx shows an error

Hi,

I'm trying to export model from easyOCR to ONNX and import it through openCV. I successfully exported it to ONNX, checked that it runs well, but failed to import the model through openCV using readNetFromONNX. Below is my model export code and the error:

batch_size=1
x = torch.rand(batch_size,1,64,256).float().cpu()
torch.onnx.export(model, (x,''), "ocr0807_0.onnx")
net = cv2.dnn.readNetFromONNX('ocr0807_0.onnx') <- where error occurs

 error: (-215:Assertion failed) (int)_numAxes == inputs[0].size() in function 'getMemoryShapes'

The error occurs at Bidirectional LSTM layer of the model even though I'm using openCV 4.4.0 and python 3.7.

Below is the part of model code from easyOCR, which include Bidirectional LSTM:

""" Sequence modeling"""
        self.SequenceModeling = nn.Sequential(
            BidirectionalLSTM(self.FeatureExtraction_output, hidden_size, hidden_size),
            BidirectionalLSTM(hidden_size, hidden_size, hidden_size))
        self.SequenceModeling_output = hidden_size

Would you please help me with this problem? Thank you.

(NEWLY ADDED) The full error message is: is:

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'

'getMemoryShapes'

Also, here is the error reproducing minimal test case code:

import torch.nn as nn
import torch

class BidirectionalLSTM(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)

   def forward(self, input):
       self.rnn.flatten_parameters()
       recurrent, _ = self.rnn(input)
       output = self.linear(recurrent)
       return output


class Model(nn.Module):
   def __init__(self):
       super(Model, self).__init__()
       self.SequenceModeling = nn.Sequential(
           BidirectionalLSTM(512, 512, 512),
           BidirectionalLSTM(512, 512, 512))

   def forward(self, input, text):
       contextual_feature = self.SequenceModeling(input)
       return contextual_feature


x = torch.rand(1, 65, 512).float().cpu()
model = Model()
model.eval()
torch.onnx.export(model, x, "ocr0811_1.onnx")

import cv2
net = cv2.dnn.readNetFromONNX('ocr0811_1.onnx')

Thank you.