VisualTorch

io.github.willyfh由 GitHub 账号 willyfh 发布v1.4.1更新于 Oct 24, 2026

Render PyTorch architecture diagrams and animated GIF reveals from trusted model source.

已验证STDIO仅桌面媒体与设计AI 与机器学习

概览

AI 生成的概览

根据 PyTorch 模型源码生成神经网络架构图,可输出静态 PNG 或逐层展示的动画 GIF。

可以做什么
VisualTorch 可将基于 Torch 的神经网络架构渲染为 flow、graph 和 LeNet 三种风格的图。它通过追踪一次真实前向传播来构建图,每种风格还可渲染为动画 GIF,逐层或逐列展示模型。该 MCP 服务器提供能力发现、结构化输出元数据、文档资源、子进程超时以及全部三种标准风格。
适用场景
当你希望助手把 PyTorch 模型定义转成架构图或动画展示,用于文档、论文或评审时,适合使用。适用于能拿到模型源码、需要网络结构可视化摘要的场景。
运行要求
以 stdio 进程在本地运行,通过 pip install "visualtorch[mcp]" 安装,或用 uvx 运行。仅限桌面端,无网页可执行版本。未声明认证、环境变量或请求头。
安装前请注意
该服务器会追踪一次真实前向传播,因此带数据依赖控制流的模型只会显示被追踪的虚拟输入恰好走到的分支。返回多个有意义输出张量的层,其节点尺寸仅基于第一个张量。它基于可信的模型源码工作,请只对可信代码使用。

安装

在 SourceWeft 中

  1. 打开 控制台中的 VisualTorch,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

VisualTorch aims to help visualize Torch-based neural network architectures. It currently supports generating flow-style, graph-style, and LeNet-style architectures for PyTorch Sequential and Custom models. Its original visual styles were inspired by visualkeras, pytorchviz, pytorch-summary, and torchview; since then, it has grown its own unified tracing backend and architecture-handling logic well beyond its origins.

Note: 1.0+ is a major release with breaking API changes, but with significantly better features and algorithms - upgrading is recommended. For the old API, use 0.2.5 or older.

Limitation: VisualTorch traces a real forward pass to build the diagram, which has an inherent limitation shared by any tracing-based approach (not a bug, and not fixable without full symbolic execution): models with data-dependent control flow (e.g. a branch only taken if a tensor value crosses some threshold) only show whichever branch the traced dummy input happened to take. Separately, a layer that returns multiple meaningful output tensors (e.g. a custom multi-task head, or nn.LSTM's (output, (h_n, c_n))) still has its node's size based on only its first tensor; with show_dimension=True, every output tensor's shape is shown in the label, not just the first. Downstream connections are correct either way. Contributions are welcome!

Animated Reveal

Every style can also render as an animated GIF, revealing the model one layer/column at a time, via visualtorch.animate(model, input_shape, style=...) - see it in action for flow, graph, and lenet styles.

Documentation

Online documentation is available at visualtorch.readthedocs.io.

The docs include usage examples, API references, and other useful information.

Installation

See the Installation page.

MCP integration

VisualTorch includes an optional, client-neutral stdio MCP server for generating static PNG diagrams and animated GIF reveals from PyTorch model source. It exposes capability discovery, structured output metadata, documentation resources, subprocess timeouts, and all three canonical styles (graph, flow, and lenet). Install it with pip install "visualtorch[mcp]" and see the MCP integration guide for the tool schemas, generic stdio configuration, examples, and trusted-code security boundary. No client-specific plugin or extension is required.

Used in Research

VisualTorch has been used in published research, including works published in Nature, IEEE, and MDPI.

See the Research Showcase page for the full list.

Used VisualTorch in your research, built something with it, or found a paper that cites it? Tell us about it or open a pull request to add it directly - we'd love to hear.

Examples

See the Usage Examples page.

Contributing

Please feel free to send a pull request to contribute to this project by following this guideline.

Releases

See GOVERNANCE.md for release methodology and cadence, and the PyPI release history for past releases.

License

This poject is available as open source under the terms of the MIT License.

Originally, this project was based on the visualkeras (under the MIT license), with additional modifications inspired by pytorchviz, pytorch-summary, and torchview, all of which are also licensed under the MIT license.

Citation

Please cite this project in your publications if it helps your research.

Note: the paper below describes VisualTorch as of its publication date (2024). The project has since been substantially refactored, including breaking API changes (see the documentation for the current API) - the DOI always resolves to what was actually reviewed and published.

bibtex
@article{Hendria2024,  doi = {10.21105/joss.06678},  url = {https://doi.org/10.21105/joss.06678},  year = {2024},  publisher = {The Open Journal},  volume = {9},  number = {102},  pages = {6678},  author = {Willy Fitra Hendria and Paul Gavrikov},  title = {VisualTorch: Streamlining Visualization for PyTorch Neural Network Architectures},  journal = {Journal of Open Source Software}}

Star History

[Star History Chart]

来源:README.md,提交 1befb48

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.4.1最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分