PromptAD icon indicating copy to clipboard operation
PromptAD copied to clipboard

模型能否导出来onnx格式?

Open Kaze816 opened this issue 1 year ago • 3 comments

我尝试在 test_seg.py中断点,将模型导出为onnx,发现有以下报错:

torch.onnx.export(model, data, "test.onnx") // 这是我临时的导出代码,以下为执行结果消息 Traceback (most recent call last): File "", line 1, in File "f:\pyenv\Torch118gpu\lib\site-packages\torch\onnx\utils.py", line 516, in export _export( File "f:\pyenv\Torch118gpu\lib\site-packages\torch\onnx\utils.py", line 1612, in _export graph, params_dict, torch_out = _model_to_graph( File "f:\pyenv\Torch118gpu\lib\site-packages\torch\onnx\utils.py", line 1134, in _model_to_graph graph, params, torch_out, module = _create_jit_graph(model, args) File "f:\pyenv\Torch118gpu\lib\site-packages\torch\onnx\utils.py", line 1010, in _create_jit_graph graph, torch_out = _trace_and_get_graph_from_model(model, args) File "f:\pyenv\Torch118gpu\lib\site-packages\torch\onnx\utils.py", line 926, in _trace_and_get_graph_from_model raise RuntimeError( RuntimeError: state_dict changed after running the tracer; something weird is happening in your model!

请问是什么原因呀? 如何解决呢?

感谢你们的开源和回复

Kaze816 avatar Jul 17 '24 01:07 Kaze816

我也遇到同样问题,请问有解决方案吗

hccv avatar Aug 23 '24 08:08 hccv

不好意思,我们没有尝试过导出onnx格式,所以没有遇到过类似的bug,我建议不要把整个模型直接进行导出,先把memory bank,学习到的prompt feature转换为模型参数,然后连同CLIP的视觉网络和语言网络一同导出试试。

@.***

发件人: hc 发送时间: 2024-08-23 16:50 收件人: FuNz-0/PromptAD 抄送: Subscribed 主题: Re: [FuNz-0/PromptAD] 模型能否导出来onnx格式? (Issue #12) 我也遇到同样问题,请问有解决方案吗 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

FuNz-0 avatar Aug 23 '24 08:08 FuNz-0

不好意思,我们没有尝试过导出onnx格式,所以没有遇到过类似的bug,我建议不要把整个模型直接进行导出,先把memory bank,学习到的prompt feature转换为模型参数,然后连同CLIP的视觉网络和语言网络一同导出试试。 @.*** 发件人: hc 发送时间: 2024-08-23 16:50 收件人: FuNz-0/PromptAD 抄送: Subscribed 主题: Re: [FuNz-0/PromptAD] 模型能否导出来onnx格式? (Issue #12) 我也遇到同样问题,请问有解决方案吗 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

好的 感谢回复

hccv avatar Aug 26 '24 01:08 hccv