breezedeus / CnOCR

CnOCR: Awesome Chinese/English OCR Python toolkits based on PyTorch. It comes with 20+ well-trained models for different application scenarios and can be used directly after installation. 【基于 PyTorch/MXNet 的中文/英文 OCR Python 包。】

Home Page:https://www.breezedeus.com/article/cnocr

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed to export densenet_lite_136-gru onnx format

sif-boudjellal opened this issue · comments

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]).
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> ...