drprojects / superpoint_transformer

Official PyTorch implementation of Superpoint Transformer introduced in [ICCV'23] "Efficient 3D Semantic Segmentation with Superpoint Transformer" and SuperCluster introduced in [3DV'24 Oral] "Scalable 3D Panoptic Segmentation As Superpoint Graph Clustering"
MIT License
545 stars 71 forks source link

nag.select().save() RuntimeError #42

Closed hpc100 closed 9 months ago

hpc100 commented 10 months ago

Hi,

I use Nag.select() and I try to save it. I get this :

Code :

Value of hierarchy :

Terminal output : image

Any ideas ?

drprojects commented 9 months ago

Hi @hpc100 have you solved this issue ?

Maybe a tensor shape error arises because you are indexing only a single element from the $P_3$ level. Can you try, for the sake of debugging:

nag.select(3, [0, 1, 2]).save( path_to_save_file + '.h5')

and

nag.select(3, [0]).save( path_to_save_file + '.h5')
hpc100 commented 9 months ago

No, I try and both and get same error :

Traceback (most recent call last): File "", line 1, in File "superpoint_transformer/src/data/nag.py", line 236, in save data.save( File "superpoint_transformer/src/data/data.py", line 586, in save save_tensor(val, f, k, fp_dtype=fp_dtype) File "superpoint_transformer/src/utils/io.py", line 53, in save_tensor d = cast_numpyfy(x, fp_dtype=fp_dtype) File "superpoint_transformer/src/utils/tensor.py", line 185, in cast_numpyfy return numpyfy(cast_to_optimal_integer_type(a)) File "superpoint_transformer/src/utils/tensor.py", line 163, in cast_to_optimal_integer_type low_enough = torch.iinfo(dtype).min <= a.min() RuntimeError: min(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the 'dim' argument.

drprojects commented 9 months ago

You need to further investigate which partition level and which data attributes cause errors. Suggestions:

add here

print(f'partition {i_level}')

and add here

print(f'key {k}: {val.shape}')
hpc100 commented 9 months ago

Thank's for your response. Print results :

partition 0 key edge_index: torch.Size([2, 35555]) key super_index: torch.Size([6533]) key x: torch.Size([6533, 5]) key edge_attr: torch.Size([35555]) key elevation: torch.Size([6533, 1]) key label: torch.Size([6533]) key linearity: torch.Size([6533, 1]) key node_size: torch.Size([6533]) key planarity: torch.Size([6533, 1]) key scattering: torch.Size([6533, 1]) key verticality: torch.Size([6533, 1]) partition 1 key edge_index: torch.Size([2, 3022]) key super_index: torch.Size([313]) key x: torch.Size([313, 5]) key edge_attr: torch.Size([3022, 7]) key log_length: torch.Size([313, 1]) key log_size: torch.Size([313, 1]) key log_surface: torch.Size([313, 1]) key log_volume: torch.Size([313, 1]) key node_size: torch.Size([313]) key normal: torch.Size([313, 3]) partition 2 key edge_index: torch.Size([2, 790]) key super_index: torch.Size([113]) key x: torch.Size([113, 5]) key edge_attr: torch.Size([790, 7]) key log_length: torch.Size([113, 1]) key log_size: torch.Size([113, 1]) key log_surface: torch.Size([113, 1]) key log_volume: torch.Size([113, 1]) key node_size: torch.Size([113]) key normal: torch.Size([113, 3]) partition 3 key edge_index: torch.Size([2, 0]) Traceback (most recent call last): File "", line 1, in File "superpoint_transformer/src/data/nag.py", line 236, in save data.save( File "superpoint_transformer/src/data/data.py", line 586, in save save_tensor(val, f, k, fp_dtype=fp_dtype) File "superpoint_transformer/src/utils/io.py", line 53, in save_tensor d = cast_numpyfy(x, fp_dtype=fp_dtype) File "superpoint_transformer/src/utils/tensor.py", line 185, in cast_numpyfy return numpyfy(cast_to_optimal_integer_type(a)) File "superpoint_transformer/src/utils/tensor.py", line 163, in cast_to_optimal_integer_type low_enough = torch.iinfo(dtype).min <= a.min() RuntimeError: min(): Expected reduction dim to be specified for input.numel() == 0. Specify the reduction dim with the 'dim' argument.

it just seems like there aren't enough points. nag.select(3, [0,1,2,3]).save('try.h5') works !

Thank's

drprojects commented 9 months ago

The error comes from the fact that your indexing operation only keeps a single element of $P_3$. As a result, the corresponding superpoint graph is empty (i.e. nag[3].edge_index is of shape (2, 0)).

I just pushed a commit addressing this issue. Can you please update your code and try again ?

hpc100 commented 9 months ago

I updated the code. And I managed to save and reload the nag without problems. Thank's

drprojects commented 9 months ago

Awesome ! I will close this issue then, thanks for the feedback