Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

导出模型为onnx的时候遇到问题 #6

Open
cigegege opened this issue Dec 19, 2023 · 2 comments
Open

导出模型为onnx的时候遇到问题 #6

cigegege opened this issue Dec 19, 2023 · 2 comments

Comments

@cigegege
Copy link

cigegege commented Dec 19, 2023

我是使用的您的ResNet_CRNN_IAM模型进行训练手写汉字的数据集,但是将模型导出为onnx的时候遇到了问题,我看您在网络中定义了forward和inference(您的inferrence应该是笔误)两个方法,我给的输入dummy_input 是torch.randn(1, 3, 192, 2048)的时候,会报
x, rec_targets, rec_lengths = input_dict['images'],
IndexError: too many indices for tensor of dimension 4,这应该跟您在forward中定义需要读入input_dict 的字典作为输入参数有关,但我将dummy_input 换成这个字典的参数,还是无法正常生成。请问我应该怎么修改呢

@Mountchicken
Copy link
Owner

试一试直接走 inferrence, 不要走 forward。forward应该是训练用的

@cigegege
Copy link
Author

onnx现在已经可以生成了,我只是修改了ModelBuilder_CTC中方法的名字,将原来的inference换成了forward,原来的forward换成了forward_training。然后再在trainers和evaluators中对应的output_dict 修改具体的方法。重新训练模型。好像torch.onnx是直接导出forward这个方法,没看见可以具体输出哪个方法。这样应该可以使用了,还没验证onnx的正确性。先谢谢大佬您了^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants