GFPGAN icon indicating copy to clipboard operation
GFPGAN copied to clipboard

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

Open Nise-2-meet-U opened this issue 3 years ago • 18 comments

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!

Nise-2-meet-U avatar Dec 01 '21 14:12 Nise-2-meet-U

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

zhu-zhaofei avatar Dec 13 '21 07:12 zhu-zhaofei

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 avatar Dec 15 '21 08:12 xuanandsix

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 avatar Dec 15 '21 08:12 zhu-zhaofei

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: [email protected] . Thanks a lot. 0.0

zhu-zhaofei avatar Dec 17 '21 01:12 zhu-zhaofei

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: [email protected]. Chress。

Alexander-code-365 avatar Dec 20 '21 02:12 Alexander-code-365

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

farazBhatti avatar Dec 21 '21 10:12 farazBhatti

Well Done @lyx326 ! Could you share the ONNX model with me, my email is [email protected] Thank you very much!

haile-vnu avatar Dec 23 '21 11:12 haile-vnu

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

rizwanishaq avatar Jan 31 '22 09:01 rizwanishaq

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

zhoumenghan avatar Feb 21 '22 09:02 zhoumenghan

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: [email protected] . 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 [email protected]

kelisiya avatar Apr 18 '22 10:04 kelisiya

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

sharozekkel avatar Apr 28 '22 05:04 sharozekkel

@kelisiya @farazBhatti @rizwanishaq @sharozekkel Can you share your ONNX model or steps you used for converting it to ONNX ,my email is [email protected]

peanut1101 avatar Jul 26 '22 09:07 peanut1101

@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: [email protected]

Thank you

spradeep28 avatar Jul 27 '22 23:07 spradeep28

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

baher3d avatar Aug 04 '22 15:08 baher3d

F.conv2d

Should be supported with the latest updates from RT

lschaupp avatar Sep 23 '22 07:09 lschaupp

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

xuanandsix avatar Oct 17 '22 14:10 xuanandsix

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

bychen7 avatar May 17 '23 10:05 bychen7

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

too late,2021.01. but,thanks.

Alexander-code-365 avatar Mar 18 '24 09:03 Alexander-code-365