yuval-alaluf / stylegan3-editing

Official Implementation of "Third Time's the Charm? Image and Video Editing with StyleGAN3" (AIM ECCVW 2022) https://arxiv.org/abs/2201.13433
https://yuval-alaluf.github.io/stylegan3-editing/
MIT License
660 stars 72 forks source link

Error using stylegan3 pkl trained model #19

Closed uselessai closed 2 years ago

uselessai commented 2 years ago

I am trying to train the encoder "train_restyle_psp" with my own stylegan3 pkl model and I've got this error.

Loading StyleGAN3 generator from path: pretrained_models/network-snapshot-002160Stylegan3.pkl Done! Traceback (most recent call last): File "inversion/scripts/train_restyle_psp.py", line 29, in <module> main() File "/home/laura/Escritorio/Anaconda/lib/python3.8/site-packages/pyrallis/argparsing.py", line 158, in wrapper_inner response = fn(cfg, *args, **kwargs) File "inversion/scripts/train_restyle_psp.py", line 24, in main coach = Coach(opts) File "./inversion/training/coach_restyle_psp.py", line 44, in __init__ self.avg_image = self.net(self.net.latent_avg.repeat(16, 1).unsqueeze(0), File "/home/laura/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "./inversion/models/psp3.py", line 66, in forward images = self.decoder.synthesis(codes, noise_mode='const', force_fp32=True) File "/home/laura/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "<string>", line 469, in forward File "/home/laura/.local/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "<string>", line 218, in forward RuntimeError: batch1 dim 2 must match batch2 dim 1

I am working with a pkl model.

yuval-alaluf commented 2 years ago

Hi @uselessai You will first need to convert your pickle to a pt file using the code snippet provided above. Please try this out and let me know if this solves your issue. I'll add a comment in the README to make this clearer.

uselessai commented 2 years ago

Hi @yuval-alaluf . Thanks for the quick response.

I tried to convert the stylegan3 pkl filo to pt using the links provided in ReStyle repository but I got an error, It only works for Stylegan2 models. I can not find the .pt generators in your repository.

Thanks in advance. Lau.

yuval-alaluf commented 2 years ago

Converting the pkls to pt for SG3 is different than what was used for SG2. Try using the snippet I provided here: https://github.com/yuval-alaluf/stylegan3-editing/issues/16#issuecomment-1101533474

YKJamesMoriarty commented 1 week ago

@uselessai Hello,I am also training my own restyle_e4e model, but when I use the SG3-R-FFHQ-102.pt model provided by the author, which is trained using the ffhq data set, the code is reporting an error. https://github.com/yuval-alaluf/stylegan3-editing/issues/53 I would like to ask if you successfully solved the error after converting pkl file to pt file? Because I now want to try to use the Stylegan3-related.PKL model file provided by NVIDIA officially, instead of the.pt file converted by the author, I would like to ask if it is meaningful for me to try this?