Code for the paper One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation, CVPR 2021.

Overview

One Thing One Click

One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation (CVPR2021)

Code for the paper One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation, CVPR 2021.

This code is based on PointGroup https://github.com/llijiang/PointGroup

Authors: Zhengzhe Liu, Xiaojuan Qi, Chi-Wing Fu

Installation

Requirements

  • Python 3.7.0
  • Pytorch 1.3.0
  • CUDA 10.1

Virtual Environment

conda create -n pointgroup python==3.7
source activate pointgroup

Install PointGroup

(1) Clone the PointGroup repository.

git clone https://github.com/liuzhengzhe/One-Thing-One-Click --recursive 
cd One-Thing-One-Click

(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. The repository is recursively downloaded at step (1). We use the version 1.0 of spconv.

Note: The author of PointGroup further modified spconv\spconv\functional.py to make grad_output contiguous. Make sure you use our modified spconv.

  • To compile spconv, firstly install the dependent libraries.
conda install libboost
conda install -c daleydeng gcc-5 # need gcc-5.4 for sparseconv

Add the $INCLUDE_PATH$ that contains boost in lib/spconv/CMakeLists.txt. (Not necessary if it could be found.)

include_directories($INCLUDE_PATH$)
  • Compile the spconv library.
cd lib/spconv
python setup.py bdist_wheel
  • Run cd dist and use pip to install the generated .whl file.

(4) Compile the pointgroup_ops library.

cd lib/pointgroup_ops
python setup.py develop

If any header files could not be found, run the following commands.

python setup.py build_ext --include-dirs=$INCLUDE_PATH$
python setup.py develop

$INCLUDE_PATH$ is the path to the folder containing the header files that could not be found.

Data Preparation

  • Download the ScanNet v2 dataset.

  • Put the data in the corresponding folders.

  • Put the file scannetv2-labels.combined.tsv in the data/ folder.

  • Change the path in prepare_data_otoc.py Line 20.

cd data/
python prepare_data_otoc.py 
  • Split the generated files into the data/train_weakly and data/val_weakly folders according to the ScanNet v2 train/val split.

Pretrained Model

We provide a pretrained model trained on ScanNet v2 dataset. Download it here. Its performance on ScanNet v2 validation set is 71.94 mIoU.

Inference and Evaluation

(1) 3D U-Net Evaluation

set the data_root in config/pointgroup_run1_scannet.yaml

cd 3D-U-Net
python test.py --config config/pointgroup_run1_scannet.yaml --pretrain pointgroup_run1_scannet-000001250.pth

Its performance on ScanNet v2 validation set is 68.96 mIoU.

(2) Relation Net Evaluation

cd relation
python test.py --config config/pointgroup_run1_scannet.yaml --pretrain pointgroup_run1_scannet-000002891_weight.pth

(3) Overall Evaluation

cd merge
python test.py --config config/pointgroup_run1_scannet.yaml

Self Training

(1) Train 3D U-Net

set the data_root/dataset in config/pointgroup_run1_scannet.yaml

cd 3D-U-Net
CUDA_VISIBLE_DEVICES=0 python train.py --config config/pointgroup_run1_scannet.yaml 

(2) Generate features and predictions of 3D U-Net

CUDA_VISIBLE_DEVICES=0 python test_train.py --config config/pointgroup_run1_scannet.yaml --pretrain $PATH_TO_THE_MODEL$.pth

(3) Train Relation Net

set the data_root/dataset in config/pointgroup_run1_scannet.yaml

cd relation
CUDA_VISIBLE_DEVICES=0 python train.py --config config/pointgroup_run1_scannet.yaml 

(4) Generate features and predictions of Relation Net

CUDA_VISIBLE_DEVICES=0 python test_train.py --config config/pointgroup_run1_scannet.yaml --pretrain $PATH_TO_THE_MODEL$_weight.pth

(5) Merge the Results via Graph Propagation

cd merge
CUDA_VISIBLE_DEVICES=0 python test_train.py --config config/pointgroup_run1_scannet.yaml

(6) Repeat from (1) to (5) for self-training for 3 to 5 times

Acknowledgement

This repo is built upon several repos, e.g., PointGrouop, SparseConvNet, spconv and ScanNet.

Contact

If you have any questions or suggestions about this repo, please feel free to contact me ([email protected]).

Comments
  • About S3DIS

    About S3DIS

    Hi Liu, Do you and your team have any plan to open source the code on S3DIS (ei. data pre process)? Or could you give some idea about how to reproduce it? Many thanks.

    opened by iris0329 5
  • Test code

    Test code

    Thus can you please give your official testing code?

    I have used the test.py to test your pre-trained model (pointgroup_run1_scannet-000001250.pth). I have used intersectionAndUnion function that I want to calculate the IoU for each sample. It seems the performance it's very poor, like only 53.36 mIoU, while you said it should be 68.96. Thus can you please give your official testing code? Many thanks.

    opened by wu-zhonghua 5
  • About two .so files:

    About two .so files: "libspconv.so" and "spconv_utils.so"

    Thanks for your great work. I met some problems at the step of training (the installation and compilation steps have been completed without problems). My environment is set the same as README, and spconv has been compiled and installed.

    The code seems to require two .so files, "libspconv.so" and "spconv_utils.so". But I only found "libspconv_nms.so.1.0" and "spconv_utils.cpython-37m-x86_64-linux-gnu.so.1.0" at "One-Thing-One-Click/3D-U-Net/spconv". So when I run "python train.py --config config/pointgroup_run1_scannet.yaml", it raised two errors as below:

    OSError: /home/xxx/One-Thing-One-Click/3D-U-Net/spconv/libspconv.so: cannot open shared object file: No such file or directory at File "train.py", line 141, in from model.pointgroup.pointgroup import PointGroup as Network File "/home/xxx/One-Thing-One-Click/3D-U-Net/model/pointgroup/pointgroup.py", line 9, in import spconv File "/home/xxx/One-Thing-One-Click/3D-U-Net/spconv/init.py", line 27, in torch.ops.load_library(_LIB_PATH)

    and,

    ImportError: cannot import name 'spconv_utils' from 'spconv' (/home/xxx/One-Thing-One-Click/3D-U-Net/spconv/init.py) at File "train.py", line 141, in from model.pointgroup.pointgroup import PointGroup as Network File "/home/xxx/One-Thing-One-Click/3D-U-Net/model/pointgroup/pointgroup.py", line 9, in import spconv File "/home/xxx/One-Thing-One-Click/3D-U-Net/spconv/init.py", line 19, in from spconv import utils File "/home/xxx/One-Thing-One-Click/3D-U-Net/spconv/utils/init.py", line 16, in from spconv import spconv_utils

    Could you give some advice on how to fix these errors? Thanks for your time.

    opened by baixiao930 5
  • semantic label is not the same inside the superpoint

    semantic label is not the same inside the superpoint

    Hi, thanks for releasing the code. I have q question regarding the superpoint of s3dis you used in the paper. I found that the semantic label inside the superpoint is not same. In this way, how to calculate the label for the superpoint?

    opened by Pixie412 4
  • ImportErrors on spconv

    ImportErrors on spconv

    Hello, I followed your instructions and got everything (environment) ready to run the code. However, I found it difficult to run the self training part.

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

    It shows ImportError: cannot import name 'spconv_utils' from 'spconv' (/.../One-Thing-One-Click/3D-U-Net/spconv/__init__.py) I managed to fix spconv by reinstalling it, and it can be imported smoothly in other folders.

    Kindly notice that there is a folder /.../One-Thing-One-Click/3D-U-Net/spconv called spconv, and python will automatically refer to this folder while doing like import spconv. But the folder is apparently not the right path that can start up spconv, the right path is /.../One-Thing-One-Click/relations/lib/spconv right? As we mentioned in the installation part.

    It's not a proper way to understand what this folder /.../One-Thing-One-Click/3D-U-Net/spconv is used to do by reading EVERY FILE in it.

    So I got a little bit confused. Can you please give some instructions on this issue? ^w^

    opened by Kaisyouu 4
  • Data pre-processing

    Data pre-processing

    Hi, I was checking the code. I found out that you choose the random segment of each instance to be annotated(https://github.com/liuzhengzhe/One-Thing-One-Click/blob/6b452493727e8fe813c85a97e6e1876767c4c053/data/prepare_data_otoc.py#L95). And at the end of this function you set all points in this segment to be annotated. For example, at scene0000_00, there are 67 instances in total, from my perspective, only 67 points should be annotated. I calculated len(np.where(sem_labels!=-100)[0]) for this scan and I found that there are 15468 points with label. I also visualized the point cloud and found it is very different from figure in paper. I think what the code did is keeping one segment of each instance but not keeping only one single point of it. Is this because later you need to propagate the one labled point to the corresponding super voxel(as segment now). So this operation is equivalent to what I described above?

    opened by argosdh 4
  • About relation net

    About relation net

    Hi,I have problem is why not just use the features of 3D unet directly? It takes a lot of time to train an extra unet.Have you done any related experiments?

    opened by chendaozai 2
  • About spatial_shape clip

    About spatial_shape clip

    Hi Liu,

    In your config file, it has full_scale: [128, 512],

    and in the trainMerge(), it has spatial_shape = np.clip((locs.max(0)[0][1:] + 1).numpy(), self.full_scale[0], None)

    Could you tell me why do you need to clip the locs with the limitation of 128? Thank you~

    opened by iris0329 2
  • Cannot import spconv in the 3D-U-Net repo

    Cannot import spconv in the 3D-U-Net repo

    Hi @liuzhengzhe!,

    I have followed all the steps to successfully install the spconv and import it without any problems, including from spconv import spconv_utils. However, I cannot import spconv inside the model repo (3D-U-Net, merge, relation). The error message is shown below.

         15 import numpy as np
    ---> 16 from spconv import spconv_utils
         17 from spconv.spconv_utils import (non_max_suppression, non_max_suppression_cpu,
         18                                  points_to_voxel_3d_np, rbbox_iou,
    
    ImportError: cannot import name 'spconv_utils' from 'spconv' (/home/jimmy15923/mnt/project_code/One-Thing-One-Click/3D-U-Net/spconv/__init__.py)
    

    And I can import spconv in the upper repo. Should I remove the original spconv after installation? Thank you

    image

    opened by NCTU-VRDL 2
  • about graph propogation

    about graph propogation

    First of all, I really admire your great work, and thanks for sharing your codes!

    When I was reading your paper and tracing these codes, I have some questions: In the training phase, you use the confidence of predictions for graph propagation (GP) and replace CRF ( paper section 3.4 ). test_train.py

    But in the evaluation phase, you use CRF for GP ( paper ablation study ). test.py

    Why does the confidence score appear in the training phase but not in the evaluation phase?

    Could you please help clarify the concept behind this difference?

    opened by yolofellow376 1
  • Point Cloud Super-Voxelization

    Point Cloud Super-Voxelization

    Hi, very cool project!

    A quick question: Can you please provide a pointer to the code that calculates the super-voxel partitioning of the input point cloud?

    Thank you!

    opened by rkjones4 1
  • About Super-voxel pooling

    About Super-voxel pooling

    Hello! Thank you for a very nice job! I want to know about the implementation part of the super-voxel pooling, where is the code implementation for this part?

    opened by chendaozai 1
  • Problem about the annotation points number in S3DIS

    Problem about the annotation points number in S3DIS

    Hi, I am very interested in your work, but there is a problem that bothers me. As mentioned in the article:“In S3DIS, only 36.15 points in each room are annotated on average using “One Thing One Click”, while the original S3DIS has 193797.1 points annotated in each room.” However, as far as I understand, there are nearly 1 million points in each scene on average, so each room should have 200 annotated points(0.02%). Please tell me where is the problem. Thanks!!!

    opened by LiuChong-911 0
  • About the deployment of spconv

    About the deployment of spconv

    Hi, I ran into a problem when I was deploying spconv. When I run this code cd lib/spconv python setup.py bdist_wheel there is a errorNo CMAKE_CUDA_COMPILER could be found.

    opened by chendaozai 0
  • Data_efficient settings

    Data_efficient settings

    Hi, could you please release the data preparation code for scannet data_efficient?

    Or, just like otoc, we need to know which 'segments' those labeled data belongs, and then label all the point in these 'segments'?

    Hoping your responce sincerely~~

    opened by fanyan121212 4
  • Notice on data preparation

    Notice on data preparation

    Hi, all. @liuzhengzhe Kindly notice that there is something different in torch.save() between torch1.3 and torch1.6+.

    Before doing python prepare_data_otoc.py, should modify line 128, add param_use_new_zipfile_serialization=False Otherwise, torch.load('xxx.pth') will raise an error pytorch_model.bin is a zip archive (did you mean to use torch.jit.load()?)

    torch1.3 has no param _use_new_zipfile_serialization=False so while preparing the data, your torch should remain ver1.6 or higher, and after generating .pth files, you should go back to torch1.3 or you will find troubles because PG_OP depends on torch1.3.

    opened by Kaisyouu 0
Owner
null
Anti-Adversarially Manipulated Attributions for Weakly and Semi-Supervised Semantic Segmentation (CVPR 2021)

Anti-Adversarially Manipulated Attributions for Weakly and Semi-Supervised Semantic Segmentation Input Image Initial CAM Successive Maps with adversar

Jungbeom Lee 110 Dec 7, 2022
Weakly Supervised Dense Event Captioning in Videos, i.e. generating multiple sentence descriptions for a video in a weakly-supervised manner.

WSDEC This is the official repo for our NeurIPS paper Weakly Supervised Dense Event Captioning in Videos. Description Repo directories ./: global conf

Melon(Xuguang Duan) 96 Nov 1, 2022
Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and Semantic Segmentation (CVPR 2022)

CCAM (Unsupervised) Code repository for our paper "CCAM: Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localizati

Computer Vision Insitute, SZU 113 Dec 27, 2022
[CVPR'22] Weakly Supervised Semantic Segmentation by Pixel-to-Prototype Contrast

wseg Overview The Pytorch implementation of Weakly Supervised Semantic Segmentation by Pixel-to-Prototype Contrast. [arXiv] Though image-level weakly

Ye Du 96 Dec 30, 2022
Perturbed Self-Distillation: Weakly Supervised Large-Scale Point Cloud Semantic Segmentation (ICCV2021)

Perturbed Self-Distillation: Weakly Supervised Large-Scale Point Cloud Semantic Segmentation (ICCV2021) This is the implementation of PSD (ICCV 2021),

null 12 Dec 12, 2022
Reducing Information Bottleneck for Weakly Supervised Semantic Segmentation (NeurIPS 2021)

Reducing Information Bottleneck for Weakly Supervised Semantic Segmentation (NeurIPS 2021) The implementation of Reducing Infromation Bottleneck for W

Jungbeom Lee 81 Dec 16, 2022
Self-supervised Augmentation Consistency for Adapting Semantic Segmentation (CVPR 2021)

Self-supervised Augmentation Consistency for Adapting Semantic Segmentation This repository contains the official implementation of our paper: Self-su

Visual Inference Lab @TU Darmstadt 132 Dec 21, 2022
[CVPR 2021] "The Lottery Tickets Hypothesis for Supervised and Self-supervised Pre-training in Computer Vision Models" Tianlong Chen, Jonathan Frankle, Shiyu Chang, Sijia Liu, Yang Zhang, Michael Carbin, Zhangyang Wang

The Lottery Tickets Hypothesis for Supervised and Self-supervised Pre-training in Computer Vision Models Codes for this paper The Lottery Tickets Hypo

VITA 59 Dec 28, 2022
The official implementation of CVPR 2021 Paper: Improving Weakly Supervised Visual Grounding by Contrastive Knowledge Distillation.

Improving Weakly Supervised Visual Grounding by Contrastive Knowledge Distillation This repository is the official implementation of CVPR 2021 paper:

null 9 Nov 14, 2022
A Comprehensive Analysis of Weakly-Supervised Semantic Segmentation in Different Image Domains (IJCV submission)

wsss-analysis The code of: A Comprehensive Analysis of Weakly-Supervised Semantic Segmentation in Different Image Domains, arXiv pre-print 2019 paper.

Lyndon Chan 48 Dec 18, 2022
Context Decoupling Augmentation for Weakly Supervised Semantic Segmentation

Context Decoupling Augmentation for Weakly Supervised Semantic Segmentation The code of: Context Decoupling Augmentation for Weakly Supervised Semanti

null 54 Dec 12, 2022
Discriminative Region Suppression for Weakly-Supervised Semantic Segmentation

Discriminative Region Suppression for Weakly-Supervised Semantic Segmentation (AAAI 2021) Official pytorch implementation of our paper: Discriminative

Beom 74 Dec 27, 2022
DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision

The Official PyTorch Implementation of DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision

Shiyi Lan 3 Oct 15, 2021
The PyTorch implementation of DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision.

DiscoBox: Weakly Supervised Instance Segmentation and Semantic Correspondence from Box Supervision The PyTorch implementation of DiscoBox: Weakly Supe

Shiyi Lan 1 Oct 23, 2021
ST++: Make Self-training Work Better for Semi-supervised Semantic Segmentation

ST++ This is the official PyTorch implementation of our paper: ST++: Make Self-training Work Better for Semi-supervised Semantic Segmentation. Lihe Ya

Lihe Yang 147 Jan 3, 2023
Code for our paper Domain Adaptive Semantic Segmentation with Self-Supervised Depth Estimation

CorDA Code for our paper Domain Adaptive Semantic Segmentation with Self-Supervised Depth Estimation Prerequisite Please create and activate the follo

Qin Wang 60 Nov 30, 2022
[CVPR 2021] MiVOS - Mask Propagation module. Reproduced STM (and better) with training code :star2:. Semi-supervised video object segmentation evaluation.

MiVOS (CVPR 2021) - Mask Propagation Ho Kei Cheng, Yu-Wing Tai, Chi-Keung Tang [arXiv] [Paper PDF] [Project Page] [Papers with Code] This repo impleme

Rex Cheng 106 Jan 3, 2023
[CVPR 21] Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR), 2021.

Vectorization and Rasterization: Self-Supervised Learning for Sketch and Handwriting, CVPR 2021. Ayan Kumar Bhunia, Pinaki nath Chowdhury, Yongxin Yan

Ayan Kumar Bhunia 44 Dec 12, 2022
Semi-supervised Semantic Segmentation with Directional Context-aware Consistency (CVPR 2021)

Semi-supervised Semantic Segmentation with Directional Context-aware Consistency (CAC) Xin Lai*, Zhuotao Tian*, Li Jiang, Shu Liu, Hengshuang Zhao, Li

Jia Research Lab 137 Dec 14, 2022