OpenPoints

repository·master·Indexed 19 days ago

https://github.com/guochengqian/openpoints

A PyTorch-based library for benchmarking and reproducing point-cloud understanding methods. Version 0.1.2 provides a configuration-driven framework for building point-based neural networks, including support for models such as PointNet, DGCNN, PointNet++, PointMLP, and PointNeXt. It includes point cloud understanding models, layers, datasets, transforms, optimizers, and training utilities, with optional C++/CUDA operators for operations like Earth-Mover-Distance (EMD) and Chamfer distance.

Tokens
1.1K
Snippets
4
Records
5
Agent score
15%

What's inside openpoints

  1. Overview of OpenPoints features and supported models

    master

    OpenPoints is a framework designed for benchmarking and reproducing point-based methods for point cloud understanding. It serves as the underlying engine for the PointNeXt project.

    Key Features

    • Extensibility: Supports a wide range of basic operations including graph convolutions, self-attention, farthest point sampling, and ball query, making it easy to build new networks.
    • Ease of Use: Configuration-based workflow for building models, optimizers, schedulers, loss functions, and data loaders.

    Supported Models

    • PointNet
    • DGCNN
    • DeepGCN
    • PointNet++
    • ASSANet
    • PointMLP
    • PointNeXt
    • Pix4Point
    • PointVector
  2. Install the EMD PyTorch Wrapper

    master

    To install the Earth-Mover-Distance (EMD) PyTorch wrapper, compile the package using setup.py. Note that the implementation was tested on Ubuntu 16.04, PyTorch 1.1.0, and CUDA 9.0.

    After installation, you must copy the compiled .so library file from the build directory to your main project directory to ensure it is importable.

    # Compile and install
    python setup.py install
    
    # Copy the compiled library to the current directory
    # Note: The specific filename may vary based on your OS, Python version, and architecture
    cp build/lib.linux-x86_64-3.6/emd_cuda.cpython-36m-x86_64-linux-gnu.so .
  3. Install OpenPoints

    master

    You can install OpenPoints as a Python package via pip. Note that while the Python library and configuration files are included in the PyPI package, CUDA/C++ operators (like pointnet2_batch_cuda, pointops_cuda, chamfer, and emd_cuda) currently require a source installation to ensure compatibility with your specific PyTorch and CUDA versions.

    Standard Installation

    pip install openpoints

    To enable full training and evaluation capabilities, you must install from source after installing PyTorch to compile the necessary C++/CUDA extensions:

    1. Clone the repository recursively.
    2. Install the Python package with optional dependencies (data, viz, wandb).
    3. Manually install each CUDA operator directory.

    If openpoints is unavailable on your package mirror, look for openpoints-torch; the import name remains openpoints.

    git clone --recursive https://github.com/guochengqian/openpoints.git
    cd openpoints
    pip install -e .[data,viz,wandb]
    cd cpp/pointnet2_batch && python setup.py install && cd ../..
    cd cpp/pointops && python setup.py install && cd ../..
    cd cpp/chamfer_dist && python setup.py install && cd ../..
    cd cpp/emd && python setup.py install && cd ../..
  4. Build models and criteria from configuration files

    master

    OpenPoints uses a configuration-driven approach. You can easily instantiate models, optimizers, schedulers, loss functions, and data loaders by passing configuration objects (typically loaded from .yaml files) to builder functions. This allows you to switch between different models and tasks by simply modifying the cfg**.yaml file.

    model = build_model_from_cfg(cfg.model)
    criterion = build_criterion_from_cfg(cfg.criterion_args)
  5. Use earth_mover_distance in PyTorch

    master

    The emd module provides the earth_mover_distance function to calculate the distance between two point clouds.

    Arguments:

    • p1: Tensor of shape (B, N1, 3) representing the first batch of point clouds.
    • p2: Tensor of shape (B, N2, 3) representing the second batch of point clouds.
    • transpose: Boolean flag (default False).
    from emd import earth_mover_distance
    
    # p1 and p2 should be tensors of shape (B, N, 3)
    d = earth_mover_distance(p1, p2, transpose=False)