yuval-alaluf / SAM

Official Implementation for "Only a Matter of Style: Age Transformation Using a Style-Based Regression Model" (SIGGRAPH 2021) https://arxiv.org/abs/2102.02754
https://yuval-alaluf.github.io/SAM/
MIT License
632 stars 151 forks source link

AttributeError: 'Namespace' object has no attribute 'encoder_type' #46

Closed yyy7124 closed 2 years ago

yyy7124 commented 2 years ago

Hello, thank you for sharing. I added the encoder_type parameter like psp, but I got this problem when running inference.py 1

yyy7124 commented 2 years ago

And how to generate GAN inversion images

yuval-alaluf commented 2 years ago

It seems like you changed the set_encoder function in psp.py, resulting in the error. Is there a reason that you added that if statement? You are trying to load a pretrained SAM model with opts that do not contain the encoder_type field. That is why your code fails.

Regarding your question on how to generate GAN inversion images, you can simply use the pSp repo if you would like. SAM is designed to edit age, not perform GAN inversion.

yyy7124 commented 2 years ago

Thanks for your prompt reply . I added the if statement for the convenience of choosing Gradualstyleencoder or Backboneencoder like in psp.Would it work if I used the weights I trained myself? I see that the image shown in your paper is a GAN inversion, which is a little different from the image in the FFHQ dataset. Why doesn't this difference need to be used as a measure?

yuval-alaluf commented 2 years ago

I see that the image shown in your paper is a GAN inversion, which is a little different from the image in the FFHQ dataset.

We showed the inverted image instead of the original FFHQ/CelebA-HQ image due to licensing reasons.

Would it work if I used the weights I trained myself?

The code provided in the repo is used to reproduce the paper as is. If you would like to make alterations to the inner workings of SAM, you will need to alter the code. So yes, if you trained our own model, you can load them, but this will require you to know how to alter the code to get what you want.