Skip to content

Commit

Permalink
Version 0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Yarroudh committed Nov 27, 2023
1 parent 8a26e7d commit 5ea45a5
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 106 deletions.
15 changes: 0 additions & 15 deletions .readthedocs.yaml

This file was deleted.

12 changes: 8 additions & 4 deletions docs/module.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ bibliography: paper.bib

`Segment-Lidar` is a Python package for automatic unsupervised segmentation of aerial LiDAR data. It proposes an image-based approach for segmenting aerial point clouds using `Segment-Anthing Model (SAM)` package from [Meta AI](https://github.com/facebookresearch).

The API provides functions and classes to define the segmentation model and its parameters, and also to handle transformation between 3D point clouds and images. The package also relies on other dependencies that make use of `SAM`. This includes the `Segment-Geospatial` package from [Open Geospatial Solutions](https://github.com/opengeos) for segmenting geospatial data and the `Grounded-SAM` package from [The International Digital Economy Academy Research (IDEA-Research)](https://github.com/IDEA-Research) that combines `SAM` with `Grounding DINO` to detect and segment anything with text prompts.

For optimization purposes, `Segment-Lidar` enables using `Fast Segment Anything Model (FastSAM)` as an alternative to `SAM` original API. The `FastSAM` is a Convolutional Neural Network (CNN) `SAM` that was trained using only 2% of the `SA-1B` dataset published by `SAM` authors. It achieves comparable performance at 50x higher run-time speed.
The API provides functions and classes to define the segmentation model and its parameters, and also to handle transformation between 3D point clouds and images. The package also relies on another dependency that make use of `SAM`, which is `Segment-Geospatial` package from [Open Geospatial Solutions](https://github.com/opengeos) for segmenting geospatial data. It also makes use of `Grounding DINO` from [The International Digital Economy Academy Research (IDEA-Research)](https://github.com/IDEA-Research) to detect and segment the 3D point cloud with text prompts.

# Statement of need

Expand All @@ -40,9 +38,7 @@ One approach for point cloud learning is to use deep neural networks. Deep learn

The Segment Anything Model (SAM) is one of the most popular image segmentation models that was released recently. The model was introduced by @kirillov:2023 as a part of the Segment Anything (SA) project and has three components: an image encoder, a flexible prompt encoder and a fast mask decoder. It was trained on SA-1B dataset that consists of 11 millions licensed and privacy respecting images and 1.1 billion high-quality segmentation masks.

Due to its zero-shot performance, SAM served as the foundation for the development of many other packages. `Segment-Geospatial` is one of these packages that was designed to segment geospatial data using Segment Anything Model [@wu:2023]. `Grounded-SAM` is another package that combines `Grounding DINO` [@liu:2023] with `Segment Anythin Model` to automatically detect and segment images using text prompts.

Other implementations focused on reducing the computation costs of SAM that prevent it from wider industry applications. @zhao:2023 introduced `Fast Segment Anything` as a speed-up alternative method for the fundamental task of SAM with comparable performance at 50 times higher run-time speed.
Due to its zero-shot performance, SAM served as the foundation for the development of many other packages. `Segment-Geospatial` is one of these packages that was designed to segment geospatial data using Segment Anything Model [@wu:2023]. `Grounded-SAM` is another package that combines `Grounding DINO` [@liu:2023] with `Segment Anything Model` to automatically detect and segment images using text prompts.

Regarding our work, we propose `Segment-Lidar` as an open-source Python package for automatic unsupervised 3D LiDAR-segmentation using Segment Anything Model (SAM) and other dependencies that make use of it.

Expand Down
Binary file removed segment_lidar/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file removed segment_lidar/__pycache__/samlidar.cpython-39.pyc
Binary file not shown.
Binary file removed segment_lidar/__pycache__/view.cpython-39.pyc
Binary file not shown.
223 changes: 148 additions & 75 deletions segment_lidar/samlidar.py

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions segment_lidar/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def __init__(self) -> None:
"""
pass


def cloud_to_image(self, points: np.ndarray, resolution: float) -> np.ndarray:
"""
Converts a point cloud to a planar image.
Expand Down Expand Up @@ -100,7 +99,7 @@ def image_to_cloud(self, points: np.ndarray, image: np.ndarray, resolution: floa
unique_values = {}
image = np.asarray(image)

for point in points:
for i, point in enumerate(points):
x, y, z, *_ = point

pixel_x = int((x - minx) / resolution)
Expand All @@ -117,6 +116,7 @@ def image_to_cloud(self, points: np.ndarray, image: np.ndarray, resolution: floa

id = unique_values[rgb]
segment_ids.append(id)

return segment_ids


Expand Down Expand Up @@ -239,8 +239,10 @@ def cloud_to_image(self, points: np.ndarray, resolution: float = 0.1, rotation:
dir_path = os.getcwd()
files = os.listdir(dir_path)
files = [file for file in files if file.startswith('Screen')]
image_path = [file for file in files if file.endswith('.png')][0]
camera_path = [file for file in files if file.endswith('.json')][0]
image_path = [file for file in files if file.endswith('.png')]
image_path = sorted(image_path, reverse=True)[0]
camera_path = [file for file in files if file.endswith('.json')]
camera_path = sorted(camera_path, reverse=True)[0]

# Load the image
image = cv2.imread(image_path)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def run(self):

setup(
name="segment-lidar",
version='0.2.0',
version='0.2.1',
description="A package for segmenting LiDAR data using Segment-Anything Model (SAM) from Meta AI Research.",
long_description=open('README.md', encoding='utf-8').read(),
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 5ea45a5

Please sign in to comment.