Skip to main content

modelport-cli

Prepare models for Flutter apps. Part of ModelPort.

Install modelport-cli; the command and the Python package are both called modelport.

Status: 0.1.0, alpha. Works end to end and is tested on a real Android phone. The spec may still change before 1.0.

The CLI converts PyTorch, Hugging Face, and torchvision models into mobile formats, checks that the converted model gives the same output as the original, and writes a modelport.json manifest that the ModelPort Dart packages read.

Install

pip install "modelport-cli[onnx,torchvision]"
Extra Adds Needed for
onnx onnx, onnxruntime, onnxscript, torch ONNX export, quantize, verify
executorch executorch, torch ExecuTorch export and verify
torchvision torchvision, torch torchvision: sources
hf transformers, huggingface_hub, torch hf: sources and publish
gguf gguf Inspecting GGUF files

Run modelport doctor to see what is installed.

Quick start

modelport export torchvision:mobilenet_v3_small --target onnx,executorch
modelport quantize dist/mobilenet_v3_small --fp16 --int8
modelport verify dist/mobilenet_v3_small
modelport publish dist/mobilenet_v3_small --hf your-name/mobilenet_v3_small

verify runs every variant on the saved golden input and compares it with PyTorch's output:

 variant                 ┃ output ┃ max diff ┃ cosine   ┃ top-1 ┃ result
━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━╇━━━━━━━━
 onnx-fp32               │ logits │ 3.34e-05 │ 1.000000 │ same  │ pass
 executorch-xnnpack-fp32 │ logits │ 3.34e-05 │ 1.000000 │ same  │ pass
 onnx-fp16               │ logits │ 1.05e-01 │ 0.999952 │ same  │ pass
 onnx-int8               │ logits │ 1.27e-01 │ 0.999933 │ same  │ pass

Commands

Command What it does
export SOURCE Convert a model and write a bundle with modelport.json, labels, and golden data.
quantize BUNDLE Add --fp16 and --int8 ONNX variants and record how far each drifts.
verify BUNDLE Run every variant on the golden input and compare with the expected output.
pack BUNDLE Refresh sizes and hashes after manual edits and list unlisted files.
publish BUNDLE --hf org/name Upload to the Hugging Face Hub. Log in first with hf auth login.
inspect FILE Show inputs, outputs, and metadata of an .onnx, .pte, or .gguf file.
validate MANIFEST... Check manifests against the spec.
schema Print the manifest JSON Schema.
doctor Check Python, optional packages, and disk space.

Sources

Source Example
torchvision classifier torchvision:efficientnet_b0
Hugging Face image classifier hf:facebook/deit-tiny-patch16-224
Your own model file:my_model.py:build

For file:, write a function that returns a SourceModel:

import torch
from modelport.manifest import DType, ImagePreprocess, InputSpec, ResizeSpec, Task
from modelport.sources import SourceModel


def build() -> SourceModel:
    net = MyNet()
    net.load_state_dict(torch.load("weights.pt", weights_only=True))
    return SourceModel(
        module=net.eval(),
        example_inputs=(torch.zeros(1, 3, 224, 224),),
        id="my_net",
        task=Task.IMAGE_CLASSIFICATION,
        license="MIT",
        inputs=[
            InputSpec(
                name="pixel_values",
                dtype=DType.FLOAT32,
                shape=[1, 3, 224, 224],
                layout="NCHW",
                preprocess=ImagePreprocess(resize=ResizeSpec(size=(224, 224))),
            )
        ],
        output_names=["logits"],
        labels=["cat", "dog"],
    )

file: runs the code in that file, so only use files you trust.

Notes on quantization

  • --fp16 halves the size and keeps inputs and outputs in float32.
  • --int8 quantizes only MatMul and Gemm weights. Dynamic int8 on convolutions changed MobileNetV3's top-1 class in testing, so convolution-heavy models shrink less. Transformers shrink to about a third.
  • Each new variant gets a tolerance of twice its measured error, so devices are checked against a realistic bar.

Metadata

Release files for modelport-cli 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modelport-cli 0.1.0
File Size Uploaded
modelport_cli-0.1.0.tar.gz 234.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modelport-cli 0.1.0
File Interpreter ABI Platform
modelport_cli-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 293.6 kB

Release files / modelport_cli-0.1.0.tar.gz

Download URL modelport_cli-0.1.0.tar.gz
Size 234.4 kB
Tags Source
SHA-256 checksum
How to use checksums
1fb299ef4fc4aaf4a441a6bacfc77dcde9012525358739d1f4fae0b610b35184
BLAKE2b-256 checksum
How to use checksums
9d1bbcab930f909aab80691cea3dd4228c26ebf0f8af06f09378ca109ed0713b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / modelport_cli-0.1.0-py3-none-any.whl

Download URL modelport_cli-0.1.0-py3-none-any.whl
Size 59.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0d55851458eb1145d81edf127ece362dcf9e8e6d91de04614456970ec3166808
BLAKE2b-256 checksum
How to use checksums
552dc6d253b3ea4d8ef206cbbbf19968747708a23ea3e5926e023f8009eb8305
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page