have trouble export "GFPGANCleanv1-NoCE-C2.pth" to ONNX #112

Open
opened 2026-01-29 21:42:21 +00:00 by claunia · 18 comments
Owner

Originally created by @Nise-2-meet-U on GitHub (Dec 1, 2021).

Dear Wang,

Great work! I am having trouble export GFPGANCleanv1-NoCE-C2.pth to onnx.
Could you please share GFPGANCleanv1-NoCE-C2.onnx for us?

Many thanks!

Originally created by @Nise-2-meet-U on GitHub (Dec 1, 2021). Dear Wang, Great work! I am having trouble export GFPGANCleanv1-NoCE-C2.pth to onnx. Could you please share GFPGANCleanv1-NoCE-C2.onnx for us? Many thanks!
Author
Owner

@zhu-zhaofei commented on GitHub (Dec 13, 2021):

@Nise-2-meet-U the same issue with you. Have you sloved this issue? 0.0

@zhu-zhaofei commented on GitHub (Dec 13, 2021): @Nise-2-meet-U the same issue with you. Have you sloved this issue? 0.0
Author
Owner

@xuanandsix commented on GitHub (Dec 15, 2021):

I have sloved it. Some issues are :
1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise.
2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming.
3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy.

@xuanandsix commented on GitHub (Dec 15, 2021): I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy.
Author
Owner

@zhu-zhaofei commented on GitHub (Dec 15, 2021):

I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy.

Thanks a lot. @lyx326 I will try the issues above . Also I am trying torch.jit.track to employ on X64 cpu., it's ok. But if using torch.jit.script , it still has issues. I am confused . ^~^

@zhu-zhaofei commented on GitHub (Dec 15, 2021): > I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy. Thanks a lot. @lyx326 I will try the issues above . Also I am trying torch.jit.track to employ on X64 cpu., it's ok. But if using torch.jit.script , it still has issues. I am confused . ^~^
Author
Owner

@zhu-zhaofei commented on GitHub (Dec 17, 2021):

I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy.

Hi,I am a freshman.I tried to modefy the stylegan2_clean_arch.py ,After two days, I still can't success.I am confused. Could you send me ac copy the stylegan2_clean_arch.py? My Email: zhu_zhaofei@outlook.com . Thanks a lot. 0.0

@zhu-zhaofei commented on GitHub (Dec 17, 2021): > I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy. Hi,I am a freshman.I tried to modefy the stylegan2_clean_arch.py ,After two days, I still can't success.I am confused. Could you send me ac copy the stylegan2_clean_arch.py? My Email: zhu_zhaofei@outlook.com . Thanks a lot. 0.0
Author
Owner

@Alexander-code-365 commented on GitHub (Dec 20, 2021):

I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy.

Hello,I'm a fresh hand,pth2onnx really confused me,I tried , import Net-load_state_dict-Random Input-export,Could you give me a hand,My Email: Alexander365136@outlook.com. Chress。

@Alexander-code-365 commented on GitHub (Dec 20, 2021): > > I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy. > > Hello,I'm a fresh hand,pth2onnx really confused me,I tried , import Net-load_state_dict-Random Input-export,Could you give me a hand,My Email: Alexander365136@outlook.com. Chress。
Author
Owner

@farazBhatti commented on GitHub (Dec 21, 2021):

can you please share the steps or does anyone have converted onnx model??
@Alexander-code-365 , @lyx326

@farazBhatti commented on GitHub (Dec 21, 2021): can you please share the steps or does anyone have converted onnx model?? @Alexander-code-365 , @lyx326
Author
Owner

@haile-vnu commented on GitHub (Dec 23, 2021):

Well Done @lyx326 !
Could you share the ONNX model with me, my email is hailh.vnu@gmail.com
Thank you very much!

@haile-vnu commented on GitHub (Dec 23, 2021): Well Done @lyx326 ! Could you share the ONNX model with me, my email is hailh.vnu@gmail.com Thank you very much!
Author
Owner

@rizwanishaq commented on GitHub (Jan 31, 2022):

@lyx326 Can you share your ONNX model or steps you used for converting it to ONNX?

@rizwanishaq commented on GitHub (Jan 31, 2022): @lyx326 Can you share your ONNX model or steps you used for converting it to ONNX?
Author
Owner

@zhoumenghan commented on GitHub (Feb 21, 2022):

@lyx326 Can you share steps you used for converting it to ONNX?

@zhoumenghan commented on GitHub (Feb 21, 2022): @lyx326 Can you share steps you used for converting it to ONNX?
Author
Owner

@kelisiya commented on GitHub (Apr 18, 2022):

I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy.

Hi,I am a freshman.I tried to modefy the stylegan2_clean_arch.py ,After two days, I still can't success.I am confused. Could you send me ac copy the stylegan2_clean_arch.py? My Email: zhu_zhaofei@outlook.com . Thanks a lot. 0.0

