Skip to main content

lexigram-multimedia-upscale

Image and video super-resolution for the Lexigram Framework — local reference-server backends (real-esrgan, hat).


Overview

lexigram-multimedia-upscale upscales images 2x or 4x with Real-ESRGAN or HAT reference servers, and registers a VideoUpscaleService for frame-level video upscaling when a VideoProcessor is available in the container.

Full documentation: docs.lexigram.dev

Install

uv add lexigram-multimedia-upscale
# Optional extras
uv add "lexigram-multimedia-upscale[real-esrgan-server]"  # Real-ESRGAN server deps
uv add "lexigram-multimedia-upscale[hat-server]"          # HAT server deps

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module
from lexigram.multimedia.upscale import UpscaleModule
from lexigram.contracts.multimedia import UpscaleProvider, UpscaleRequest, MediaAsset


@module(imports=[UpscaleModule.configure()])
class AppModule(Module):
    pass


async def main() -> None:
    async with Application.boot(modules=[AppModule]) as app:
        upscale = await app.container.resolve(UpscaleProvider)
        asset = MediaAsset(mime_type="image/png", provider="local", bytes_data=b"<png>")
        result = await upscale.upscale(UpscaleRequest(asset=asset, scale_factor=4))
        if result.is_ok():
            upscaled = result.unwrap()  # MediaAsset — upscaled image bytes or URI


if __name__ == "__main__":
    import asyncio

    asyncio.run(main())

Configuration

Zero-config usage: Call UpscaleModule.configure() with no arguments to use the real-esrgan backend at http://localhost:5400.

Option 1 — YAML file

# application.yaml
multimedia:
  upscale:
    backend: "hat"

Option 2 — Profiles + Environment Variables

export LEX_PROFILE=production
export LEX_MULTIMEDIA__UPSCALE__BACKEND=real-esrgan

Option 3 — Python

from lexigram.multimedia.upscale import UpscaleModule
from lexigram.multimedia.upscale.config import UpscaleConfig

UpscaleModule.configure(config=UpscaleConfig(backend="hat"))

The upscale factor is a per-request parameter — UpscaleRequest(asset=..., scale_factor=Literal[2, 4]), default 4. It is not part of UpscaleConfig.

Config reference

Field Default Env var Description
backend "real-esrgan" LEX_MULTIMEDIA__UPSCALE__BACKEND real-esrgan, hat
real_esrgan_base_url "http://localhost:5400" LEX_MULTIMEDIA__UPSCALE__REAL_ESRGAN_BASE_URL Real-ESRGAN server URL
hat_base_url "http://localhost:5401" LEX_MULTIMEDIA__UPSCALE__HAT_BASE_URL HAT server URL
timeout 30.0 LEX_MULTIMEDIA__UPSCALE__TIMEOUT Request timeout in seconds

Module Factory Methods

Method Description
UpscaleModule.configure(config) Configure with explicit upscale config
UpscaleModule.stub() Real module pinned to the default real-esrgan backend for tests

Key Features

  • Two backendsreal-esrgan, hat reference servers
  • Video upscalingVideoUpscaleService for frame-level video super-resolution (when VideoProcessor is available)
  • Reference serverslexigram-upscale-real-esrgan-serve and lexigram-upscale-hat-serve console scripts run each local model server
  • Result-basedupscale() -> Result[MediaAsset, MultimediaError]; errors are domain values, not exceptions

Testing

from lexigram import Application
from lexigram.multimedia.upscale import UpscaleModule


async def test_boot():
    async with Application.boot(modules=[UpscaleModule.stub()]) as app:
        assert app.container is not None

Key Source Files

File What it contains
src/lexigram/multimedia/upscale/module.py UpscaleModule.configure() and .stub()
src/lexigram/multimedia/upscale/config.py UpscaleConfig
src/lexigram/multimedia/upscale/di/provider.py UpscaleGenerationProvider — registers UpscaleProvider, wires task handlers
src/lexigram/multimedia/upscale/providers/ Backend implementations (real_esrgan, hat)
src/lexigram/multimedia/upscale/servers/ Reference-server entry points (lexigram-upscale-*-serve)
src/lexigram/multimedia/upscale/video_upscale_service.py VideoUpscaleService — frame-level video upscaling
src/lexigram/multimedia/upscale/tasks.py Background upscale task handlers
src/lexigram/multimedia/upscale/exceptions.py UpscaleError hierarchy

Download files

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

Source Distribution

lexigram_multimedia_upscale-0.1.5004.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

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

lexigram_multimedia_upscale-0.1.5004-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_multimedia_upscale-0.1.5004.tar.gz.

File metadata

File hashes

Hashes for lexigram_multimedia_upscale-0.1.5004.tar.gz
Algorithm Hash digest
SHA256 3748f24fb8de59224126bdac158aa91bfcee013ae116990a9fd722be45f2fcf6
MD5 543f5a4dc0c254278e20a3126f72997a
BLAKE2b-256 76fc20feb1bec86d6703ad324e79f15095b6ddb6d678394f509474405ca3c3e3

See more details on using hashes here.

File details

Details for the file lexigram_multimedia_upscale-0.1.5004-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_multimedia_upscale-0.1.5004-py3-none-any.whl
Algorithm Hash digest
SHA256 fd24f328a73cec63bdb48a3a1fdc2be603e90d1b1be0bb6e022efe2cfeca8859
MD5 581f207c3197c25a0927caaa06c1a0ca
BLAKE2b-256 51754a2f6116c0cf184401b6df3e4e2e029092a72ee512c2a47e9d9034370cfc

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5008

1 file

This release

0.1.5004 This release

2 files

0.1.5001

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

1 file

0.1.4

2 files

0.1.0

1 file

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