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.
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.1"
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.
For Ask image, download the SmolVLM model and projector and launch the dashboard directly with the VLM. Stop the classifier dashboard first if it is using port 8080.
zmq-inference web --vlm --model-path smolvlm.gguf --projector-path projector.gguf
From a source checkout, run ./scripts/demo-web.sh --vlm --model-path smolvlm.gguf --projector-path projector.gguf. The dashboard disables tasks the connected server cannot run. The download-free demo supports Classify, and SmolVLM supports Generate and Ask image.
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.1"
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.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 |
|---|---|---|---|---|
| zmq_vision-0.5.1.tar.gz | 826.6 kB | With provenance | Details for zmq_vision-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zmq_vision-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for zmq_vision-0.5.1-py3-none-any.whl |
Total release size: 883.3 kB
Release files / zmq_vision-0.5.1.tar.gz
| Download URL | zmq_vision-0.5.1.tar.gz |
|---|---|
| Size | 826.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
183aeeb263641052e1ba14e32863f57c0eb90b5e1e0da090a51bd4172d40bfc7
|
|
BLAKE2b-256 checksum How to use checksums |
94975981a7b439668bacf3e3f6feb0e13fdc532e9a791029f98b3aff347294cb
|
| 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 logRelease files / zmq_vision-0.5.1-py3-none-any.whl
| Download URL | zmq_vision-0.5.1-py3-none-any.whl |
|---|---|
| Size | 56.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8262a5fe75fa665c08644d222abe00a8ff00f7885382881c71ba87d514c9f7c1
|
|
BLAKE2b-256 checksum How to use checksums |
778f8e13ec7cf67ed260c287d27153acf02ba3d885dc2ffa430c9fa161618823
|
| 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 logSecurity for zmq-vision 0.5.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
Both files in this release have been uploaded with provenance metadata.
Attestation for zmq_vision-0.5.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 19, 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.