XingangPan / GAN2Shape

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

Please can you make a demo of the colab. #3

Open molo32 opened 3 years ago

molo32 commented 3 years ago

Please can you make a demo of the colab,to prove with your own images.

leelang7 commented 3 years ago

Please can you make a demo of the colab,to prove with your own images.

i hope so.. i can't check image in result folder

XingangPan commented 3 years ago

Due to some limitations of colab, I am not planning to make a colab version recently. But I do hope to make this code work well. So feel free to let me know if you encounter any problems when using this code :-) I have tested with images in the downloaded 'data' folder, which should work well. So I recommend to have a try with the provided scripts like 'sh scripts/run_car.sh'.

molo32 commented 3 years ago

running !sh scripts / run_car.sh gives this error.

StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    Traceback (most recent call last):
from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
  File "run.py", line 7, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
ModuleNotFoundError: No module named 'neural_renderer'
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
        from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
        from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
    import neural_renderer as nr
ModuleNotFoundError: No module named 'neural_renderer'
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
ModuleNotFoundError: No module named 'neural_renderer'
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
ModuleNotFoundError: No module named 'neural_renderer'
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/launch.py", line 260, in <module>
    main()
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/launch.py", line 256, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-u', 'run.py', '--local_rank=3', '--launcher', 'pytorch', '--config', 'configs/car.yml']' returned non-zero exit status 1.
*****************************************
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. 
*****************************************

I think it is because neural_renderer_pytorch was not installed but i can't install neural_renderer_pytorch. What options are there?

!pip install neural_renderer_pytorch

Collecting neural_renderer_pytorch
  Downloading https://files.pythonhosted.org/packages/15/28/dd59b5098e60e75948ae414ee65700597217199591dffa22797f47914702/neural_renderer_pytorch-1.1.3.tar.gz
Requirement already satisfied: torch in /usr/local/lib/python3.7/dist-packages (from neural_renderer_pytorch) (1.7.0+cu101)
Requirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from neural_renderer_pytorch) (1.19.5)
Requirement already satisfied: scikit-image in /usr/local/lib/python3.7/dist-packages (from neural_renderer_pytorch) (0.16.2)
Requirement already satisfied: typing-extensions in /usr/local/lib/python3.7/dist-packages (from torch->neural_renderer_pytorch) (3.7.4.3)
Requirement already satisfied: future in /usr/local/lib/python3.7/dist-packages (from torch->neural_renderer_pytorch) (0.16.0)
Requirement already satisfied: dataclasses in /usr/local/lib/python3.7/dist-packages (from torch->neural_renderer_pytorch) (0.6)
Requirement already satisfied: PyWavelets>=0.4.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->neural_renderer_pytorch) (1.1.1)
Requirement already satisfied: pillow>=4.3.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->neural_renderer_pytorch) (7.0.0)
Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->neural_renderer_pytorch) (3.2.2)
Requirement already satisfied: networkx>=2.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->neural_renderer_pytorch) (2.5)
Requirement already satisfied: scipy>=0.19.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->neural_renderer_pytorch) (1.4.1)
Requirement already satisfied: imageio>=2.3.0 in /usr/local/lib/python3.7/dist-packages (from scikit-image->neural_renderer_pytorch) (2.4.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->neural_renderer_pytorch) (2.8.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->neural_renderer_pytorch) (2.4.7)
Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.7/dist-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->neural_renderer_pytorch) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.7/dist-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->neural_renderer_pytorch) (1.3.1)
Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.7/dist-packages (from networkx>=2.0->scikit-image->neural_renderer_pytorch) (4.4.2)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.7/dist-packages (from python-dateutil>=2.1->matplotlib!=3.0.0,>=2.0.0->scikit-image->neural_renderer_pytorch) (1.15.0)
Building wheels for collected packages: neural-renderer-pytorch
  Building wheel for neural-renderer-pytorch (setup.py) ... error
  ERROR: Failed building wheel for neural-renderer-pytorch
  Running setup.py clean for neural-renderer-pytorch
Failed to build neural-renderer-pytorch
Installing collected packages: neural-renderer-pytorch
    Running setup.py install for neural-renderer-pytorch ... error
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-hy3yzui7/neural-renderer-pytorch/setup.py'"'"'; __file__='"'"'/tmp/pip-install-hy3yzui7/neural-renderer-pytorch/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-wogq2bly/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
XingangPan commented 3 years ago

