Skip to main content

Model-agnostic generative vision abstractions (image/video) for the Abstract ecosystem

Project description

AbstractVision

PyPI version CI Tested Python license GitHub stars

Model-agnostic generative vision API (images, optional video) for Python and the Abstract* ecosystem.

What you get

How it fits together (diagram)

flowchart LR
  Caller[Python / CLI / AbstractCore] --> VM[VisionManager]
  VM --> BE[VisionBackend]
  BE --> VM
  VM -->|optional| Store[MediaStore]
  Store --> Ref[Artifact ref dict]
  VM -->|no store| Asset["GeneratedAsset (bytes + mime)"]

Status (current backend support)

  • Development status: Alpha (0.x). The public API is stable-by-design, but breaking changes may still happen and will be called out in CHANGELOG.md.
  • Built-in backends implement: text_to_image and image_to_image.
  • Video (text_to_video, image_to_video) is supported only via the OpenAI-compatible backend when endpoints are configured.
  • multi_view_image is part of the public API (VisionManager.generate_angles) but no built-in backend implements it yet.

Details: docs/reference/backends.md.

Installation

pip install abstractvision

The base install includes the local Diffusers backend because it is the default local execution path. stable-diffusion.cpp python bindings are optional; install abstractvision[sdcpp] only when you want the pip binding fallback instead of an external sd-cli executable.

Optional extras:

Extra Use
abstractvision[sdcpp] Install stable-diffusion-cpp-python for the pip binding fallback.
abstractvision[local] Compatibility convenience for both local backend dependency sets, including sdcpp.
abstractvision[huggingface] Compatibility extra for callers that still request the historical Diffusers extra.
abstractvision[huggingface-dev] Looser dependency pins for newer/unreleased Diffusers pipelines; install Diffusers main separately if needed.
abstractvision[abstractcore] Compatibility marker only; AbstractCore is still supplied by the host application.
abstractvision[test], abstractvision[docs], abstractvision[dev] Contributor/test/docs tooling.

