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/README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'desktop/modules/appearance/README.md') diff --git a/desktop/modules/appearance/README.md b/desktop/modules/appearance/README.md index f933ac0..59868b4 100644 --- a/desktop/modules/appearance/README.md +++ b/desktop/modules/appearance/README.md @@ -111,6 +111,36 @@ and closes the settings window, as a successful Apply does, so the desk shows. It goes through `gtk-launch` and the app's desktop entry, so `~/bin` need not be on quickshell's PATH. +When the image staged for the target screen is too small for it (the yellow +or red border), "Upscale 4×" appears beside it. It runs Real-ESRGAN through +stable-diffusion.cpp's `sd-cli -M upscale` and replaces the file in place, +keeping its name, so wallp's state and the engine's lists still find it; +Apply then sets the larger copy. Only files under `~/Pictures/wallpapers` are +offered. + +Which Real-ESRGAN model is decided per image by Imajev-4B, a small Jev-style +vision decision model, run once 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, which is the +decision; about 1.7 s. Anime goes to the anime model, which keeps line art +clean; anything else, and any failure of the decider, to the general one. +Measured on 22 wallpapers, it got all 12 anime and all 4 photos right and +called 4 of 6 painted 3D renders anime, which then come out smoother than +painted. The 2B got 17 of 22, and a three-way prompt adding "painted or +render" dropped both to 15 or fewer, with most anime called painted. + +The button takes two clicks so the choice shows before anything is +rewritten: "Upscale 4×: pick model" runs the decider and becomes +"Upscale 4× (anime)" or "(photo)", and that click upscales. The decision is +kept for the image it was made for, so staging another and coming back +still shows it. + +The models are read from `/data/LLM-models/SD/upscalers/` and +`/data/LLM-models/SD/imajev/` (`Wallpapers.upscalers`, `Wallpapers.decider`). +Deciding takes about 2 seconds, upscaling a 1280x720 image about 7. sd-cli exits 0 even when the +model fails to load, saving the input unscaled, so an `[E]` line in its log +counts as a failure too, and a failure leaves the original untouched. + `wallp` does the actual work, including running `udt-accent`, so the accent follows the new wallpaper exactly as it does from a terminal. This page replaces its qarma file dialog, not the script. -- cgit v1.2.3