dong0625 commited on
Commit
6943410
Β·
1 Parent(s): 750d90c

add original README

Browse files
Files changed (1) hide show
  1. README.md +207 -0
README.md ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # [ICLR 2024 spotlight] InstructScene
2
+
3
+ <h4 align="center">
4
+
5
+ InstructScene: Instruction-Driven 3D Indoor Scene Synthesis with Semantic Graph Prior
6
+
7
+ [Chenguo Lin](https://chenguolin.github.io), [Yadong Mu](http://www.muyadong.com)
8
+
9
+ [![arXiv](https://img.shields.io/badge/arXiv-2402.04717-b31b1b.svg?logo=arXiv)](https://arxiv.org/abs/2402.04717)
10
+ [![Project page](https://img.shields.io/badge/Project-Page-brightgreen)](https://chenguolin.github.io/projects/InstructScene)
11
+ [![Dataset](https://img.shields.io/badge/HF-Dataset-yellow)](https://huggingface.co/datasets/chenguolin/InstructScene_dataset)
12
+
13
+ <p>
14
+ <img width="240" alt="bedroom" src="./assets/bedroom_1.gif">
15
+ <img width="240" alt="diningroom" src="./assets/diningroom_1.gif">
16
+ <img width="240" alt="livingroom" src="./assets/livingroom_1.gif">
17
+ </p>
18
+
19
+ <p>
20
+ <img width="730" alt="pipeline", src="./assets/pipeline.png">
21
+ </p>
22
+
23
+ </h4>
24
+
25
+ This repository contains the official implementation of the paper: [InstructScene: Instruction-Driven 3D Indoor Scene Synthesis with Semantic Graph Prior](https://arxiv.org/abs/2402.04717), which is accepted to ICLR 2024 for spotlight presentation.
26
+ InstructScene is a generative framework to synthesize 3D indoor scenes from instructions. It is composed of a semantic graph prior and a layout decoder.
27
+
28
+ Feel free to contact me (chenguolin@stu.pku.edu.cn) or open an issue if you have any questions or suggestions.
29
+
30
+
31
+ ## πŸ”₯ See Also
32
+
33
+ You may also be interested in our other works:
34
+ - [**InstructLayout**](https://arxiv.org/abs/2407.07580): extends InstructScene to generate 2D layouts from instructions.
35
+ - [**[ICLR 2025] DiffSplat**](https://github.com/chenguolin/DiffSplat): generates individual 3D objects that can replace the retrieving operation in InstructScene.
36
+
37
+
38
+ ## πŸ“’ News
39
+
40
+ - **2024-07-11**: Unofficial pretrained parameters of two-stage generative models are provided by [@arjuntheprogrammer](https://github.com/arjuntheprogrammer). Thank you very much! Please see [issue#9](https://github.com/chenguolin/InstructScene/issues/9) for more information.
41
+ - **2024-04-12**: Script for caption refinement by OpenAI ChatGPT is uploaded (sorry for the late update).
42
+ - **2024-02-28**: The pretrained weights of fVQ-VAE are released.
43
+ - **2024-02-28**: The source code and preprocessed dataset are released.
44
+ - **2024-02-07**: The paper is available on arXiv.
45
+ - **2024-01-16**: InstructScene is accepted to ICLR 2024 for spotlight presentation.
46
+
47
+
48
+ ## πŸ“‹ TODO
49
+
50
+ - [x] Release the training and evaluation code.
51
+ - [x] Release the preprocessed dataset and rendered images on HuggingFace.
52
+ - [x] Release the pretrained weights of fVQ-VAE to quantize OpenShape features of 3D-FRONT objects.
53
+ - [x] Release the script for caption refinement by OpenAI ChatGPT.
54
+
55
+
56
+ ## πŸ”§ Installation
57
+
58
+ You may need to modify the specific version of `torch` in `settings/setup.sh` according to your CUDA version.
59
+ There are not restrictions on the `torch` version, feel free to use your preferred one.
60
+ ```bash
61
+ git clone https://github.com/chenguolin/InstructScene.git
62
+ cd InstructScene
63
+ bash settings/setup.sh
64
+ ```
65
+
66
+ Download the Blender software for visualization.
67
+ ```bash
68
+ cd blender
69
+ wget https://download.blender.org/release/Blender3.3/blender-3.3.1-linux-x64.tar.xz
70
+ tar -xvf blender-3.3.1-linux-x64.tar.xz
71
+ rm blender-3.3.1-linux-x64.tar.xz
72
+ ```
73
+
74
+
75
+ ## πŸ“Š Dataset
76
+
77
+ Dataset used in InstructScene is based on [3D-FORNT](https://tianchi.aliyun.com/specials/promotion/alibaba-3d-scene-dataset) and [3D-FUTURE](https://tianchi.aliyun.com/specials/promotion/alibaba-3d-future).
78
+ Please refer to the instructions provided in their [official website](https://tianchi.aliyun.com/dataset/65347) to download the original dataset.
79
+ One can refer to the dataset preprocessing scripts in [ATISS](https://github.com/nv-tlabs/ATISS?tab=readme-ov-file#dataset) and [DiffuScene](https://github.com/tangjiapeng/DiffuScene?tab=readme-ov-file#dataset), which are similar to ours.
80
+
81
+ We provide the preprocessed instruction-scene paired dataset used in the paper and rendered images for evaluation on [HuggingFace](https://huggingface.co/datasets/chenguolin/InstructScene_dataset).
82
+ ```python
83
+ import os
84
+ from huggingface_hub import hf_hub_url
85
+ url = hf_hub_url(repo_id="chenguolin/InstructScene_dataset", filename="InstructScene.zip", repo_type="dataset")
86
+ os.system(f"wget {url} && unzip InstructScene.zip")
87
+ url = hf_hub_url(repo_id="chenguolin/InstructScene_dataset", filename="3D-FRONT.zip", repo_type="dataset")
88
+ os.system(f"wget {url} && unzip 3D-FRONT.zip")
89
+ ```
90
+
91
+ Please refer to [dataset/README.md](./dataset/README.md) for more details.
92
+
93
+
94
+ ## πŸ‘€ Visualization
95
+
96
+ We provide a helpful script to visualize synthesized scenes by [Blender](https://www.blender.org/).
97
+ Please refer to [blender/README.md](./blender/README.md) for more details.
98
+
99
+ We also provide many useful visualization functions in [src/utils/visualize.py](./src/utils/visualize.py), including creating appropriate floor plans, drawing scene graphs, adding instructions as titles in the rendered images, making gifs, etc.
100
+
101
+
102
+ ## πŸš€ Usage
103
+
104
+ Note that:
105
+
106
+ - All scripts in this project are executed in only one GPU. It takes 1~3 days to train the semantic graph prior or layout decoder on a single NVIDIA A40 GPU depending on the room type.
107
+
108
+ - We use `TensorBoard` to track the training process by executing `tensorboard --logdir out/`.
109
+
110
+ - The training of "1. layout decoder" and "2. semantic graph prior" are independent and can be trained parallelly, as we use ground-truth semantic graphs to train the layout decoder.
111
+ During inference, to render syntheiszed scenes from instruction prompts, one needs to have both the semantic graph prior and the layout decoder trained.
112
+
113
+ ### 0️. πŸ“¦ fVQ-VAE: quantize OpenShape/CLIP features of objects
114
+
115
+ #### Training
116
+ We provide the pretrained weights of fVQ-VAE on [HuggingFace](https://huggingface.co/datasets/chenguolin/InstructScene_dataset). Our preprocessed dataset contains the original OpenShape features and **correspondingly quantization indices**.
117
+ ```python
118
+ import os
119
+ from huggingface_hub import hf_hub_url
120
+ os.system("mkdir -p out/threedfront_objfeat_vqvae/checkpoints")
121
+ url = hf_hub_url(repo_id="chenguolin/InstructScene_dataset", filename="threedfront_objfeat_vqvae_epoch_01999.pth", repo_type="dataset")
122
+ os.system(f"wget {url} -O out/threedfront_objfeat_vqvae/checkpoints/epoch_01999.pth")
123
+ url = hf_hub_url(repo_id="chenguolin/InstructScene_dataset", filename="objfeat_bounds.pkl", repo_type="dataset")
124
+ os.system(f"wget {url} -O out/threedfront_objfeat_vqvae/objfeat_bounds.pkl")
125
+ ```
126
+
127
+ You can also train the fVQ-VAE from scratch. However, you should **update the quantization indices in the dataset** (stored in `dataset/InstructScene/threed_front_<room_type>/<scene_id>/models_info.pkl`) accordingly.
128
+ ```bash
129
+ # bash scripts/train_objfeatvqvae.sh <tag> <gpu_id>
130
+ bash scripts/train_objfeatvqvae.sh threedfront_objfeat_vqvae 0
131
+ ```
132
+
133
+ #### Inference (only for debugging)
134
+ ```bash
135
+ # bash scripts/inference_objfeatvqvae.sh <tag> <gpu_id> <epoch>
136
+ bash scripts/inference_objfeatvqvae.sh threedfront_objfeat_vqvae 0 -1
137
+ # '-1' means the latest checkpoint
138
+ ```
139
+
140
+ ### 1️. 🦾 Layout Decoder: embody 3D scenes from semantic graphs
141
+
142
+ #### Training
143
+ ```bash
144
+ # bash scripts/train_sg2sc_objfeat.sh <room_type> <tag> <gpu_id> <fvqvae_tag>
145
+ bash scripts/train_sg2sc_objfeat.sh bedroom bedroom_sg2scdiffusion_objfeat 0 threedfront_objfeat_vqvae
146
+ ```
147
+
148
+ #### Inference (only for debugging)
149
+ ```bash
150
+ # bash scripts/inference_sg2sc_objfeat.sh <room_type> <tag> <gpu_id> <epoch> <fvqvae_tag> <(optional) cfg_scale>
151
+ bash scripts/inference_sg2sc_objfeat.sh bedroom bedroom_sg2scdiffusion_objfeat 0 -1 threedfront_objfeat_vqvae 1.0
152
+ ```
153
+
154
+ To visualize synthesized scenes, replace `--n_scene 0` in `scripts/inference_sg2sc_objfeat.sh` to `--n_scenes 5 --visualize --resolution 1024`, which means to visualize 5 synthesized scenes and save the rendered images with a resolution of 1024x1024.
155
+ Otherwise, it will only compute the iRecall score for evaluation.
156
+
157
+ ### 2️. πŸ€– Semantic Graph Prior: design semantic graphs from instructions
158
+
159
+ #### Training
160
+ ```bash
161
+ # bash scripts/train_sg_vq_objfeat.sh <room_type> <tag> <gpu_id>
162
+ bash scripts/train_sg_vq_objfeat.sh bedroom bedroom_sgdiffusion_vq_objfeat 0
163
+ ```
164
+
165
+ #### Inference
166
+ ```bash
167
+ # bash scripts/inference_sg_vq_objfeat.sh <room_type> <tag> <gpu_id> <epoch> <fvqvae_tag> <sg2sc_tag> <(optional) cfg_scale> <(optional) sg2sc_cfg_scale>
168
+ bash scripts/inference_sg_vq_objfeat.sh bedroom bedroom_sgdiffusion_vq_objfeat 0 -1 threedfront_objfeat_vqvae bedroom_sg2scdiffusion_objfeat 1.0 1.0
169
+ ```
170
+
171
+ To visualize synthesized scenes, replace `--n_scene 0` in `scripts/inference_sg_vq_objfeat.sh` to `--n_scenes 5 --visualize --resolution 1024`, which means to visualize 5 synthesized scenes and save the rendered images with a resolution of 1024x1024.
172
+ Otherwise, it will only compute the iRecall score for evaluation.
173
+
174
+ #### Evaluation
175
+
176
+ Evaluation should be conducted after the inference script is executed with the `--visualize` flag, which will save the rendered images in the output directory.
177
+
178
+ ##### FID, CLIP-FID and KID
179
+ ```bash
180
+ python3 src/compute_fid_scores.py configs/bedroom_sgdiffusion_vq_objfeat.yaml --tag bedroom_sgdiffusion_vq_objfeat --checkpoint_epoch -1
181
+ ```
182
+
183
+ ##### SCA (scene classification accuracy)
184
+ ```bash
185
+ python3 src/synthetic_vs_real_classifier.py configs/bedroom_sgdiffusion_vq_objfeat.yaml --tag bedroom_sgdiffusion_vq_objfeat --checkpoint_epoch -1
186
+ ```
187
+
188
+ #### Applications
189
+ Replace the python file name in `scripts/inference_sg_vq_objfeat.sh` from `generate_sg.py` to `stylize_sg.py`, `rearrange_sg.py` or `complete_sg.py` for "stylization", "rearrangement" or "completion" downstream tasks, respectively.
190
+
191
+ Please refer to these python files for more detailed arguments and usage.
192
+
193
+
194
+ ## 😊 Acknowledgement
195
+ We would like to thank the authors of [ATISS](https://github.com/nv-tlabs/ATISS), [DiffuScene](https://github.com/tangjiapeng/DiffuScene), [OpenShape](https://github.com/Colin97/OpenShape_code), [NAP](https://arxiv.org/abs/2305.16315) and [CLIPLayout](https://arxiv.org/abs/2303.03565) for their great work and generously providing source codes, which inspired our work and helped us a lot in the implementation.
196
+
197
+
198
+ ## πŸ“š Citation
199
+ If you find our work helpful, please consider citing:
200
+ ```bibtex
201
+ @inproceedings{lin2024instructscene,
202
+ title={InstructScene: Instruction-Driven 3D Indoor Scene Synthesis with Semantic Graph Prior},
203
+ author={Chenguo Lin and Yadong Mu},
204
+ booktitle={International Conference on Learning Representations (ICLR)},
205
+ year={2024}
206
+ }
207
+ ```