can you solved this problem ? Can you share your ONNX model or steps you used for converting it to ONNX , my email is kelisiyaer@gmail.com

@kelisiya commented on GitHub (Apr 18, 2022): > > I have sloved it. Some issues are : 1、noise = out.new_empty(b, 1, h, w).normal_() in stylegan2_clean_arch.py can‘t be supported in ONNX. I move it out the Model class, like noise = Noise[i], the Noise is a list or others which prestores generated random noise. 2、the forward function of Model is very bad, especially stylegan, so many " if else " and class be reused. Like the StyleConv " in "useself.style_convs.append StyleConv ...". So I rewrite and make it in single forward, load the ,GFPGANCleanv1-NoCE-C2.pth, it works. This step is time-consuming. 3、I also find the F.conv2d op not be supported for tensorrt, but it's not easy. > > Hi,I am a freshman.I tried to modefy the stylegan2_clean_arch.py ,After two days, I still can't success.I am confused. Could you send me ac copy the stylegan2_clean_arch.py? My Email: [zhu_zhaofei@outlook.com](mailto:zhu_zhaofei@outlook.com) . Thanks a lot. 0.0 can you solved this problem ? Can you share your ONNX model or steps you used for converting it to ONNX , my email is kelisiyaer@gmail.com
Author
Owner

@sharozekkel commented on GitHub (Apr 28, 2022):

did anyone suceed ? @lyx326 @kelisiya @farazBhatti @rizwanishaq . Please share steps or onnx model.

@sharozekkel commented on GitHub (Apr 28, 2022): did anyone suceed ? @lyx326 @kelisiya @farazBhatti @rizwanishaq . Please share steps or onnx model.
Author
Owner

@peanut1101 commented on GitHub (Jul 26, 2022):

@kelisiya @farazBhatti @rizwanishaq @sharozekkel Can you share your ONNX model or steps you used for converting it to ONNX ,my email is chen347444625@163.com

@peanut1101 commented on GitHub (Jul 26, 2022): @kelisiya @farazBhatti @rizwanishaq @sharozekkel Can you share your ONNX model or steps you used for converting it to ONNX ,my email is chen347444625@163.com
Author
Owner

@spradeep28 commented on GitHub (Jul 28, 2022):

@kelisiya @farazBhatti @rizwanishaq @sharozekkel @peanut1101
Please help share onnx model file or script to convert .pth pre-trained models to onnx. Tried multiple options...But, not able to ....email: riverbreeze512@gmail.com

Thank you

@spradeep28 commented on GitHub (Jul 28, 2022): @kelisiya @farazBhatti @rizwanishaq @sharozekkel @peanut1101 Please help share onnx model file or script to convert .pth pre-trained models to onnx. Tried multiple options...But, not able to ....email: riverbreeze512@gmail.com Thank you
Author
Owner

@baher3d commented on GitHub (Aug 4, 2022):

@kelisiya @farazBhatti @rizwanishaq @sharozekkel @peanut1101 @spradeep28 Can anyone, please share the onnx model if they were successful in exporting it? ... email: bahermursi@hotmail.com

@baher3d commented on GitHub (Aug 4, 2022): @kelisiya @farazBhatti @rizwanishaq @sharozekkel @peanut1101 @spradeep28 Can anyone, please share the onnx model if they were successful in exporting it? ... email: bahermursi@hotmail.com
Author
Owner

@lschaupp commented on GitHub (Sep 23, 2022):

F.conv2d

Should be supported with the latest updates from RT

@lschaupp commented on GitHub (Sep 23, 2022): > F.conv2d Should be supported with the latest updates from RT
Author
Owner

@xuanandsix commented on GitHub (Oct 17, 2022):

A demo for onnxruntime,
https://github.com/xuanandsix/GFPGAN-onnxruntime-demo

@xuanandsix commented on GitHub (Oct 17, 2022): A demo for onnxruntime, https://github.com/xuanandsix/GFPGAN-onnxruntime-demo
Author
Owner

@bychen7 commented on GitHub (May 17, 2023):

A simple face restoration TensorRT deployment solution https://github.com/bychen7/Face-Restoration-TensorRT.

@bychen7 commented on GitHub (May 17, 2023): A simple face restoration TensorRT deployment solution https://github.com/bychen7/Face-Restoration-TensorRT.
Author
Owner

@Alexander-code-365 commented on GitHub (Mar 18, 2024):

A demo for onnxruntime, https://github.com/xuanandsix/GFPGAN-onnxruntime-demo

too late,2021.01. but,thanks.

@Alexander-code-365 commented on GitHub (Mar 18, 2024): > A demo for onnxruntime, https://github.com/xuanandsix/GFPGAN-onnxruntime-demo too late,2021.01. but,thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TencentARC/GFPGAN#112