Skip to main content

PySalty(Python Structural Architecture Layout Tool), publication-ready PyTorch model visualization library

Project description

PySalty (Python Structural Architecture Layout Tool)

PySalty is a lightweight Python library for visualizing PyTorch neural network architectures as clean, publication ready diagrams.

It is designed for:

  • research papers
  • presentations
  • documentation
  • understanding complex models

PySalty focuses on clarity and aesthetics rather than training, execution, or graph theory.


Features

  • Automatic PyTorch model parsing
  • Hierarchical visualization of nn.Sequential blocks
  • Intelligent edge routing that avoids overlapping modules
  • Multiple built in visual themes
  • Fully customizable colors, fonts, and layout
  • High resolution PNG export
  • Zero dependency on model execution
  • No arrows or ports for clean publication ready figures

Installation

Install from PyPI:

pip install pysalty

Quick Start

import torch.nn as nn
from salt import Visualize, PaperTheme

class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.Stem = nn.Sequential(
            nn.Conv2d(3, 64, 3),
            nn.ReLU(),
        )
        self.Head = nn.Sequential(
            nn.AdaptiveAvgPool2d(1),
            nn.Flatten(),
            nn.Linear(64, 10),
        )

model = SimpleNet()

Visualize(
    model,
    theme=PaperTheme,
    save_path="model.png"
)

This produces a clean architecture diagram suitable for papers or slides.


How model parsing works

PySalty parses only the top level children of your PyTorch model.

Example structure:

class MyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.Stem = ...
        self.Stage1 = ...
        self.Stage2 = ...
        self.Head = ...

Each top level attribute becomes a block in the diagram.


Containers nn.Sequential

If a top level module is an nn.Sequential, PySalty will:

  • Draw it as a container box
  • Draw each sub layer inside it
  • Automatically connect internal layers vertically

Example:

self.Stem = nn.Sequential(
    ConvBNAct(...),
    ConvBNAct(...),
)

This becomes a container labeled Stem with child blocks inside.


Non sequential modules

If a module is not an nn.Sequential, it is drawn as a single block labeled by its class name.


Connections

  • Blocks are connected in the order they appear in the model definition
  • Routing automatically avoids overlapping other blocks
  • Long connections are lifted above the diagram when needed
  • No manual configuration is required

Built in Themes

PySalty includes several ready to use themes defined in salt.theme.

DarkTheme

Dark background with soft purple highlights. Suitable for presentations and screen viewing.

from salt import DarkTheme

LightTheme

Clean white background with subtle gray outlines. Suitable for documentation.

from salt import LightTheme

PaperTheme

Pure black and white styling with sharp corners and thinner edges. Recommended for research papers and LaTeX figures.

from salt import PaperTheme

DraculaTheme

Dark purple background with neon accents inspired by the Dracula color palette.

from salt import DraculaTheme

LightTheme

Clean white background with subtle gray outlines. Suitable for documentation.

from salt import LightTheme

PaperTheme

Pure black and white styling with sharp corners and thinner edges. Recommended for research papers and LaTeX figures.

from salt import PaperTheme

DraculaTheme

Dark purple background with neon accents inspired by the Dracula color palette.

from salt import DraculaTheme

Creating your own theme

You can fully customize the appearance by creating a Theme object. All styling options are defined in salt.theme.Theme.

from salt import Theme

MyTheme = Theme(
    Background="#0B1020",
    Primary="#00E5FF",
    Accent="#FFD54F",
    Text="#E0F7FA",
    Line="#90A4AE",
    BoxFill="#102027",
    ChildFill="#1C313A",

    FontFamily="Times New Roman",
    FontSize=12,
    TitleFontSize=13,
    FontWeight="regular",

    CornerRadius=0.3,
    EdgeWidth=2.5,
)

Then use it:

Visualize(model, theme=MyTheme)

Fonts

PySalty uses Matplotlib fonts.

Any font installed on your system can be used by setting:

FontFamily="Times New Roman"

Common choices for papers include Times New Roman, Computer Modern, and DejaVu Serif.


Output

  • By default, the figure is returned and can be shown inline in Jupyter
  • Use save_path to export a high resolution PNG
Visualize(model, save_path="architecture.png")

License

MIT License

Free for academic and commercial use.


Notes and Limitations

  • PySalty is a visualization tool, not a graph execution engine
  • Skip connections and general DAGs are not yet supported
  • Only top level modules are visualized by design

These decisions are intentional to keep diagrams clean and readable.


Contributing

Contributions are welcome, including new themes, layout improvements, export formats, and documentation improvements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysalty-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysalty-0.1.1-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file pysalty-0.1.1.tar.gz.

File metadata

  • Download URL: pysalty-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for pysalty-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6591f6153b9e516eb80d1a7480a47ed4a2b309c8190a213b5339747aaee2a243
MD5 e169b49ad08e544b9e6b0789567f6d34
BLAKE2b-256 685a9ba98334eb42a93fd367c81df5f211faff463a6d408c293c75320d75a92e

See more details on using hashes here.

File details

Details for the file pysalty-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pysalty-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for pysalty-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7697cfb1422d5abf9cf74d88387b3c69499da560f406eb9b5bf21a340e7dea6a
MD5 7dddd6a4e82fd4cbcfb4dbe86ca91200
BLAKE2b-256 02791561374d72d37cae7fec21077c79cf588e44c018885c1a82998e5c659ae5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page