New Tool Radar

Local AI

How to Upscale an Image with LocalAI and ESRGAN

Install the RealESRGAN anime upscaler in LocalAI, send an existing image to the /v1/images/upscale endpoint, and open the bigger image from data[0].url.

Schematic diagram with three steps: install the realesrgan-x4plus-anime-6b model, send an image to the /v1/images/upscale endpoint with scale 4, then open the bigger image from data[0].url, 1024 pixels wide from a 256-pixel input.

The stablediffusion-ggml backend in LocalAI supports standalone ESRGAN upscaling through POST /v1/images/upscale. This is a separate, upscale-only model, not a diffusion pipeline, and image generation does not automatically upscale its results. This guide starts from an image file you already have and makes it bigger and sharper — it does not write a prompt and it does not generate a new image.

Install the ESRGAN upscaler model

Install the gallery model:

local-ai models install realesrgan-x4plus-anime-6b

This uses the official RealESRGAN_x4plus_anime_6B.pth release, a six-block model for anime images with a native 4x scale. The PyTorch .pth checkpoint is supported directly by stable-diffusion.cpp; no GGUF conversion is needed. The upstream project is licensed under BSD-3-Clause.

For manual installation, download that checkpoint into your models directory and save the following as realesrgan-x4plus-anime-6b.yaml alongside it (the gallery installer configures these settings for you):

name: realesrgan-x4plus-anime-6b
backend: stablediffusion-ggml
parameters:
  model: RealESRGAN_x4plus_anime_6B.pth
known_usecases: [upscale]
options:
  - upscale_scale:4
  - upscale_tile_size:128

upscale_scale and upscale_tile_size are backend options, expressed as key:value strings in options, not root-level configuration fields. upscale_scale must be a positive integer. Keep known_usecases explicitly set to [upscale]: do not add image or diffusion_model options to this configuration.

Send your image to the upscale endpoint

The multipart fields model, image, and scale are required. The HTTP endpoint accepts only integer scales from 1 through 16, rejecting missing, malformed, zero, negative, or larger values with HTTP 400. This range is not a promise that each model supports every scale: for ESRGAN, the configured upscale_scale, the loaded model’s detected native scale, and the request’s scale must all match exactly. Mismatches fail rather than silently resizing or running multiple passes. For this model, always request scale=4:

curl http://localhost:8080/v1/images/upscale \
  -F model=realesrgan-x4plus-anime-6b \
  -F scale=4 \
  -F [email protected]

Open the upscaled image

The response follows the image-generation response format, with the output URL in data[0].url under /generated-images. A successful 4x upscale multiplies both width and height by four, so a 256-pixel-wide input comes back 1024 pixels wide.

You can also do this in Studio: open an existing image, choose Upscale, select an installed upscaler, and submit. The scale is read-only and comes from the selected model’s configured scale. A successful result becomes an Upscale child node of the source image, leaving the original intact. Unlike the Diffusers upscaling described on the same docs page, this path uses ESRGAN inference and does not fall back to Lanczos resizing.

Try it: four checks from install to bigger image

Check What you should see If you do not see it
Model installed realesrgan-x4plus-anime-6b installed with backend stablediffusion-ggml and known_usecases: [upscale] Check the install finished and the YAML name, backend, and known_usecases match the docs
Request sent A reply from /v1/images/upscale with no error A 400 means the scale is missing or not an integer from 1 to 16 — check the scale field is 4
Scale matches scale=4 matching the model’s native 4x scale Mismatched scales fail rather than resizing — check upscale_scale is 4 and the request scale is 4
Bigger image data[0].url under /generated-images opens an image 4x the input; a 256 px wide input comes back 1024 px wide Check the URL is under /generated-images and the model named in the request is the upscaler, not an image-generation model

Expected result. We checked the LocalAI image generation docs page, which gives the stablediffusion-ggml backend supporting standalone ESRGAN upscaling through POST /v1/images/upscale as a separate upscale-only model, image generation not automatically upscaling its results, the gallery install command local-ai models install realesrgan-x4plus-anime-6b, the official RealESRGAN_x4plus_anime_6B.pth release as a six-block model for anime images with a native 4x scale, the PyTorch .pth checkpoint supported directly with no GGUF conversion and the BSD-3-Clause licence, the manual YAML with backend stablediffusion-ggml, model RealESRGAN_x4plus_anime_6B.pth, known_usecases [upscale], upscale_scale:4, and upscale_tile_size:128, the required multipart fields model, image, and scale with integer scales from 1 through 16 and HTTP 400 otherwise, the exact-match rule for the configured scale, the detected native scale, and the request scale with scale=4 for this model, the curl command with model realesrgan-x4plus-anime-6b, scale 4, and image @input.png, the response format with the output URL in data[0].url under /generated-images, a successful 4x upscale multiplying both width and height by four, and the Studio Upscale flow with the result as an Upscale child node leaving the original intact and no Lanczos fallback. We did not install LocalAI, download any model, or upscale any image on this machine.

Limits

This guide covers the ESRGAN anime upscaler only. The scale you request must match the model’s native scale exactly — a mismatch fails, it does not resize to a compromise. upscale_tile_size controls ESRGAN tiling in pixels: omit it or set it to 0 for stable-diffusion.cpp full-frame processing; set a positive value (such as the gallery entry’s 128) to enable tiling, where smaller tiles reduce working memory at the cost of more tile work. The Diffusers backend has its own separate x4 upscaler gallery model (stable-diffusion-x4-upscaler), which is a different setup from this ESRGAN one. An upscale works from the pixels in the file you send, so a tiny or heavily compressed original still limits what comes out. We did not run any of this ourselves.

Sources

See all