isl-org / isl-org/Open3D-ML

Error plotting custom data with np.uint8 dtype

Open
#671 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
2.3k
Forks
365
Avg merge
4h 6m
Merged PRs (30d)
1

Description

### Checklist

- [x] I have searched for [similar issues](https://github.com/isl-org/Open3D-ML/issues).
- [x] I have tested with the [latest development wheel](http://www.open3d.org/docs/latest/getting_started.html#development-version-pip).
- [x] I have checked the [release documentation](http://www.open3d.org/docs/release/) and the [latest documentation](http://www.open3d.org/docs/latest/) (for `main` branch).

### Describe the issue

When I try to plot a custom point cloud data with an additional attribute (`classes` attribute) with `np.uint8` dtype, all my labels wrongly turn to zero. When using with the dtype `np.int64`, the plot works fine.

### Steps to reproduce the bug

```python
import numpy as np
import open3d.ml.torch as ml3d

# Correct
data = [
{
'name': 'test',
'points': np.array([
[0, 0, 0],
[0.1, 0, 0], [0.1, 0.1, 0],
[0.2, 0, 0], [0.2, 0.1, 0], [0.2, 0.2, 0]
]),
'classes': np.array([
1,
0, 0,
2, 2, 2
], dtype=np.int64)
}
]

lut = ml3d.vis.LabelLUT()
lut.add_label('zero', 0, [1, 0, 0])
lut.add_label('one', 1, [0, 1, 0])
lut.add_label('two', 2, [0, 0, 1])

vis = ml3d.vis.Visualizer()
vis.set_lut("classes", lut)

vis.visualize(data)

# Wrong
data = [
{
'name': 'test',
'points': np.array([
[0, 0, 0],
[0.1, 0, 0], [0.1, 0.1, 0],
[0.2, 0, 0], [0.2, 0.1, 0], [0.2, 0.2, 0]
]),
'classes': np.array([
1,
0, 0,
2, 2, 2
], dtype=np.uint8)
}
]

lut = ml3d.vis.LabelLUT()
lut.add_label('zero', 0, [1, 0, 0])
lut.add_label('one', 1, [0, 1, 0])
lut.add_label('two', 2, [0, 0, 1])

vis = ml3d.vis.Visualizer()
vis.set_lut("classes", lut)

vis.visualize(data)
```

### Error message

Using `np.uint8`, the plot is:

![Image](https://github.com/user-attachments/assets/df7a653e-9536-49ce-80d9-9b6d32dfb1d8)

Where all points are wrongly in the classe zero (`red`)

### Expected behavior

Its expected the plot with `np.uint8` to be the same of the plot with `np.int64`. The result of the `np.int64` is given bellow:

![Image](https://github.com/user-attachments/assets/6729b4ef-2d3d-4885-a94d-c13596b0cadf)

### Open3D, Python and System information

```markdown
- Operating system: Windows 11 (WSL Ubuntu 24.01)
- Python version: Python 3.12.3
- Open3D version: 0.19.0
- System type: x86_64
- Is this remote workstation?: no
- How did you install Open3D?: pip (with venv)
```

### Additional information

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.