Title here
Summary here
import { parseSavedModel } from "@wetron/savedmodel";
const graph = parseSavedModel(bytes); // synchronous, returns ModelGraph
Or use the unified entry point - .pb files are routed here automatically:
import { parseModel } from "@wetron/core";
const graph = await parseModel(bytes, "model.pb");Detected by first byte 0x0a (protobuf field 1, length-delimited). Contains a Keras layer graph serialized as JSON inside the protobuf.
Sequential, FunctionalInputLayer entries -> ModelGraph.inputs (excluded from nodes)class_name -> node opTypeattributesinbound_nodes for Functional; chained for SequentialDetected by first byte 0x08 (protobuf field 1, varint - schema version). Contains a TensorFlow GraphDef with raw TF ops.
Placeholder nodes -> ModelGraph.inputsModelGraph.nodesConst node tensor shape and dtype are folded into ModelGraph.initializers; consumers see them as initializer edges in the rendered graphStatefulPartitionedCall and PartitionedCall function bodies are inlined from the library.function table; body node names are prefixed with the call-site name to avoid collisionsVarHandleOp nodes mark variables backed by an external checkpoint - the parser sets ModelGraph.hasExternalWeights = true so a host app knows to load them via loadSavedModelWeightsPlaceholder (input)
↓
Conv2D ← Const (weight)
↓
BiasAdd ← Const (bias)
↓
Relu
↓
...
↓
Softmax (output)parseModel detects .pb by filename extension; the first-byte check then selects the variant.ModelGraph.weights is not populated by parseSavedModel itself. For TF2 models, load the checkpoint pair (variables.index + variables.data-00000-of-00001) with loadSavedModelWeights and call attachCheckpointToGraph to produce a graph with weights re-keyed by node name. See
Weights.^) are ignored.:0, :1) are stripped from input tensor names. As a
consequence, multi-output ops (Split, TopK, …) cannot be fully
disambiguated - every consumer of split:0, split:1 is recorded as a
consumer of split. Connectivity is preserved; per-port labelling is not.warnings on the returned graph.ParseError if the file is too short or has unrecognized first byte.