yuval-alaluf/stylegan3-editing

Error using stylegan3 pkl trained model

uselessai opened this issue · 3 comments

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.

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.

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.

Converting the pkls to pt for SG3 is different than what was used for SG2. Try using the snippet I provided here:
#16 (comment)