jiaxinxie97 / HFGI3D

200 stars 17 forks source link

Incomplete quick start #10

Open parsa-ra opened 1 year ago

parsa-ra commented 1 year ago

Hey,

I think the driver code for the running your method on custom imgs is not complete, for example the run_PTI script requires multiview imgs, but the multi_views/generate_multi_views.py is not called in the provided scripts.

jiaxinxie97 commented 1 year ago

Hi,

Do you mean I need to call multi_views/generate_multi_views.py in run_pti.py? You can refer to this line. https://github.com/jiaxinxie97/HFGI3D/blob/139d0c67046ee4fd3a41edd6320646c8c6b0b287/inversion/scripts/run_pti.py#L59

artificialnouveau commented 10 months ago

When I run run_pti.py, I get the following error. Is 0.png not created or is the file path not correct?

../../example_configs/config_00001.py
CUDA is available. Using device: cuda
Setting up [LPIPS] perceptual loss: trunk [alex], v[0.1], spatial [off]
/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
  warnings.warn(
/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=AlexNet_Weights.IMAGENET1K_V1`. You can also use `weights=AlexNet_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
Loading model from: /usr/local/lib/python3.10/dist-packages/lpips/weights/v0.1/alex.pth
../ffhq512-128.pkl
../ffhq512-128.pkl
  0% 0/1 [00:00<?, ?it/s]../ffhq512-128.pkl
../ffhq512-128.pkl
Setting up PyTorch plugin "bias_act_plugin"... Done.
Downloading https://nvlabs-fi-cdn.nvidia.com/stylegan2-ada-pytorch/pretrained/metrics/vgg16.pt ... done

  0% 0/500 [00:00<?, ?it/s]Setting up PyTorch plugin "upfirdn2d_plugin"... Done.
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1130: UserWarning: operator() profile_node %106 : int = prim::profile_ivalue(%104)
 does not have profile information (Triggered internally at  ../torch/csrc/jit/codegen/cuda/graph_fuser.cpp:104.)
  return forward_call(*input, **kwargs)
/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py:1130: UserWarning: concrete shape for bias input is required to decompose into conv + bias (Triggered internally at  ../torch/csrc/jit/codegen/cuda/graph_fuser.cpp:2233.)
  return forward_call(*input, **kwargs)

  0% 1/500 [01:01<8:28:15, 61.11s/it]
  0% 2/500 [01:02<3:36:11, 26.05s/it]
  ....

 93% 28/30 [00:08<00:00,  3.17it/s]

 97% 29/30 [00:09<00:00,  3.13it/s]

100% 30/30 [00:09<00:00,  3.16it/s]
 42% 210/501 [02:17<03:10,  1.52it/s]
100% 1/1 [09:39<00:00, 579.81s/it]
/usr/local/lib/python3.10/dist-packages/pytorch3d/io/obj_io.py:544: UserWarning: No mtl file provided
  warnings.warn("No mtl file provided")
/content/HFGI3D/inversion/scripts/../../multi_views/generate_multi_views.py:244: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.
  input = imageio.imread(data_folder+'/%s.png'%(name))/255.
/usr/local/lib/python3.10/dist-packages/torch/nn/functional.py:4215: UserWarning: Default grid_sample and affine_grid behavior has changed to align_corners=False since 1.3.0. Please specify align_corners=True if the old behavior is desired. See the documentation of grid_sample for details.
  warnings.warn(
/content/HFGI3D/inversion/scripts/../../multi_views/generate_multi_views.py:411: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.
  mask = imageio.imread(outputdir+maskname)
/content/HFGI3D/inversion/scripts/../../multi_views/generate_multi_views.py:414: DeprecationWarning: Starting with ImageIO v3 the behavior of this function will switch to that of iio.v3.imread. To keep the current behavior (and make this warning disappear) use `import imageio.v2 as imageio` or call `imageio.v2.imread` directly.
  contour = imageio.imread(outputdir+contourname)/255.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 3080, in fromarray
    mode, rawmode = _fromarray_typemap[typekey]
KeyError: ((1, 1, 3), '<f8')
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/content/HFGI3D/inversion/scripts/../../multi_views/generate_multi_views.py", line 430, in <module>
    imageio.imwrite(outputdir+'eroded_mask_{}.png'.format(i),mask)
  File "/usr/local/lib/python3.10/dist-packages/imageio/v2.py", line 397, in imwrite
    return file.write(im, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/imageio/plugins/pillow.py", line 425, in write
    pil_frame = Image.fromarray(frame, mode=mode)
  File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 3083, in fromarray
    raise TypeError(msg) from e
TypeError: Cannot handle this data type: (1, 1, 3), <f8
CUDA is available. Using device: cuda
Setting up [LPIPS] perceptual loss: trunk [alex], v[0.1], spatial [off]
/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:208: UserWarning: The parameter 'pretrained' is deprecated since 0.13 and will be removed in 0.15, please use 'weights' instead.
  warnings.warn(
/usr/local/lib/python3.10/dist-packages/torchvision/models/_utils.py:223: UserWarning: Arguments other than a weight enum or `None` for 'weights' are deprecated since 0.13 and will be removed in 0.15. The current behavior is equivalent to passing `weights=AlexNet_Weights.IMAGENET1K_V1`. You can also use `weights=AlexNet_Weights.DEFAULT` to get the most up-to-date weights.
  warnings.warn(msg)
Loading model from: /usr/local/lib/python3.10/dist-packages/lpips/weights/v0.1/alex.pth
../ffhq512-128.pkl
../ffhq512-128.pkl
Traceback (most recent call last):
  File "/content/HFGI3D/inversion/scripts/run_pti.py", line 72, in <module>
    run_PTI(paths_config,run_name='',multi_views=True,use_wandb=False, use_multi_id_training=False)
  File "/content/HFGI3D/inversion/scripts/run_pti.py", line 59, in run_PTI
    coach.train()
  File "/content/HFGI3D/inversion/scripts/../training/coaches/single_id_coach.py", line 91, in train
    teacher_img = PIL.Image.open(f'{self.paths_config.multi_views_output_dir}/{self.paths_config.name}/{img_i}.png').convert('RGB')
  File "/usr/local/lib/python3.10/dist-packages/PIL/Image.py", line 3227, in open
    fp = builtins.open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '../multi_views_blending/00001/0.png'
wynsmile commented 5 months ago

Hello, I have the same problem, have you solved it?