[Stable Diffusion] Enable image upscaling for external calls - #2842
[Stable Diffusion] Enable image upscaling for external calls#2842NineBallo wants to merge 6 commits into
Conversation
…enable-upscaling-external
|
This one has a few possibly polarizing decisions, opening for review but just lmk where you want to go with it. I think it makes a lot of sense but idk. |
|
[AI-assisted review] Automated pre-review from repo-manager — flags for the human reviewer, not a replacement for one. Attention level: Elevated — any reviewer can take it, but the to-dos below need resolving before approval (2 documentation gap(s)) Documentation gaps
Scopeminor — The PR extends the existing sd-cpp recipe with a new optional Suggested reviewers
Reviewed at head |
|
@NineBallo please see TODOs in the comment above @ramkrishna2910 I think you should review |
|
Also @NineBallo please be aware that we have a feature freeze on gui2, and the gui changes will need to go into GUI3. If you can remove the gui features from this PR and rebase them into gui3 in a future PR that would be great. |
|
@jeremyfowers Oops totally forgot about the docs! Some of these pr's won't be directly usable in that case but I'll strip ui changes out and open up seperate prs. GUI PR questions:
|
Wait for gui3 to merge to main first
@kpoineal - heads up there's 3 PRs adding some minor UI elements to the image gen UI. |
|
Thanks for picking this up @NineBallo — the gap in #2836 is real, and I agree the Some context that's relevant here: an earlier iteration of the upscaling work did have exactly this design — an Concerns I'd like to talk through before this lands:
I want us to make that tradeoff on purpose, and to not lose the progress reporting and side-by-side comparison in the process. |
|
The goal of this is to be optional, opt-in, and per-model, only for external calls. So you can still have the same flow in the webui chat if you'd like; you could still generate an image and call /images/upscale if you'd like; but you can also now use upscaling for chat apps that don't call /images/upscale (most of em). Given that this project is targeting self-hosters I think this makes a lot of sense, there is no case where the latency is unexplained because they set it up. People with true multi-step image workflows will be using comfyui or something anyway, this directly targets the main usecase for this endpoint. Giving users the choice to get higher quality images in generic chat apps without the exponential cost of generating the base at a higher resolution (especially with consumer hardware).
Next Steps:
|
This adds the ability to set upscaling models, per sd-model. For when you hit the /generate /edit endpoints and want it to go through the upscaler as well.
ESRGAN image upscaling for sd-cpp models
Per-model upscaler configuration in
ModelOptionsModalwith automatic GPU pass-through to sd-cpp models.What
ModelOptionsModalfor sd-cpp recipes ("None" + dynamically discovered upscalers filtered byupscalinglabel)upscale_modelrecipe option — persists per-model, not per-session--backend <device>flag, avoiding CPU fallbackHow
/models?show_all=true, filters byupscalinglabel, renders dropdown above merge-args checkboxapply_upscale_if_configured()intercepts image responses inhandle_image_generations,handle_image_edits, andhandle_image_variations, resolves/downloads the upscaler model,and runs
sd-cli -M upscaledo_upscale()helper +sd_backend_for_recipe()mappingFiles changed
src/cpp/include/lemon/backends/sdcpp/sdcpp.hupscale_modelbackend descriptorsrc/cpp/include/lemon/backends/sdcpp/sdcpp_server.hbackendparam toupscale_via_cli()src/cpp/include/lemon/server.happly_upscale_if_configured(),do_upscale(),sd_backend_for_recipe()src/cpp/server/server.cppsrc/app/src/renderer/ModelOptionsModal.tsxsrc/app/src/renderer/recipes/recipeOptionsConfig.tsupscaleModeloption definitionsrc/cpp/server/backends/sdcpp/sdcpp_server.cppupscale_via_cli()