### Verify MMDetection3D Installation Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Checks the installed version of the MMDetection3D library by importing it and printing its version attribute. This confirms a successful installation. ```python import mmdet3d print(mmdet3d.__version__) ``` -------------------------------- ### Install MMEngine, MMCV, and MMDetection Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs core MMLab libraries (MMEngine, MMCV, MMDetection) using MIM. MIM (MMLab Installation Manager) is used for efficient installation of MMLab packages. ```shell pip install -U openmim mim install mmengine mim install 'mmcv>=2.0.0rc4' mim install 'mmdet>=3.0.0' ``` -------------------------------- ### Example: Convert PLY to BIN Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md An example demonstrating the usage of the `convert_ply` function to convert a sample 'test.ply' file to 'test.bin'. ```python convert_ply('./test.ply', './test.bin') ``` -------------------------------- ### Install MMDetection3D from Source Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Clones the MMDetection3D repository from GitHub and installs it in editable mode using pip. This is suitable for development and direct usage. ```shell git clone https://github.com/open-mmlab/mmdetection3d.git -b dev-1.x # "-b dev-1.x" means checkout to the `dev-1.x` branch. cd mmdetection3d pip install -v -e . # "-v" means verbose, or more output # "-e" means installing a project in edtiable mode, ``` -------------------------------- ### Install MMDetection3D from Source on Colab Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Clones the MMDetection3D repository from GitHub and installs it in editable mode using pip. This is typically done after installing dependencies. ```shell !git clone https://github.com/open-mmlab/mmdetection3d.git -b dev-1.x %cd mmdetection3d !pip install -e . ``` -------------------------------- ### Example: Convert OBJ to PLY Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md An example demonstrating the usage of the `to_ply` function to convert a sample 'test.obj' file to 'test.ply'. ```python to_ply('./test.obj', './test.ply', 'obj') ``` -------------------------------- ### Install MMDetection3D with MIM Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs MMDetection3D version 1.1.0 or higher using the MIM package manager. This is the recommended method when using MMDetection3D as a dependency. ```shell mim install "mmdet3d>=1.1.0" ``` -------------------------------- ### Install Torchsparse with APT and Pip Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs the Torchsparse sparse convolution backend using system package manager (apt) for sparsehash-dev, followed by pip installation of the library from its GitHub repository. This method requires sudo privileges. ```shell sudo apt-get install libsparsehash-dev pip install --upgrade git+https://github.com/mit-han-lab/torchsparse.git@v1.4.0 ``` -------------------------------- ### Install MMEngine using Pip Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs the MMEngine library using pip, providing an alternative to installation via MIM. This command ensures MMEngine is available for use in your Python environment. ```shell pip install mmengine ``` -------------------------------- ### Download MMDetection3D Config and Checkpoint Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Downloads the necessary configuration and checkpoint files for MMDetection3D using the 'mim' tool. Ensure 'mim' is installed and the specified config name is correct. Files are downloaded to the current directory. ```shell mim download mmdet3d --config pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car --dest . ``` -------------------------------- ### Run MMDetection3D Inference Demo (from source) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Executes a point cloud inference demo using MMDetection3D when installed from source. Requires a pre-downloaded configuration file, checkpoint file, and a sample point cloud file. The '--show' flag displays the results visually. ```shell python demo/pcd_demo.py demo/data/kitti/000008.bin pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth --show ``` -------------------------------- ### Install PyTorch (CPU) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs PyTorch and Torchvision for CPU-only platforms using Conda. This is an alternative if a GPU is not available or required. ```shell conda install pytorch torchvision cpuonly -c pytorch ``` -------------------------------- ### Install PyTorch (GPU) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs PyTorch and Torchvision for GPU platforms using Conda. Ensure CUDA is properly configured before running. ```shell conda install pytorch torchvision -c pytorch ``` -------------------------------- ### Install Torchsparse with Conda and Pip Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs the Torchsparse sparse convolution backend using conda to install sparsehash, setting a CPLUS_INCLUDE_PATH environment variable, and then installing the library via pip from its GitHub repository. This method avoids the need for sudo. ```shell conda install -c bioconda sparsehash export CPLUS_INCLUDE_PATH=CPLUS_INCLUDE_PATH:${YOUR_CONDA_ENVS_DIR}/include pip install --upgrade git+https://github.com/mit-han-lab/torchsparse.git@v1.4.0 ``` -------------------------------- ### Install and Initialize Pre-commit Hooks Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Installs the pre-commit framework and initializes its hooks within the repository. These hooks automatically format code before commits. ```bash pip install -U pre-commit pre-commit install ``` -------------------------------- ### Run MMDetection3D Docker Container Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Runs a Docker container created from the MMDetection3D image. It maps host directories to container volumes and enables GPU access. ```shell docker run --gpus all --shm-size=8g -it -v {DATA_DIR}:/mmdetection3d/data mmdetection3d ``` -------------------------------- ### Build MMDetection3D Docker Image Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Builds a Docker image for MMDetection3D. The command allows customization by modifying the Dockerfile for different PyTorch and CUDA versions. ```shell # build an image with PyTorch 1.9, CUDA 11.1 # If you prefer other versions, just modified the Dockerfile docker build -t mmdetection3d docker/ ``` -------------------------------- ### Run MMDetection3D Inference Demo (with MIM) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Performs object detection inference using MMDetection3D's API within a Python interpreter. Initializes the model with specified config and checkpoint, then runs inference on a point cloud file. Outputs are Det3DDataSample objects. ```python from mmdet3d.apis import init_model, inference_detector config_file = 'pointpillars_hv_secfpn_8xb6-160e_kitti-3d-car.py' checkpoint_file = 'hv_pointpillars_secfpn_6x8_160e_kitti-3d-car_20220331_134606-d42d15ed.pth' model = init_model(config_file, checkpoint_file) inference_detector(model, 'demo/data/kitti/000008.bin') ``` -------------------------------- ### Install MMEngine, MMCV, MMDetection via MIM on Colab Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs core MMLab libraries (MMEngine, MMCV, MMDetection) on Google Colab using the MIM package manager. It assumes PyTorch is already installed. ```shell !pip3 install openmim !mim install mmengine !mim install "mmcv>=2.0.0rc4,<2.1.0" !mim install "mmdet>=3.0.0,<3.1.0" ``` -------------------------------- ### Convert PLY to BIN format for MMDetection3D Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Converts a .ply file to a .bin file, a format compatible with MMDetection3D demos. Requires 'pandas' and 'plyfile' to be installed. Reads point cloud data properties and writes them to a binary file. ```python import numpy as np import pandas as pd from plyfile import PlyData def convert_ply(input_path, output_path): plydata = PlyData.read(input_path) # read file data = plydata.elements[0].data # read data data_pd = pd.DataFrame(data) # convert to DataFrame data_np = np.zeros(data_pd.shape, dtype=np.float) # initialize array to store data property_names = data[0].dtype.names # read names of properties for i, name in enumerate( property_names): # read data by property data_np[:, i] = data_pd[name] data_np.astype(np.float32).tofile(output_path) ``` -------------------------------- ### Metafile.yml Configuration Example in MMDetection3D Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/example_project/README.md Illustrates the structure and purpose of a `metafile.yml` file, which is parsed by MIM and Inferencer for model configuration and metadata. Includes an example link. ```yaml # Example metafile.yml content # models: # - name: fcos3d # path: configs/fcos3d/fcos3d_8xb2-36e50_coco-3d.py # metadata: # task: 3d object detection # dataset: coco-3d ``` -------------------------------- ### Install Minkowski Engine with Conda and Pip Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs the Minkowski Engine sparse convolution backend. This involves installing openblas-devel via conda, setting a CPLUS_INCLUDE_PATH environment variable, and then installing the engine via pip with specific options for BLAS include directories and type. ```shell conda install openblas-devel -c anaconda export CPLUS_INCLUDE_PATH=CPLUS_INCLUDE_PATH:${YOUR_CONDA_ENVS_DIR}/include pip install -U git+https://github.com/NVIDIA/MinkowskiEngine -v --no-deps --install-option="--blas_include_dirs=/opt/conda/include" --install-option="--blas=openblas" ``` -------------------------------- ### Create and Activate Conda Environment Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Creates a new Conda environment named 'openmmlab' with Python 3.8 and then activates it. This is a standard practice for managing project dependencies. ```shell conda create --name openmmlab python=3.8 -y conda activate openmmlab ``` -------------------------------- ### Set PYTHONPATH for Development Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Manually prepends the current directory's parent to the PYTHONPATH. This ensures that development scripts use the local version of MMDetection3D. ```shell PYTHONPATH="$(dirname $0)/..":$PYTHONPATH ``` -------------------------------- ### Install MMCV with Pip (PyTorch 1.12.0, CUDA 11.6) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs MMCV using pip by specifying a find-url tailored for a specific PyTorch and CUDA version. This method bypasses the MIM package manager. ```shell pip install "mmcv>=2.0.0rc4" -f https://download.openmmlab.com/mmcv/dist/cu116/torch1.12.0/index.html ``` -------------------------------- ### Clone MMDetection3D Repository Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Clones the forked MMDetection3D repository to your local machine. This is the first step for new contributors. ```bash git clone git@github.com:XXX/mmdetection3d.git ``` -------------------------------- ### Standard README Structure Example Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/BEVFusion/README.md This example illustrates the structure for a standard README file, which should be followed when refactoring project documentation or creating new ones. ```markdown [Example](/configs/textdet/dbnet/README.md) ``` -------------------------------- ### Unit Testing Example in MMDetection3D Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/example_project/README.md Provides an example of where unit tests for modules can be found within the MMDetection3D repository, ensuring code correctness and robustness. ```python # Example of a unit test file path # tests/test_models/test_dense_heads/test_fcos_mono3d_head.py ``` -------------------------------- ### Install spconv 2.0 for CUDA 10.2 Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Installs the spconv 2.0 library for CUDA 10.2. This version is optimized for memory usage compared to the default mmcv spconv. Ensure your CUDA version matches the specified suffix. ```shell pip install cumm-cu102 && pip install spconv-cu102 ``` -------------------------------- ### Install Waymo Open Dataset Evaluation Tool Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/datasets/waymo.md This snippet outlines the steps to clone the Waymo Open Dataset repository, install Bazel, and build the `compute_detection_metrics_main` binary required for evaluating detection performance on Waymo datasets. ```shell # download the code and enter the base directory git clone https://github.com/waymo-research/waymo-open-dataset.git waymo-od # git clone https://github.com/Abyssaledge/waymo-open-dataset-master waymo-od # if you want to use faster multi-thread version. cd waymo-od git checkout remotes/origin/master # use the Bazel build system sudo apt-get install --assume-yes pkg-config zip g++ zlib1g-dev unzip python3 python3-pip BAZEL_VERSION=3.1.0 wget https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh sudo bash bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh sudo apt install build-essential # configure .bazelrc ./configure.sh ``` -------------------------------- ### Docstring Standards and Examples in MMDetection3D Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/example_project/README.md Highlights the requirement for docstrings in major objects, describing functionality and arguments. It also advises citing adapted code sources and adhering to license compatibility. Provides an example link for style. ```python # Example docstring for a model component class MyModel: """A sample model for demonstration. Args: in_channels (int): Number of input channels. out_channels (int): Number of output channels. """ def __init__(self, in_channels, out_channels): pass # ... methods ``` -------------------------------- ### Download SemanticKITTI Dataset using MIM Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/dataset_prepare.md This code block shows how to use the MIM tool to download and install the SemanticKITTI dataset. It includes installing necessary CLI tools and logging into the OpenDataLab platform, which hosts the dataset. ```bash # install OpenDataLab CLI tools pip install -U opendatalab # log in OpenDataLab. Note that you should register an account on [OpenDataLab](https://opendatalab.com/) before. pip install odl odl login ``` -------------------------------- ### Install Waymo Open Dataset Package Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/datasets/waymo.md Installs the Waymo Open Dataset package using pip. This is a prerequisite for preparing the Waymo dataset with MMDetection3D. ```bash pip install waymo-open-dataset-tf-2-6-0 ``` ```bash pip install -r requirements/optional.txt ``` -------------------------------- ### Example Slurm training command Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/user_guides/train_test.md An example demonstrating how to use the `slurm_train.sh` script to train a PointPillars model with 16 GPUs. ```shell GPUS=16 ./tools/slurm_train.sh dev pp_kitti_3class configs/pointpillars/pointpillars_hv_secfpn_8xb6-160e_kitti-3d-3class.py /nfs/xxxx/pp_kitti_3class ``` -------------------------------- ### Download and Prepare KITTI Data using MIM Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/dataset_prepare.md This snippet shows how to install OpenDataLab CLI tools, log in, and download/preprocess the KITTI dataset using the MIM command-line interface. ```bash pip install -U opendatalab pip install odl odl login mim download mmdet3d --dataset kitti ``` -------------------------------- ### Convert Various 3D Formats to PLY using Trimesh Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/get_started.md Converts 3D model files (e.g., .obj, .off) to the .ply format using the 'trimesh' library. This is a preparatory step before converting to .bin if the original data is not in .ply format. ```python import trimesh def to_ply(input_path, output_path, original_type): mesh = trimesh.load(input_path, file_type=original_type) # read file mesh.export(output_path, file_type='ply') # convert to ply ``` -------------------------------- ### Metafile.yml Example for mmdetection3d Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/DETR3D/README.md Shows an example of a `metafile.yml` file, which is essential for project integration with MIM and Inferencer tools. This file contains metadata crucial for package management and deployment. ```yaml Example: https://github.com/open-mmlab/mmdetection3d/blob/dev-1.x/configs/fcos3d/metafile.yml ``` -------------------------------- ### Python Type Hints and Docstrings Example in mmdetection3d Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/DETR3D/README.md Illustrates the recommended practice for adding type hints and docstrings to Python code within mmdetection3d. This enhances code readability, maintainability, and aids in static analysis. The example references a specific file within the project for context. ```python Example: https://github.com/open-mmlab/mmdetection3d/blob/dev-1.x/mmdet3d/models/detectors/fcos_mono3d.py ``` -------------------------------- ### Unit Test Example for mmdetection3d Models Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/DETR3D/README.md Provides an example of how unit tests should be structured for modules within mmdetection3d. This specific example targets the testing of dense heads, demonstrating the expected format and location for unit tests. ```python Example: https://github.com/open-mmlab/mmdetection3d/blob/dev-1.x/tests/test_models/test_dense_heads/test_fcos_mono3d_head.py ``` -------------------------------- ### README Structure Example for mmdetection3d Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/DETR3D/README.md Demonstrates the standard structure for a README file within the mmdetection3d project. This example follows the pattern used for text detection configurations, serving as a template for project-specific documentation. ```markdown Example: /configs/textdet/dbnet/README.md ``` -------------------------------- ### Install MMDetection3D Compatible Libraries Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/faq.md Ensures compatibility between MMDetection3D, MMEngine, MMCV, and MMDetection by specifying version ranges. This helps avoid installation issues and runtime errors like 'ConvWS is already registered'. ```shell pip uninstall pycocotools mmpycocotools pip install mmpycocotools ``` -------------------------------- ### Download and Prepare NuScenes Dataset using MIM Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/dataset_prepare.md This sequence of commands installs the OpenDataLab CLI, logs into the platform, and then uses the MIM tool to download and preprocess the NuScenes dataset. This is an alternative to manual downloading. ```bash # install OpenDataLab CLI tools pip install -U opendatalab # log in OpenDataLab. Note that you should register an account on [OpenDataLab](https://opendatalab.com/) before. pip install odl odl login # download and preprocess by MIM mim download mmdet3d --dataset nuscenes ``` -------------------------------- ### Initialize LidarDet3DInferencer Source: https://github.com/open-mmlab/mmdetection3d/blob/main/demo/inference_demo.ipynb Initializes the LidarDet3DInferencer with a specified model configuration. This is the first step before performing any inference. ```python from mmdet3d.apis import LidarDet3DInferencer # initialize inferencer inferencer = LidarDet3DInferencer('pointpillars_kitti-3class') ``` -------------------------------- ### Distributed Evaluation Command (Shell) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/datasets/nuscenes.md Example shell command to initiate distributed testing for a PointPillars model on the NuScenes dataset using 8 GPUs. ```shell bash ./tools/dist_test.sh configs/pointpillars/pointpillars_hv_fpn_sbn-all_8xb4-2x_nus-3d.py checkpoints/hv_pointpillars_fpn_sbn-all_4x8_2x_nus-3d_20200620_230405-2fa62f3d.pth 8 ``` -------------------------------- ### PointPillars Training Data Pipeline Example (Python) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/data_pipeline.md An example of a data pipeline configuration for training PointPillars models. It includes steps for loading point clouds, annotations, applying transformations like rotation, scaling, flipping, filtering, shuffling, and formatting for the model. ```python train_pipeline = [ dict( type='LoadPointsFromFile', load_dim=5, use_dim=5, backend_args=backend_args), dict( type='LoadPointsFromMultiSweeps', sweeps_num=10, backend_args=backend_args), dict(type='LoadAnnotations3D', with_bbox_3d=True, with_label_3d=True), dict( type='GlobalRotScaleTrans', rot_range=[-0.3925, 0.3925], scale_ratio_range=[0.95, 1.05], translation_std=[0, 0, 0]), dict(type='RandomFlip3D', flip_ratio_bev_horizontal=0.5), dict(type='PointsRangeFilter', point_cloud_range=point_cloud_range), dict(type='ObjectRangeFilter', point_cloud_range=point_cloud_range), dict(type='ObjectNameFilter', classes=class_names), dict(type='PointShuffle'), dict(type='DefaultFormatBundle3D', class_names=class_names), dict(type='Collect3D', keys=['points', 'gt_bboxes_3d', 'gt_labels_3d']) ] ``` -------------------------------- ### PointPillars Testing Data Pipeline Example (Python) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/data_pipeline.md An example of a data pipeline configuration for testing PointPillars models. It includes loading point clouds and multi-sweeps data, applying multi-scale and flip augmentation, filtering, formatting, and collecting necessary data for inference. ```python test_pipeline = [ dict( type='LoadPointsFromFile', load_dim=5, use_dim=5, backend_args=backend_args), dict( type='LoadPointsFromMultiSweeps', sweeps_num=10, backend_args=backend_args), dict( type='MultiScaleFlipAug', img_scale=(1333, 800), pts_scale_ratio=1.0, flip=False, pcd_horizontal_flip=False, pcd_vertical_flip=False, transforms=[ dict( type='GlobalRotScaleTrans', rot_range=[0, 0], scale_ratio_range=[1., 1.], translation_std=[0, 0, 0]), dict(type='RandomFlip3D'), dict( type='PointsRangeFilter', point_cloud_range=point_cloud_range), dict( type='DefaultFormatBundle3D', class_names=class_names, with_label=False), dict(type='Collect3D', keys=['points']) ]) ] ``` -------------------------------- ### Unit Testing Example in mmdetection3d Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/BEVFusion/README.md Unit tests are required for each module to ensure code correctness and reliability. The provided example demonstrates the structure for testing model components within the project. ```python [Example](https://github.com/open-mmlab/mmdetection3d/blob/dev-1.x/tests/test_models/test_dense_heads/test_fcos_mono3d_head.py) ``` -------------------------------- ### Train TR3D Model (Bash) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/TR3D/README.md Command to initiate the training process for the TR3D model using the provided configuration file within the MMDet3D framework. Requires MMDet3D to be installed. ```bash python tools/train.py projects/TR3D/configs/tr3d_1xb16_scannet-3d-18class.py ``` -------------------------------- ### Distributed Testing with slurm_test.sh (KITTI Submission) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/train_test.md Example of testing a SECOND model on KITTI using 8 GPUs with SLURM. Generates PKL files and submission data for official evaluation. ```shell ./tools/slurm_test.sh ${PARTITION} ${JOB_NAME} configs/second/second_hv_secfpn_8xb6-80e_kitti-3d-3class.py \ checkpoints/hv_second_secfpn_6x8_80e_kitti-3d-3class_20200620_230238-9208083a.pth \ --cfg-options 'test_evaluator.pklfile_prefix=./second_kitti_results' 'submission_prefix=./second_kitti_results' ``` -------------------------------- ### Creating Metafile.yml for mmdetection3d Projects Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/CENet/README.md Explains the necessity of a `metafile.yml` file for project integration with MIM and Inferencer. An example file structure is referenced for guidance. ```yaml It will be parsed by MIM and Inferencer. [Example](https://github.com/open-mmlab/mmdetection3d/blob/dev-1.x/configs/fcos3d/metafile.yml) ``` -------------------------------- ### Stage and Commit Changes Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Stages specified files for commit and records the changes with a descriptive message. Pre-commit hooks will run automatically. ```bash git add [files] git commit -m 'messages' ``` -------------------------------- ### Remote Inference and Visualization Source: https://github.com/open-mmlab/mmdetection3d/blob/main/demo/inference_demo.ipynb Handles inference on environments without a display, saving predictions to a directory, and then visualizing them from the saved files. This is suitable for server-side processing. ```python # If your operating environment does not have a display device, # (e.g. a remote server), you can save the predictions and visualize # them in local devices. inferencer(inputs, show=False, out_dir='./remote_outputs') # Simulate the migration process # %mv ./remote_outputs ./local_outputs # Visualize the predictions from the saved files # NOTE: use the `Esc` key to exit Open3D window in Jupyter Notebook Environment local_inferencer = LidarDet3DInferencer('pointpillars_kitti-3class') inputs = local_inferencer._inputs_to_list(inputs) local_inferencer.visualize_preds_fromfile(inputs, ['local_outputs/preds/000008.json'], show=True) ``` -------------------------------- ### Create New Git Branch Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Creates a new local branch for your contributions, based on the 'dev-1.x' or 'dev' branch. Ensure clarity by checking out 'dev-1.x' first. ```bash git checkout -b branchname ``` -------------------------------- ### Example Annotation Structure (Python Dictionary) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/pure_point_cloud_dataset.md Demonstrates the expected dictionary structure for dataset annotations stored in pickle files, including sample index, lidar point paths, and 3D bounding box information. ```python { 'sample_idx': 120, 'lidar_points': {'lidar_path': 'training/000004.bin'}, 'annos': { 'bbox_type_3d': 'LiDAR', 'gt_bboxes_3d': array([[1.48129511, 3.52074146, 1.85652947, 1.74445975, 0.23195696, 0.57235193, -0.25525], [ 2.90395617, -3.48033905, 1.52682471,[0.66077662, 0.17072392, 0.67153597, 2.23145]]), 'gt_names': ['car', 'pedestrian'] } } ``` -------------------------------- ### Test Model using Dummy ResNet Wrapper Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/example_project/README.md Command to test the model using the dummy ResNet wrapper with a specific configuration file and checkpoint path. Assumes execution from the MMDetection3D root directory. ```bash python tools/test.py projects/example_project/configs/fcos3d_dummy-resnet-caffe-dcn_fpn_head-gn_8xb2-1x_nus-mono3d.py ${CHECKPOINT_PATH} ``` -------------------------------- ### Multi-machine distributed training (Node 2) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/user_guides/train_test.md Command to start distributed training on the second node of a multi-machine setup. Similar to the first node, but with `NODE_RANK` set to 1. ```shell NNODES=2 NODE_RANK=1 PORT=$MASTER_PORT MASTER_ADDR=$MASTER_ADDR ./tools/dist_train.sh $CONFIG $GPUS ``` -------------------------------- ### Multi-machine distributed training (Node 1) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/user_guides/train_test.md Command to start distributed training on the first node of a multi-machine setup. Requires specifying the number of nodes, rank, port, and master address. ```shell NNODES=2 NODE_RANK=0 PORT=$MASTER_PORT MASTER_ADDR=$MASTER_ADDR ./tools/dist_train.sh $CONFIG $GPUS ``` -------------------------------- ### Train Model using Dummy ResNet Wrapper Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/example_project/README.md Command to train the model using the dummy ResNet wrapper with a specific configuration file. Assumes execution from the MMDetection3D root directory. ```bash python tools/train.py projects/example_project/configs/fcos3d_dummy-resnet-caffe-dcn_fpn_head-gn_8xb2-1x_nus-mono3d.py ``` -------------------------------- ### Install PyTorch Scatter Source: https://github.com/open-mmlab/mmdetection3d/blob/main/projects/DSVT/README.md Installs the torch_scatter library, a dependency for the DSVT model. This is a crucial step before compiling custom CUDA operations. ```shell pip install torch_scatter==2.0.9 ``` -------------------------------- ### Build mmdet3d-serve Docker Image (Shell) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/useful_tools.md Builds the Docker image for serving MMDetection3D models with TorchServe. ```shell docker build -t mmdet3d-serve:latest docker/serve/ ``` -------------------------------- ### Install pypcd library Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/customize_dataset.md Installs the pypcd library from its GitHub repository using pip. This library is used for reading and processing .pcd files, which is a step in converting point cloud data to .bin format. ```bash pip install git+https://github.com/DanielPollithy/pypcd.git ``` -------------------------------- ### Build Waymo Detection Metrics Tool with Bazel Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/datasets/waymo.md Builds the `compute_detection_metrics_main` tool using Bazel and copies it to the MMDetection3D directory for evaluation. ```shell bazel clean bazel build waymo_open_dataset/metrics/tools/compute_detection_metrics_main cp bazel-bin/waymo_open_dataset/metrics/tools/compute_detection_metrics_main ../mmdetection3d/mmdet3d/evaluation/functional/waymo_utils/ ``` -------------------------------- ### 下载 KITTI 数据集划分文件 (Bash) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/user_guides/dataset_prepare.md 此脚本用于下载 KITTI 数据集所需的测试、训练、验证和训练验证划分文件,并将它们保存到指定目录。它依赖于 `wget` 命令。 ```bash mkdir ./data/kitti/ && mkdir ./data/kitti/ImageSets # 下载数据划分文件 wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/test.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/test.txt wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/train.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/train.txt wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/val.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/val.txt wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/trainval.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/trainval.txt ``` -------------------------------- ### Train a new model in MMDetection3D Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/new_data_model.md This command initiates the training process for a new model using a specified configuration file. It requires Python and the MMDetection3D environment to be set up. ```shell python tools/train.py configs/pointpillars/pointpillars_hv_secfpn_sbn-all_16xb2-2x_waymoD5-3d-3class.py ``` -------------------------------- ### Download KITTI Data Splits Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/dataset_prepare.md Commands to download the necessary train, validation, and test split files for the KITTI dataset using wget. These files are essential for organizing the dataset. ```bash mkdir ./data/kitti/ && mkdir ./data/kitti/ImageSets wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/test.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/test.txt wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/train.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/train.txt wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/val.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/val.txt wget -c https://raw.githubusercontent.com/traveller59/second.pytorch/master/second/data/ImageSets/trainval.txt --no-check-certificate --content-disposition -O ./data/kitti/ImageSets/trainval.txt ``` -------------------------------- ### Download SemanticKITTI Dataset using MIM Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/dataset_prepare.md Downloads the SemanticKITTI dataset using the MIM package manager. This is a prerequisite for further preprocessing steps. ```bash mim download mmdet3d --dataset semantickitti ``` -------------------------------- ### PointPillars Model Configuration Example Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/advanced_guides/customize_dataset.md Example configuration for a PointPillars model, detailing voxelization parameters, feature network, backbone, neck, and bbox head. Key parameters like `voxel_size` and `point_cloud_range` should be adjusted for specific datasets. The `output_shape` in `middle_encoder` must also be updated based on these changes. ```python _base_ = [ '../_base_/models/pointpillars_hv_secfpn_custom.py', '../_base_/datasets/custom.py', '../_base_/schedules/cyclic-40e.py', '../_base_/default_runtime.py' ] ``` ```python voxel_size = [0.16, 0.16, 4] # 根据您的数据集做调整 point_cloud_range = [0, -39.68, -3, 69.12, 39.68, 1] # 根据您的数据集做调整 model = dict( type='VoxelNet', data_preprocessor=dict( type='Det3DDataPreprocessor', voxel=True, voxel_layer=dict( max_num_points=32, point_cloud_range=point_cloud_range, voxel_size=voxel_size, max_voxels=(16000, 40000))), voxel_encoder=dict( type='PillarFeatureNet', in_channels=4, feat_channels=[64], with_distance=False, voxel_size=voxel_size, point_cloud_range=point_cloud_range), # `output_shape` 需要根据 `point_cloud_range` 和 `voxel_size` 做相应调整 middle_encoder=dict( type='PointPillarsScatter', in_channels=64, output_shape=[496, 432]), backbone=dict( type='SECOND', in_channels=64, layer_nums=[3, 5, 5], layer_strides=[2, 2, 2], out_channels=[64, 128, 256]), neck=dict( type='SECONDFPN', in_channels=[64, 128, 256], upsample_strides=[1, 2, 4], out_channels=[128, 128, 128]), bbox_head=dict( type='Anchor3DHead', num_classes=3, in_channels=384, feat_channels=384, use_direction_classifier=True, assign_per_class=True, # 根据您的数据集调整 `ranges` 和 `sizes` anchor_generator=dict( type='AlignedAnchor3DRangeGenerator', ranges=[ [0, -39.68, -0.6, 69.12, 39.68, -0.6], [0, -39.68, -0.6, 69.12, 39.68, -0.6], [0, -39.68, -1.78, 69.12, 39.68, -1.78], ], sizes=[[0.8, 0.6, 1.73], [1.76, 0.6, 1.73], [3.9, 1.6, 1.56]], rotations=[0, 1.57], reshape_out=False), diff_rad_by_sin=True, bbox_coder=dict(type='DeltaXYZWLHRBBoxCoder'), loss_cls=dict( type='mmdet.FocalLoss', use_sigmoid=True, gamma=2.0, alpha=0.25, loss_weight=1.0), loss_bbox=dict( type='mmdet.SmoothL1Loss', beta=1.0 / 9.0, loss_weight=2.0), loss_dir=dict( type='mmdet.CrossEntropyLoss', use_sigmoid=False, loss_weight=0.2)), # 模型训练和测试设置 train_cfg=dict( assigner=[ dict( # for Pedestrian type='Max3DIoUAssigner', iou_calculator=dict(type='BboxOverlapsNearest3D'), pos_iou_thr=0.5, neg_iou_thr=0.35, min_pos_iou=0.35, ignore_iof_thr=-1), dict( # for Cyclist type='Max3DIoUAssigner', iou_calculator=dict(type='BboxOverlapsNearest3D'), pos_iou_thr=0.5, neg_iou_thr=0.35, min_pos_iou=0.35, ignore_iof_thr=-1), dict( # for Car type='Max3DIoUAssigner', iou_calculator=dict(type='BboxOverlapsNearest3D'), pos_iou_thr=0.6, neg_iou_thr=0.45, min_pos_iou=0.45, ignore_iof_thr=-1), ], allowed_border=0, pos_weight=-1, debug=False), test_cfg=dict( use_rotate_nms=True, nms_across_levels=False, nms_thr=0.01, score_thr=0.1, min_bbox_size=0, nms_pre=100, max_num=50)) ``` -------------------------------- ### Run mmdet3d-serve Docker Container (Shell) Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/useful_tools.md Runs the mmdet3d-serve Docker container, mapping ports for inference, management, and metrics. Supports GPU or CPU execution. Mounts a model store directory. ```shell docker run --rm \ --cpus 8 \ --gpus device=0 \ -p8080:8080 -p8081:8081 -p8082:8082 \ --mount type=bind,source=$MODEL_STORE,target=/home/model-server/model-store \ mmdet3d-serve:latest ``` -------------------------------- ### Create S3DIS Dataset with tools/create_data.py Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/datasets/s3dis.md This command initiates the dataset creation process for S3DIS. It converts point cloud, semantic label, and instance label files into a .bin format and generates .pkl info files. The script requires specifying the root path, output directory, and an extra tag for the dataset. ```shell python tools/create_data.py s3dis --root-path ./data/s3dis \ --out-dir ./data/s3dis --extra-tag s3dis ``` -------------------------------- ### Push Changes to Forked Repository Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Pushes your committed changes from your local branch to your forked remote repository on GitHub. ```bash git push origin branchname ``` -------------------------------- ### Overall ScanNet Data Preparation Script Source: https://github.com/open-mmlab/mmdetection3d/blob/main/data/scannet/README.md A composite script demonstrating the sequence of operations for preparing ScanNet data, including loading, image extraction, and data generation. ```bash python batch_load_scannet_data.py python extract_posed_images.py cd ../.. python tools/create_data.py scannet --root-path ./data/scannet --out-dir ./data/scannet --extra-tag scannet ``` -------------------------------- ### Update Local Repository Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Updates your local 'dev-1.x' branch with the latest changes from the upstream repository. Recommended for ongoing contributions. ```bash git checkout dev-1.x git pull upstream dev-1.x ``` -------------------------------- ### Execute S3DIS Data Preparation Script Source: https://github.com/open-mmlab/mmdetection3d/blob/main/data/s3dis/README.md This command collects indoor 3D data, navigates to the project root, and then generates S3DIS training data. It's a convenient way to perform the entire data preparation process. ```bash python collect_indoor3d_data.py cd ../.. python tools/create_data.py s3dis --root-path ./data/s3dis --out-dir ./data/s3dis --extra-tag s3dis ``` -------------------------------- ### Add Upstream Repository Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Adds the official OpenMMLab MMDetection3D repository as an upstream remote. This allows you to pull the latest changes. ```bash git remote add upstream git@github.com:open-mmlab/mmdetection3d ``` -------------------------------- ### Generate KITTI Ground Truth Database and Info Files Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/dataset_prepare.md Python script to specifically generate ground truth database files and annotations for KITTI, which is required for augmentations like ObjectSample. ```bash python tools/create_data.py kitti --root-path ./data/kitti --out-dir ./data/kitti --extra-tag kitti --only-gt-database ``` -------------------------------- ### Delete Local and Remote Branches Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/notes/contribution_guides.md Deletes a local branch after its changes have been merged and then removes the corresponding branch from the remote forked repository. ```bash git branch -d branchname git push origin --delete branchname ``` -------------------------------- ### Create KITTI Dataset and ImageSets Folder Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/advanced_guides/datasets/kitti.md This command sequence creates the necessary directory structure for the KITTI dataset, specifically the main 'kitti' folder and its 'ImageSets' subdirectory, which is a prerequisite for processing KITTI data within MMDetection3D. ```bash mkdir ./data/kitti/ && mkdir ./data/kitti/ImageSets ``` -------------------------------- ### Configuring Test Evaluator for NuScenes Submission Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/advanced_guides/datasets/nuscenes.md Example of how to modify the `test_evaluator` in a configuration file to set the `jsonfile_prefix` for NuScenes evaluation results, which is required for submission. ```python test_evaluator = dict(type='NuScenesMetric', jsonfile_prefix='work_dirs/pp-nus/results_eval.json') ``` -------------------------------- ### 构建 MMDetection3D Docker 镜像 Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/zh_cn/get_started.md 使用 Dockerfile 构建 MMDetection3D 的 Docker 镜像。该命令将基于 PyTorch 1.9 和 CUDA 11.1 构建镜像,用户可以根据需要修改 Dockerfile 以使用其他版本。 ```shell # 基于 PyTorch 1.9,CUDA 11.1 构建镜像 # 如果您想要其他版本,只需要修改 Dockerfile docker build -t mmdetection3d docker/ ``` -------------------------------- ### Modifying Specific Model Components in MMDetection3D Source: https://github.com/open-mmlab/mmdetection3d/blob/main/docs/en/user_guides/config.md Example of how to modify a specific component, such as the `pts_neck`, within a model definition, potentially overriding settings from a base configuration. ```python model = dict( type='MVXFasterRCNN', data_preprocessor=dict(voxel_layer=dict(...)), pts_voxel_encoder=dict(...), pts_middle_encoder=dict(...), pts_backbone=dict(...), pts_neck=dict( type='FPN', norm_cfg=dict(type='naiveSyncBN2d', eps=1e-3, momentum=0.01), act_cfg=dict(type='ReLU'), in_channels=[64, 128, 256], out_channels=256, start_level=0, num_outs=3), pts_bbox_head=dict(...)) ```