Back to Ultralytics

YAML2ModelGraph Architecture Visualization for YOLO Models

docs/en/integrations/yaml2modelgraph.md

8.4.1432.7 KB
Original Source

Visualize YOLO Architectures with YAML2ModelGraph

YAML2ModelGraph is a community tool that converts Ultralytics YOLO model YAML files into SVG architecture diagrams. It can help document custom models or inspect their backbone, neck, and head structure.

<p align="center"> </p>

Installation

Clone the project and install its PyYAML dependency:

bash
git clone https://github.com/WangQvQ/YAML2ModelGraph.git
cd YAML2ModelGraph
pip install pyyaml

Usage

Generate a diagram from the included YOLO26 example:

bash
python main.py examples/yolo26.yaml output.svg

Use --head multi to draw separate scale-specific head nodes, or select one of the included themes:

bash
python main.py examples/yolo26.yaml output.svg --head multi --theme paper_ryb

Available themes include paper, paper_ryb, candy, dark, ocean, retro, blueprint, forest, and journal. The generated SVG requires no Graphviz installation.

Node Metadata

Edit DISPLAY_CONFIG in YAML2ModelGraph's main.py to choose which details appear in each node:

python
DISPLAY_CONFIG = {
    "show_channels": True,
    "show_repeats": True,
    "show_stride": True,
    "show_args": False,
}

Custom YAML module names are rendered automatically. Theme colors, shapes, and typography are configured in the tool's themes.py.

Limitations

YAML2ModelGraph specially aligns standard Detect heads. Other task heads such as OBB, Pose, and Segment are currently rendered as generic neck-lane nodes. See the YAML2ModelGraph repository for current support and usage details.

FAQ

Does YAML2ModelGraph work with custom model YAMLs?

Yes. Any Ultralytics model YAML that follows the [from, repeats, module, args] layer format renders, and custom module names are drawn as generic nodes. See the model YAML configuration guide for the format.

Do I need Graphviz installed?

No. The tool writes SVG directly and depends only on PyYAML.

Which heads are drawn with their scale-specific structure?

Only standard Detect heads. OBB, Pose, and Segment heads are drawn as generic neck-lane nodes; check the YAML2ModelGraph repository for current support.