$ show lutzroeder/netron
Netron is a cross-platform neural network model visualizer that supports a wide range of deep learning frameworks (ONNX, TensorFlow, PyTorch, CoreML, etc.). It operates as an Electron desktop application, a web app, and a Python-based CLI/server. The architecture is modular: each model format is handled by a dedicated `ModelFactory` class implementing `match()` and `open()` methods, which parse binary or protobuf/flatbuffers serialized models into a uniform internal graph representation (Model -> Graph -> Node -> Value/Tensor). The application provides interactive graph visualization with SVG rendering, attribute inspection, and export capabilities. While primarily an application, it contains substantial data-processing code for format parsing, tensor decoding, and schema-driven metadata handling. The codebase is well-structured with consistent patterns, though it exhibits some duplication across format parsers and experimental/partial support for minority formats. The Python server (`server.py`) and the core binary parsing libraries (`base.js`, `protobuf.js`, `flatbuffers.js`) are independently reusable.
The LLM identified 3 files worth highlighting for reuse:
Provides a suite of low-level binary stream readers (`BinaryReader`, `StreamReader`) and a `Tensor` class that decodes multi-dimensional arrays with support for a wide range of numeric types, including float16, bfloat16, FP8 variants, FP4, and complex numbers. It also extends `DataView.prototype` with polyfills for these non-standard types. This module is self-contained, has no internal dependencies, and can be extracted as a standalone library for any project that needs to read binary ML model weights or custom binary formats.
A custom protobuf decoder that reads both binary and text protobuf formats without relying on the official protobuf library. It implements variable-length integer decoding, wire type handling, and supports nested messages, packed fields, and enums. Used by multiple format parsers (CNTK, MindIR, XModel, etc.) and can be extracted as a lightweight, dependency-free protobuf reader for JavaScript/TypeScript applications.
A FlatBuffers binary and text reader that provides a unified API (`BinaryReader`, `TextReader`) for parsing FlatBuffers serialized data. It handles vtable offsets, nested structs, and string tables. Used by many format parsers (Arm NN, MNN, TOSA, ESP-DL). Self-contained with no internal imports, making it reusable for any project that needs to read FlatBuffers files in JavaScript.