PeterWang512 / GANSketching

Sketch Your Own GAN: Customizing a GAN model with hand-drawn sketches.
https://peterwang512.github.io/GANSketching
MIT License
710 stars 95 forks source link

How to transform my own sketch to latent z ? #12

Open hahaCui opened 2 years ago

hahaCui commented 2 years ago

Hi! Glad to see your work! But I have a question, as follows.

Consider practical usage: step 1: I make a cat sketch image by hand. step 2: transform the sketch image to latent_z. step 3: feed latent_z to netG network to get a cat image.

I am surprised how to realize step2 ? Do you mean that I need netG, photo2Sketch network, and use pix2latent method? Or only need netG and use pix2latent method? If I just use netG to get z, it will still generate the cat sketch, but not cat image. Is not it ?

Thanks!

PeterWang512 commented 2 years ago

I think you are asking about two things in our paper. (1) Our method takes in one or a few cat sketches, and update the entire generator to synthesis endless cats with similar shape and poses. (2) We show an application to transform a real cat image into latent_z. Note that this projection is done on the original cat network. We can then feed the latent_z into the new created generator to achieve an image manipulation effect (i.e. changing the shape and pose of the real cat into the one depicted by the sketch).

hahaCui commented 2 years ago

Nice to receive your reply! Now I get it.

If so, suppose using handreds of cat sketches with each with different pose and shape from others, I'm afraid there may exists two problems: (1) Just as your reply to @qingqingisrunning, If I use whole sketches to train sketchGan, the inference result may be a strange result; (2) But If I train one model for each cat sketch, it really consumes much time and computation cost!

Looking forward to your new research !

PeterWang512 commented 2 years ago

yes these are great suggestions, and unfortunately our method currently is not capable of achieving fast model creation right now. It would be a great direction to speed up the model creation process.

Zeeshan75 commented 2 years ago

Hi @PeterWang512, Thanks for sharing your work. It's Interesting!

I have gone through your recent repo gan warping, There I could find the saved latent spaces for cats and you were doing warping or edits by using those .npz latent space files.

Can you give me the suggestions or the approach to the below questions:

  1. How can we generate the latent space by taking the input cat image by using your cat pre-trained model?
  2. How can we transform the above latent space (or) train the model to generate the cartoon(toonify) cat image?

Thanks in advance.

jingnian-yxq commented 1 year ago

I tried pix2latent for getting latent_z, but the model provided is for size 512, and my images are size 256. It reports "RuntimeError: mat1 dim 1 must match mat2 dim 0". How should I change to apply for 256x256 images?