How to Get Started with Mask3D: A Guide to 3D Instance Segmentation

Jul 14, 2023 | Data Science

Welcome to the world of Mask3D, the Mask Transformer designed specifically for 3D instance segmentation! If you are venturing into 3D semantic segmentation, you’re likely to be excited about the state-of-the-art performance that Mask3D achieves on datasets such as ScanNet, ScanNet200, S3DIS, and STPLS3D. In this guide, we’ll walk you through the essential steps to get started with Mask3D, highlight some key features, and troubleshoot common issues you may encounter.

Getting Started with Mask3D

Before diving into our first steps, let’s lay down our objectives. This guide will cover:

  • Setting up the environment for Mask3D
  • Data preprocessing
  • Training and testing the model

1. Setting Up the Environment

First, you’ll want to establish a proper environment to execute Mask3D. It is adaptable with a codebase inspired by Mix3D, meaning it’s modularized for ease of use. Here’s how to set it up:

  • Ensure you have Python version 3.10.9 and CUDA 11.3.
  • Create a conda environment and install the required dependencies:
  • conda env create -f environment.yml
    conda activate mask3d_cuda113
    pip3 install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
    pip3 install torch-scatter -f https://data.pyg.org/whl/torch-1.12.1+cu113.html
    pip3 install git+https://github.com/facebookresearch/detectron2.git@710e7795d0eeadf9def0e7ef957eea13532e34cf --no-deps
    mkdir third_party
    cd third_party
    git clone --recursive https://github.com/NVIDIA/MinkowskiEngine
    cd MinkowskiEngine
    git checkout 02fc608bea4c0549b0a7b00ca1bf15dee4a0b228
    python setup.py install --force_cuda --blas=openblas
    cd ..
    git clone https://github.com/ScanNet/ScanNet.git
    cd ScanNetSegmentator
    git checkout 3e5726500896748521a6ceb81271b0f5b2c0e7d2
    make
    cd ..
    pip3 install pytorch-lightning==1.7.2
    

2. Data Preprocessing

After setting up the environment, it’s time to preprocess datasets like ScanNet, S3DIS, and STPLS3D. Here’s how:

  • For ScanNet and ScanNet200, apply Felzenswalb and Huttenlocher’s Graph Based Image Segmentation algorithm.
  • Use the preprocessing script as follows:
  • python -m datasets.preprocessing.scannet_preprocessing preprocess --data_dir=PATH_TO_RAW_SCANNET_DATASET --save_dir=data/processed/scannet --git_repo=PATH_TO_SCANNET_GIT_REPO --scannet200=false
    
  • Handle the S3DIS dataset by fixing any small bugs manually or apply the preprocessing script that we will release shortly.
  • For STPLS3D, the command will look like this:
  • python -m datasets.preprocessing.stpls3d_preprocessing preprocess --data_dir=PATH_TO_STPLS3D --save_dir=data/processed/stpls3d
    

3. Training and Testing

Now that the datasets are ready, let’s get Mask3D trained and tested.

  • To train Mask3D on the ScanNet dataset, use the command:
  • python main_instance_segmentation.py
    
  • For inference, if you’ve obtained a checkpoint, simply run:
  • python main_instance_segmentation.py general.checkpoint=PATH_TO_CHECKPOINT.ckpt general.train_mode=false
    

Understanding Mask3D’s Architecture Like a Puzzle

Think of Mask3D as an intricate 3D puzzle. Each piece has a specific role in forming the complete picture:

  • The preprocessors are like the edges of the puzzle, setting the boundaries.
  • The main instance segmentation script acts as the core piece that connects everything together.
  • Finally, the individual datasets resemble puzzle pieces that, when placed correctly, reveal cohesive instances in 3D space.

Troubleshooting Common Issues

While using Mask3D, you may occasionally run into some hiccups. Here are common problems and their solutions:

  • Error when setting up the environment: Ensure you have the necessary dependencies installed, particularly the correct Python version.
  • Data inconsistencies: Double-check dataset paths and preprocess thoroughly.
  • CUDA-related errors: Confirm that the proper CUDA version is installed and accessible.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox