# fishandwasabi/yolo-ms architecture

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

- Interactive diagram: https://gitdiagram.com/fishandwasabi/yolo-ms
- Repository: https://github.com/fishandwasabi/yolo-ms

## Overview

This repository implements YOLO-MS, a real-time object-detection research codebase, with an MMYOLO-based model plus Segment Anything utilities for promptable and automatic mask generation. The principal workflow is to configure and train a detector, whose multi-scale backbone and feature pyramid use MSBlocks; detection heads and dataset-specific configurations are also present. Separate branches cover dataset preparation and deployment configurations. The graph reflects only relationships visible in the supplied excerpts, SOURCE INDEX, or README; unsampled model internals are not linked speculatively.

Main entry points: [`mmyolo/yoloms/models/segment_anything/predictor.py`](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/predictor.py) (Prompt predictor), [`mmyolo/yoloms/models/layers/msblock.py`](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/layers/msblock.py) (Multi-scale block), [`mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py`](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py) (Automatic masks), [`mmyolo/tools/train.py`](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/tools/train.py) (Training entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_detector["Detection model"]
  node_detector_model["YOLO-MS backbone<br/>[yoloms.py]"]
  node_msblock["Multi-scale block<br/>[msblock.py]"]
  node_msblock_layers["Block layers<br/>[msblock_layers.py]"]
  node_neck["Feature pyramid<br/>[yoloms_pafpn.py]"]
  node_head["Detection head<br/>[yoloms_head.py]"]
  node_distill["Distillation detector<br/>[yolo_distill.py]"]
end

subgraph group_sam["Mask generation"]
  node_sam_predictor["Prompt predictor<br/>[predictor.py]"]
  node_sam_encoder["Image encoder<br/>[image_encoder.py]"]
  node_sam_common["Encoder components<br/>[common.py]"]
  node_sam_components["SAM model components"]
  node_auto_masks["Automatic masks"]
  node_mask_utils["Mask utilities<br/>[amg.py]"]
  node_sam_transforms["Image transforms<br/>[transforms.py]"]
end

subgraph group_workflow["Training and data"]
  node_train["Training entry<br/>[train.py]"]
  node_runner["MMEngine runner"]
  node_configs["Model configurations"]
  node_dataset_tools["Dataset tools"]
end

subgraph group_deploy["Deployment"]
  node_deploy_configs["Deployment configs"]
end

node_user(("Researcher"))

node_user -->|"starts training"| node_train
node_train -->|"builds and runs"| node_runner
node_detector_model -->|"uses blocks"| node_msblock
node_msblock -->|"builds layers"| node_msblock_layers
node_neck -->|"uses blocks"| node_msblock
node_sam_predictor -->|"imports model"| node_sam_components
node_sam_predictor -->|"uses transforms"| node_sam_transforms
node_sam_encoder -->|"uses components"| node_sam_common
node_auto_masks -->|"creates predictor"| node_sam_predictor
node_auto_masks -->|"uses utilities"| node_mask_utils

click node_train "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/tools/train.py"
click node_configs "https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/configs/yoloms"
click node_dataset_tools "https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/tools/dataset_converters"
click node_detector_model "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/backbones/yoloms.py"
click node_msblock "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/layers/msblock.py"
click node_msblock_layers "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/layers/msblock_layers.py"
click node_neck "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/necks/yoloms_pafpn.py"
click node_head "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/dense_head/yoloms_head.py"
click node_distill "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/detectors/yolo_distill.py"
click node_sam_predictor "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/predictor.py"
click node_sam_encoder "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/modeling/image_encoder.py"
click node_sam_common "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/modeling/common.py"
click node_sam_components "https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/yoloms/models/segment_anything/modeling"
click node_auto_masks "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py"
click node_mask_utils "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/utils/amg.py"
click node_sam_transforms "https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/utils/transforms.py"
click node_deploy_configs "https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/configs/deployment"

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_detector_model,node_msblock,node_msblock_layers,node_neck,node_head,node_distill toneBlue
class node_sam_predictor,node_sam_encoder,node_sam_common,node_sam_components,node_auto_masks,node_mask_utils,node_sam_transforms toneAmber
class node_train,node_runner,node_configs,node_dataset_tools toneMint
class node_deploy_configs toneRose
class node_user toneIndigo
```

## Components

### Detection model

- [YOLO-MS backbone](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/backbones/yoloms.py): `mmyolo/yoloms/models/backbones/yoloms.py`
- [Multi-scale block](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/layers/msblock.py): `mmyolo/yoloms/models/layers/msblock.py`
- [Block layers](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/layers/msblock_layers.py): `mmyolo/yoloms/models/layers/msblock_layers.py`
- [Feature pyramid](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/necks/yoloms_pafpn.py): `mmyolo/yoloms/models/necks/yoloms_pafpn.py`
- [Detection head](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/dense_head/yoloms_head.py): `mmyolo/yoloms/models/dense_head/yoloms_head.py`
- [Distillation detector](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/detectors/yolo_distill.py): `mmyolo/yoloms/models/detectors/yolo_distill.py`

### Mask generation

- [Prompt predictor](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/predictor.py): `mmyolo/yoloms/models/segment_anything/predictor.py`
- [Image encoder](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/modeling/image_encoder.py): `mmyolo/yoloms/models/segment_anything/modeling/image_encoder.py`
- [Encoder components](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/modeling/common.py): `mmyolo/yoloms/models/segment_anything/modeling/common.py`
- [SAM model components](https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/yoloms/models/segment_anything/modeling): `mmyolo/yoloms/models/segment_anything/modeling`
- [Automatic masks](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py): `mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py`
- [Mask utilities](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/utils/amg.py): `mmyolo/yoloms/models/segment_anything/utils/amg.py`
- [Image transforms](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/yoloms/models/segment_anything/utils/transforms.py): `mmyolo/yoloms/models/segment_anything/utils/transforms.py`

### Training and data

- [Training entry](https://github.com/fishandwasabi/yolo-ms/blob/main/mmyolo/tools/train.py): `mmyolo/tools/train.py`
- **MMEngine runner**
- [Model configurations](https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/configs/yoloms): `mmyolo/configs/yoloms`
- [Dataset tools](https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/tools/dataset_converters): `mmyolo/tools/dataset_converters`

### Deployment

- [Deployment configs](https://github.com/fishandwasabi/yolo-ms/tree/main/mmyolo/configs/deployment): `mmyolo/configs/deployment`

### Other components

- **Researcher**

## Connections

- Researcher → Training entry: starts training (evidence: `mmyolo/tools/train.py`)
- Training entry → MMEngine runner: builds and runs (evidence: `mmyolo/tools/train.py`)
- YOLO-MS backbone → Multi-scale block: uses blocks (evidence: `mmyolo/yoloms/models/backbones/yoloms.py`)
- Multi-scale block → Block layers: builds layers (evidence: `mmyolo/yoloms/models/layers/msblock.py`)
- Feature pyramid → Multi-scale block: uses blocks (evidence: `mmyolo/yoloms/models/necks/yoloms_pafpn.py`)
- Prompt predictor → SAM model components: imports model (evidence: `mmyolo/yoloms/models/segment_anything/predictor.py`)
- Prompt predictor → Image transforms: uses transforms (evidence: `mmyolo/yoloms/models/segment_anything/predictor.py`)
- Image encoder → Encoder components: uses components (evidence: `mmyolo/yoloms/models/segment_anything/modeling/image_encoder.py`)
- Automatic masks → Prompt predictor: creates predictor (evidence: `mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py`)
- Automatic masks → Mask utilities: uses utilities (evidence: `mmyolo/yoloms/models/segment_anything/automatic_mask_generator.py`)
