From c5ce8451d0aa634fc7bcece4a4132f9508e54bf1 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Thu, 29 Oct 2026 18:26:15 +0100 Subject: wallpaper: upscale a too-small staged image in place A staged wallpaper smaller than its screen (yellow or red border) gets an "Upscale 4x" button. It rewrites the file with Real-ESRGAN through stable-diffusion.cpp's `sd-cli -M upscale`, keeping the name, so wallp's state and the engine's lists, which name it by path, still find it. sd-cli writes to a dot-named sibling the scan skips, and only a successful run is moved over the original. Success needs no [E] line as well as exit 0: with a model that fails to load, sd-cli logs "[E] new_upscaler_ctx failed", saves the input unscaled and exits 0 (measured). The button takes two clicks so the model choice shows before anything is rewritten. The first runs Imajev-4B, a small Jev-style vision decision model, through llama-mtmd-cli on a 512 px thumbnail, with a grammar that allows only A (anime) or B (photo or render); greedy decoding then returns the higher-logit option, about 1.7 s. The label becomes "Upscale 4x (anime)" or "(photo)", and the second click upscales with the anime or the general model. Anything but A, including a failed decider, picks the general model, safe on any image. Imajev-4B was chosen by measurement on 22 wallpapers: all 12 anime and 4 photos right, 4 of 6 painted 3D renders called anime (those come out smoother than painted). The 2B got 17 of 22, leaning to photo; a three-way prompt adding "painted or render" dropped both to 15 or fewer, with most anime called painted. Co-Authored-By: Claude Opus 5.5 --- desktop/modules/appearance/WallpaperTab.qml | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'desktop/modules/appearance/WallpaperTab.qml') diff --git a/desktop/modules/appearance/WallpaperTab.qml b/desktop/modules/appearance/WallpaperTab.qml index 640f1ef..134c90e 100644 --- a/desktop/modules/appearance/WallpaperTab.qml +++ b/desktop/modules/appearance/WallpaperTab.qml @@ -142,12 +142,42 @@ Column { color: Wallpapers.qualityColor(subject, Wallpapers.target) } + Text { + width: parent.width + visible: Wallpapers.upscaleError !== "" + wrapMode: Text.Wrap + text: Wallpapers.upscaleError + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 } + color: Theme.red + } + // A Flow, not a Row: a Row overflows its width and clipped the // last button in a narrow window (AGENTS.md). Flow { + id: actions + readonly property string staged: Wallpapers.target === "V" ? Wallpapers.pendingV : Wallpapers.pendingH + readonly property bool small: Wallpapers.canUpscale(staged, Wallpapers.target) width: parent.width spacing: 8 + // Rewrite the staged image 4x larger before applying it, when + // it is too small for its screen. Two clicks: the first asks + // the decider which model suits it and shows the answer, the + // second upscales with that model (Wallpapers.decide and + // upscaleFile). + Tab { + readonly property bool decided: Wallpapers.decidedFor === actions.staged + readonly property bool busy: Wallpapers.deciding !== "" || Wallpapers.upscaling !== "" + visible: actions.small || busy + enabled: !busy + text: Wallpapers.deciding !== "" ? "deciding…" + : Wallpapers.upscaling !== "" ? "upscaling…" + : decided ? `Upscale 4× (${Wallpapers.decidedKind})` + : "Upscale 4×: pick model" + selected: decided && !busy + onClicked: decided ? Wallpapers.upscaleFile(actions.staged) : Wallpapers.decide(actions.staged) + } + // Apply and Reset are in the page header, with every settings // page's. // wallhaven-dl searches wallhaven.cc and finds larger -- cgit v1.2.3