Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: cannot reshape array of size 0 into shape #43

Open
kaixin-bai opened this issue Nov 18, 2024 · 1 comment
Open

ValueError: cannot reshape array of size 0 into shape #43

kaixin-bai opened this issue Nov 18, 2024 · 1 comment

Comments

@kaixin-bai
Copy link

while import 3dgs file, i got error below:

Traceback (most recent call last):
  File "/home/kb/.config/blender/4.2/scripts/addons/blender-addon/__init__.py", line 80, in execute
    features_extra = features_extra.reshape((N, 3, 15))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot reshape array of size 0 into shape (36426,3,15)

I also upload my ply file here, hopefully could solve this problem.

3dgs_tum_dataset.zip

@kaixin-bai
Copy link
Author

kaixin-bai commented Nov 18, 2024

I checked the file, and find that the problem is because that there's no attribute name start with "f_test_", the testing code is below:

        extra_f_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("f_rest_")]
        extra_f_names = sorted(extra_f_names, key = lambda x: int(x.split('_')[-1]))
        
        features_extra = np.zeros((N, len(extra_f_names)))
        for idx, attr_name in enumerate(extra_f_names):
            features_extra[:, idx] = np.asarray(plydata.elements[0][attr_name])
        features_extra = features_extra.reshape((N, 3, 15))
In [2]: from plyfile import PlyData, PlyElement

In [3]: filepath = "/home/kb/Downloads/3dgs_tum_dataset.ply"

In [4]: plydata = PlyData.read(filepath)

In [5]: import numpy as np

In [6]: np.asarray(plydata.elements[0]["x"])
Out[6]: 
array([-0.1656777 , -1.6436013 , -0.7537645 , ...,  0.44135675,
       -0.61030936, -0.46284845], dtype=float32)

In [7]: extra_f_names = [p.name for p in plydata.elements[0].properties if p.name.startswith("f_rest_")]

In [8]: extra_f_names = sorted(extra_f_names, key = lambda x: int(x.split('_')[-1]))

In [9]: extra_f_names
Out[9]: []

In [10]: plydata.elements[0].properties
Out[10]: 
(PlyProperty('x', 'float'),
 PlyProperty('y', 'float'),
 PlyProperty('z', 'float'),
 PlyProperty('nx', 'float'),
 PlyProperty('ny', 'float'),
 PlyProperty('nz', 'float'),
 PlyProperty('f_dc_0', 'float'),
 PlyProperty('f_dc_1', 'float'),
 PlyProperty('f_dc_2', 'float'),
 PlyProperty('opacity', 'float'),
 PlyProperty('scale_0', 'float'),
 PlyProperty('scale_1', 'float'),
 PlyProperty('scale_2', 'float'),
 PlyProperty('rot_0', 'float'),
 PlyProperty('rot_1', 'float'),
 PlyProperty('rot_2', 'float'),
 PlyProperty('rot_3', 'float'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant