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.2"
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
Try classification without downloading weights
zmq-inference web --demo
Open http://127.0.0.1:8080, choose Use sample, then select Run classification. From a source checkout, ./scripts/demo-web.sh starts the same RGB classifier dashboard.
Ask a question about an image
Install the VLM extra and download the matching SmolVLM model and projector. The two 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 --upgrade "zmq-vision[vlm]>=0.5.2"
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 web --vlm --model-path smolvlm.gguf --projector-path projector.gguf --port 8081
Open http://127.0.0.1:8081, select Choose image, enter a prompt such as “What is the main subject in this image?”, then select Ask about image. The dashboard shows the answer, token usage, and recent server times. Port 8081 lets the classifier dashboard keep running on port 8080. From a source checkout, replace zmq-inference web in the launch command with ./scripts/demo-web.sh.
If Ask image is disabled or the dashboard reports that the backend cannot answer image questions, open the SmolVLM dashboard on port 8081. After upgrading, restart the dashboard process so the browser loads the new version. Use zmq-inference --version to check the installed version.
To use an existing ZeroMQ server, run zmq-inference web --zmq-port 5576 or ./scripts/demo-web.sh --connect --zmq-port 5576. The dashboard binds to loopback and shows the tasks the connected backend supports.
Serve a model
Run SmolVLM from the CLI
Install the VLM extra and download the SmolVLM model and projector. Start a standalone ZeroMQ server.
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
The VLM also accepts text-only requests. It uses two CPU threads and resizes images to fit 512 × 512 before model processing. The weights use Apache 2.0. SmolVLM model card
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.2
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.2.tar.gz | 827.0 kB | With provenance | Details for zmq_vision-0.5.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zmq_vision-0.5.2-py3-none-any.whl | Python 3 | none | any | Details for zmq_vision-0.5.2-py3-none-any.whl |
Total release size: 883.7 kB
Release files / zmq_vision-0.5.2.tar.gz
| Download URL | zmq_vision-0.5.2.tar.gz |
|---|---|
| Size | 827.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
641652ff1c46d47ca002a1348faea3dc9cfc84e27355fbbbfa1b47096e0bef3a
|
|
BLAKE2b-256 checksum How to use checksums |
59afa6ed70149b8b0f56442676f8ee456309d464e369d49ad6645bac2b8bb344
|
| 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.2-py3-none-any.whl
| Download URL | zmq_vision-0.5.2-py3-none-any.whl |
|---|---|
| Size | 56.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66a779d2eed17f48a13e95439468fca4a7bba111badbf033b5a78ef9ed96cb5a
|
|
BLAKE2b-256 checksum How to use checksums |
843774f21f37834cd937eb05da5f7e928b4376641b1f624e1496570e34fbf244
|
| 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.2
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.2.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.