My name is Anass Yarroudh. I'm a Reasearch Engineer at the Geomatics Unit of University of Liege. This is my Github profile where you can find all my source code projects and repositories.
- 📫 How to reach me: [email protected]
Python package for segmenting LiDAR data using Segment-Anything Model (SAM) from Meta AI.
Home Page: https://yarroudh.github.io/segment-lidar/
License: BSD 3-Clause "New" or "Revised" License
My name is Anass Yarroudh. I'm a Reasearch Engineer at the Geomatics Unit of University of Liege. This is my Github profile where you can find all my source code projects and repositories.
Can I use this for my real-time lidar pointcloud data in the format of *.pcd? How? Thanks for your reply!
The following error occurs while writing the segmented point cloud :
Hi, appreciate if you could provide few sample data to test this package
hi there Yarroudh,
Can you please help me understand where should I retrieve: raster.tif and labels.tif related to the pointcloud.las example given, in order to run one of the lines from the tutorial.
labels, *_ = model.segment(points=points, view=viewpoint, image_path="raster.tif", labels_path="labeled.tif")
model.write(points=points, segment_ids=labels, save_path="segmented.las")
thank you so much
Hi, thanks for the great work. Is there a way to save each segmented object/instance as a separate point cloud file? Thank you.
labels, *_ = model.segment(points=points, view=view, image_path="raster.tif", labels_path="labeled.tif")
the view = view should be view = viewpoint which is defined above.
to run the example one needs CSF, but you don't specify it as a requirement:
this seems to be the good one? pip install cloth-simulation-filter
?
Hello,
Thank you for releasing this repository. I face this error when I tried to install it on pycharm.
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
segment-lidar 0.2.1 requires supervision==0.8.0, but you have supervision 0.6.0 which is incompatible.
[notice] A new release of pip is available: 23.2.1 -> 24.1.1
[notice] To update, run: python.exe -m pip install --upgrade pip
I would appreciate it if you please help me.
While im trying to run the segment anything workflow. I ran into some issues.
TypeError: unhashable type: 'numpy.ndarray'
while trying to run the image_to_cloud function in the line :
if rgb not in unique_values:
my solution was rgb=tuple(rgb)
.
Another issue i was running into is when rearraring the array that rasterio returns when reading a tif.
image_rgb = image_rgb.reshape((image_rgb.shape[1], image_rgb.shape[2], image_rgb.shape[0]))
instead i use:
image_rgb = np.transpose(image_rgb, (1, 2, 0))
And finally in the part of the segment method:
with rasterio.open(labels_path, 'r') as src:
segmented_image = src.read()
segmented_image = np.squeeze(segmented_image)
print(f'- Generating segment IDs...')
segment_ids = image_to_cloud(points, minx, maxy, segmented_image, self.resolution)
end = time.time()
the error was that most of the points didnt pass the if stament:
if not (0 <= pixel_x < image.shape[1]) or not (0 <= pixel_y < image.shape[0]):
because rasterio arrange width, height,bands different than the classic.
so i use
with rasterio.open(labels_path, 'r') as src:
segmented_image = src.read()
segmented_image = np.squeeze(segmented_image)
segmented_image=np.transpose(segmented_image, (1, 2, 0))
print(f'- Generating segment IDs...')
segment_ids = image_to_cloud(points, minx, maxy, segmented_image, self.resolution)
end = time.time()
hi, thanks for publishing this cool packages.
But, I am having issue with CSF module not being found in the docker image of segment-lidar.
`fw@w-Crosshair-15-A11UCK:~/lidar_segmentation$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
01cf113224e7 yarroudh/segment-lidar "python -c 'while Tr…" About an hour ago Up About an hour priceless_wu
w@w-Crosshair-15-A11UCK:~/lidar_segmentation$ docker exec 01cf113224e7 python segment.py
Traceback (most recent call last):
File "segment.py", line 1, in
from segment_lidar import samlidar, view
File "/opt/conda/lib/python3.8/site-packages/segment_lidar/samlidar.py", line 6, in
import CSF
ModuleNotFoundError: No module named 'CSF'
`
I also installed CSF inside the docker, but still CSF is not found.
Request : Ability to import & segment the new VPC format!
https://www.lutraconsulting.co.uk/blog/2023/06/08/virtual-point-clouds/
It seems so since you rasterise and SAM is I believe using this, but this not clear.
You mention in the tutorial that AHN4 is used, but there is no RGB provided with AHN4?! Unless you download from geotiles.nl where RGB has been added (but derived product, not the original one).
So: can it work without RGB values? I tried and I get not very good results...
Hi I install the package as given in the guide.
ImportError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from segment_lidar import samlidar
ImportError: cannot import name 'samlidar' from 'segment_lidar' (/Users/sanjij/anaconda3/envs/geospatial_demo/lib/python3.9/site-packages/segment_lidar/init.py)
please help
Hi Anass Yarroudh,
Congrats for pulling out this work! Amazing.
I was following this installation tutorial here, and when I run the following command on linux terminal (debian):
python -c "import segment_lidar; print(segment_lidar.version)"
I always get:
Traceback (most recent call last):
File "", line 1, in
AttributeError: module 'segment_lidar' has no attribute 'version'
I've installed python 3.9.0, 3.9.18 or .19 (not sure), now I've 3.11.5 and error remains the same.
Besides I always have a version conflict for supervision==0.8.0. Because by pip installing or even by git cloning the version end up supervision 0.6.0.
Is there a way to solve for this ? What do you think?
Thank you again
Any idea why I get the following error?
ValueError: could not broadcast input array from shape (3114735,) into shape (8392998,)
This is my code,
from segment_lidar import samlidar, view
import torch
device_set = 'cuda:0' if torch.cuda.is_available() else 'cpu'
model = samlidar.SamLidar(ckpt_path='segment_anything/checkpoints/sam_vit_h_4b8939.pth',
device=device_set, # 'cuda:0',
algorithm='segment-geospatial',
model_type = "vit_h",
resolution=1,
sam_kwargs=False)
points = model.read("L4.las")
cloud, non_ground, ground = model.csf(points, class_threshold=0.1)
labels, *_ = model.segment(points=cloud,
image_path="results/raster_L4.tif",
labels_path="results/labeled_L4.tif")
model.write(points=points, segment_ids=labels, save_path="results/segmented_L4.las")
Below is the full output when running the script,
- Classification value is not provided. Reading all points...
- Reading RGB values...
File reading is completed in 0.96 seconds. The point cloud contains 8392998 points.Applying CSF algorithm...
[0] Configuring terrain...
[0] Configuring cloth...
[0] - width: 5004 height: 5004
[0] Rasterizing...
[0] Simulating...
CSF algorithm is completed in 552.40 seconds. The filtered non-ground cloud contains 8392998 points.
- Generating raster image...
- Saving raster image...
- Applying segment-geospatial to raster image...
- Saving segmented image...
- Generating segment IDs...
Segmentation is completed in 305.05 seconds. Number of instances: 212Writing the segmented point cloud to results/segmented_L4.las...
Traceback (most recent call last):
File "/samlidar/segmentLiDAR_playground_nv.py", line 73, in
model.write(points=points, segment_ids=labels, save_path="results/segmented_L4.las")
File "/samlidar/lib/python3.10/site-packages/segment_lidar/samlidar.py", line 454, in write
lidar.segment_id = segment_ids
File "/samlidar/lib/python3.10/site-packages/laspy/lasdata.py", line 403, in setattr
self[key] = value
File "/samlidar/lib/python3.10/site-packages/laspy/lasdata.py", line 435, in setitem
self.points[key] = value
File "/samlidar/lib/python3.10/site-packages/laspy/point/record.py", line 222, in setitem
self[key][:] = value
ValueError: could not broadcast input array from shape (3114735,) into shape (8392998,)
Hello,
I've been trying to use your segment-lidar
project and followed the instructions as per the documentation. However, I encountered a CUDA out of memory error that suggests I need about 130GB of GPU memory, which seems unusually high.
Here are the steps I took:
from segment_lidar import samlidar, view
viewpoint = view.TopView()
model = samlidar.SamLidar(ckpt_path="./sam_vit_b_01ec64.pth")
points = model.read("./point_cloud.las")
labels, *_ = model.segment(points=points, view=viewpoint, image_path="./raster.tif", labels_path="./labeled.tif")
model.write(points=points, segment_ids=labels, save_path="segmented.las")
I would like to know if there's something wrong with my setup or if I missed any configuration step that's leading to this issue. Is it expected to require this much GPU memory, or could there be a potential issue or bug?
Thank you for your help!
hi,
Can we reduce the observation size with a bbox before segmentation process?
tks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.