Elffuss BraidHub

kikocis/SpatialLM public

main · 18.0 KiBRenderedRawPermalink
1# SpatialLM
2
3<!-- markdownlint-disable first-line-h1 -->
4<!-- markdownlint-disable html -->
5<!-- markdownlint-disable no-duplicate-header -->
6
7<div align="center">
8 <img src="figures/logo_light.png#gh-light-mode-only" width="60%" alt="SpatialLM" />
9 <img src="figures/logo_dark.png#gh-dark-mode-only" width="60%" alt="SpatialLM" />
10</div>
11<hr style="margin-top: 0; margin-bottom: 8px;">
12<div align="center" style="margin-top: 0; padding-top: 0; line-height: 1;">
13 <a href="https://manycore-research.github.io/SpatialLM" target="_blank" style="margin: 2px;"><img alt="Project"
14 src="https://img.shields.io/badge/🌐%20Website-SpatialLM-ffc107?color=42a5f5&logoColor=white" style="display: inline-block; vertical-align: middle;"/></a>
15 <a href="https://arxiv.org/abs/2506.07491" target="_blank" style="margin: 2px;"><img alt="arXiv"
16 src="https://img.shields.io/badge/arXiv-Techreport-b31b1b?logo=arxiv&logoColor=white" style="display: inline-block; vertical-align: middle;"/></a>
17 <a href="https://github.com/manycore-research/SpatialLM" target="_blank" style="margin: 2px;"><img alt="GitHub"
18 src="https://img.shields.io/badge/GitHub-SpatialLM-24292e?logo=github&logoColor=white" style="display: inline-block; vertical-align: middle;"/></a>
19</div>
20<div align="center" style="line-height: 1;">
21 <a href="https://huggingface.co/manycore-research/SpatialLM1.1-Qwen-0.5B" target="_blank" style="margin: 2px;"><img alt="Hugging Face"
22 src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-SpatialLM-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/></a>
23 <a href="https://huggingface.co/datasets/manycore-research/SpatialLM-Dataset" target="_blank" style="margin: 2px;"><img alt="Dataset"
24 src="https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-Dataset-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/></a>
25 <a href="https://huggingface.co/datasets/manycore-research/SpatialLM-Testset" target="_blank" style="margin: 2px;"><img alt="Dataset"
26 src="https://img.shields.io/badge/%F0%9F%A4%97%20Dataset-Testset-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/></a>
27</div>
28
29## ✨ News
30
31- [Sept, 2025] [SpatialLM-Dataset](https://huggingface.co/datasets/manycore-research/SpatialLM-Dataset) is now available on Hugging Face.
32- [Sept, 2025] SpatialLM accepted at NeurIPS 2025.
33- [Jun, 2025] Added finetuning instructions in [FINETUNE.md](./FINETUNE.md).
34- [Jun, 2025] Check out our new models: [SpatialLM1.1-Llama-1B](https://huggingface.co/manycore-research/SpatialLM1.1-Llama-1B) and [SpatialLM1.1-Qwen-0.5B](https://huggingface.co/manycore-research/SpatialLM1.1-Qwen-0.5B), now available on Hugging Face. SpatialLM1.1 doubles the point cloud resolution, incorporates a more powerful point cloud encoder [Sonata](https://xywu.me/sonata/) and supports detection with user-specified categories.
35- [Jun, 2025] SpatialLM [Technical Report](https://arxiv.org/abs/2506.07491) is now on arXiv.
36- [Mar, 2025] We're excited to release the [SpatialLM-Llama-1B](https://huggingface.co/manycore-research/SpatialLM-Llama-1B) and [SpatialLM-Qwen-0.5B](https://huggingface.co/manycore-research/SpatialLM-Qwen-0.5B) on Hugging Face.
37- [Mar, 2025] Initial release of SpatialLM!
38
39## Introduction
40
41SpatialLM is a 3D large language model designed to process 3D point cloud data and generate structured 3D scene understanding outputs. These outputs include architectural elements like walls, doors, windows, and oriented object bounding boxes with their semantic categories. Unlike previous methods that require specialized equipment for data collection, SpatialLM can handle point clouds from diverse sources such as monocular video sequences, RGBD images, and LiDAR sensors. This multimodal architecture effectively bridges the gap between unstructured 3D geometric data and structured 3D representations, offering high-level semantic understanding. It enhances spatial reasoning capabilities for applications in embodied robotics, autonomous navigation, and other complex 3D scene analysis tasks.
42
43<div align="center">
44 <video src="https://github.com/user-attachments/assets/c0218d6a-f676-41f8-ae76-bba228866306" poster="figures/cover.png"> </video>
45 <p><i>SpatialLM reconstructs 3D layout from a monocular RGB video with MASt3R-SLAM. Results aligned to video with GT cameras for visualization.</i></p>
46</div>
47
48## SpatialLM Models
49
50<div align="center">
51
52| **Model** | **Download** |
53| :--------------------: | --------------------------------------------------------------------------------- |
54| SpatialLM1.1-Llama-1B | [🤗 HuggingFace](https://huggingface.co/manycore-research/SpatialLM1.1-Llama-1B) |
55| SpatialLM1.1-Qwen-0.5B | [🤗 HuggingFace](https://huggingface.co/manycore-research/SpatialLM1.1-Qwen-0.5B) |
56| SpatialLM1.0-Llama-1B | [🤗 HuggingFace](https://huggingface.co/manycore-research/SpatialLM-Llama-1B) |
57| SpatialLM1.0-Qwen-0.5B | [🤗 HuggingFace](https://huggingface.co/manycore-research/SpatialLM-Qwen-0.5B) |
58
59</div>
60
61## Usage
62
63### Installation
64
65Tested with the following environment:
66
67- Python 3.11
68- Pytorch 2.4.1
69- CUDA Version 12.4
70
71```bash
72# clone the repository
73git clone https://github.com/manycore-research/SpatialLM.git
74cd SpatialLM
75
76# create a conda environment with cuda 12.4
77conda create -n spatiallm python=3.11
78conda activate spatiallm
79conda install -y -c nvidia/label/cuda-12.4.0 cuda-toolkit conda-forge::sparsehash
80
81# Install dependencies with poetry
82pip install poetry && poetry config virtualenvs.create false --local
83poetry install
84# SpatialLM1.0 dependency
85poe install-torchsparse # Building wheel for torchsparse will take a while
86# SpatialLM1.1 dependency
87poe install-sonata # Building wheel for flash-attn will take a while
88```
89
90### Inference
91
92In the current version of SpatialLM, input point clouds are considered axis-aligned where the z-axis is the up axis. This orientation is crucial for maintaining consistency in spatial understanding and scene interpretation across different datasets and applications.
93Example preprocessed point clouds, reconstructed from RGB videos using [MASt3R-SLAM](https://github.com/rmurai0610/MASt3R-SLAM), are available in [SpatialLM-Testset](#spatiallm-testset).
94
95Download an example point cloud:
96
97```bash
98huggingface-cli download manycore-research/SpatialLM-Testset pcd/scene0000_00.ply --repo-type dataset --local-dir .
99```
100
101Run inference:
102
103```bash
104python inference.py --point_cloud pcd/scene0000_00.ply --output scene0000_00.txt --model_path manycore-research/SpatialLM1.1-Qwen-0.5B
105```
106
107### Detection with user-specified categories
108
109SpatialLM1.1 supports object detection conditioned on user-specified categories by leveraging the flexibility of LLMs.
110
111SpatialLM1.1 offers three variants of structured indoor modeling tasks:
112
113- **Structured Reconstruction**: Detect walls, doors, windows, boxes.
114- **Layout Estimation**: Detect walls, doors, windows.
115- **3D Object Detection**: Detect boxes.
116
117For tasks that include object box estimation, you can specify a subset of the 59 furniture categories, and the model will only predict objects within those specified categories. For example:
118
119```bash
120python inference.py --point_cloud pcd/scene0000_00.ply --output scene0000_00.txt --model_path manycore-research/SpatialLM1.1-Qwen-0.5B --detect_type object --category bed nightstand
121```
122
123### Visualization
124
125Use `rerun` to visualize the point cloud and the predicted structured 3D layout output:
126
127```bash
128# Convert the predicted layout to Rerun format
129python visualize.py --point_cloud pcd/scene0000_00.ply --layout scene0000_00.txt --save scene0000_00.rrd
130
131# Visualize the point cloud and the predicted layout
132rerun scene0000_00.rrd
133```
134
135### Evaluation
136
137To evaluate the performance of SpatialLM, we provide `eval.py` script that reports the benchmark results on the SpatialLM-Testset in the table below in section [Benchmark Results](#benchmark-results).
138
139Download the testset:
140
141```bash
142huggingface-cli download manycore-research/SpatialLM-Testset --repo-type dataset --local-dir SpatialLM-Testset
143```
144
145Run evaluation:
146
147```bash
148# Run inference on the PLY point clouds in folder SpatialLM-Testset/pcd with SpatialLM1.1-Qwen-0.5B model
149python inference.py --point_cloud SpatialLM-Testset/pcd --output SpatialLM-Testset/pred --model_path manycore-research/SpatialLM1.1-Qwen-0.5B
150
151# Evaluate the predicted layouts
152python eval.py --metadata SpatialLM-Testset/test.csv --gt_dir SpatialLM-Testset/layout --pred_dir SpatialLM-Testset/pred --label_mapping SpatialLM-Testset/benchmark_categories.tsv
153```
154
155### Example using a custom video
156
157We provide an example of how to use our model to estimate scene layout starting from a RGB video with the newly released [SLAM3R](https://github.com/PKU-VCL-3DV/SLAM3R) in [EXAMPLE.md](EXAMPLE.md). These steps work for MASt3R-SLAM, and other reconstruction methods as well.
158
159### Finetune on Custom Data
160
161For instructions on fine-tuning SpatialLM on your own data, please refer to [FINETUNE.md](./FINETUNE.md). We provide an example using the [ARKitScenes](https://github.com/apple/ARKitScenes) dataset.
162
163## SpatialLM Dataset
164
165The SpatialLM dataset is a large-scale, high-quality synthetic dataset designed by professional 3D designers and used for real-world production. It contains point clouds from 12,328 diverse indoor scenes comprising 54,778 rooms, each paired with rich ground-truth 3D annotations. SpatialLM dataset provides an additional valuable resource for advancing research in indoor scene understanding, 3D perception, and related applications.
166
167For access to photorealistic RGB/Depth/Normal/Semantic/Instance panoramic renderings and camera trajectories used to generate the SpatialLM point clouds, please refer to the [SpatialGen project](https://manycore-research.github.io/SpatialGen) for more details.
168
169<div align="center">
170
171| **Dataset** | **Download** |
172| :---------------: | ---------------------------------------------------------------------------------- |
173| SpatialLM-Dataset | [🤗 Datasets](https://huggingface.co/datasets/manycore-research/SpatialLM-Dataset) |
174
175</div>
176
177## SpatialLM Testset
178
179We provide a test set of 107 preprocessed point clouds, reconstructed from RGB videos using [MASt3R-SLAM](https://github.com/rmurai0610/MASt3R-SLAM). SpatialLM-Testset is quite challenging compared to prior clean RGBD scans datasets due to the noises and occlusions in the point clouds reconstructed from monocular RGB videos.
180
181<div align="center">
182
183| **Dataset** | **Download** |
184| :---------------: | ---------------------------------------------------------------------------------- |
185| SpatialLM-Testset | [🤗 Datasets](https://huggingface.co/datasets/manycore-research/SpatialLM-TestSet) |
186
187</div>
188
189## Benchmark Results
190
191### Layout Estimation
192
193Layout estimation focuses on predicting architectural elements, i.e., walls, doors, and windows, within an indoor scene. We evaluated this task on the [Structured3D](https://structured3d-dataset.org) dataset. For [RoomFormer](https://github.com/ywyue/RoomFormer), we directly downloaded the model checkpoint. SceneScript and SpatialLM were first trained on our dataset, and further fine-tuned on Structured3D.
194
195We thank @chinmay0301ucsd for identifying and fixing a bug [#88](https://github.com/manycore-research/SpatialLM/pull/88) in the evaluation script that affected door and window metrics. As a result, the scores are higher than previously reported.
196
197<div align="center">
198
199| **Method** | **RoomFormer** | **SceneScript (finetuned)** | **SpatialLM1.1-Qwen-0.5B (finetuned)** |
200| :-------------: | :------------: | :-------------------------: | :------------------------------------: |
201| **F1 @.25 IoU** | 83.4 | 90.4 | 94.3 |
202| **F1 @.5 IoU** | 81.4 | 89.2 | 93.5 |
203
204</div>
205
206### 3D Object Detection
207
208We evaluate 3D object detection on [ScanNet](http://www.scan-net.org) with annotations of 18 object categories. For [V-DETR](https://github.com/V-DETR/V-DETR), we directly download the model checkpoint. SceneScript and SpatialLM were first trained on our dataset, and further fine-tuned on ScanNet.
209
210<div align="center">
211
212| **Method** | **V-DETR** | **SceneScript (finetuned)** | **SpatialLM1.1-Qwen-0.5B (finetuned)** |
213| :-------------: | :--------: | :-------------------------: | :------------------------------------: |
214| **F1 @.25 IoU** | 65.1 | 49.1 | 65.6 |
215| **F1 @.5 IoU** | 56.8 | 36.8 | 52.6 |
216
217</div>
218
219### Zero-shot Detection on Videos
220
221Zero-shot detection results on the challenging SpatialLM-Testset are reported in the following table:
222
223<div align="center">
224
225| **Method** | **SpatialLM1.1-Llama-1B** | **SpatialLM1.1-Qwen-0.5B** |
226| :-------------: | :-----------------------: | :------------------------: |
227| **Layout** | **F1 @.25 IoU (2D)** | **F1 @.25 IoU (2D)** |
228| wall | 68.9 | 68.2 |
229| door | 49.1 | 47.4 |
230| window | 47.0 | 51.4 |
231| | | |
232| **Objects** | **F1 @.25 IoU (3D)** | **F1 @.25 IoU (2D)** |
233| curtain | 34.9 | 37.0 |
234| nightstand | 62.8 | 67.0 |
235| chandelier | 53.5 | 36.8 |
236| wardrobe | 29.4 | 39.6 |
237| bed | 96.8 | 95.2 |
238| sofa | 66.9 | 69.1 |
239| chair | 20.8 | 32.3 |
240| cabinet | 15.2 | 11.2 |
241| dining table | 40.7 | 24.2 |
242| plants | 29.5 | 26.3 |
243| tv cabinet | 34.4 | 27.3 |
244| coffee table | 56.4 | 64.9 |
245| side table | 14.6 | 9.7 |
246| air conditioner | 16.7 | 24.0 |
247| dresser | 46.7 | 46.7 |
248| stool | 17.6 | 30.8 |
249| refrigerator | 0.0 | 16.7 |
250| painting | 34.9 | 38.2 |
251| carpet | 40.3 | 24.1 |
252| tv | 16.0 | 18.0 |
253
254</div>
255
256### Result Visualizations
257
258<div align="center">
259
260| Layout Estimation | Object Detection | Zero-shot Reconstruction |
261| :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------: |
262| ![Structured3D](./figures/stru3d.jpg) | ![ScanNet](./figures/scannet.jpg) | ![Zero-shot](./figures/zeroshot.jpg) |
263| [Structured3D Results](https://manycore-research-azure.kujiale.com/manycore-research/SpatialLM/supplementary/visualization_layout.html) | [ScanNet Results](https://manycore-research-azure.kujiale.com/manycore-research/SpatialLM/supplementary/visualization_object.html) | [Zeroshot Results](https://manycore-research-azure.kujiale.com/manycore-research/SpatialLM/supplementary/visualization_zeroshot.html) |
264
265</div>
266
267## License
268
269SpatialLM-Llama-1B is derived from Llama3.2-1B-Instruct, which is licensed under the Llama3.2 license.
270SpatialLM-Qwen-0.5B is derived from the Qwen-2.5 series, originally licensed under the Apache 2.0 License.
271
272SpatialLM1.0 are built upon the SceneScript point cloud encoder, licensed under the CC-BY-NC-4.0 License. TorchSparse, utilized in this project, is licensed under the MIT License.
273
274SpatialLM1.1 are built upon Sonata point cloud encoder, model weight is licensed under the CC-BY-NC-4.0 License. Code built on Pointcept is licensed under the Apache 2.0 License.
275
276## Citation
277
278If you find this work useful, please consider citing:
279
280```bibtex
281@inproceedings{SpatialLM,
282 title = {SpatialLM: Training Large Language Models for Structured Indoor Modeling},
283 author = {Mao, Yongsen and Zhong, Junhao and Fang, Chuan and Zheng, Jia and Tang, Rui and Zhu, Hao and Tan, Ping and Zhou, Zihan},
284 booktitle = {Advances in Neural Information Processing Systems},
285 year = {2025}
286}
287```
288
289## Acknowledgements
290
291We would like to thank the following projects that made this work possible:
292
293[Llama3.2](https://github.com/meta-llama) | [Qwen2.5](https://github.com/QwenLM/Qwen2.5) | [Transformers](https://github.com/huggingface/transformers) | [SceneScript](https://github.com/facebookresearch/scenescript) | [TorchSparse](https://github.com/mit-han-lab/torchsparse) | [Sonata](https://xywu.me/sonata/) | [Pointcept](https://github.com/Pointcept/Pointcept)