Pytorch Implementation of Various Point Transformers

Overview

Pytorch Implementation of Various Point Transformers

Recently, various methods applied transformers to point clouds: PCT: Point Cloud Transformer (Meng-Hao Guo et al.), Point Transformer (Nico Engel et al.), Point Transformer (Hengshuang Zhao et al.). This repo is a pytorch implementation for these methods and aims to compare them under a fair setting. Currently, all three methods are implemented, while tuning their hyperparameters.

Classification

Data Preparation

Download alignment ModelNet here and save in modelnet40_normal_resampled.

Run

Change which method to use in config/config.yaml and run

python train.py

Results

Using Adam with learning rate decay 0.3 for every 50 epochs, train for 200 epochs; data augmentation follows this repo. For Hengshuang and Nico, initial LR is 1e-3 (maybe fine-tuned later); for Menghao, initial LR is 1e-4, as suggested by the author. ModelNet40 classification results (instance average) are listed below:

Model Accuracy
Hengshuang 89.6
Menghao 92.6
Nico 85.5

Miscellaneous

Some code and training settings are borrowed from https://github.com/yanx27/Pointnet_Pointnet2_pytorch. Code for PCT: Point Cloud Transformer (Meng-Hao Guo et al.) is adapted from the author's Jittor implementation https://github.com/MenghaoGuo/PCT.

