XingangPan / GAN2Shape

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

To generate latent for new data, what shoud be revise under ../../GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/project_dist.sh #40

Open cynthia-you opened 2 years ago

cynthia-you commented 2 years ago

Dr.Pan ,thanks for sharing your work.

I'm trying to reconstruct the 3D shape or info of old bulidng according to your repo. The inference of church(you offered) works well . But for new data , i'm a little bit confused, could you please give me some hint.

In the bash of ../../GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/project_dist.sh , you write: python projector.py \ --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

Frist , I found that the checkpoints/stylegan2-synface40k-config-e.pt donest exist, so i revised the sh like: !python /content/drive/MyDrive/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/projector.py \ --ckpt /content/drive/MyDrive/GAN2Shape/checkpoints/stylegan2/stylegan2-synface-config-e.pt --size 128 \ --step 1001 --channel_multiplier 1 --synface \ --with_vgg --lr 0.1 --noise 0.05 --no_noise \ --list_path /content/drive/MyDrive/GAN2Shape/my_data/train/img_list.txt \ --img_root /content/drive/MyDrive/GAN2Shape/my_data/train/depth \ --save_path /content/drive/MyDrive/GAN2Shape/my_data/latent \ --batch_size 1

Actually, i have no idea of the exact checkpoints i should revise. As for the input size, i revised the from 128 to 64 to 256.

Since I don't know which ckpts to use, I've been arranging and combining the ckpts(/checkpoints/stylegan2/, wich your scripts/dounlad.sh mentioned) and input sizes... Could you please tell how to revise? thanx~~~~

XingangPan commented 2 years ago

For church, you should use checkpoint at checkpoints/stylegan2/stylegan2-church-config-f.pt (--size 256 --channel_multiplier 2). You can find these settings at https://github.com/XingangPan/GAN2Shape/blob/main/configs/church.yml

cynthia-you commented 2 years ago

For church, you should use checkpoint at checkpoints/stylegan2/stylegan2-church-config-f.pt (--size 256 --channel_multiplier 2). You can find these settings at https://github.com/XingangPan/GAN2Shape/blob/main/configs/church.yml

Thanks for you reply. But it seems that the vgg.pt is not compatible to the church.yml !python /content/drive/MyDrive/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/projector.py \ --ckpt /content/drive/MyDrive/GAN2Shape/checkpoints/stylegan2/stylegan2-church-config-f.pt --size 256 \ --step 1001 --channel_multiplier 2 --synface \ --with_vgg --lr 0.1 --noise 0.05 --no_noise \ --list_path /content/drive/MyDrive/GAN2Shape/my_data/train/img_list.txt \ --img_root /content/drive/MyDrive/GAN2Shape/my_data/train/depth \ --save_path /content/drive/MyDrive/GAN2Shape/my_data/latent \ --batch_size 1

the error: Setting up Perceptual loss... Loading model from: /content/drive/MyDrive/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/weights/v0.1/vgg.pth Traceback (most recent call last): File "/content/drive/MyDrive/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/projector.py", line 189, in <module> model='net-lin', net='vgg', use_gpu=True, gpu_ids=[rank] File "/content/drive/MyDrive/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/__init__.py", line 21, in __init__ self.model.initialize(model=model, net=net, use_gpu=use_gpu, colorspace=colorspace, spatial=self.spatial, gpu_ids=gpu_ids) File "/content/drive/MyDrive/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/dist_model.py", line 75, in initialize self.net.load_state_dict(torch.load(model_path, **kw), strict=False) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 386, in load return _load(f, map_location, pickle_module, **pickle_load_args) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 573, in _load result = unpickler.load() File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 536, in persistent_load deserialized_objects[root_key] = restore_location(obj, location) File "/usr/local/lib/python3.7/dist-packages/torch/serialization.py", line 409, in restore_location result = map_location(storage, location) TypeError: 'int' object is not callable

I checked the projector.py the argument must be: parser.add_argument('--synface', action='store_true')

Could u tell me what can i do to fix it

jojoWd commented 2 years ago

no /GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/project_dist.sh
no projector.py Please let me get where to load those files?