Files
LocalAI/core/config/upscale_options.go
T
mudler-agentandEttore Di Giacinto 0177e4988c feat(images): add ESRGAN upscaling and Studio workflow (#12620)
* feat(images): add upscale model capabilities

* fix(config): keep SD GGML upscale opt-in

* feat(stablediffusion): add lazy ESRGAN upscale bridge

Keep native image ownership in C++ and serialize context creation, inference and teardown. Use upscale_scale in backend options as the explicit upscale-only marker because ModelOptions does not carry usecases.

Assisted-by: Codex:gpt-5

* fix(stablediffusion): validate ESRGAN settings

* fix(upscale): forward typed settings and contain resolved model paths

Typed settings replace legacy options without duplicates. Resolve model and trusted root symlinks before caching the model path, rejecting missing files and escapes.

Assisted-by: Codex:gpt-5

* fix(upscale): validate scale and clean failed HTTP outputs

Require an explicit scale bounded to 1-16, check backend results, and keep destination cleanup owned by the allocating endpoint. Cover validation, result failures, cleanup, and successful URL responses.

Assisted-by: Codex:gpt-5

* feat(studio): add inline image upscale workflow

Assisted-by: OpenAI:gpt-5

* test(studio): serve upscale capability fixtures

* fix(stablediffusion): default ESRGAN tiling to full frame

* feat(gallery): add RealESRGAN anime upscaler

* fix(stablediffusion): allow full-frame ESRGAN tiles

* fix(routes): select explicit upscale models

Give image upscaling dedicated usecase-filtered middleware and keep ordinary image models out of the endpoint. Mark and verify the legacy Diffusers x4 gallery model as an explicit upscaler.

Assisted-by: OpenAI:gpt-5 [shell]

* refactor(upscale): keep settings in backend options

* test(config): keep upscale options backend-specific

* fix: keep upscale routing metadata out of backend options

---------

Co-authored-by: Ettore Di Giacinto <mudler@localai.io>
2026-10-11 00:30:09 +02:00

32 lines
700 B
Go

// SPDX-License-Identifier: MIT
package config
import (
"strconv"
"strings"
)
// UpscaleScaleFromOptions reports the declared native scale for client metadata.
// Match the backend's int32 range and reject duplicates rather than advertising
// a value that the backend will reject. This does not replace backend validation.
func UpscaleScaleFromOptions(c ModelConfig) int {
var scale int
seen := false
for _, option := range c.Options {
key, value, _ := strings.Cut(option, ":")
if key != "upscale_scale" {
continue
}
if seen {
return 0
}
seen = true
n, err := strconv.ParseInt(value, 10, 32)
if err != nil || n <= 0 {
return 0
}
scale = int(n)
}
return scale
}