Quickstart
Get image and video super-resolution running in minutes.
Install
Section titled “Install”uv add lexigram-multimedia-upscale# Optional: local reference-server dependenciesuv add "lexigram-multimedia-upscale[real-esrgan-server]" # Real-ESRGAN server (torch + realesrgan)uv add "lexigram-multimedia-upscale[hat-server]" # HAT server (torch + timm)lexigram-multimedia-upscale depends on lexigram, lexigram-contracts, and aiohttp (installed automatically).
The package works zero-config: the default backend is real-esrgan talking to http://localhost:5400.
Minimal Upscale
Section titled “Minimal Upscale”import asyncio
from lexigram import Applicationfrom lexigram.di.module import Module, modulefrom lexigram.multimedia.upscale import UpscaleModulefrom lexigram.contracts.multimedia import MediaAsset, UpscaleProvider, UpscaleRequest
@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"<your png bytes>", ) result = await upscale.upscale(UpscaleRequest(asset=asset, scale_factor=4)) if result.is_ok(): upscaled = result.unwrap() # MediaAsset — upscaled image bytes print("upscaled:", upscaled.mime_type, len(upscaled.bytes_data or b""))
if __name__ == "__main__": asyncio.run(main())With an application.yaml:
multimedia: upscale: backend: "real-esrgan" real_esrgan_base_url: "http://localhost:5400"Calling UpscaleModule.configure() with no arguments also works — UpscaleConfig defaults apply.
What Just Happened
Section titled “What Just Happened”UpscaleModule.configure()creates aDynamicModulewith anUpscaleGenerationProvider.Application.boot()runs the provider lifecycle:- register —
UpscaleConfigis bound in the container; the configured backend (RealEsrganUpscaleProviderorHatUpscaleProvider) is constructed and bound asUpscaleProvider; anUpscaleTaskhandler is bound; if aVideoProcessoris already resolvable, aVideoUpscaleServiceis bound too. - boot — a no-op: all HTTP happens per-request.
- register —
upscale.upscale(UpscaleRequest(...))base64-encodes the input, POSTs it to<base_url>/upscale, and returnsOk(MediaAsset)— orErr(UpscaleError)for transport/HTTP failures.
The reference server must be running on port 5400:
lexigram-upscale-real-esrgan-serveNext Steps
Section titled “Next Steps”- Guide — mental model: assets, requests, backends, results
- How-Tos — task-oriented recipes
- Configuration — every config key and env-var override
- Architecture — internal design and extension points