8000 GitHub - rktraz/treePoinTr: PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers -- adapted for completion of individual trees in a forestry context
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers -- adapted for completion of individual trees in a forestry context

License

Notifications You must be signed in to change notification settings

rktraz/treePoinTr

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
8000 Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

This repository contains the PyTorch implementation for PoinTr, which was adapted for a study on point cloud completion of terrestrial laserscanning data of individual trees.

🚨 GCC 11+ Compatibility Notice

⚠️ This repository includes critical fixes for GCC 11+ compatibility!

If you're using GCC 11+ or CUDA 12+, please follow the SETUP.md guide instead of the original installation instructions below. The original installation will fail with modern compiler versions.

Quick Start:

# 1. Create environment
conda create -n treepointr_py310 python=3.10 -y
conda activate treepointr_py310

# 2. Install PyTorch 
conda install pytorch==1.13.1 torchvision==0.14.1 torchaudio==0.13.1 pytorch-cuda=11.7 -c pytorch -c nvidia -y

# 3. Install dependencies
pip install -r requirements.txt

# 4. Install CUDA extensions (with fixes!)
bash install.sh

# 5. Install PointNet++ (optional)
bash install_pointnet2.sh

πŸ“š For detailed setup instructions, see SETUP.md


The folder tree_workflow contains jupyter notebooks for:

  • Creating training samples from individual tree point clouds (make_samples_for_treePoinTr.ipynb)
  • Applying the completion approach to individual trees (whole_tree_completion_workflow.ipynb)

The data used in the study and the models trained in the study can be downloaded from Zenodo: doi.org/10.5281/zenodo.13303159

The folder treehull_workflow contains scripts and instructions for the completion of the outer hull shape of individual trees.

For installation and usage, please follow the original instructions below, provided by the authors of PoinTr.

PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers

PWC

Created by Xumin Yu*, Yongming Rao*, Ziyi Wang, Zuyan Liu, Jiwen Lu, Jie Zhou

[arXiv] [Video] [Dataset] [Models] [supp]

This repository contains PyTorch implementation for PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers (ICCV 2021 Oral Presentation).

PoinTr is a transformer-based model for point cloud completion. By representing the point cloud as a set of unordered groups of points with position embeddings, we convert the point cloud to a sequence of point proxies and employ a transformer encoder-decoder architecture for generation. We also propose two more challenging benchmarks ShapeNet-55/34 with more diverse incomplete point clouds that can better reflect the real-world scenarios to promote future research.

intro

