
VisualTorch
io.github.willyfhPublished by GitHub account willyfhv1.4.1Updated Oct 24, 2026
Render PyTorch architecture diagrams and animated GIF reveals from trusted model source.
Overview
Generates PyTorch neural network architecture diagrams as static PNGs or animated GIF reveals from model source code.
- What you can do
- VisualTorch renders diagrams of Torch-based neural network architectures in flow, graph, and LeNet styles. It traces a real forward pass to build the diagram, and every style can also be rendered as an animated GIF that reveals the model one layer or column at a time. The MCP server exposes capability discovery, structured output metadata, documentation resources, subprocess timeouts, and all three canonical styles.
- When to use it
- Useful when you want an assistant to turn PyTorch model definitions into architecture diagrams or animated reveals for documentation, papers, or review. It fits workflows where the model source is available and a visual summary of the network structure is needed.
- Requirements
- Runs locally as a stdio process, installed with pip install "visualtorch[mcp]" or run with uvx. Desktop only; no web executable. No authentication, environment variables, or headers are declared.
Installation
In SourceWeft
- Open VisualTorch in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
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.
Star History
[Star History Chart]Source: README.md at commit 1befb48
Tools
0Version history
1- v1.4.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts