yanconglin / VanishingPoint_HoughTransform_GaussianSphere

Official implementation: Deep vanishing point detection: Geometric priors make dataset variations vanish, CVPR'22.
MIT License
91 stars 9 forks source link

demo.py throws an error #5

Closed premchedella closed 2 years ago

premchedella commented 2 years ago

For one of our project, we would like to use this project.

python demo.py -d 0 config\nyu.yaml checkpoints\nyu\checkpoint_latest.pth.tar example_yud.jpg

Results the following error.

Created and checkpoints and parameterization directories and then copied necessary files from the https://surfdrive.surf.nl/files/index.php/s/nKOCFAgZxulxHH0?path=%2FNYU.

(D:\KAUST\projects\datasets\street_sings\env) D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere>python demo.py -d 0 config\nyu.yaml checkpoints\nyu\checkpoint_latest.pth.tar example_yud.jpg
<Box: {'io': {'logdir': 'logs/', 'resume_from': None, 'dataset': 'NYU', 'datadir': 'dataset/nyu_vp/processed_data', 'ht_mapping': 'parameterization/nyu/ht_240_320_403_180.npz', 'sphere_mapping': 'parameterization/nyu/sphere_neighbors_403_180_32768.npz', 'focal_length': 1.0, 'num_neighbors': 20, 'num_vpts': None, 'num_nodes': 32768, 'percentage': 1, 'num_workers': 2}, 'model': {'batch_size': 3, 'backbone': 'stacked_hourglass', 'depth': 4, 'num_stacks': 1, 'num_blocks': 1, 'lpos': 1.0, 'lneg': 1.0, 'num_channels': 64, 'im2col_step': 32}, 'optim': {'name': 'Adam', 'lr': 0.0004, 'amsgrad': True, 'weight_decay': 1e-05, 'max_epoch': 36, 'lr_decay_epoch': 24}}>
Let's use 1 GPU(s)!
kth, device name 0 NVIDIA TITAN Xp
vote_ht_dict  memory MB torch.Size([13824000, 3]) 158.203125
vote_sphere_dict  memory MB 32768 torch.Size([17134246, 3]) 196.08588409423828
#################### im2ht compiling ############################
INFO: Could not find files for the given pattern(s).
Traceback (most recent call last):
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\demo.py", line 253, in <module>
    main()
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\demo.py", line 168, in main
    model = vpd.models.VanishingNet(backbone, vote_ht_dict, vote_sphere_dict)
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\vpd\models\vanishing_net.py", line 24, in __init__
    self.ht = HT_CUDA(vote_mapping_dict=vote_ht_dict)
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\vpd\models\ht\ht_cuda.py", line 36, in __init__
    self.ht = IM2HT(im_size=self.im_size, ht_size=self.ht_size, vote_mapping=vote_mapping)
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\vpd\models\ht\im2ht.py", line 90, in __init__
    im2ht = load_cpp_ext("im2ht")
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\vpd\models\ht\im2ht.py", line 23, in load_cpp_ext
    ext = load(
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\utils\cpp_extension.py", line 1202, in load
    return _jit_compile(
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\utils\cpp_extension.py", line 1425, in _jit_compile
    _write_ninja_file_and_build_library(
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\utils\cpp_extension.py", line 1524, in _write_ninja_file_and_build_library
    _write_ninja_file_to_build_library(
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\utils\cpp_extension.py", line 1963, in _write_ninja_file_to_build_library
    _write_ninja_file(
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\utils\cpp_extension.py", line 2090, in _write_ninja_file
    cl_paths = subprocess.check_output(['where',
  File "D:\KAUST\projects\datasets\street_sings\env\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "D:\KAUST\projects\datasets\street_sings\env\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1.

(D:\KAUST\projects\datasets\street_sings\env) D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere>

Could you please help me to solve the error. Thanks

yanconglin commented 2 years ago

that is strange. first time seeing this error. I am also clueless...

Are these two links from Pytorch forum helpful? link1 and link2.

premchedella commented 2 years ago

Thanks for the links. It seems conda environment is not able to find cl.exe in it's path. I am using Windows work station. Let me figure it out.

premchedella commented 2 years ago

I was able to solve the subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1. by adding cl.exe to the system path in the windows. For example set PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64

I am able to run the demo.py with the example_yud.jpg file.

With .png file, I am getting the run-time error.

(D:\KAUST\projects\datasets\street_sings\env) D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere>python demo.py -d 0 config\nyu.yaml checkpoints\nyu\checkpoint_latest.pth.tar example_yud.jpg
<Box: {'io': {'logdir': 'logs/', 'resume_from': None, 'dataset': 'NYU', 'datadir': 'dataset/nyu_vp/processed_data', 'ht_mapping': 'parameterization/nyu/ht_240_320_403_180.npz', 'sphere_mapping': 'parameterization/nyu/sphere_neighbors_403_180_32768.npz', 'focal_length': 1.0, 'num_neighbors': 20, 'num_vpts': None, 'num_nodes': 32768, 'percentage': 1, 'num_workers': 2}, 'model': {'batch_size': 3, 'backbone': 'stacked_hourglass', 'depth': 4, 'num_stacks': 1, 'num_blocks': 1, 'lpos': 1.0, 'lneg': 1.0, 'num_channels': 64, 'im2col_step': 32}, 'optim': {'name': 'Adam', 'lr': 0.0004, 'amsgrad': True, 'weight_decay': 1e-05, 'max_epoch': 36, 'lr_decay_epoch': 24}}>
Let's use 1 GPU(s)!
kth, device name 0 NVIDIA TITAN Xp
vote_ht_dict  memory MB torch.Size([13824000, 3]) 158.203125
vote_sphere_dict  memory MB 32768 torch.Size([17134246, 3]) 196.08588409423828
#################### im2ht compiling ############################
#################### done! ############################
#################### ht2im compiling ############################
#################### done! ############################
#################### ht2sphere compiling ############################
#################### done! ############################
############# MultiscaleRadiusGraph ######################################
args["<checkpoint>"] checkpoints\nyu\checkpoint_latest.pth.tar
checkpoint 29376 35
num of total parameters 7997443
num of trainable parameters 6686723
processing:  example_yud.jpg
D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\sklearn\neighbors\_base.py:199: EfficiencyWarning: Precomputed sparse input was not sorted by data.
  warnings.warn(

(D:\KAUST\projects\datasets\street_sings\env) D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere>python demo.py -d 0 config\nyu.yaml checkpoints\nyu\checkpoint_latest.pth.tar image_10.png
<Box: {'io': {'logdir': 'logs/', 'resume_from': None, 'dataset': 'NYU', 'datadir': 'dataset/nyu_vp/processed_data', 'ht_mapping': 'parameterization/nyu/ht_240_320_403_180.npz', 'sphere_mapping': 'parameterization/nyu/sphere_neighbors_403_180_32768.npz', 'focal_length': 1.0, 'num_neighbors': 20, 'num_vpts': None, 'num_nodes': 32768, 'percentage': 1, 'num_workers': 2}, 'model': {'batch_size': 3, 'backbone': 'stacked_hourglass', 'depth': 4, 'num_stacks': 1, 'num_blocks': 1, 'lpos': 1.0, 'lneg': 1.0, 'num_channels': 64, 'im2col_step': 32}, 'optim': {'name': 'Adam', 'lr': 0.0004, 'amsgrad': True, 'weight_decay': 1e-05, 'max_epoch': 36, 'lr_decay_epoch': 24}}>
Let's use 1 GPU(s)!
kth, device name 0 NVIDIA TITAN Xp
vote_ht_dict  memory MB torch.Size([13824000, 3]) 158.203125
vote_sphere_dict  memory MB 32768 torch.Size([17134246, 3]) 196.08588409423828
#################### im2ht compiling ############################
#################### done! ############################
#################### ht2im compiling ############################
#################### done! ############################
#################### ht2sphere compiling ############################
#################### done! ############################
############# MultiscaleRadiusGraph ######################################
args["<checkpoint>"] checkpoints\nyu\checkpoint_latest.pth.tar
checkpoint 29376 35
num of total parameters 7997443
num of trainable parameters 6686723
processing:  image_10.png
warning: images resized to [480, 640]!
Traceback (most recent call last):
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\demo.py", line 253, in <module>
    main()
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\demo.py", line 211, in main
    result = model(input_dict)
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\parallel\data_parallel.py", line 166, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\vpd\models\vanishing_net.py", line 36, in forward
    x = self.backbone(image)[0]
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\KAUST\projects\datasets\street_sings\VanishingPoint_HoughTransform_GaussianSphere\vpd\models\hourglass_pose.py", line 177, in forward
    x = self.conv1(x)
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\modules\conv.py", line 457, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "D:\KAUST\projects\datasets\street_sings\env\lib\site-packages\torch\nn\modules\conv.py", line 453, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[1, 4, 480, 640] to have 3 channels, but got 4 channels instead

image_10

Is demo.py works only with .jpg file?

yanconglin commented 2 years ago

input is expected to be RGB. It seems your input has 4 channels.

premchedella commented 2 years ago

input is expected to be RGB. It seems your input has 4 channels.

Yes, I do agree with you. PNG file has 4 channels where as JPG has 3 channels. With the JPG file, it works.

You can close this issue. Thanks for the support.