πŸ”₯News

  • 2023-9-2 AdaPoinTr accepted by T-PAMI, Projected-ShapeNet dataset see here
  • 2023-1-11 Release AdaPoinTr (PoinTr + Adaptive Denoising Queries), achieving SOTA performance on various benchmarks. Arxiv.
  • 2022-06-01 Implement SnowFlakeNet.
  • 2021-10-07 Our solution based on PoinTr wins the Championship on MVP Completion Challenge (ICCV Workshop 2021). The code will come soon.
  • 2021-09-09 Fix a bug in datasets/PCNDataset.py(#27), and update the performance of PoinTr on PCN benchmark (CD from 8.38 to 7.26).

Pretrained Models

We provide pretrained PoinTr models:

dataset url performance
ShapeNet-55 [Tsinghua Cloud] / [Google Drive] / [BaiDuYun] (code:erdh) CD = 1.09e-3
ShapeNet-34 [Tsinghua Cloud] / [Google Drive] / [BaiDuYun] (code:atbb ) CD = 2.05e-3
PCN [Tsinghua Cloud] / [Google Drive] / [BaiDuYun] (code:9g79) CD = 8.38e-3
PCN_new [Tsinghua Cloud] / [Google Drive] / [BaiDuYun] (code:aru3 ) CD = 7.26e-3
KITTI [Tsinghua Cloud] / [Google Drive] / [BaiDuYun] (code:99om) MMD = 5.04e-4

We provide pretrained AdaPoinTr models (coming soon):

dataset url performance
ShapeNet-55 Tsinghua Cloud / Google Drive / BaiDuYun CD = 0.81e-3
ShapeNet-34 Tsinghua Cloud / Google Drive / BaiDuYun CD = 1.23e-3
Projected_ShapeNet-55 Tsinghua Cloud / Google Drive / [BaiDuYun](code:dycc) CD = 9.58e-3
Projected_ShapeNet-34 Tsinghua Cloud / Google Drive / [BaiDuYun](code:dycc) CD = 9.12e-3
PCN [Tsinghua Cloud] / [Google Drive] / [BaiDuYun](code:rc7p) CD = 6.53e-3

Usage

Requirements

  • PyTorch >= 1.7.0
  • python >= 3.7
  • CUDA >= 9.0
  • GCC >= 4.9
  • torchvision
  • timm
  • open3d
  • tensorboardX
pip install -r requirements.txt

Building Pytorch Extensions for Chamfer Distance, PointNet++ and kNN

NOTE: PyTorch >= 1.7 and GCC >= 4.9 are required.

# Chamfer Distance
bash install.sh

The solution for a common bug in chamfer distance installation can be found in Issue #6

# PointNet++
pip install "git+https://github.com/erikwijmans/Pointnet2_PyTorch.git#egg=pointnet2_ops&subdirectory=pointnet2_ops_lib"
# GPU kNN
pip install --upgrade https://github.com/unlimblue/KNN_CUDA/releases/download/0.2/KNN_CUDA-0.2-py3-none-any.whl

Note: If you still get ModuleNotFoundError: No module named 'gridding' or something similar then run these steps

    1. cd into extensions/Module (eg extensions/gridding)
    2. run `python setup.py install`

That will fix the ModuleNotFoundError.

Dataset

The details of our new ShapeNet-55/34 datasets and other existing datasets can be found in DATASET.md.

Inference

To inference sample(s) with pretrained model

python tools/inference.py \
${POINTR_CONFIG_FILE} ${POINTR_CHECKPOINT_FILE} \
[--pc_root <path> or --pc <file>] \
[--save_vis_img] \
[--out_pc_root <dir>] \

For example, inference all samples under demo/ and save the results under inference_result/

python tools/inference.py \
cfgs/PCN_models/AdaPoinTr.yaml ckpts/AdaPoinTr_PCN.pth \
--pc_root demo/ \ 
--save_vis_img  \
--out_pc_root inference_result/ \

Evaluation

To evaluate a pre-trained PoinTr model on the Three Dataset with single GPU, run:

bash ./scripts/test.sh <GPU_IDS>  \
    --ckpts <path> \
    --config <config> \
    --exp_name <name> \
    [--mode <easy/median/hard>]

Some examples:

Test the PoinTr (AdaPoinTr) pretrained model on the PCN benchmark or Projected_ShapeNet:

bash ./scripts/test.sh 0 \
    --ckpts ./pretrained/PoinTr_PCN.pth \
    --config ./cfgs/PCN_models/PoinTr.yaml \
    --exp_name example

bash ./scripts/test.sh 0 \
    --ckpts ./pretrained/PoinTr_ps55.pth \
    --config ./cfgs/Projected_ShapeNet55_models/AdaPoinTr.yaml \
    --exp_name example

Test the PoinTr pretrained model on ShapeNet55 benchmark (easy mode):

bash ./scripts/test.sh 0 \
    --ckpts ./pretrained/PoinTr_ShapeNet55.pth \
    --config ./cfgs/ShapeNet55_models/PoinTr.yaml \
    --mode easy \
    --exp_name example

Test the PoinTr pretrained model on the KITTI benchmark:

bash ./scripts/test.sh 0 \
    --ckpts ./pretrained/PoinTr_KITTI.pth \
    --config ./cfgs/KITTI_models/PoinTr.yaml \
    --exp_name example
CUDA_VISIBLE_DEVICES=0 python KITTI_metric.py \
    --vis <visualization_path> 

Training

To train a point cloud completion model from scratch, run:

# Use DistributedDataParallel (DDP)
bash ./scripts/dist_train.sh <NUM_GPU> <port> \
    --config <config> \
    --exp_name <name> \
    [--resume] \
    [--start_ckpts <path>] \
    [--val_freq <int>]
# or just use DataParallel (DP)
bash ./scripts/train.sh <GPUIDS> \
    --config <config> \
    --exp_name <name> \
    [--resume] \
    [--start_ckpts <path>] \
    [--val_freq <int>]

Some examples:

Train a PoinTr model on PCN benchmark with 2 gpus:

CUDA_VISIBLE_DEVICES=0,1 bash ./scripts/dist_train.sh 2 13232 \
    --config ./cfgs/PCN_models/PoinTr.yaml \
    --exp_name example

Resume a checkpoint:

CUDA_VISIBLE_DEVICES=0,1 bash ./scripts/dist_train.sh 2 13232 \
    --config ./cfgs/PCN_models/PoinTr.yaml \
    --exp_name example --resume

Finetune a PoinTr on PCNCars

CUDA_VISIBLE_DEVICES=0,1 bash ./scripts/dist_train.sh 2 13232 \
    --config ./cfgs/KITTI_models/PoinTr.yaml \
    --exp_name example \
    --start_ckpts ./weight.pth

Train a PoinTr model with a single GPU:

bash ./scripts/train.sh 0 \
    --config ./cfgs/KITTI_models/PoinTr.yaml \
    --exp_name example

We also provide the Pytorch implementation of several baseline models including GRNet, PCN, TopNet and FoldingNet. For example, to train a GRNet model on ShapeNet-55, run:

CUDA_VISIBLE_DEVICES=0,1 bash ./scripts/dist_train.sh 2 13232 \
    --config ./cfgs/ShapeNet55_models/GRNet.yaml \
    --exp_name example

Completion Results on ShapeNet55 and KITTI-Cars

results

πŸ”§ Changelog - GCC 11+ Compatibility Fixes

This fork includes the following improvements:

Fixed Issues:

  • βœ… GCC 11+ Compatibility: Resolved std::function parameter pack expansion errors
  • βœ… CUDA Version Mismatches: Bypassed PyTorch's strict CUDA version checking
  • βœ… Missing CUDA Headers: Proper include/library path detection
  • βœ… Runtime Library Issues: Automatic LD_LIBRARY_PATH configuration
  • βœ… Modern Compiler Support: Automatic GCC 9 installation via conda

Enhanced Installation:

  • πŸš€ One-command install: bash install.sh handles everything automatically
  • πŸ” Environment validation: Checks conda environment, PyTorch, CUDA availability
  • πŸ“ Comprehensive logging: Detailed error logs for debugging
  • πŸ› οΈ Automatic recovery: Cleans and retries installation on failure

Files Modified:

  • install.sh - Enhanced installation script with environment management
  • extensions/*/setup.py - All 5 CUDA extensions with compatibility fixes
  • external_deps/Pointnet2_PyTorch/pointnet2_ops_lib/setup.py - PointNet++ compatibility fixes
  • install_pointnet2.sh - PointNet++ installation script
  • test_installation.py - Comprehensive installation testing
  • SETUP.md - Complete setup guide for new users
  • README.md - Added compatibility notices

Original TreePoinTr functionality is preserved - only installation improvements added.

License

MIT License

Acknowledgements

Our code is inspired by GRNet and mmdetection3d.

Citation

If you find our work useful in your research, please consider citing:

@inproceedings{yu2021pointr,
  title={PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers},
  author={Yu, Xumin and Rao, Yongming and Wang, Ziyi and Liu, Zuyan and Lu, Jiwen and Zhou, Jie},
  booktitle={ICCV},
  year={2021}
}

About

PoinTr: Diverse Point Cloud Completion with Geometry-Aware Transformers -- adapted for completion of individual trees in a forestry context

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 68.7%
  • Jupyter Notebook 17.0%
  • Cuda 11.1%
  • C++ 1.9%
  • Shell 1.3%
0