Note (CUDA): on Windows/Linux, pip install abstractvision may install a CPU-only PyTorch build. If you want to use an NVIDIA GPU, install a CUDA-enabled PyTorch build first (see https://pytorch.org/get-started/locally/) and verify torch.cuda.is_available() is True.

AbstractCore is not installed by AbstractVision. When an AbstractCore application has AbstractVision installed in the same environment, AbstractCore can discover the plugin entry point and use the integration modules lazily.

If you hit “missing pipeline class” errors for newer model families, see docs/getting-started.md. In that case you may need Diffusers from source (main):

pip install -U "abstractvision[huggingface-dev]"
pip install -U "git+https://github.com/huggingface/diffusers@main"

For local dev (from a repo checkout):

pip install -e .

Usage

Start here:

Recommended default model (local / cross-platform)

The REPL defaults to a cache-only Diffusers setup using runwayml/stable-diffusion-v1-5 on auto device. Pre-download the model outside the REPL, then start generating:

huggingface-cli download runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_BACKEND=diffusers
export ABSTRACTVISION_MODEL_ID=runwayml/stable-diffusion-v1-5
export ABSTRACTVISION_DIFFUSERS_DEVICE=auto
abstractvision repl

For a fresh cache, you can also permit the REPL to download missing files:

ABSTRACTVISION_DIFFUSERS_ALLOW_DOWNLOAD=1 abstractvision repl

More recommendations by VRAM: docs/getting-started.md.

Capability-driven model selection

from abstractvision import VisionModelCapabilitiesRegistry

reg = VisionModelCapabilitiesRegistry()
assert reg.supports("runwayml/stable-diffusion-v1-5", "text_to_image")

print(reg.list_tasks())
print(reg.models_for_task("text_to_image"))

Backend wiring + generation (artifact outputs)

The default install includes Torch + Diffusers for the default local backend, but heavy modules are imported lazily (see src/abstractvision/backends/__init__.py). Install abstractvision[sdcpp] only if you want the optional stable-diffusion.cpp python binding fallback.

from abstractvision import LocalAssetStore, VisionManager, VisionModelCapabilitiesRegistry, is_artifact_ref
from abstractvision.backends import OpenAICompatibleBackendConfig, OpenAICompatibleVisionBackend

reg = VisionModelCapabilitiesRegistry()

backend = OpenAICompatibleVisionBackend(
    config=OpenAICompatibleBackendConfig(
        base_url="http://localhost:1234/v1",
        api_key="YOUR_KEY",      # optional for local servers
        model_id="REMOTE_MODEL", # optional (server-dependent)
    )
)

vm = VisionManager(
    backend=backend,
    store=LocalAssetStore(),         # enables artifact-ref outputs
    model_id="zai-org/GLM-Image",    # optional: capability gating
    registry=reg,                   # optional: reuse loaded registry
)

out = vm.generate_image("a cinematic photo of a red fox in snow")
assert is_artifact_ref(out)
print(out)  # {"$artifact": "...", "content_type": "...", ...}

png_bytes = vm.store.load_bytes(out["$artifact"])  # type: ignore[union-attr]

When installed next to AbstractCore, AbstractVision is also discovered as a llm.vision capability plugin. The plugin defaults to the OpenAI-compatible HTTP backend for compatibility with existing AbstractCore deployments; set ABSTRACTVISION_BASE_URL for OpenAI or a local compatible /v1 server, and set ABSTRACTVISION_MODEL_ID when the server requires an explicit image model (for example gpt-image-1.5 for OpenAI). Set ABSTRACTVISION_BACKEND=diffusers or ABSTRACTVISION_BACKEND=sdcpp when you want AbstractCore to launch local AbstractVision generation directly.

Interactive testing (CLI / REPL)

abstractvision models
abstractvision tasks
abstractvision show-model runwayml/stable-diffusion-v1-5

abstractvision repl

Inside the REPL:

/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open

For a newer but still relatively small local model, try black-forest-labs/FLUX.2-klein-4B after installing Diffusers from source (see docs/getting-started.md):

/backend diffusers black-forest-labs/FLUX.2-klein-4B mps float16
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --open

OpenAI-compatible server example:

/backend openai http://localhost:1234/v1
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open

The CLI/REPL can also be configured via ABSTRACTVISION_* env vars; see docs/reference/configuration.md.

Local web playground

The playground is owned by AbstractVision and runs without AbstractCore:

abstractvision playground --port 8091

Open http://127.0.0.1:8091/vision_playground.html, select a cached model, then load it. The page and the API are served by the same process.

One-shot commands (OpenAI-compatible HTTP backend only):

abstractvision t2i --base-url http://localhost:1234/v1 "a studio photo of an espresso machine"
abstractvision i2i --base-url http://localhost:1234/v1 --image ./input.png "make it watercolor"

Local GGUF via stable-diffusion.cpp

If you want to run GGUF diffusion models locally, use the stable-diffusion.cpp backend (sdcpp). Start with a single-file Stable Diffusion model when possible; Qwen Image and FLUX GGUF component sets are heavier.

Recommended:

  • macOS (Apple Silicon / Metal): install sd-cli (stable-diffusion.cpp executable) from releases and use CLI mode for Metal acceleration.
  • Otherwise (pip-only convenience): pip install "abstractvision[sdcpp]" installs the stable-diffusion.cpp python bindings (stable-diffusion-cpp-python), but this may run CPU-only depending on the wheel build.

Alternative (external executable):

In the REPL:

/backend sdcpp /path/to/sd-v1-5.gguf /path/to/sd-cli
/t2i "a watercolor painting of a lighthouse" --width 512 --height 512 --steps 10 --open

FLUX.2-klein-4B GGUF component example:

/backend sdcpp /path/to/flux-2-klein-4b-Q8_0.gguf /path/to/flux2_ae.safetensors /path/to/Qwen3-4B-Q4_K_M.gguf /path/to/sd-cli
/t2i "a product photo of a matte black espresso machine" --steps 4 --guidance-scale 1.0 --sampling-method euler --diffusion-fa --offload-to-cpu --open

Extra flags are forwarded via request.extra. In CLI mode they are forwarded to sd-cli; in python bindings mode, keys are mapped to python binding kwargs when supported and unsupported keys are ignored.

AbstractCore tool integration (artifact refs)

If you’re using AbstractCore tool calling, AbstractVision can expose vision tasks as tools:

from abstractvision.integrations.abstractcore import make_vision_tools

tools = make_vision_tools(vision_manager=vm, model_id="zai-org/GLM-Image")

Install abstractcore in the host application environment when you use these helpers; it is not pulled in by AbstractVision.

AbstractFramework ecosystem

AbstractVision is part of the AbstractFramework ecosystem and is designed to compose with:

In practice:

  • AbstractVision standardizes generative vision outputs (image/video) behind VisionManager.
  • AbstractCore can discover and use AbstractVision via the capability plugin (src/abstractvision/integrations/abstractcore_plugin.py) or you can expose vision tasks as tools (src/abstractvision/integrations/abstractcore.py).
  • Artifact refs returned by AbstractVision are designed to travel across processes; RuntimeArtifactStoreAdapter bridges to an AbstractRuntime-style artifact store (src/abstractvision/artifacts.py).

Project

Requirements

  • Python >= 3.9

License

MIT License - see LICENSE file for details.

Author

Laurent-Philippe Albou

Contact

contact@abstractcore.ai

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

abstractvision-0.2.6.tar.gz (173.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

abstractvision-0.2.6-py3-none-any.whl (71.3 kB view details)

Uploaded Python 3

File details

Details for the file abstractvision-0.2.6.tar.gz.

File metadata

  • Download URL: abstractvision-0.2.6.tar.gz
  • Upload date:
  • Size: 173.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for abstractvision-0.2.6.tar.gz
Algorithm Hash digest
SHA256 7a85a8e3bdfce7b5a4c50629ce4b2f7b881185822a2f6a504df74f7312c85976
MD5 20d731b8bcca7285daca44f6748c96a8
BLAKE2b-256 2b45c3ab71d962fde6ecdbf69b808a2248fb1670d26fc82ff6a4495671cf24e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for abstractvision-0.2.6.tar.gz:

Publisher: release.yml on lpalbou/AbstractVision

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file abstractvision-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: abstractvision-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 71.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for abstractvision-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 5f6ac5d759c2f93a47c4d5782617951b14843b3d738b6b89abe73b06650cb48f
MD5 5407163e7ce61c4f12095ed8007097ef
BLAKE2b-256 191f9041560ff29c49326f9cc53201085029922532b0c541e528e14fe521648f

See more details on using hashes here.

Provenance

The following attestation bundles were made for abstractvision-0.2.6-py3-none-any.whl:

Publisher: release.yml on lpalbou/AbstractVision

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page