Visers Nano Python API
visers computes L2-normalized visual embeddings on the CPU. It calls the same Rust decoder, resizer and Nano model as the nano_image CLI. The wheel contains the model weights and returns NumPy arrays directly. Existing applications can also import the API as visers_nano.
Install
Add Visers to your Python 3.10+ project with uv.
uv add visers
To install from source, run these commands from the repository root.
uv venv
uv pip install .
A source build needs Rust 1.88 or newer, a C compiler and CMake. NASM enables SIMD in the bundled JPEG decoder on x86. uv installs NumPy and uses maturin to build the native extension.
Encode images
Replace photo.jpg with a local image. Its path and encoded bytes produce the same embedding.
from pathlib import Path
import numpy as np
import visers as nano
image = Path("photo.jpg")
upload = image.read_bytes()
vector = nano.encode_single(image)
rows = nano.encode([image, upload], jobs=2)
assert vector.shape == (nano.DIMENSIONS,)
assert rows.shape == (2, nano.dimensions())
assert rows.dtype == np.float32
np.testing.assert_array_equal(rows[0], rows[1])
print(nano.similarity(vector, rows[1]))
| Call | Result |
|---|---|
encode_single(image, *, mode="fast") |
One contiguous float32 array of shape (D,) |
encode(images, *, mode="fast", jobs=None) |
A C-contiguous float32 matrix of shape (N, D), in input order |
DIMENSIONS, dimensions() |
Embedding width of the installed build, 256 by default |
similarity(a, b) |
Cosine similarity of two finite nonzero vectors |
distance(a, b) |
Euclidean distance between two finite vectors |
An image can be a str or os.PathLike[str] path, or the contents of a JPEG, PNG, WebP, GIF, BMP or PNM file as bytes, bytearray or memoryview. The file signature selects the decoder. Immutable bytes are borrowed during inference. Mutable buffers and memory views are copied when accepted.
encode takes one image or an iterable of images. One image yields shape (1, D), and an empty iterable yields (0, D). The iterable is gathered before processing. For a large collection, submit batches that fit in memory.
The two comparison functions take one-dimensional array-like inputs of equal, nonzero length. They convert values to float32 and accumulate in float64. For example, compare two rows using nano.distance(rows[0], rows[1]).
Preprocessing and workers
mode="fast"uses decoder-side scaling for large JPEGs and opaque still WebPs. This is the default for Python, the Rust convenience functions and the CLI.mode="full"decodes the full raster, applies EXIF orientation and reproduces Forge's Pillow 13 BOX resize of the whole frame to 128×128. Choose the same mode when building an index and embedding queries.jobs=Noneuses available CPU parallelism, limited by the number of inputs. A positive integer caps workers per call. Usejobs=1to process a batch sequentially. The extension releases the GIL during decoding and inference.- The process loads the baked model on first use. A calling thread reuses its decoder and inference workspace across calls. Workers write their results directly into rows of the output matrix.
Errors
Invalid input types raise TypeError. Malformed or unsupported images and invalid modes raise ValueError. Filesystem failures raise OSError subclasses such as FileNotFoundError. Inputs are type-checked before dispatch. For read or decode failures, the exception identifies the lowest failing input index, starting at zero, and includes the path when applicable. A successful call returns all rows.
Build a different embedding width
The default wheel embeds the 256D head. To build a 64D wheel, run maturin from the repository root with uvx. Use dim-128 for 128D. Each build exports its width through DIMENSIONS.
uvx --from "maturin>=1.12,<2" maturin build --release --locked --features dim-64 --out dist/64
Metadata
Release files for visers 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| visers-1.1.1.tar.gz | 2.5 MB | With provenance | Details for visers-1.1.1.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| visers-1.1.1-cp310-abi3-win_amd64.whl | CPython 3.10 | abi3 | Windows x86-64 | Details for visers-1.1.1-cp310-abi3-win_amd64.whl |
| visers-1.1.1-cp310-abi3-manylinux_2_28_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ x86-64 | Details for visers-1.1.1-cp310-abi3-manylinux_2_28_x86_64.whl |
| visers-1.1.1-cp310-abi3-manylinux_2_28_aarch64.whl | CPython 3.10 | abi3 | Linux glibc 2.28+ ARM64 | Details for visers-1.1.1-cp310-abi3-manylinux_2_28_aarch64.whl |
| visers-1.1.1-cp310-abi3-macosx_11_0_arm64.whl | CPython 3.10 | abi3 | macOS 11.0+ ARM64 | Details for visers-1.1.1-cp310-abi3-macosx_11_0_arm64.whl |
| visers-1.1.1-cp310-abi3-macosx_10_12_x86_64.whl | CPython 3.10 | abi3 | macOS 10.12+ x86-64 | Details for visers-1.1.1-cp310-abi3-macosx_10_12_x86_64.whl |
Total release size: 12.5 MB
Release files / visers-1.1.1.tar.gz
| Download URL | visers-1.1.1.tar.gz |
|---|---|
| Size | 2.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
144aa6042ce477887b03607d597942bd1361806d7af49685a8c971f4ce849648
|
|
BLAKE2b-256 checksum How to use checksums |
983512f3785585266676bff502e99016b71cf813b22c1ab25cc45871aa69109f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 28, 2026.
Transparency logRelease files / visers-1.1.1-cp310-abi3-win_amd64.whl
| Download URL | visers-1.1.1-cp310-abi3-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9efc6d6a2cfcab57dbf894c33c86283fc96fa726959cbdfa144b37973ce4e127
|
|
BLAKE2b-256 checksum How to use checksums |
8ea4912e75b208570156094d4c45cea4d7ebfab2f00215834b014aa25876a00f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 28, 2026.
Transparency logRelease files / visers-1.1.1-cp310-abi3-manylinux_2_28_x86_64.whl
| Download URL | visers-1.1.1-cp310-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
cd13260071e6c5de148911ea3cdf6130e23dbb1bdce6a6d8192a7cc82327ec63
|
|
BLAKE2b-256 checksum How to use checksums |
ea84b02fffa55e44cb398973d0461a811809ad37de65140890868469f8ec9be5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 28, 2026.
Transparency logRelease files / visers-1.1.1-cp310-abi3-manylinux_2_28_aarch64.whl
| Download URL | visers-1.1.1-cp310-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.10 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
56826eb8c1cfaeb47796446bd1937561fcedf12388ab8b7b8bb507dfb0774107
|
|
BLAKE2b-256 checksum How to use checksums |
f8a1d8d32de41bbc323d7df5ff14cfa13b7055b147c35c1c89793154b1356f15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 28, 2026.
Transparency logRelease files / visers-1.1.1-cp310-abi3-macosx_11_0_arm64.whl
| Download URL | visers-1.1.1-cp310-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.8 MB |
| Tags | CPython 3.10 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
056b2c2c25dc2843e2de848d8e4973d5943e3616287d7c7b40b9184a81cdbcc2
|
|
BLAKE2b-256 checksum How to use checksums |
4ce5b54be161c47e67e501a9b3539c36d3969cc49844e6ec345cf8f5c4a92570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 28, 2026.
Transparency logRelease files / visers-1.1.1-cp310-abi3-macosx_10_12_x86_64.whl
| Download URL | visers-1.1.1-cp310-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
499c7ea4266580045e972f121053e0baaaed3e40023a7571ae2e241232775b83
|
|
BLAKE2b-256 checksum How to use checksums |
a9f98c37a2a73acbfc0cb82514f6b175523f7b4bf4fda04006ca28a6294bed3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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 Nov 28, 2026.
Transparency logSecurity for visers 1.1.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.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for visers-1.1.1.tar.gz
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 Nov 28, 2026.
Transparency logA 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.