clinplayer / Point2Skeleton

Point2Skeleton: Learning Skeletal Representations from Point Clouds (CVPR2021)
MIT License
206 stars 38 forks source link

TypeError: 'str' object cannot be interpreted as an integer #9

Closed yicheng6o6 closed 2 years ago

yicheng6o6 commented 2 years ago

When I run python test.py... I met: GPU Number: 1 GPUs! Traceback (most recent call last): File "test.py", line 103, in for iter, batch_data in enumerate(data_loader): File "/home/dodo/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 517, in next data = self._next_data() File "/home/dodo/.local/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "/home/dodo/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/dodo/.local/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/dodo/Point2Skeleton/code/DataUtil.py", line 17, in getitem data_pc = rw.load_ply_points(self.data_folder + self.data_id[index] + '.ply', expected_point=self.point_num) File "/home/dodo/Point2Skeleton/code/FileRW.py", line 167, in load_ply_points pts = np.zeros((expected_point, 3), np.float64) TypeError: 'str' object cannot be interpreted as an integer

May i have your suggestions to fix this problem?

Best wishes, Yicheng

clinplayer commented 2 years ago

Hi, I think this is because of the implementation of the PLY loader. I simply assume the input PLY files are in Unicode format with fixed header information while your PLY may have different headers. You can re-write the function load_ply_points(pc_filepath, expected_point=2000) defined in FileRW.py based on your PLY header information. Just make sure this function returns an N*3 NumPy array (N is fixed) that stores xyz point locations.

For your reference, here is a general PLY loader: https://github.com/dranjan/python-plyfile

trung6 commented 2 years ago

Hi, I encountered the same problem. I just used the data you provided here https://github.com/clinplayer/Point2Skeleton/tree/master/data

trung6 commented 2 years ago

The problem disappears if I run python test.py instead of python test.py --pc_list_file ../data/data-split/all-test.txt --data_root ../data/pointclouds/ --point_num 2000 --skelpoint_num 100 --gpu 0 --load_skelnet_path ../weights/weights-skelpoint.pth --load_gae_path ../weights/weights-gae.pth --save_result_path ../results/

clinplayer commented 2 years ago

The problem disappears if I run python test.py instead of python test.py --pc_list_file ../data/data-split/all-test.txt --data_root ../data/pointclouds/ --point_num 2000 --skelpoint_num 100 --gpu 0 --load_skelnet_path ../weights/weights-skelpoint.pth --load_gae_path ../weights/weights-gae.pth --save_result_path ../results/

Hey, could you explain your problem more clearly? Did you mean it worked if you run the later full command?

trung6 commented 2 years ago

No, it worked if I run python test.py.

yicheng6o6 commented 2 years ago

Hi, @clinplayer Thank you very much for your reply:)

I'm wondering how to check header information? I use ros to record point cloud into a rosbag file, so I may need convert it into PLY format.

I can replay my bag files and use rostopic echo to check some information, but I don't know how to check PLY files.

May i have your suggestions? Any help is much appreciated:)

yicheng6o6 commented 2 years ago

Hi, @trung6 Thank you very much for your reply:)

Yes, it worked if I run python test.py only, but I don’t know why.

brian220 commented 2 years ago

Hi, @yicheng6o6 I found out why this happened. In test.py line 22, Just changing the type of argument --point_num from str to int can solve the type error.

clinplayer commented 2 years ago

Hi, @yicheng6o6 I found out why this happened. In test.py line 22, Just changing the type of argument --point_num from str to int can solve the type error.

Thanks for pointing out this issue! Now it is fixed. Thanks! @brian220