orpatashnik / StyleCLIP

Official Implementation for "StyleCLIP: Text-Driven Manipulation of StyleGAN Imagery" (ICCV 2021 Oral)
MIT License
4k stars 560 forks source link

How to invert and edit an image #1

Closed ramtiin closed 3 years ago

ramtiin commented 3 years ago

Hello,

I looked at the codes but couldn't locate the code that inverts the image so it can be edited. You said you used e4e, but I couldn't find the relevant codes.

Thank you.

orpatashnik commented 3 years ago

Hi @ramtiin ,

Thanks for your interest in the project! The code of e4e will be released within the next few days here. In the meanwhile, I recommend performing the inversion using pSp. The pSp repository contains a notebook that is really easy to work with. Let me know if you need any help.

ramtiin commented 3 years ago

Thank you for your fast response!

I opened this notebook and set experiment_type to ffhq_encode, but I couldn't figure out how to get a latent code. I can only get the inversion in png format. Do you know which part I need to change?

woctezuma commented 3 years ago

You could use the official implementations:

orpatashnik commented 3 years ago

As @woctezuma mentioned, it is also possible to invert using the official StyleGAN implementation. An advantage of using pSp is the fast inference. To obtain the latent code from pSp's notebook, you can modify it as follows:

image

It is important to note that different latent codes behave differently when trying to edit them, so you may need to tune a bit the --l2_lambda parameter. Anyway, I hope that the code of e4e will be available as soon as possible because the latent codes that it provides are suitable for high-quality editing :-)

ramtiin commented 3 years ago

Thank you! The problem has been solved, so I'm closing this issue.

woctezuma commented 3 years ago

FYI e4e has been released! Open In Colab