XingangPan / GAN2Shape

Code for GAN2Shape (ICLR2021 oral)
https://arxiv.org/abs/2011.00844
MIT License
573 stars 101 forks source link

How to create your own data set #30

Open AKclown opened 3 years ago

AKclown commented 3 years ago

I have a face picture, and I want to generate the corresponding .pt file from it, which is the same as the data set provided by the demo. How do I generate a 3D model of my own picture?
Can you give me a hint? thank

XingangPan commented 3 years ago

Hi, you need to first perform GAN inversion to get the latent code of the images. To do this you may use code from https://github.com/rosinality/stylegan2-pytorch/blob/master/projector.py or use our code here https://drive.google.com/file/d/1pCfnDiHZNnRoEVZ4RhcLfZyPrJgUWEYk/view?usp=sharing. Next, you can run this GAN2Shape code to get the 3D shape. You need to revise the config file accordingly by changing the input image path and latent code path.

leonel-rocks commented 2 years ago

Hi, you need to first perform GAN inversion to get the latent code of the images. To do this you may use code from https://github.com/rosinality/stylegan2-pytorch/blob/master/projector.py or use our code here https://drive.google.com/file/d/1pCfnDiHZNnRoEVZ4RhcLfZyPrJgUWEYk/view?usp=sharing. Next, you can run this GAN2Shape code to get the 3D shape. You need to revise the config file accordingly by changing the input image path and latent code path.

Hi @XingangPan I'm using your code from https://drive.google.com/file/d/1pCfnDiHZNnRoEVZ4RhcLfZyPrJgUWEYk/view?usp=sharing. However when I run sh project_dist.sh I keep getting the following error:

Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.
*****************************************
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "/home/jgutierrez/anaconda3/envs/gan2/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/jgutierrez/anaconda3/envs/gan2/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/jgutierrez/anaconda3/envs/gan2/lib/python3.7/site-packages/torch/distributed/launch.py", line 246, in <module>
    main()
  File "/home/jgutierrez/anaconda3/envs/gan2/lib/python3.7/site-packages/torch/distributed/launch.py", line 242, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/home/jgutierrez/anaconda3/envs/gan2/bin/python', '-u', 'projector.py', '--local_rank=7', '--ckpt', 'checkpoints/stylegan2-synface40k-config-e.pt', '--size', '128', '--step', '1001', '--channel_multiplier', '1', '--synface', '--with_vgg', '--lr', '0.1', '--noise', '0.05', '--no_noise', '--list_path', '/home/xgpan/projects/GAN/unsup3d/data/synface/train/img_list_200.txt', '--img_root', '/home/xgpan/projects/GAN/unsup3d/data/synface/train/image', '--save_path', 'project/synface_train_40k', '--batch_size', '25', '--distributed']' returned non-zero exit status 1.
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'
Traceback (most recent call last):
  File "projector.py", line 15, in <module>
    from model import Generator, Discriminator
ModuleNotFoundError: No module named 'model'

Can you help me?

XingangPan commented 2 years ago

@DarKayserLeo Hi, please run the script under https://github.com/rosinality/stylegan2-pytorch or https://github.com/XingangPan/GAN2Shape/tree/main/gan2shape/stylegan2/stylegan2-pytorch

leonel-rocks commented 2 years ago

Thanks!