Failed to export densenet_lite_136-gru onnx format
sif-boudjellal opened this issue · comments
Sif eddine BOUDJELLAL commented
Hello CnOCR Community,
I got this error when I tried to export the trained weights to Onnx.
! cnocr export-onnx -m densenet_lite_136-gru -i /content/cnocr-v2.3-densenet_lite_136-gru-model.ckpt -o densenet_lite_136-gru-model.onnx
The Error
RuntimeError: Error(s) in loading state_dict for OcrModel:
size mismatch for linear.weight: copying a param with shape torch.Size([38, 256]) from checkpoint, the shape in current model is torch.Size([6683, 256]).
size mismatch for linear.bias: copying a param with shape torch.Size([38]) from checkpoint, the shape in current model is torch.Size([6683]).
Breezedeus commented
size mismatch for linear.weight: copying a param with shape torch.Size([38, 256]) from checkpoint, the shape in current model is torch.Size([6683, 256]).
I assume you are using a new vocab, then you need to pass in the vocab file path when using export-onnx:
cnocr export-onnx -m densenet_lite_136-gru -v <path/to/vocab.txt> ...