Skip to main content

canvit-mlx

The MLX implementation of CanViT (Canvas Vision Transformer) for Apple Silicon. Read the root backend documentation for the cross-backend API and tensor conventions.

Install

uv add canvit-mlx

Load a Hugging Face checkpoint

Load a pretrained model and an ADE20K probe from Hugging Face. Replace path/to/image.jpg with your image path.

import mlx.core as mx
from PIL import Image

from canvit_mlx import CanViTForSemanticSegmentation, Viewpoint, sample_at_viewpoint
from canvit_mlx.preprocess import preprocess

scene = mx.array(preprocess(512)(Image.open("path/to/image.jpg").convert("RGB")))[None]
model = CanViTForSemanticSegmentation.from_pretrained_with_probe(
    pretrained_repo="canvit/canvitb16-add-vpe-pretrain-g128px-s512px-in21k-dv3b16-2026-02-02-mlx",
    probe_repo="canvit/probe-ade20k-40k-s512-c64-in21k-mlx",
)
model.eval()
viewpoint = Viewpoint.full_scene(batch_size=1)
state = model.init_state(batch_size=1, canvas_grid_size=64)
glimpse = sample_at_viewpoint(spatial=scene, viewpoint=viewpoint, glimpse_size_px=128)
logits, state = model(glimpse=glimpse, state=state, viewpoint=viewpoint)
mx.eval(logits)
print(logits.shape)  # [1, 64, 64, 150]

The model and probe remain separate checkpoints. They use NHWC arrays: scenes and glimpses are [B, H, W, 3], and the wrapper returns canvas logits as [B, G, G, num_classes]. Viewpoint centers use (row, col) scene coordinates in [-1, 1]; each scale is the crop's half-side.

The example uses the ImageNet-21k CanViT-B checkpoint and the ADE20K probe. The Hub lists every MLX checkpoint by its mlx tag.

Develop from a checkout

cd canvit-mlx
uv sync

The checkout resolves canvit-core from its sibling directory. To convert a PyTorch checkpoint and run the conversion checks from the repository root:

uv run --project canvit-mlx python -m tools.convert_checkpoints --help

Metadata

Release files for canvit-mlx 0.2.1

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

Source distribution (sdist)

Source distribution for canvit-mlx 0.2.1
File Size Uploaded Provenance Actions
canvit_mlx-0.2.1.tar.gz 63.7 kB Without provenance Details for canvit_mlx-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for canvit-mlx 0.2.1
File Interpreter ABI Platform Actions
canvit_mlx-0.2.1-py3-none-any.whl Python 3 none any Details for canvit_mlx-0.2.1-py3-none-any.whl

Total release size: 80.5 kB

Release files / canvit_mlx-0.2.1.tar.gz

Download URL canvit_mlx-0.2.1.tar.gz
Size 63.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9d6d3a53c7f76b6b942c824911b72714eb36a37d96c0157945ddb94a8c64c341
BLAKE2b-256 checksum
How to use checksums
2eac329311d63ac78fd8fd3be721364ddd16235d60c4532cf143f09e042c97c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / canvit_mlx-0.2.1-py3-none-any.whl

Download URL canvit_mlx-0.2.1-py3-none-any.whl
Size 16.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
661ddbd10f826fe17801dcbeb9ce91c4da65c6d31a564014c9a466fe9cc6aec6
BLAKE2b-256 checksum
How to use checksums
94e9b6f3574cf6c5f7c48baa5e8d8fdb3b3386605e83ce082cef92ea69f9c01c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for canvit-mlx 0.2.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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