# clvrai/n2m architecture

> Architecture diagram of the GitHub repository clvrai/n2m, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/clvrai/n2m
- Repository: https://github.com/clvrai/n2m
- Video tour (about a minute): https://gitdiagram.com/clvrai/n2m/video

## Overview

N2M learns a distribution over preferable robot starting poses from local-scene point clouds, then samples a collision-checked pose at inference. The documented workflow is raw labeled data → viewpoint augmentation → model training → inference. The graph also preserves PointBERT internals, training utilities and visualization, and the documented rendering stage. Edges are limited to README statements and relationships visible in the supplied excerpts or SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`scripts/train.py`](https://github.com/clvrai/n2m/blob/main/scripts/train.py) (Training orchestration), [`n2m/module/N2Mmodule.py`](https://github.com/clvrai/n2m/blob/main/n2m/module/N2Mmodule.py) (Inference wrapper), [`scripts/sample_camera_poses.py`](https://github.com/clvrai/n2m/blob/main/scripts/sample_camera_poses.py) (Camera pose sampling), [`n2m/model/pointbert/point_encoder.py`](https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/point_encoder.py) (PointBERT transformer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_raw_data[("Labeled point clouds")]
  node_pose_sampling["Camera pose sampling"]
  node_sample_utils["Pose sampling utilities<br/>[sample_utils.py]"]
  node_renderer["Point-cloud renderer<br/>[fpv_render.cpp]"]
  node_augmented_data[("Augmented clouds and labels")]
end

subgraph group_learning["Model and training"]
  node_dataset["Training dataset<br/>[dataset.py]"]
  node_trainer["Training orchestration<br/>[train.py]"]
  node_loss["Training loss<br/>[loss.py]"]
  node_n2m_model["GMM pose model<br/>[N2Mnet.py]"]
  node_point_transformer["PointBERT transformer<br/>[point_encoder.py]"]
  node_dvae["Point grouping and VAE<br/>[dvae.py]"]
  node_pointbert_helpers["PointBERT checkpoint and logging<br/>[checkpoint.py]"]
  node_training_logs[("Training logs and checkpoints")]
end

subgraph group_inference["Pose inference"]
  node_inference_module["Inference wrapper<br/>[N2Mmodule.py]"]
  node_collision_checker["Collision checker"]
  node_valid_pose["Valid initial pose"]
end

subgraph group_support["Shared utilities"]
  node_point_cloud_utils["Point-cloud preprocessing<br/>[point_cloud.py]"]
  node_config["Configuration loading<br/>[config.py]"]
  node_visualizer["Pose visualization<br/>[visualizer.py]"]
end

node_operator(("Dataset operator"))
node_inference_user(("Inference caller"))

node_operator -->|"provides labels"| node_raw_data
node_operator -->|"runs augmentation"| node_pose_sampling
node_pose_sampling -->|"uses sampling"| node_sample_utils
node_pose_sampling -->|"invokes renderer"| node_renderer
node_renderer -->|"generates augmentation"| node_augmented_data
node_operator -->|"starts training"| node_trainer
node_trainer -->|"loads samples"| node_dataset
node_dataset -->|"augments and sizes"| node_point_cloud_utils
node_trainer -->|"trains model"| node_n2m_model
node_trainer -->|"computes loss"| node_loss
node_trainer -->|"saves checkpoints"| node_training_logs
node_n2m_model -->|"encodes clouds"| node_point_transformer
node_point_transformer -->|"uses grouping"| node_dvae
node_point_transformer -->|"imports helpers"| node_pointbert_helpers
node_inference_user -->|"requests prediction"| node_inference_module
node_inference_module -->|"sizes input"| node_point_cloud_utils
node_inference_module -->|"predicts distribution"| node_n2m_model
node_inference_module -->|"checks collisions"| node_collision_checker
node_inference_module -->|"returns pose"| node_valid_pose
node_trainer -->|"loads configuration"| node_config
node_trainer -->|"renders validation"| node_visualizer
node_inference_module -->|"visualizes prediction"| node_visualizer

click node_pose_sampling "https://github.com/clvrai/n2m/blob/main/scripts/sample_camera_poses.py"
click node_sample_utils "https://github.com/clvrai/n2m/blob/main/n2m/utils/sample_utils.py"
click node_renderer "https://github.com/clvrai/n2m/blob/main/scripts/render/fpv_render.cpp"
click node_dataset "https://github.com/clvrai/n2m/blob/main/n2m/data/dataset.py"
click node_trainer "https://github.com/clvrai/n2m/blob/main/scripts/train.py"
click node_loss "https://github.com/clvrai/n2m/blob/main/n2m/utils/loss.py"
click node_n2m_model "https://github.com/clvrai/n2m/blob/main/n2m/model/N2Mnet.py"
click node_point_transformer "https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/point_encoder.py"
click node_dvae "https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/dvae.py"
click node_pointbert_helpers "https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/checkpoint.py"
click node_inference_module "https://github.com/clvrai/n2m/blob/main/n2m/module/N2Mmodule.py"
click node_point_cloud_utils "https://github.com/clvrai/n2m/blob/main/n2m/utils/point_cloud.py"
click node_config "https://github.com/clvrai/n2m/blob/main/n2m/utils/config.py"
click node_visualizer "https://github.com/clvrai/n2m/blob/main/n2m/utils/visualizer.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raw_data,node_pose_sampling,node_sample_utils,node_renderer,node_augmented_data toneBlue
class node_dataset,node_trainer,node_loss,node_n2m_model,node_point_transformer,node_dvae,node_pointbert_helpers,node_training_logs toneAmber
class node_inference_module,node_collision_checker,node_valid_pose toneMint
class node_point_cloud_utils,node_config,node_visualizer toneRose
class node_operator,node_inference_user toneIndigo
```

## Components

### Data preparation

- **Labeled point clouds**
- [Camera pose sampling](https://github.com/clvrai/n2m/blob/main/scripts/sample_camera_poses.py): `scripts/sample_camera_poses.py`
- [Pose sampling utilities](https://github.com/clvrai/n2m/blob/main/n2m/utils/sample_utils.py): `n2m/utils/sample_utils.py`
- [Point-cloud renderer](https://github.com/clvrai/n2m/blob/main/scripts/render/fpv_render.cpp): `scripts/render/fpv_render.cpp`
- **Augmented clouds and labels**

### Model and training

- [Training dataset](https://github.com/clvrai/n2m/blob/main/n2m/data/dataset.py): `n2m/data/dataset.py`
- [Training orchestration](https://github.com/clvrai/n2m/blob/main/scripts/train.py): `scripts/train.py`
- [Training loss](https://github.com/clvrai/n2m/blob/main/n2m/utils/loss.py): `n2m/utils/loss.py`
- [GMM pose model](https://github.com/clvrai/n2m/blob/main/n2m/model/N2Mnet.py): `n2m/model/N2Mnet.py`
- [PointBERT transformer](https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/point_encoder.py): `n2m/model/pointbert/point_encoder.py`
- [Point grouping and VAE](https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/dvae.py): `n2m/model/pointbert/dvae.py`
- [PointBERT checkpoint and logging](https://github.com/clvrai/n2m/blob/main/n2m/model/pointbert/checkpoint.py): `n2m/model/pointbert/checkpoint.py`
- **Training logs and checkpoints**

### Pose inference

- [Inference wrapper](https://github.com/clvrai/n2m/blob/main/n2m/module/N2Mmodule.py): `n2m/module/N2Mmodule.py`
- **Collision checker**
- **Valid initial pose**

### Shared utilities

- [Point-cloud preprocessing](https://github.com/clvrai/n2m/blob/main/n2m/utils/point_cloud.py): `n2m/utils/point_cloud.py`
- [Configuration loading](https://github.com/clvrai/n2m/blob/main/n2m/utils/config.py): `n2m/utils/config.py`
- [Pose visualization](https://github.com/clvrai/n2m/blob/main/n2m/utils/visualizer.py): `n2m/utils/visualizer.py`

### Other components

- **Dataset operator**
- **Inference caller**

## Connections

- Dataset operator → Labeled point clouds: provides labels (evidence: `README.md`)
- Dataset operator → Camera pose sampling: runs augmentation (evidence: `README.md`)
- Camera pose sampling → Pose sampling utilities: uses sampling (evidence: `scripts/sample_camera_poses.py`)
- Camera pose sampling → Point-cloud renderer: invokes renderer (evidence: `README.md`)
- Point-cloud renderer → Augmented clouds and labels: generates augmentation (evidence: `README.md`)
- Dataset operator → Training orchestration: starts training (evidence: `README.md`)
- Training orchestration → Training dataset: loads samples (evidence: `scripts/train.py`)
- Training dataset → Point-cloud preprocessing: augments and sizes (evidence: `n2m/data/dataset.py`)
- Training orchestration → GMM pose model: trains model (evidence: `scripts/train.py`)
- Training orchestration → Training loss: computes loss (evidence: `scripts/train.py`)
- Training orchestration → Training logs and checkpoints: saves checkpoints (evidence: `scripts/train.py`)
- GMM pose model → PointBERT transformer: encodes clouds (evidence: `n2m/model/N2Mnet.py`)
- PointBERT transformer → Point grouping and VAE: uses grouping (evidence: `n2m/model/pointbert/point_encoder.py`)
- PointBERT transformer → PointBERT checkpoint and logging: imports helpers (evidence: `n2m/model/pointbert/point_encoder.py`)
- Inference caller → Inference wrapper: requests prediction (evidence: `README.md`)
- Inference wrapper → Point-cloud preprocessing: sizes input (evidence: `n2m/module/N2Mmodule.py`)
- Inference wrapper → GMM pose model: predicts distribution (evidence: `n2m/module/N2Mmodule.py`)
- Inference wrapper → Collision checker: checks collisions (evidence: `README.md`)
- Inference wrapper → Valid initial pose: returns pose (evidence: `n2m/module/N2Mmodule.py`)
- Training orchestration → Configuration loading: loads configuration (evidence: `scripts/train.py`)
- Training orchestration → Pose visualization: renders validation (evidence: `scripts/train.py`)
- Inference wrapper → Pose visualization: visualizes prediction (evidence: `n2m/module/N2Mmodule.py`)
