Westlake-AI / openmixup

CAIRI Supervised, Semi- and Self-Supervised Visual Representation Learning Toolbox and Benchmark
https://openmixup.readthedocs.io
Apache License 2.0
624 stars 62 forks source link

How to convert model output to torchscript file? #34

Closed nikbobo closed 1 year ago

nikbobo commented 1 year ago

Checklist

Describe the question you meet

I already using config modified from MogaNet to train the perfect model, but I need to convert it to torchscript. How to convert the .pth to torchscript(.pt), I try the general method but get error, because the .pth file only contains the weight, and not contains the model.

如何能转换模型文件到 TorchScript 格式? 我已经使用修改的 MogaNet 配置文件训练出了一个良好的模型,但是我需要转换 .pth 文件到 .pt 文件,即 TorchScript 格式。 如何转换模型输出文件 .pth 到 TorchScript?我尝试了一些通用方法,但是不能成功,因为 .pth 文件仅仅包含权重,并不包含模型网络。

Lupin1998 commented 1 year ago

Hi, @nikbobo. Thanks for your attention to our MogaNet, and I apologize for the late reply. Unfortunately, OpenMixup hasn't supported converting the model to TorchScript (.pt). We plan to support this function in the next commit. Please watch us for the latest update.

Lupin1998 commented 1 year ago

Hi @nikbobo, thanks for your attention to OpenMixup and your patience with our updates. We have supported TorchScript deployment in issue #35, and you can convert the pre-trained classification models to TorchScript (.pt) by tools/deployment/pytorch2torchscript.py according to tutorial. Feel free to ask me if you have further questions.

Lupin1998 commented 1 year ago

I closed this issue if there is no more question. You can reopen it or start a new issue if you have more questions. Thanks again for your attention.