@molo32 It seems that you have pytorch1.7, which neural_renderer_pytorch does not support by default. You may try pytorch1.1 or 1.2. I'll try to add support to pytorch1.7.

XingangPan commented 3 years ago

@molo32 I have checked the code of neural_renderer_pytorch, which does not support pytorch1.7 for now. To make it fit with pytorch1.7, you meed to switch to 'at_assert_fix' branch, change the 'AT_CHECK' to 'TORCH_CHECK' in the code, and perhaps more revisions. So I recommend to use pytorch1.1 or 1.2 for now.

molo32 commented 3 years ago

with pytorch = 1.10 gives this error

!sh /content/GAN2Shape/scripts/run_synface.sh

StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/__init__.py", line 3, in <module>
    from .load_obj import load_obj
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/load_obj.py", line 8, in <module>
    import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /usr/local/lib/python3.7/dist-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/__init__.py", line 3, in <module>
    from .load_obj import load_obj
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/load_obj.py", line 8, in <module>
    import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /usr/local/lib/python3.7/dist-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/__init__.py", line 3, in <module>
    from .load_obj import load_obj
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/load_obj.py", line 8, in <module>
    import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /usr/local/lib/python3.7/dist-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/content/GAN2Shape/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/content/GAN2Shape/gan2shape/model.py", line 17, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/__init__.py", line 1, in <module>
    from .renderer import Renderer
  File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 6, in <module>
    import neural_renderer as nr
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/__init__.py", line 3, in <module>
    from .load_obj import load_obj
  File "/usr/local/lib/python3.7/dist-packages/neural_renderer/load_obj.py", line 8, in <module>
    import neural_renderer.cuda.load_textures as load_textures_cuda
ImportError: /usr/local/lib/python3.7/dist-packages/neural_renderer/cuda/load_textures.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN6caffe26detail37_typeMetaDataInstance_preallocated_32E
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/launch.py", line 235, in <module>
    main()
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/launch.py", line 231, in main
    cmd=process.args)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-u', 'run.py', '--local_rank=0', '--launcher', 'pytorch', '--config', 'configs/synface.yml']' returned non-zero exit status 1.

with pytorch = 1.2.0 gives this error

StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op FusedLeakyReLU not available, using native PyTorch fallback.
StyleGAN2: Optimized CUDA op UpFirDn2d not available, using native PyTorch fallback.
Load config from yml file: configs/synface.yml
Loading configs from configs/synface.yml
Traceback (most recent call last):
  File "run.py", line 26, in <module>
    init_dist(args.launcher, backend='nccl')
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/dist_utils.py", line 20, in init_dist
    _init_dist_pytorch(backend, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/mmcv/runner/dist_utils.py", line 34, in _init_dist_pytorch
    dist.init_process_group(backend=backend, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/distributed_c10d.py", line 406, in init_process_group
    store, rank, world_size = next(rendezvous(url))
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/rendezvous.py", line 143, in _env_rendezvous_handler
    store = TCPStore(master_addr, master_port, world_size, start_daemon)
RuntimeError: Address already in use
Load config from yml file: configs/synface.yml
Loading configs from configs/synface.yml
Load config from yml file: configs/synface.yml
Loading configs from configs/synface.yml
{'checkpoint_dir': 'results/synface', 'save_checkpoint_freq': 500, 'keep_num_checkpoint': 2, 'use_logger': True, 'log_freq': 100, 'joint_train': False, 'independent': True, 'reset_weight': True, 'save_results': False, 'num_stage': 1, 'flip1_cfg': [False], 'flip3_cfg': [True], 'stage_len_dict': {'step1': 500, 'step2': 500, 'step3': 200}, 'image_size': 64, 'crop': 170, 'load_gt_depth': True, 'img_list_path': 'data/synface/test/list.txt', 'img_root': 'data/synface/test/image', 'latent_root': 'data/synface/test/latents', 'model_name': 'gan2shape_synface', 'category': 'synface', 'share_weight': True, 'relative_enc': True, 'use_mask': False, 'add_mean_L': True, 'add_mean_V': True, 'num_scale': 1, 'min_depth': 0.9, 'max_depth': 1.1, 'xyz_rotation_range': 60, 'xy_translation_range': 0.1, 'z_translation_range': 0, 'view_scale': 1.2, 'collect_iters': 100, 'batchsize': 16, 'lr': 0.0001, 'lam_perc': 0.5, 'lam_smooth': 0.01, 'lam_regular': 0.01, 'pretrain': 'checkpoints/gan2shape/synface_pretrain.pth', 'view_mvn_path': 'checkpoints/view_light/synface_view_mvn.pth', 'light_mvn_path': 'checkpoints/view_light/synface_light_mvn.pth', 'channel_multiplier': 1, 'gan_size': 128, 'gan_ckpt': 'checkpoints/stylegan2/stylegan2-synface-config-e.pt', 'F1_d': 8, 'rot_center_depth': 1.0, 'fov': 10, 'tex_cube_size': 2, 'config': 'configs/synface.yml', 'seed': 0, 'num_workers': 4, 'distributed': True}
{'checkpoint_dir': 'results/synface', 'save_checkpoint_freq': 500, 'keep_num_checkpoint': 2, 'use_logger': True, 'log_freq': 100, 'joint_train': False, 'independent': True, 'reset_weight': True, 'save_results': False, 'num_stage': 1, 'flip1_cfg': [False], 'flip3_cfg': [True], 'stage_len_dict': {'step1': 500, 'step2': 500, 'step3': 200}, 'image_size': 64, 'crop': 170, 'load_gt_depth': True, 'img_list_path': 'data/synface/test/list.txt', 'img_root': 'data/synface/test/image', 'latent_root': 'data/synface/test/latents', 'model_name': 'gan2shape_synface', 'category': 'synface', 'share_weight': True, 'relative_enc': True, 'use_mask': False, 'add_mean_L': True, 'add_mean_V': True, 'num_scale': 1, 'min_depth': 0.9, 'max_depth': 1.1, 'xyz_rotation_range': 60, 'xy_translation_range': 0.1, 'z_translation_range': 0, 'view_scale': 1.2, 'collect_iters': 100, 'batchsize': 16, 'lr': 0.0001, 'lam_perc': 0.5, 'lam_smooth': 0.01, 'lam_regular': 0.01, 'pretrain': 'checkpoints/gan2shape/synface_pretrain.pth', 'view_mvn_path': 'checkpoints/view_light/synface_view_mvn.pth', 'light_mvn_path': 'checkpoints/view_light/synface_light_mvn.pth', 'channel_multiplier': 1, 'gan_size': 128, 'gan_ckpt': 'checkpoints/stylegan2/stylegan2-synface-config-e.pt', 'F1_d': 8, 'rot_center_depth': 1.0, 'fov': 10, 'tex_cube_size': 2, 'config': 'configs/synface.yml', 'seed': 0, 'num_workers': 4, 'distributed': True}
Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/launch.py", line 246, in <module>
    main()
  File "/usr/local/lib/python3.7/dist-packages/torch/distributed/launch.py", line 242, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-u', 'run.py', '--local_rank=3', '--launcher', 'pytorch', '--config', 'configs/synface.yml']' returned non-zero exit status 1.
*****************************************
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. 
*****************************************
Load config from yml file: configs/synface.yml
Loading configs from configs/synface.yml
{'checkpoint_dir': 'results/synface', 'save_checkpoint_freq': 500, 'keep_num_checkpoint': 2, 'use_logger': True, 'log_freq': 100, 'joint_train': False, 'independent': True, 'reset_weight': True, 'save_results': False, 'num_stage': 1, 'flip1_cfg': [False], 'flip3_cfg': [True], 'stage_len_dict': {'step1': 500, 'step2': 500, 'step3': 200}, 'image_size': 64, 'crop': 170, 'load_gt_depth': True, 'img_list_path': 'data/synface/test/list.txt', 'img_root': 'data/synface/test/image', 'latent_root': 'data/synface/test/latents', 'model_name': 'gan2shape_synface', 'category': 'synface', 'share_weight': True, 'relative_enc': True, 'use_mask': False, 'add_mean_L': True, 'add_mean_V': True, 'num_scale': 1, 'min_depth': 0.9, 'max_depth': 1.1, 'xyz_rotation_range': 60, 'xy_translation_range': 0.1, 'z_translation_range': 0, 'view_scale': 1.2, 'collect_iters': 100, 'batchsize': 16, 'lr': 0.0001, 'lam_perc': 0.5, 'lam_smooth': 0.01, 'lam_regular': 0.01, 'pretrain': 'checkpoints/gan2shape/synface_pretrain.pth', 'view_mvn_path': 'checkpoints/view_light/synface_view_mvn.pth', 'light_mvn_path': 'checkpoints/view_light/synface_light_mvn.pth', 'channel_multiplier': 1, 'gan_size': 128, 'gan_ckpt': 'checkpoints/stylegan2/stylegan2-synface-config-e.pt', 'F1_d': 8, 'rot_center_depth': 1.0, 'fov': 10, 'tex_cube_size': 2, 'config': 'configs/synface.yml', 'seed': 0, 'num_workers': 4, 'distributed': True}
Setting up Perceptual loss...
Setting up Perceptual loss...
Setting up Perceptual loss...
Loading model from: /content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/weights/v0.1/vgg.pth
Loading model from: /content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/weights/v0.1/vgg.pth
Loading model from: /content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/weights/v0.1/vgg.pth
Traceback (most recent call last):
  File "run.py", line 31, in <module>
    trainer = Trainer(cfgs, GAN2Shape)
  File "/content/GAN2Shape/gan2shape/trainer.py", line 23, in __init__
    self.model = model(cfgs)
  File "/content/GAN2Shape/gan2shape/model.py", line 88, in __init__
    model='net-lin', net='vgg', use_gpu=True, gpu_ids=[self.rank]
  File "/content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/__init__.py", line 22, in __init__
    self.model.initialize(model=model, net=net, use_gpu=use_gpu, colorspace=colorspace, spatial=self.spatial, gpu_ids=gpu_ids)
  File "/content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/dist_model.py", line 99, in initialize
    self.net.to(gpu_ids[0])
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 432, in to
    return self._apply(convert)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 208, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 251, in _apply
    self._buffers[key] = fn(buf)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 430, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
RuntimeError: CUDA error: invalid device ordinal
Traceback (most recent call last):
  File "run.py", line 31, in <module>
    trainer = Trainer(cfgs, GAN2Shape)
  File "/content/GAN2Shape/gan2shape/trainer.py", line 23, in __init__
    self.model = model(cfgs)
  File "/content/GAN2Shape/gan2shape/model.py", line 88, in __init__
    model='net-lin', net='vgg', use_gpu=True, gpu_ids=[self.rank]
  File "/content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/__init__.py", line 22, in __init__
    self.model.initialize(model=model, net=net, use_gpu=use_gpu, colorspace=colorspace, spatial=self.spatial, gpu_ids=gpu_ids)
  File "/content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/dist_model.py", line 99, in initialize
    self.net.to(gpu_ids[0])
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 432, in to
    return self._apply(convert)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 208, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 251, in _apply
    self._buffers[key] = fn(buf)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 430, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
RuntimeError: CUDA error: invalid device ordinal
Traceback (most recent call last):
  File "run.py", line 31, in <module>
    trainer = Trainer(cfgs, GAN2Shape)
  File "/content/GAN2Shape/gan2shape/trainer.py", line 23, in __init__
    self.model = model(cfgs)
  File "/content/GAN2Shape/gan2shape/model.py", line 88, in __init__
    model='net-lin', net='vgg', use_gpu=True, gpu_ids=[self.rank]
  File "/content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/__init__.py", line 22, in __init__
    self.model.initialize(model=model, net=net, use_gpu=use_gpu, colorspace=colorspace, spatial=self.spatial, gpu_ids=gpu_ids)
  File "/content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/dist_model.py", line 99, in initialize
    self.net.to(gpu_ids[0])
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 432, in to
    return self._apply(convert)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 208, in _apply
    module._apply(fn)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 251, in _apply
    self._buffers[key] = fn(buf)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 430, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
RuntimeError: CUDA error: invalid device ordinal
XingangPan commented 3 years ago

@molo32 For the case of pytorch = 1.2.0, it seems you need to change the value of 'PORT' in the script to another value. Also make sure you have at least four GPUs in your server, otherwise you need to revise the script accordingly. For the case of pytorch=1.1.0, it seems the neural_renderer library is not correctly installed. You may check these two issues: https://github.com/svip-lab/impersonator/issues/13 , https://github.com/svip-lab/impersonator/issues/35

ucalyptus2 commented 3 years ago

@XingangPan @molo32 here is a colab demo. https://colab.research.google.com/drive/124D_f0RIu7Bbwa1SFV6pmvmBrNkB8Ow_?usp=sharing If you cite in the readme, please tag my original account -> https://github.com/ucalyptus

XingangPan commented 3 years ago

@forkbabu Thanks :-)

AKclown commented 2 years ago

I have the same problem , pip install neural_renderer_pytorch successfully executed, what should I do to give suggestion, thank you very much.

pytorch = 1.2.0 python = 3.7.2

Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/model.py", line 16, in <module>
    from .stylegan2 import Generator, Discriminator, PerceptualLoss
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/__init__.py", line 14, in <module>
    from model import Generator, Discriminator
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 11, in <module>
    from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/fused_act.py", line 14, in <module>
    import fused
ImportError: /home/ak/anaconda3/lib/python3.7/site-packages/upfirdn2d-0.0.0-py3.7-linux-x86_64.egg/fused.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/model.py", line 16, in <module>
    from .stylegan2 import Generator, Discriminator, PerceptualLoss
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/__init__.py", line 14, in <module>
    from model import Generator, Discriminator
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 11, in <module>
    from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/fused_act.py", line 14, in <module>
    import fused
ImportError: /home/ak/anaconda3/lib/python3.7/site-packages/upfirdn2d-0.0.0-py3.7-linux-x86_64.egg/fused.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/model.py", line 16, in <module>
    from .stylegan2 import Generator, Discriminator, PerceptualLoss
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/__init__.py", line 14, in <module>
    from model import Generator, Discriminator
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 11, in <module>
    from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/fused_act.py", line 14, in <module>
    import fused
ImportError: /home/ak/anaconda3/lib/python3.7/site-packages/upfirdn2d-0.0.0-py3.7-linux-x86_64.egg/fused.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev
Traceback (most recent call last):
  File "run.py", line 7, in <module>
    from gan2shape import setup_runtime, Trainer, GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/__init__.py", line 3, in <module>
    from .model import GAN2Shape
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/model.py", line 16, in <module>
    from .stylegan2 import Generator, Discriminator, PerceptualLoss
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/__init__.py", line 14, in <module>
    from model import Generator, Discriminator
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 11, in <module>
    from op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/__init__.py", line 1, in <module>
    from .fused_act import FusedLeakyReLU, fused_leaky_relu
  File "/home/ak/Downloads/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/op/fused_act.py", line 14, in <module>
    import fused
ImportError: /home/ak/anaconda3/lib/python3.7/site-packages/upfirdn2d-0.0.0-py3.7-linux-x86_64.egg/fused.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZNSt19basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev
Traceback (most recent call last):
  File "/home/ak/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/home/ak/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/ak/anaconda3/lib/python3.7/site-packages/torch/distributed/launch.py", line 246, in <module>
    main()
  File "/home/ak/anaconda3/lib/python3.7/site-packages/torch/distributed/launch.py", line 242, in main
    cmd=cmd)
subprocess.CalledProcessError: Command '['/home/ak/anaconda3/bin/python', '-u', 'run.py', '--local_rank=3', '--launcher', 'pytorch', '--config', 'configs/synface.yml']' returned non-zero exit status 1.
*****************************************
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. 

AKclown commented 2 years ago

@molo32 For the case of pytorch = 1.2.0, it seems you need to change the value of 'PORT' in the script to another value. Also make sure you have at least four GPUs in your server, otherwise you need to revise the script accordingly. For the case of pytorch=1.1.0, it seems the neural_renderer library is not correctly installed. You may check these two issues: svip-lab/impersonator#13 , svip-lab/impersonator#35

Hello, what value should my port value be changed to? And how to check how many GPUs there are? Hope to give me some suggestions, thank you