chenhsuanlin / photometric-mesh-optim

Photometric Mesh Optimization for Video-Aligned 3D Object Reconstruction :globe_with_meridians: (CVPR 2019)
MIT License
208 stars 25 forks source link

model.py: Bool cast Runtime Error #9

Closed ErnieLud closed 3 years ago

ErnieLud commented 3 years ago

Hi, I am trying to run the code but I get this error in line 113 (model.py) "RuntimeError: result type Byte can't be cast to the desired output type Bool" I am using your pretrained model for airplane and downloaded the ground-truth point clouds from AtlasNet v2.2 repository (since it has been greatly refactored recently). When I change the valid_mask cast from .byte() to .bool() in line 110 I don't get any RuntimeError running the code. But the video reconstruction seems to get corrupted, since the last 27 frames won't render and I am not able to open the mp4 file at all (I have to use Blender to visualize the frames).

Here's the full output if it helps:

======================================================= main.py (photometric mesh optimization)

setting configurations... H : 224 W : 224 aug_transl : None avg_frame : False batch_size : 32 batch_size_pmo : -1 category : 02691156 code : 0.05 cpu : False device : cuda:1 eval : False from_epoch : 0 gpu : 1 group : 0 imagenet_enc : False init_idx : 27 load : pretrained/oryysitkhn2eldgb90qkr3lh7j469sj1.npz log_tb : False log_visdom : False lr_decay : 1.0 lr_pmo : 0.003 lr_pretrain : 0.0001 lr_step : 100 name : debug_seed0 noise : 0.1 num_meshgrid : 5 num_points : 100 num_points_all : 2500 num_prim : 25 num_workers : 8 pointcloud_path : data/customShapeNet pretrained_dec : None rendering_path : data/rendering scale : 0.02 seed : 0 seq_path : data/sequences sfm : False size : 224x224 sphere : False sphere_densify : 3 sun360_path : data/background to_epoch : 500 to_it : 100 video : True vis_port : 8097 vis_server : http://localhost

reading list of sequences... number of sequences: 1 building AtlasNet... loading checkpoint pretrained/oryysitkhn2eldgb90qkr3lh7j469sj1.npz... ======= OPTIMIZATION START ======= loading sequence... reading RGB .npy file... reading ground-truth camera .npz file... noise -- scale: -0.0925, rot: [0.0181,-0.0552,0.0924], trans: [0.2544,-0.0716,-0.0493] /home/esumoso/PMO/lib/python3.6/site-packages/torch/nn/functional.py:3384: 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("Default grid_sample and affine_grid behavior has changed " Traceback (most recent call last): File "main.py", line 31, in pmo.optimize(opt) File "/data/esumoso/photometric-mesh-optim/model.py", line 185, in optimize loss = self.compute_loss(opt,var) File "/data/esumoso/photometric-mesh-optim/model.py", line 75, in compute_loss loss.photom += self.compute_photometric_loss_batch(opt,var,idx_a,idx_b) File "/data/esumoso/photometric-mesh-optim/model.py", line 113, in compute_photometric_loss_batch valid_mask RuntimeError: result type Byte can't be cast to the desired output type Bool

chenhsuanlin commented 3 years ago

It probably doesn't have anything to do with AtlasNet, but rather something with type casting. Could you try changing this line to just: mask_map = index_map!=-1 (without the float casting)? I had to use byte tensors because Pytorch didn't use to support boolean tensors when I wrote the code. If this fixes your issue, I can update the repo for the newer Pytorch versions. Thanks!

ErnieLud commented 3 years ago

Hi, thank you for quick response. I changed the line but unfortunately I'm getting the same output

chenhsuanlin commented 3 years ago

I tried rerunning the code on my side (byte() changed to bool()) and could reproduce with no problem. Could you please elaborate exactly what errors you were getting, or was the program able to exit normally? If you were able to visualize with Blender but have trouble with the .mp4 video output, then it's probably an issue with the video output or codec (I was able to open the output video with at least Google Chrome); if that's the case, you might need to make some modifications in this function.