# open-mmlab/mmdetection3d architecture

> Architecture diagram of the GitHub repository open-mmlab/mmdetection3d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/open-mmlab/mmdetection3d
- Repository: https://github.com/open-mmlab/mmdetection3d

## Overview

##### Main Components
- Core Library (mmdet3d): This is where the primary logic resides, including:
– APIs and Inference Modules (e.g., mmdet3d/apis, inferencers)
– Model definitions (models/backbones, dense_heads, decode_heads, detectors, ROI heads, etc.)
– Dataset interfaces and transforms (datasets, datasets/transforms, dataset wrappers)
– Evaluation, metrics, and utility modules (evaluation, structures, utils, visualization)
- Configuration System (configs & mmdet3d/configs): Unified config files (including _base_ directories and many nested subsets) that let users easily customize experiments.
- Projects: A separate folder for additional state-of-the-art models (BEVFusion, CENet, CenterFormer, DETR3D, DSVT, NeRF-Det, PETR, TPVFormer, TR3D, etc.) that are built on the core framework.
- Tools: Training scripts, dataset converters, benchmarking and analysis scripts, model conversion, and deployment scripts.
- CI/CD and DevOps: Directories like .circleci, .github, and dev_scripts that contain instructions for continuous integration, tests, linting, Docker configurations, etc.
- Documentation & User Guides: The docs and README files provide user and advanced guides along with model zoo, benchmarks, and tutorials.

##### Relationships and Interactions
– The configuration system acts as the “glue” that allows different modules to plug into the training loop (in mmdet3d/engine) and model building. The config files are composed in a hierarchical manner (base configs, model parts, dataset details, schedule, etc.)
– Models (backbones, heads, detectors) receive input from data pipelines (datasets and transforms) and produce outputs that are passed onto evaluation modules for metric calculation.
– Training and inference modules (within mmdet3d/apis and mmdet3d/engine) coordinate data loading, model forward passes, loss computation, and logging.
– Evaluation and visualization components process the model predictions, often using utility modules in mmdet3d/structures and mmdet3d/evaluation to produce metrics or visual outputs.
– External dependencies include PyTorch (as the underlying deep learning engine) and integration with other OpenMMLab projects (like MMCV and MMEngine), plus deployment tools (Docker, GitHub Actions, etc.).

