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

IDTReeS: remove support for plotting lidar point cloud #2428

Merged
merged 1 commit into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ jobs:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ runner.arch }}-Python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements/required.txt', 'requirements/datasets.txt', 'requirements/tests.txt') }}
if: ${{ runner.os != 'macOS' }}
- name: Setup headless display for pyvista
uses: pyvista/setup-headless-display-action@v3
- name: Install pip dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down Expand Up @@ -68,8 +66,6 @@ jobs:
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-${{ runner.arch }}-Python-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements/min-reqs.old') }}
- name: Setup headless display for pyvista
uses: pyvista/setup-headless-display-action@v3
- name: Install pip dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ repos:
- numpy>=1.22
- pillow>=10.4.0
- pytest>=6.1.2
- pyvista>=0.34.2
- scikit-image>=0.22.0
- torch>=2.3
- torchmetrics>=0.10
Expand Down
1 change: 0 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
'numpy': ('https://numpy.org/doc/stable/', None),
'python': ('https://docs.python.org/3', None),
'lightning': ('https://lightning.ai/docs/pytorch/stable/', None),
'pyvista': ('https://docs.pyvista.org/version/stable/', None),
'rasterio': ('https://rasterio.readthedocs.io/en/stable/', None),
'rtree': ('https://rtree.readthedocs.io/en/stable/', None),
'segmentation_models_pytorch': ('https://smp.readthedocs.io/en/stable/', None),
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ datasets = [
"pandas[parquet]>=2",
# pycocotools 2.0.7+ required for wheels
"pycocotools>=2.0.7",
# pyvista 0.34.2+ required to avoid ImportError in CI
"pyvista>=0.34.2",
# scikit-image 0.19+ required for Python 3.10 wheels
"scikit-image>=0.19",
# scipy 1.7.2+ required for Python 3.10 wheels
Expand Down
1 change: 0 additions & 1 deletion requirements/datasets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ laspy==2.5.4
opencv-python==4.10.0.84
pandas[parquet]==2.2.3
pycocotools==2.0.8
pyvista==0.44.2
scikit-image==0.25.0
scipy==1.15.0
2 changes: 0 additions & 2 deletions requirements/min-reqs.old
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ laspy==2.0.0
opencv-python==4.5.4.58
pycocotools==2.0.7
pyarrow==15.0.0 # Remove when we upgrade min version of pandas to `pandas[parquet]>=2`
pyvista==0.34.2
scikit-image==0.19.0
scipy==1.7.2
vtk==9.3.1 # PyVista is not yet compatible with VTK 9.4+

# tests
pytest==7.3.0
Expand Down
8 changes: 0 additions & 8 deletions tests/datasets/test_idtrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,3 @@ def test_plot(self, dataset: IDTReeS) -> None:
x['prediction_label'] = x['label']
dataset.plot(x, show_titles=False)
plt.close()

def test_plot_las(self, dataset: IDTReeS) -> None:
pyvista = pytest.importorskip('pyvista', minversion='0.34.2')
pyvista.OFF_SCREEN = True

# Test point cloud without colors
point_cloud = dataset.plot_las(index=0)
pyvista.plot(point_cloud, scalars=point_cloud.points, cpos='yz', cmap='viridis')
36 changes: 1 addition & 35 deletions torchgeo/datasets/idtrees.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ class IDTReeS(NonGeoDataset):

* https://doi.org/10.1101/2021.08.06.453503

This dataset requires the following additional libraries to be installed:
This dataset requires the following additional library to be installed:

* `laspy <https://pypi.org/project/laspy/>`_ to read lidar point clouds
* `pyvista <https://pypi.org/project/pyvista/>`_ to plot lidar point clouds

.. versionadded:: 0.2
"""
Expand Down Expand Up @@ -552,36 +551,3 @@ def normalize(x: Tensor) -> Tensor:
plt.suptitle(suptitle)

return fig

def plot_las(self, index: int) -> 'pyvista.Plotter': # type: ignore[name-defined] # noqa: F821
"""Plot a sample point cloud at the index.

Args:
index: index to plot

Returns:
pyvista.PolyData object. Run pyvista.plot(point_cloud, ...) to display

Raises:
DependencyNotFoundError: If laspy or pyvista are not installed.

.. versionchanged:: 0.4
Ported from Open3D to PyVista, *colormap* parameter removed.
"""
laspy = lazy_import('laspy')
pyvista = lazy_import('pyvista')
path = self.images[index]
path = path.replace('RGB', 'LAS').replace('.tif', '.las')
las = laspy.read(path)
points: np.typing.NDArray[np.int_] = np.stack(
[las.x, las.y, las.z], axis=0
).transpose((1, 0))
point_cloud = pyvista.PolyData(points)

# Some point cloud files have no color->points mapping
if hasattr(las, 'red'):
colors = np.stack([las.red, las.green, las.blue], axis=0)
colors = colors.transpose((1, 0)) / np.iinfo(np.uint16).max
point_cloud['colors'] = colors

return point_cloud
Loading