-m yobx mermaid … convert an onnx model into Mermaid flowchart format#
The command converts an onnx model into a Mermaid flowchart string that can be embedded in Markdown, GitHub READMEs, or any tool that renders Mermaid diagrams.
Description#
See yobx.helpers.mermaid_helper.to_mermaid().
usage: mermaid [-h] [-o OUTPUT] [-v VERBOSE] input
Converts a model into a Mermaid flowchart string.
positional arguments:
input onnx model to convert
options:
-h, --help show this help message and exit
-o, --output OUTPUT file to save the Mermaid output or empty to print out
the result
-v, --verbose VERBOSE
verbosity
Examples#
Print the Mermaid source to the terminal:
python -m yobx mermaid model.onnx
Save the Mermaid source to a file:
python -m yobx mermaid model.onnx -o model.mmd
Output on a Dummy Model#
The following block builds a small Add + Relu model on the fly and runs
the command to show what the output actually looks like.
flowchart TB
t_X(["X<br/>float[2,3]"]):::onnxInput
t_Y(["Y<br/>float[2,3]"]):::onnxInput
n_Add_0["Add"]:::onnxOp
t_X -->|"float[2,3]"| n_Add_0
t_Y -->|"float[2,3]"| n_Add_0
n_Add_0 --> t_added
n_Relu_1["Relu"]:::onnxOp
t_added --> n_Relu_1
n_Relu_1 -->|"float[2,3]"| t_Z
t_Z(["Z<br/>float[2,3]"]):::onnxOutput
classDef onnxInput fill:#cde4ff,stroke:#3a6ea5,color:#000;
classDef onnxOutput fill:#ffe1b3,stroke:#a35a00,color:#000;
classDef onnxInitializer fill:#eeeeee,stroke:#888,color:#000;
classDef onnxOp fill:#d4ecd4,stroke:#3a8c3a,color:#000;
classDef onnxTagShape fill:#f4d6ff,stroke:#8744a2,color:#000;
classDef onnxTagAxes fill:#ffe9a8,stroke:#9e7a00,color:#000;
classDef onnxTagWeight fill:#e0e0e0,stroke:#666666,color:#000;
classDef onnxTagAmbiguous fill:#ffd9d9,stroke:#a33a3a,color:#000;