WeightExportGuide class

Utility for converting PyTorch/HuggingFace model weights to a format suitable for the Dart Donut model.

Use this with a Python script to export weights:

import torch, json, base64
from safetensors.torch import load_file

weights = load_file("model.safetensors")
out = {}
for name, tensor in weights.items():
    t = tensor.cpu().float().numpy()
    out[name] = {
        "shape": list(t.shape),
        "dtype": "float32",
        "data": base64.b64encode(t.tobytes()).decode()
    }
with open("weights.json", "w") as f:
    json.dump(out, f)

Constructors

WeightExportGuide()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

exportScript → const String
Python script to convert HuggingFace model to JSON weights.
tokenizerExportScript → const String
Python script to export tokenizer in HuggingFace format.