Comments
  • Question about modelnet40_normal_resampled

    Question about modelnet40_normal_resampled

    Hi @qq456cvb,

    I've had experience working with the ModelNet40 data which usually comes in the format of .OFF https://segeval.cs.princeton.edu/public/off_format.html with x, y, z listed in each file. However, the dataset provided on this repo is from the shapenet website and seems to be in a different format.

    Digging through the files, I find that there are 3 extra values following the x, y, z. What do these 3 additional values represent? What are the differences between the two mentioned datsets?

    Thanks!

    opened by jah05 4
  • Hengshuang new result

    Hengshuang new result

    batch_size: 32
    epoch: 500
    learning_rate: 0.0005
    gpu: 0
    num_point: 1024
    optimizer: Adam
    weight_decay: 0.0001
    normal: true
    model:
      nneighbor: 16
      nblocks: 4
      transformer_dim: 512
      name: Hengshuang
    

    Best Instance Accuracy: 0.917067, Class Accuracy: 0.893971

    opened by yuchenlichuck 3
  • AssertionError: Torch not compiled with CUDA enabled

    AssertionError: Torch not compiled with CUDA enabled

    I have installed Torch and CUDA,and my computer system also has GPU. QQ截图20210411145948 QQ截图20210411150139 However, this model still is successfully transformed to CUDA. As this QQ截图20210411150658 How to solve this problem?

    opened by GCH-upup 3
  • question about pytorch version

    question about pytorch version

    Hi, @qq456cvb,

    I got the error RuntimeError: cuda runtime error (38) : no CUDA-capable device is detected at /pytorch/aten/src/THC/THCGeneral.cpp:50 . The details is here (https://gist.github.com/amiltonwong/9feaaa7d91721ccf6ad8a0d9b5d27d56)

    The version of pytorch in my system is v1.3. Which version should we use?

    Thanks!

    opened by amiltonwong 3
  • A question about initial learning rate.

    A question about initial learning rate.

    Thanks for your attention to PCT ! In our experiments, I find the PCT is sensitive to initial lr. 1e-3 is too large to make pct converge. I change the initial lr from 1e-3 to 1e-4 and get following results.

    batch_size: 16 epoch: 200 gpu: 1 learning_rate: 0.0001 model: name: Menghao name: Menghao normal: true num_point: 1024 optimizer: Adam weight_decay: 0.0001

    [2021-01-13 11:59:39,205][main][INFO] - Load dataset ... The size of train data is 9843 The size of test data is 2468 [2021-01-13 11:59:42,420][main][INFO] - No existing model, starting training from scratch... [2021-01-13 11:59:42,421][main][INFO] - Start training... [2021-01-13 11:59:42,421][main][INFO] - Epoch 1 (1/200): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [03:09<00:00, 3.25it/s] [2021-01-13 12:02:51,857][main][INFO] - Train Instance Accuracy: 0.387277 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 155/155 [00:48<00:00, 3.20it/s] [2021-01-13 12:03:40,472][main][INFO] - Test Instance Accuracy: 0.511694, Class Accuracy: 0.345986 [2021-01-13 12:03:40,472][main][INFO] - Best Instance Accuracy: 0.511694, Class Accuracy: 0.345986 [2021-01-13 12:03:40,472][main][INFO] - Save model... [2021-01-13 12:03:40,472][main][INFO] - Saving at best_model.pth [2021-01-13 12:03:40,559][main][INFO] - Epoch 2 (2/200): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [03:13<00:00, 3.18it/s] [2021-01-13 12:06:54,418][main][INFO] - Train Instance Accuracy: 0.488636 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 155/155 [00:48<00:00, 3.16it/s] [2021-01-13 12:07:43,537][main][INFO] - Test Instance Accuracy: 0.663710, Class Accuracy: 0.506854 [2021-01-13 12:07:43,538][main][INFO] - Best Instance Accuracy: 0.663710, Class Accuracy: 0.506854 [2021-01-13 12:07:43,538][main][INFO] - Save model... [2021-01-13 12:07:43,538][main][INFO] - Saving at best_model.pth [2021-01-13 12:07:43,680][main][INFO] - Epoch 3 (3/200): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [03:09<00:00, 3.25it/s] [2021-01-13 12:10:53,202][main][INFO] - Train Instance Accuracy: 0.549682 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 155/155 [00:49<00:00, 3.11it/s] [2021-01-13 12:11:43,145][main][INFO] - Test Instance Accuracy: 0.747581, Class Accuracy: 0.612702 [2021-01-13 12:11:43,146][main][INFO] - Best Instance Accuracy: 0.747581, Class Accuracy: 0.612702 [2021-01-13 12:11:43,146][main][INFO] - Save model... [2021-01-13 12:11:43,146][main][INFO] - Saving at best_model.pth [2021-01-13 12:11:43,239][main][INFO] - Epoch 4 (4/200): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [03:11<00:00, 3.22it/s] [2021-01-13 12:14:54,499][main][INFO] - Train Instance Accuracy: 0.592549 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 155/155 [00:49<00:00, 3.16it/s] [2021-01-13 12:15:43,646][main][INFO] - Test Instance Accuracy: 0.799597, Class Accuracy: 0.684245 [2021-01-13 12:15:43,647][main][INFO] - Best Instance Accuracy: 0.799597, Class Accuracy: 0.684245 [2021-01-13 12:15:43,647][main][INFO] - Save model... [2021-01-13 12:15:43,647][main][INFO] - Saving at best_model.pth [2021-01-13 12:15:43,773][main][INFO] - Epoch 5 (5/200): 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 616/616 [03:10<00:00, 3.23it/s] [2021-01-13 12:18:54,845][main][INFO] - Train Instance Accuracy: 0.625095 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 155/155 [00:48<00:00, 3.19it/s] [2021-01-13 12:19:43,585][main][INFO] - Test Instance Accuracy: 0.813306, Class Accuracy: 0.711771 [2021-01-13 12:19:43,586][main][INFO] - Best Instance Accuracy: 0.813306, Class Accuracy: 0.711771 [2021-01-13 12:19:43,586][main][INFO] - Save model... [2021-01-13 12:19:43,586][main][INFO] - Saving at best_model.pth [2021-01-13 12:19:43,692][main][INFO] - Epoch 6 (6/200): 7%|██████████▏ | 44/616 [00:15<02:27, 3.89it/s]

    Best Regards, Menghao

    opened by MenghaoGuo 3
  • AttributeError: module 'hydra' has no attribute 'main'

    AttributeError: module 'hydra' has no attribute 'main'

    Hi. Thanks for sharing the code.

    When I run

    python train.py
    

    there's an error

    Traceback (most recent call last):
      File "train.py", line 44, in <module>
        @hydra.main(config_path='config', config_name='config')
    AttributeError: module 'hydra' has no attribute 'main'
    

    How can I solve this?

    opened by trisct 2
  • question about output feature dimension

    question about output feature dimension

    Hi, @qq456cvb ,

    According to the Fig. 3 in Hengshuang's Point Transformer model, the output feature dimension of each transformer block should be different . e.g. [32, 64, 128, 256, 512]. But your implementation uses a unqiue one, e.g. 512. Any comment on this?

    Thanks!

    opened by amiltonwong 2
  • Differences between this implementation and paper(Menghao. PCT: Point Cloud Transformer).

    Differences between this implementation and paper(Menghao. PCT: Point Cloud Transformer).

    1. In the paper, the output of the encoder would be processed by a MA-Pool layer, instead of a single max pooling.
    2. The initial learning rate in paper is 0.01, with a cosine annealing schedule.
    opened by JLU-Neal 1
  • The question on PointNetFeaturePropagation class

    The question on PointNetFeaturePropagation class

    https://github.com/qq456cvb/Point-Transformers/blob/5caf2caede06b452592a16e2b342df48d24fbdd3/pointnet_util.py#L261

    In this class, there is one line code as following:

    interpolated_points = torch.sum(index_points(points2, idx) * weight.view(B, N, 3, 1), dim=2)

    I think points2 should be replaced by points1.

    The variable "idx" refers to the top3 index of points1 whose distance is short to points2, and the “index_points” function is to find k(k=3) nearest neighbor of each point in points2 , which is found in points1.

    Are there any questions in my understanding? I really sincerely want to get your answer, thanks !

    opened by HustQBW 0
  • which version of hydra do you recommend to work with CUDA?

    which version of hydra do you recommend to work with CUDA?

    Hello. I am getting this error everytime I run the code

    /home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/_internal/defaults_list.py:251: UserWarning: In 'cls': Defaults list is missing _self_. See https://hydra.cc/docs/upgrades/1.0_to_1.1/default_composition_order for more information warnings.warn(msg, UserWarning) /home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/core/default_element.py:126: UserWarning: In 'model/Menghao': Usage of deprecated keyword in package header '# @package group'. See https://hydra.cc/docs/next/upgrades/1.0_to_1.1/changes_to_package_header for more information See {url} for more information""" {'model': {'name': 'Menghao'}, 'batch_size': 16, 'epoch': 200, 'learning_rate': 0.001, 'gpu': 1, 'num_point': 1024, 'optimizer': 'Adam', 'weight_decay': 0.0001, 'normal': True} [2022-09-17 13:35:42,215][main][INFO] - Load dataset ... The size of train data is 9843 The size of test data is 2468 Error executing job with overrides: [] Traceback (most recent call last): File "train_cls.py", line 162, in main() File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/main.py", line 52, in decorated_main config_name=config_name, File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/_internal/utils.py", line 378, in _run_hydra lambda: hydra.run( File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/_internal/utils.py", line 214, in run_and_report raise ex File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/_internal/utils.py", line 211, in run_and_report return func() File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/_internal/utils.py", line 381, in overrides=args.overrides, File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 111, in run _ = ret.return_value File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/core/utils.py", line 233, in return_value raise self._return_value File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/hydra/core/utils.py", line 160, in run_job ret.return_value = task_function(task_cfg) File "train_cls.py", line 68, in main classifier = getattr(importlib.import_module('models.{}.model'.format(args.model.name)), 'PointTransformerCls')(args).cuda() File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 689, in cuda return self._apply(lambda t: t.cuda(device)) File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 579, in _apply module._apply(fn) File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 602, in _apply param_applied = fn(param) File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/torch/nn/modules/module.py", line 689, in return self._apply(lambda t: t.cuda(device)) File "/home/myuser/anaconda3/envs/myenv/lib/python3.7/site-packages/torch/cuda/init.py", line 217, in _lazy_init torch._C._cuda_init() RuntimeError: No CUDA GPUs are available

    If I dont run it through hydra, it compiles easily. Any specific versions of Hydra that you are using?

    opened by ahsanfarooqui 0
  • About part segmentation best inctance avg mIOU

    About part segmentation best inctance avg mIOU

    In my experiment based on shapenet, thebest inctance avg mIOU is only 84.4%, which is 2% lower than that in the paper. Do you know the reason?Thank you very much

    opened by sh4175515 1
  • Why the test accuracy can be higher than train accuracy?

    Why the test accuracy can be higher than train accuracy?

    Hello,

    When I used ModelNet 40 and other dataset to train Point Transformer(Hengshuang), I found after the 3rd epoch, the test accuracy would be higher than train accuracy. It makes no sense a model could perform better when processing unseen data, right? Do you also meet this phenomenon?

    opened by Gary769581667 1
  • Hardware requirement

    Hardware requirement

    Thank you for your great work ! I wonder the hardware requirements for the all three versions of Point Transformer. It seems that Hengshuang's method needs 4 24GB GPUs (TITAN RTX),how about the another two versions? Can several RTX 2080 Ti GPUs work? Looking forward to your reply!

    opened by FuJingyun 0
Owner
Neil You
A Ph.D candidate, stay simple, stay naive. 理论和工程两手抓,都要硬。
Neil You
Implementation of the "Point 4D Transformer Networks for Spatio-Temporal Modeling in Point Cloud Videos" paper.

Point 4D Transformer Networks for Spatio-Temporal Modeling in Point Cloud Videos Introduction Point cloud videos exhibit irregularities and lack of or

Hehe Fan 101 Dec 29, 2022
Unofficial implementation of Point-Unet: A Context-Aware Point-Based Neural Network for Volumetric Segmentation

Point-Unet This is an unofficial implementation of the MICCAI 2021 paper Point-Unet: A Context-Aware Point-Based Neural Network for Volumetric Segment

Namt0d 9 Dec 7, 2022
Implementation of various Vision Transformers I found interesting

Implementation of various Vision Transformers I found interesting

Kim Seonghyeon 78 Dec 6, 2022
Style-based Point Generator with Adversarial Rendering for Point Cloud Completion (CVPR 2021)

Style-based Point Generator with Adversarial Rendering for Point Cloud Completion (CVPR 2021) An efficient PyTorch library for Point Cloud Completion.

Microsoft 119 Jan 2, 2023
Code for "PV-RAFT: Point-Voxel Correlation Fields for Scene Flow Estimation of Point Clouds", CVPR 2021

PV-RAFT This repository contains the PyTorch implementation for paper "PV-RAFT: Point-Voxel Correlation Fields for Scene Flow Estimation of Point Clou

Yi Wei 43 Dec 5, 2022
Point Cloud Denoising input segmentation output raw point-cloud valid/clear fog rain de-noised Abstract Lidar sensors are frequently used in environme

Point Cloud Denoising input segmentation output raw point-cloud valid/clear fog rain de-noised Abstract Lidar sensors are frequently used in environme

null 75 Nov 24, 2022
Synthetic LiDAR sequential point cloud dataset with point-wise annotations

SynLiDAR dataset: Learning From Synthetic LiDAR Sequential Point Cloud This is official repository of the SynLiDAR dataset. For technical details, ple

null 78 Dec 27, 2022
[ICCV 2021 Oral] SnowflakeNet: Point Cloud Completion by Snowflake Point Deconvolution with Skip-Transformer

This repository contains the source code for the paper SnowflakeNet: Point Cloud Completion by Snowflake Point Deconvolution with Skip-Transformer (ICCV 2021 Oral). The project page is here.

AllenXiang 65 Dec 26, 2022
Point-NeRF: Point-based Neural Radiance Fields

Point-NeRF: Point-based Neural Radiance Fields Project Sites | Paper | Primary c

Qiangeng Xu 662 Jan 1, 2023
Not All Points Are Equal: Learning Highly Efficient Point-based Detectors for 3D LiDAR Point Clouds (CVPR 2022, Oral)

Not All Points Are Equal: Learning Highly Efficient Point-based Detectors for 3D LiDAR Point Clouds (CVPR 2022, Oral) This is the official implementat

Yifan Zhang 259 Dec 25, 2022
[ICCV 2021 Oral] PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers

PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers Created by Xumin Yu*, Yongming Rao*, Ziyi Wang, Zuyan Liu, Jiwen Lu, Jie Zhou

Xumin Yu 317 Dec 26, 2022
REGTR: End-to-end Point Cloud Correspondences with Transformers

REGTR: End-to-end Point Cloud Correspondences with Transformers This repository contains the source code for REGTR. REGTR utilizes multiple transforme

Zi Jian Yew 108 Dec 17, 2022
Multivariate Time Series Forecasting with efficient Transformers. Code for the paper "Long-Range Transformers for Dynamic Spatiotemporal Forecasting."

Spacetimeformer Multivariate Forecasting This repository contains the code for the paper, "Long-Range Transformers for Dynamic Spatiotemporal Forecast

QData 440 Jan 2, 2023
Woosung Choi 63 Nov 14, 2022
🍀 Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐

?? Pytorch implementation of various Attention Mechanisms, MLP, Re-parameter, Convolution, which is helpful to further understand papers.⭐⭐⭐

xmu-xiaoma66 7.7k Jan 5, 2023
Pytorch implementation of various High Dynamic Range (HDR) Imaging algorithms

Deep High Dynamic Range Imaging Benchmark This repository is the pytorch impleme

Tianhong Dai 5 Nov 16, 2022
Pytorch implementation of PCT: Point Cloud Transformer

PCT: Point Cloud Transformer This is a Pytorch implementation of PCT: Point Cloud Transformer.

Yi_Zhang 265 Dec 22, 2022
Implementation of the Point Transformer layer, in Pytorch

Point Transformer - Pytorch Implementation of the Point Transformer self-attention layer, in Pytorch. The simple circuit above seemed to have allowed

Phil Wang 501 Jan 3, 2023
[PyTorch] Official implementation of CVPR2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency". https://arxiv.org/abs/2103.05465

PointDSC repository PyTorch implementation of PointDSC for CVPR'2021 paper "PointDSC: Robust Point Cloud Registration using Deep Spatial Consistency",

null 153 Dec 14, 2022