##### Architectural Patterns & Design Choices
– Modular & Config-driven: Separation of concerns via independent components (config, dataset, model, training loop) managed through a centralized configuration system.
– Plugin-like Architecture: Many modules (e.g., custom backbone or head) can be dropped in and registered (note the registry.py file) to extend the toolbox.
– Layered Design: At the lowest layer, utility functions and data structures handle raw data; the next layer includes dataset building and augmentation; above that there are model definitions and training logic; then evaluation and deployment layers.
– CI/CD and Containerization: The presence of Dockerfiles and CI pipelines indicate a design that supports automated testing, deployment, and reproducible research.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "External Dependencies"
        PyTorch["PyTorch"]:::external
        MMCV["MMCV"]:::external
        MMEngine["MMEngine"]:::external
    end

    subgraph "Configuration System"
        UserConfigs["User Configs (configs)"]:::config
        CoreConfigs["Core Configs (mmdet3d/configs)"]:::config
    end

    subgraph "Core Engine"
        direction TB
        CoreLibrary["Core Library (mmdet3d)"]:::core
        APIs["APIs (mmdet3d/apis)"]:::core
        Inferencers["Inferencers (mmdet3d/apis/inferencers)"]:::core
        ModelDefs["Model Definitions (mmdet3d/models)"]:::core
        Datasets["Datasets (mmdet3d/datasets)"]:::core
        Transforms["Transforms (mmdet3d/datasets/transforms)"]:::core
        Evaluation["Evaluation (mmdet3d/evaluation)"]:::core
        Metrics["Metrics (mmdet3d/evaluation/metrics)"]:::core
        Structures["Structures (mmdet3d/structures)"]:::core
        Utilities["Utilities (mmdet3d/utils)"]:::core
        Visualization["Visualization (mmdet3d/visualization)"]:::core
    end

    subgraph "Projects & Extensions"
        Projects["Projects (projects)"]:::projects
    end

    subgraph "Tools & DevOps"
        direction TB
        Tools["Tools (tools)"]:::tools
        CircleCI["CI: .circleci"]:::devops
        GitHub["CI: .github"]:::devops
        DevScripts["Dev Scripts (.dev_scripts)"]:::devops
    end

    subgraph "Documentation"
        Docs["Docs (docs)"]:::docs
        README["README (README.md)"]:::docs
        README_CN["README_CN (README_zh-CN.md)"]:::docs
    end

    %% Relationships
    UserConfigs -->|"configures"| CoreLibrary
    CoreConfigs -->|"configures"| CoreLibrary

    PyTorch -->|"depends_on"| CoreLibrary
    MMCV -->|"depends_on"| CoreLibrary
    MMEngine -->|"depends_on"| CoreLibrary

    CoreLibrary -->|"APIs"| APIs
    APIs -->|"inferencers"| Inferencers
    CoreLibrary -->|"models"| ModelDefs
    CoreLibrary -->|"datasets"| Datasets
    Datasets -->|"transforms"| Transforms
    CoreLibrary -->|"evaluation"| Evaluation
    Evaluation -->|"metrics"| Metrics
    CoreLibrary -->|"structures"| Structures
    Structures -->|"utilities"| Utilities
    CoreLibrary -->|"visualization"| Visualization

    Transforms -->|"dataFeed"| APIs
    APIs -->|"trainingFlow"| Evaluation
    Evaluation -->|"feedback"| UserConfigs

    CoreLibrary -->|"extends"| Projects
    Projects -->|"usesCore"| CoreLibrary

    CoreLibrary -->|"deployment"| Tools
    Projects -->|"projectTools"| Tools

    Tools -->|"CI/CD"| CircleCI
    Tools -->|"CI/CD"| GitHub
    Tools -->|"DevOps"| DevScripts

    Docs -->|"supports"| CoreLibrary
    README -->|"info"| CoreLibrary

    %% Class Definitions
    classDef core fill:#ccf,stroke:#333,stroke-width:2px;
    classDef config fill:#f9f,stroke:#333,stroke-width:2px;
    classDef projects fill:#cfc,stroke:#333,stroke-width:2px;
    classDef tools fill:#fcf,stroke:#333,stroke-width:2px;
    classDef devops fill:#ff9,stroke:#333,stroke-width:2px;
    classDef docs fill:#cff,stroke:#333,stroke-width:2px;
    classDef external fill:#ddd,stroke:#333,stroke-width:2px;

    %% Click Events
    click CoreLibrary "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d"
    click APIs "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/apis"
    click Inferencers "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/apis/inferencers"
    click ModelDefs "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/models"
    click Datasets "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/datasets"
    click Transforms "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/datasets/transforms"
    click Evaluation "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/evaluation"
    click Metrics "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/evaluation/metrics"
    click Structures "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/structures"
    click Utilities "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/utils"
    click Visualization "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/visualization"
    click CoreConfigs "https://github.com/open-mmlab/mmdetection3d/tree/main/mmdet3d/configs"
    click UserConfigs "https://github.com/open-mmlab/mmdetection3d/tree/main/configs"
    click Projects "https://github.com/open-mmlab/mmdetection3d/tree/main/projects"
    click Tools "https://github.com/open-mmlab/mmdetection3d/tree/main/tools"
    click CircleCI "https://github.com/open-mmlab/mmdetection3d/blob/main/.circleci"
    click GitHub "https://github.com/open-mmlab/mmdetection3d/blob/main/.github"
    click DevScripts "https://github.com/open-mmlab/mmdetection3d/blob/main/.dev_scripts"
    click Docs "https://github.com/open-mmlab/mmdetection3d/tree/main/docs"
    click README "https://github.com/open-mmlab/mmdetection3d/blob/main/README.md"
    click README_CN "https://github.com/open-mmlab/mmdetection3d/blob/main/README_zh-CN.md"
```
