November 30, 2023

Visualizing ML Models in GitHub Using Netron

Srini Kadamati

What is Netron?

Netron is a fantastic library created and maintained by Lutz Roeder that helps you browse and visualize model architectures. Here’s a model visualization of an OpenAI GPT-2 model:

Netron has robust support for ONNX, Keras, Caffe, and a handful of others. The library also has experimental support for PyTorch, TensorFlow, scikit-learn, and other model formats. You can find the full, up-to-date list of supported model types in the project’s README.

Here are the 3 most common ways to visualize your ML models using Netron:

  • Install the netron Python library, run the server, and point the service to a model file

  • Install the Netron viewer as a desktop app for your operating system

  • Upload individual model files to the Netron.app website

We love the Netron library and wanted to find a way to bring the experience closer to version controlled, machine learning repos where ML models actually live. Our vision is to scale Git so ML teams can version code, large datasets, and models together in the same repository.

To help teams build shared context into their ML models, we’re excited to share that we’ve integrated the Netron into all XetHub views. XetHub scales Git to version control ML assets, providing flexible access patterns and custom views. Check out our onnx-models repo and browse to any onnx model file to see Netron views in action!‍

Browsing Model Architectures in your Git Repo

Already tracking your code in GitHub? No problem! You can install the XetData GitHub app to add large file support and XetHub views to your existing GitHub repos.

By installing the Git-Xet extension and adding the app to your GitHub repo, large datasets and models will be managed by XetHub and will display in the GitHub file browser as a pointer file, as seen below. Installing our browser extension adds a convenient “View File on XetHub” link for Xet-managed files.

Clicking the link will lead you to the XetHub view of the file, which in this case will be a Netron visualization.

Comparing Models in Pull Requests

Every time you make a pull request in GitHub, our bot will link to a Netron view of the before and after states of all model files that changed.

Clicking View diff on XetHub takes you to a side-by-side Netron model visualization:

One More Thing!

I wanted to end this post by showcasing my favorite trick that uses our repo mounting feature with Netron.

I often want to quickly browse, visualize, and compare different ML models quickly however ML repos can often be larger than 100 GB. To speed up the exploration process, Xet-managed Git repos can both be mounted to a local folder using our mount command.‍

# XetHub
git xet mount xet@xethub.com:XetHub/onnx-models.git

# GitHub + XetData
git xet mount git

We use NFS to create a read-only mounted folder on your machine:

After you install the desktop Netron app, you can then open any onnx model file using it. Behind the scenes, the model file will be downloaded and cached (in ~/.xet by default).

Because it can take a few seconds to download and cache model files behind the scenes, I recommend opening a few models at once and queueing the Netron windows.

As a bonus, you can also mount Xet-managed repos on remote machines if you want to try out onnx models from your Docker container without having to wait for the models to download! Check out our docs for more details.‍

Get Help

If you have questions or run into issues, reach out to us in our Slack community! You can also file bugs in our public GitHub issue tracker.

Share on

Get started today.

Contact us for recommendations on XetHub can help your team accelerate your ML development.

Get started today.

Contact us for recommendations on XetHub can help your team accelerate your ML development.

Get started today.

Contact us for recommendations on XetHub can help your team accelerate your ML development.