fullcyxuc / B-Seg

Code for our SIGGRAPH'2023 paper: "UrbanBIS: a Large-scale Benchmark for Fine-grained Urban Building Instance Segmentation"
MIT License
50 stars 7 forks source link

B-Seg

Code for our SIGGRAPH'2023 paper: "UrbanBIS: a Large-scale Benchmark for Fine-grained Urban Building Instance Segmentation"

Pipeline Image

Installation

Requirements

Virtual Environment

conda create -n bseg python==3.6
source activate bseg

Install B-Seg

(1) Clone from the repository.

git clone https://github.com/fullcyxuc/B-Seg.git
cd B-Seg

(2) Install the dependent libraries.

pip install -r requirements.txt
conda install -c bioconda google-sparsehash 

(3) For the SparseConv, we apply the implementation of spconv as Pointgroup did. The repository is recursively downloaded at step (1). We use the version 1.0 of spconv.

Note: it was modify spconv\spconv\functional.py to make grad_output contiguous. Make sure you use the modified spconv.

(4) We also use other cuda and cpp extension(pointgroup_ops,pcdet_ops), and put them into the lib, to compile them:

cd lib/**  # (** refer to a specific extension)
python setup.py develop

Data Preparation

(1) Download the UranBIS training set and test set for the building instance segmentation

(2) Put the data in the corresponding folders, which are organized as follows.

B-Seg
├── dataset
│   ├── UrbanBIS
│   │   ├── original
│   │   │   ├── Qingdao
│   │   │   │   ├── train
│   │   │   │   │   ├── Areax.txt 
│   │   │   │   ├── test
│   │   │   │   │   ├── Areax.txt 
│   │   │   │   ├── val
│   │   │   │   │   ├── Areax.txt 
│   │   │   ├── Wuhu
│   │   │   │   ├── train
│   │   │   │   │   ├── Areax.txt 
│   │   │   │   ├── test
│   │   │   │   │   ├── Areax.txt 
│   │   │   │   ├── val
│   │   │   │   │   ├── Areax.txt 
...

(3) Preprocess and generate the block files _inst_nostuff.pth for building instance segmentation.

cd dataset/UrbanBIS
python prepare_data_inst_instance_UrbanBIS.py

then, it will create a processed folder under the UrbanBIS folder, which contains the files for training and testing. That will be:

B-Seg
├── dataset
│   ├── UrbanBIS
│   │   ├── original
│   │   ├── processed
│   │   │   ├── Qingdao
│   │   │   │   ├── train
│   │   │   │   │   ├── X.pth or X.txt 
│   │   │   │   ├── test_w_label
│   │   │   │   │   ├── X.pth or X.txt 
│   │   │   │   ├── test_w_label_gt
│   │   │   │   │   ├── X.txt 
│   │   │   │   ├── val
│   │   │   │   │   ├── X.pth or X.txt 
│   │   │   │   ├── val_gt
│   │   │   │   │   ├── X.txt 
│   │   │   ├── Wuhu
│   │   │   │   ├── train
│   │   │   │   │   ├── X.pth or X.txt 
│   │   │   │   ├── test_w_label
│   │   │   │   │   ├── X.pth or X.txt 
│   │   │   │   ├── test_w_label_gt
│   │   │   │   │   ├── X.txt 
│   │   │   │   ├── val
│   │   │   │   │   ├── X.pth or X.txt 
│   │   │   │   ├── val_gt
│   │   │   │   │   ├── X.txt 
...

By default, it only processes the Qingdao city scene, and this can be changed at the line 177 in the prepare_data_inst_instance_UrbanBIS.py file.

Training

CUDA_VISIBLE_DEVICES=0 python train.py --config config/BSeg_default_urbanbis.yaml

Inference and Evaluation

For evaluation, please set eval as True in the config file, and set split as val for validation set or test_w_label for testing set with labels

CUDA_VISIBLE_DEVICES=0 python test.py --config config/BSeg_default_urbanbis.yaml

Acknowledgement

This repo is built upon several repos, e.g., Pointgroup, HAIS, DyCo3D, SoftGroup, DKNet, SparseConvNet, spconv, IA-SSD and STPLS3D.