williamyang1991 / DualStyleGAN

[CVPR 2022] Pastiche Master: Exemplar-Based High-Resolution Portrait Style Transfer
Other
1.61k stars 249 forks source link

The results aren't coming out well #37

Closed wonjunchoi-arc closed 1 year ago

wonjunchoi-arc commented 2 years ago

cartoon_transfer_53_081680_overview

As shown in the picture above, the result of style_transfer.py does not come out properly. Why is that?

The output of the terminal is as follows

(dualstylegan_env) [lucass@nipa2019-0211 DualStyleGAN]$ python style_transfer.py /home/lucass/anaconda3/envs/dualstylegan_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py:266: UserWarning:

!! WARNING !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your compiler (c++) is not compatible with the compiler Pytorch was built with for this platform, which is g++ on linux. Please use g++ to to compile your extension. Alternatively, you may compile PyTorch from source using c++, and then you can also use c++ to compile your extension.

See https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md for help with compiling PyTorch from source. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!! WARNING !!

warnings.warn(WRONG_COMPILER_WARNING.format( /home/lucass/anaconda3/envs/dualstylegan_env/lib/python3.8/site-packages/torch/utils/cpp_extension.py:266: UserWarning:

!! WARNING !!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Your compiler (c++) is not compatible with the compiler Pytorch was built with for this platform, which is g++ on linux. Please use g++ to to compile your extension. Alternatively, you may compile PyTorch from source using c++, and then you can also use c++ to compile your extension.

See https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md for help with compiling PyTorch from source. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!! WARNING !!

warnings.warn(WRONG_COMPILER_WARNING.format( Load options align_face: False content: ./data/content/081680.jpg data_path: ./data/ exstyle_name: exstyle_code.npy model_name: generator.pt model_path: ./checkpoint/ name: cartoon_transfer output_path: ./output/ preserve_color: False style: cartoon style_id: 2 truncation: 0.75 weight: [0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]


Loading pSp from checkpoint: ./checkpoint/encoder.pt Load models successfully! Generate images successfully! Save images successfully! (dualstylegan_env) [lucass@nipa2019-0211 DualStyleGAN]$

williamyang1991 commented 2 years ago

I think this is not a problem of the code. It is the problem of package installtion. You can search on Google with the key words like Your compiler (c++) is not compatible with the compiler Pytorch was built with for this platform to see if there are solutions.

For example, I found related issues here https://github.com/rosinality/stylegan2-pytorch/issues/220 https://github.com/NVIDIA/apex/issues/974

wonjunchoi-arc commented 2 years ago

cartoon_transfer_53_081680_overview

Well, I solved the package installation problem as you told me, but the results keep coming out like the picture above.

Below is the output of the terminal after solving the package installation

(dualstylegan_env) [lucass@nipa2019-0211 DualStyleGAN]$ python style_transfer.py Load options align_face: False content: ./data/content/081680.jpg data_path: ./data/ exstyle_name: exstyle_code.npy model_name: generator.pt model_path: ./checkpoint/ name: cartoon_transfer output_path: ./output/ preserve_color: False style: cartoon style_id: 1 truncation: 0.75 weight: [0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 0.75, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]


Loading pSp from checkpoint: ./checkpoint/encoder.pt Load models successfully! Generate images successfully! Save images successfully! (dualstylegan_env) [lucass@nipa2019-0211 DualStyleGAN]$ gcc --version gcc (GCC) 8.3.1 20190311 (Red Hat 8.3.1-3) Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

williamyang1991 commented 2 years ago

I'm not sure what the problem is. The second image is a pure reconstructed image by pSp encoder and StyleGAN, which is not related to DualStyleGAN. Can you successfully generate images by StyleGAN in https://github.com/rosinality/stylegan2-pytorch? If not, I think there is still something wrong with your enironment/model.

Maybe you can try style transfer with DualStyleGAN on the colab platform: http://colab.research.google.com/github/williamyang1991/DualStyleGAN/blob/master/notebooks/inference_playground.ipynb

huyen-spec commented 1 year ago

This probably too late but I got the same issue as you when tried running the demo. The code executed successfully, but the returned images are just wrong. I am using pytorch 1.12 and cuda 11.3. The problem is probably with the pytorch native version of fused_leaky_relu, which seemed to return very small number. After replacing the function fused_leaky_relu with what this thread said:

https://github.com/rosinality/stylegan2-pytorch/issues/81

I was able to get the ouput correctly. I think it has something to do with cuda version mismatch, since cuda 10 seemed to work, but anyway that was what helped solve my problem.