Skip to main content

ZMQ Inference

Serve local vision and language models over ZeroMQ. Classify images with PyTorch or TensorFlow, generate text with SmolLM2, and ask questions about images with SmolVLM. Use the same Python clients, CLI, or local browser dashboard.

PyPI CI License: MIT

Quick start · Browser dashboard · Model examples · Python API · Architecture · Benchmarks

Quick start

In a Python 3.10+ virtual environment:

python -m pip install --upgrade "zmq-vision>=0.5.0"
zmq-inference demo

The demo starts a real localhost TCP server, sends generated images using both Python clients, and checks the responses and shutdown. It ranks RGB channel intensity and runs without a model download or GPU. GitHub release wheels

Browser dashboard

zmq-inference web --demo

Open http://127.0.0.1:8080, choose Use sample, then run classification. The dashboard shows model scores, token usage when applicable, request IDs, and a chart of recent server times. The launcher works from a checkout with ./scripts/demo-web.sh. To test an existing model server, use zmq-inference web or ./scripts/demo-web.sh --connect.

The local ZMQ Inference dashboard shows an image prompt, a real SmolVLM response, token metrics, and server times

The bridge listens on loopback and connects to ZeroMQ on port 5576 by default. Use --port for the dashboard port and --zmq-port for the model port. The three tasks map to Classify for demo, PyTorch, or TensorFlow, Generate for an LLM or VLM, and Ask image for a VLM.

Serve a model

Ask a question about an image

Install the optional VLM extra and download the matching SmolVLM-256M Instruct model and projector. The two quantized files total about 279 MB. Python 3.12 on Linux or WSL is the tested setup. If pip builds llama.cpp from source, it needs a C/C++ toolchain. llama-cpp-python installation

python -m pip install "zmq-vision[vlm]>=0.5.0"
base=https://huggingface.co/ggml-org/SmolVLM-256M-Instruct-GGUF/resolve/b9e4379657e1450d04d02eec8e345667265b0a00
curl -fL "$base/SmolVLM-256M-Instruct-Q8_0.gguf" -o smolvlm.gguf
curl -fL "$base/mmproj-SmolVLM-256M-Instruct-Q8_0.gguf" -o projector.gguf
zmq-inference serve --backend vlm --model-path smolvlm.gguf --projector-path projector.gguf

In another terminal, pass a local image:

zmq-inference generate "What is shown in this photo?" --image photo.jpg --async --json

Or run zmq-inference web and choose Ask image. The VLM accepts text-only requests too. The server uses two CPU threads and resizes images to fit 512 × 512 before model processing. The SmolVLM weights use Apache 2.0.

Generate text with a small LLM

python -m pip install "zmq-vision[llm]>=0.4.0"
curl -fL -o smollm2.gguf \
  https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/09816acd5d99df7be770d85ea30822623dab342c/SmolLM2-135M-Instruct-Q4_K_M.gguf
zmq-inference serve --backend llm --model-path smollm2.gguf

From another terminal:

zmq-inference generate "Name three uses for a Raspberry Pi." --max-tokens 48

The text-only setup uses a 105 MB GGUF and two CPU threads. Generation returns text, prompt and output token counts, and a finish reason. Both GGUF backends run from local files. Base model · Quantized weights · llama-cpp-python

Classify an image

python -m pip install "zmq-vision[torch]"
zmq-inference serve --backend torch --model mobilenetv2_100 --device cpu

From another terminal:

zmq-inference infer photo.jpg --async --json

For TensorFlow, install zmq-vision[tf] and use zmq-inference serve --backend tf --device cpu. The supplied classifiers download pretrained weights on first use. Custom backend example

Python API

Both clients support ping(), infer(image), and generate(prompt, image=...). The image argument is optional for generation.

import asyncio

from zmq_inference.client.async_client import AsyncClient


async def main():
    async with AsyncClient() as client:
        result = await client.generate("What is in this photo?", image="photo.jpg", max_tokens=48)
        if not result.ok:
            raise RuntimeError(result.error)
        print(result.generation.text)


asyncio.run(main())

Use a VLM server for the example above. Import SyncClient from zmq_inference.client for the synchronous equivalent. The PyPI package is still published as zmq-vision, and both CLI names work. Migration guide

Architecture

flowchart LR
    Browser["Browser dashboard"] -->|"HTTP on loopback"| Bridge["Python web bridge"]
    Bridge --> D["DEALER socket per client"]
    CLI["CLI"] --> D
    Clients["Sync and asyncio clients"] --> D
    D <-->|"ZeroMQ TCP · JSON · request ID"| Router["ROUTER network thread"]
    subgraph Server["Model server"]
        Router --> Admission["Bounded admission"]
        Admission --> Worker["Model worker"]
        Worker --> Model{"Backend"}
        Model --> Classification["Classifier"]
        Model --> LLM["Text generation"]
        Model --> VLM["Image + text generation"]
        Worker -->|"Completed future"| Router
    end
  • Bounded admission. One thread owns the ROUTER socket. The worker pool handles inference. Once 16 requests are running or queued, the default server returns a busy response.
  • Correlated replies. Every response carries a request ID. Timeout and async cancellation replace the client socket so late replies cannot be mistaken for a later result.
  • Predictable lifecycle. Readiness follows model load and bind. Shutdown stops admission and drains active work.

Wire format, limits, and delivery semantics

Benchmarks

On WSL2, single-client RGB demo p95 fell from 56.5 ms to 3.3 ms in 0.4. SmolLM2 delivered 98 output tokens/s on two CPU threads. The benchmark guide also covers MobileNet and SmolVLM, with commands and raw results. Benchmark guide

Contribute

Built by Jamal Saeedi. Fork the repo to try another model or extend the transport.

Star on GitHub · Fork · Report an issue · Contributing guide

Metadata

Release files for zmq-vision 0.5.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 zmq-vision 0.5.0
File Size Uploaded Provenance Actions
zmq_vision-0.5.0.tar.gz 824.0 kB With provenance Details for zmq_vision-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for zmq-vision 0.5.0
File Interpreter ABI Platform Actions
zmq_vision-0.5.0-py3-none-any.whl Python 3 none any Details for zmq_vision-0.5.0-py3-none-any.whl

Total release size: 879.5 kB

Release files / zmq_vision-0.5.0.tar.gz

Download URL zmq_vision-0.5.0.tar.gz
Size 824.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ab024a941639a1e4b06851c1203a993aa49c0c0a31f34da91d9276ac6416b692
BLAKE2b-256 checksum
How to use checksums
6d72354cc755a7ad6e2c7de7e5694c1b8e523a41295489f0655e7a3c643d3a8a
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 19, 2026.

Transparency log

Release files / zmq_vision-0.5.0-py3-none-any.whl

Download URL zmq_vision-0.5.0-py3-none-any.whl
Size 55.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cf927d93655f9c97ef4a0d6545d1f6b0128d6a3274226b0b896670f8075cc19
BLAKE2b-256 checksum
How to use checksums
2bc23939be4236bb1fb61ec3d5a6ea9c80eda01e91fb57b4e9b86abca1b367f5
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 19, 2026.

Transparency log

Security for zmq-vision 0.5.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for zmq_vision-0.5.0.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 19, 2026.

Transparency log

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