Package: segment-lidar
segment-lidarPython package for segmenting aerial LiDAR data using Segment-Anything Model (SAM) from Meta AI.This package is specifically designed forunsupervised instance segmentationofLiDAR data. It brings together the power of theSegment-Anything Model (SAM)developed byMeta Researchand thesegment-geospatialpackage fromOpen Geospatial Solutionsto automatize instance segmentation of 3D point cloud data.InstallationWe recommand usingPython>=3.9. First, you need to installPyTorch. Please follow the instructionshere.Then, you can easily installsegment-lidarfromPyPI:pipinstallsegment-lidarOr, you can install it from source by running the following commands:gitclonehttps://github.com/Yarroudh/segment-lidarcdsegment-lidar
pythonsetup.pyinstallPlease, note that the actual version is always under tests. If you find any issues or bugs, please report them inissuessection. The second version should implement more advanced features and fonctionalities.DocumentationIf you are usingsegment-lidar, we highly recommend that you take the time to read thedocumentation. The documentation is an essential resource that will help you understand the features of the package, as well as provide guidance on how to use it effectively.Basic tutorialA basic tutorial is availablehere.You can also refer toAPIfor more information about different parameters.Without ground filteringfromsegment_lidarimportsamlidar,viewviewpoint=view.TopView()model=samlidar.SamLidar(ckpt_path="sam_vit_h_4b8939.pth")points=model.read("pointcloud.las")labels,*_=model.segment(points=points,view=view,image_path="raster.tif",labels_path="labeled.tif")model.write(points=points,segment_ids=labels,save_path="segmented.las")With ground filteringfromsegment_lidarimportsamlidar,viewviewpoint=view.TopView()model=samlidar.SamLidar(ckpt_path="sam_vit_h_4b8939.pth")points=model.read("pointcloud.las")cloud,non_ground,ground=model.csf(points)labels,*_=model.segment(points=cloud,view=view,image_path="raster.tif",labels_path="labeled.tif")model.write(points=points,non_ground=non_ground,ground=ground,segment_ids=labels,save_path="segmented.las")Note: The latest version ofsegment-lidarsupports defining a custom pinhole camera, with or without interactive visualization, and save the view as an image. Please, refer to thedocumentationfor more details.Sample dataFor testing purposes, you can download a sample here:pointcloud.las.This data was retrieved fromAHN-4. For more data, please visitGeoTiles.nl.Model checkpointsClick the links below to download the checkpoint for the corresponding model type.vit_h:ViT-H SAM model.vit_l:ViT-L SAM model.vit_b:ViT-B SAM model.Docker Imagesegment-lidaris also available asDocker image.These are the steps to runsegment-lidaras a Docker container:First pull the image using thedocker pullcommand:dockerpullyarroudh/segment-lidarTo run the Docker container and mount your data and script file inside it, use thedocker runcommand with the-voption to specify the path to the host directory and the path to the container directory where you want to mount the data folder. For example:dockerrun-d-vABSOLUTE_PATH_TO_HOST_DATA:/home/useryarroudh/segment-lidarThis command will start a Docker container in detached mode, mount theABSOLUTE_PATH_TO_HOST_DATAdirectory on the host machine to the/home/user/datadirectory inside the container, and run theyarroudh/segment-lidarimage. Do not change the path of the directory inside the container.Find the container ID and copy it. You can use thedocker pscommand to list all running containers and their IDs.Launch a command inside the container usingdocker exec, use the container ID or name and the command you want to run. For example:dockerexecCONTAINER_IDpythonSCRIPT_FILETo copy the output of the command from the container to a local path, use thedocker cpcommand with the container ID or name, the path to the file inside the container, and the path to the destination on the host machine. For example:dockercpCONTAINER_ID:/home/user/PATH_TO_OUTPUTPATH_ON_HOST_MACHINEFinally, after executing all the commands and copying the results to your local machine, you can stop the Docker container using thedocker stopcommand followed by the container ID or name:dockerstopCONTAINER_IDRelated repositoriesWe would like to express our acknowledgments to the creators of:segment-anythingsegment-geospatialPlease, visit these repositories for more information about image raster automatic segmentation using SAM from Meta AI.LicenseThis software is under the BSD 3-Clause "New" or "Revised" license which is a permissive license that allows you almost unlimited freedom with the software so long as you include the BSD copyright and license notice in it. Please refer to theLICENSEfile for more detailed information.CitationThe use of open-source software repositories has become increasingly prevalent in scientific research. If you use this repository for your research, please make sure to cite it appropriately in your work. The recommended citation format for this repository is provided in the accompanyingBibTeX citation. Additionally, please make sure to comply with any licensing terms and conditions associated with the use of this repository.@misc{yarroudh:2023:samlidar,author={Yarroudh, Anass},title={LiDAR Automatic Unsupervised Segmentation using Segment-Anything Model (SAM) from Meta AI},year={2023},howpublished={GitHub Repository},url={https://github.com/Yarroudh/segment-lidar}}Yarroudh, A. (2023).LiDAR Automatic Unsupervised Segmentation using Segment-Anything Model (SAM) from Meta AI[GitHub repository]. Retrieved fromhttps://github.com/Yarroudh/segment-lidarAuthorThis software was developped byAnass Yarroudh, a Research Engineer in theGeomatics Unit of the University of Liege.
For more detailed information please contact us viaayarroudh@uliege.be, we are pleased to send you the necessary information.Copyright © 2023,Geomatics Unit of ULiège. Released underBSD-3 Clause License.