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

Pretrained stylegan2 models #9

Open qingqingisrunning opened 2 years ago

qingqingisrunning commented 2 years ago

Thanks for sharing this repo. I would like to train my own sketchgan for generating pictures of vehicles. Could you provide the pytorch pretrained stylegan2-car (and train, bus etc.) netD and netG model? Thanks.

PeterWang512 commented 2 years ago

You can download the official styleGAN2 weights from here: https://nvlabs-fi-cdn.nvidia.com/stylegan2/networks/ For example, you would want to download the car model from https://nvlabs-fi-cdn.nvidia.com/stylegan2/networks/stylegan2-car-config-f.pkl

The official styleGAN2 weights are in TensorFlow, so I converted the weights into PyTorch weights using this script: https://github.com/rosinality/stylegan2-pytorch/blob/master/convert_weight.py

Hope this helps!

qingqingisrunning commented 2 years ago

Thank you very much! The tensorflow weights have been converted into pytorch weights on gtx2060...Thanks!!!

And how could I convert/project user sketch into fixed_z (expect a .pth file) in generate.py?

qingqingisrunning commented 2 years ago

We first provide some certain vehicle sketches with similar poses for training customized vehicle sketchgan model, and in the generation stage, we must put a random z or a real projected image rather than a user sketch into this customized gan model to generate real car images with similar poses of the input training sketches.

Do different vehicle poses correspond to different customized gan models? @PeterWang512

PeterWang512 commented 2 years ago

Inference time the new model takes in the latent vector, and it can be sampled from a Gaussian or a latent projected from an image.

Yes, different vehicle poses correspond to different customized gan if the training sketches consist of just one pose. We haven't tried training on sketches with multiple poses yet, but it is possible that, for example, you can get a sports car model by using sport car sketches of different poses as training inputs. Hope this helps!

PeterWang512 commented 2 years ago

For projection, we use pix2latent to get the latent z vector. The repo is here: https://github.com/minyoungg/pix2latent

qingqingisrunning commented 2 years ago

I really appreciate your help!

Zoofashan commented 2 years ago

Can you please tell if we have our own model trained in stylegan2 how can we generate netG and netD files

jingnian-yxq commented 1 year ago

we must put a random z or a real projected image rather than a user sketch into this customized gan model to generate real car images with similar poses of the input training sketches.

@qingqingisrunning Can you tell me how can I put my sketch into the trained model? I have completed the training, but don't know how to generate images according to a new sketch. I noticed a .pth file(fixed_z) is needed, but how to convert an image into the .pth? (pix2latent has been tried, but (1)it outputs a .npy file, is it the same format as the required .pth? (2)sample is in size512, my image sized 256 resulting error[RuntimeError: mat1 dim 1 must match mat2 dim 0])