Skip to content

Add embedded WebUI#1207

Merged
leejet merged 10 commits intomasterfrom
embed_ui
Mar 15, 2026
Merged

Add embedded WebUI#1207
leejet merged 10 commits intomasterfrom
embed_ui

Conversation

@leejet
Copy link
Owner

@leejet leejet commented Jan 18, 2026

Generate index.html and gen_index_html.h

cd examples/server/frontend
pnpm install
pnpm build
pnpm build:header

Build sd.cpp

cd build
cmake .. -DSD_CUDA=ON
cmake --build . --config Release -j

Example

.\bin\Release\sd-server.exe -m ..\..\stable-diffusion-webui\models\Stable-diffusion\v1-5-pruned-emaonly.safetensors -v
image

@kalebbroo
Copy link

https://github.com/HartsyAI/SwarmUI-SD.cpp-Backend

I made an extension for SwarmUI that lets you use SDcpp. Its not built in like you are making but it can use almost all the features Swarm has been building on.

@Danmoreng
Copy link

Oh just saw this. I actually thought about implementing a webui for this project and already did so, but only posted it on Reddit. In the end I created a separate project because I also wanted to add more features like chat with llama.cpp support. But maybe if you want something a bit nicer I could simplify and backport it?

https://old.reddit.com/r/StableDiffusion/comments/1prn3h9/what_does_a_good_webui_need/

https://github.com/Danmoreng/stable-diffusion.cpp/tree/archive/pre-sync-work

@opsec-ai
Copy link

opsec-ai commented Feb 3, 2026

Nice look. Works well.

  • I missed the part where I had to generate examples/server/frontend/dist/gen_index_html.h
    • Could have used some docs on git submodule update --init && git pull --recurse-submodules
    • Finally pnpm install && pnpm build && pnpm build:header works.
  • Dark mode based on browser preference works.

@engrtipusultan
Copy link

When will it be merged in the master ?

@Green-Sky
Copy link
Contributor

I think it would be better if the index.html (and gen_index_html.h?) where generated in the frontend repo, and exported as release assets and then fetched (optionally) from there.

@Green-Sky
Copy link
Contributor

I think it would be better if the index.html (and gen_index_html.h?) where generated in the frontend repo, and exported as release assets and then fetched (optionally) from there.

A submodule is a bit of a heavy hammer when you are really just interested in the ready index.html. Cmake is good at (optionally or not) fetching remote resources.

@Nauscar
Copy link
Contributor

Nauscar commented Mar 4, 2026

Thank you for adding this UI!

If anyone else finds this PR and wants to try this out, I had to run the following command and apply this patch (in addition to the instructions above). Hopefully this saves somebody some time.

node scripts/build_gen_index_html.js
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e731d95..90b61c9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,7 +40,7 @@ option(SD_FAST_SOFTMAX               "sd: x1.5 faster softmax, inde
terministic (
 option(SD_BUILD_SHARED_LIBS          "sd: build shared libs" OFF)
 option(SD_BUILD_SHARED_GGML_LIB      "sd: build ggml as a separate shared lib" OFF)
 option(SD_USE_SYSTEM_GGML            "sd: use system-installed GGML library" OFF)
-#option(SD_BUILD_SERVER               "sd: build server example"                    
       ON)
+option(SD_BUILD_SERVER               "sd: build server example"                     
      ON)
 
 if(SD_CUDA)
     message("-- Use CUDA as backend stable-diffusion")

@leejet
Copy link
Owner Author

leejet commented Mar 15, 2026

I think it would be better if the index.html (and gen_index_html.h?) where generated in the frontend repo, and exported as release assets and then fetched (optionally) from there.

The externally generated gen_index_html.h is difficult to review in terms of its actual source code. Therefore it is currently included as a submodule. Developers who need it can build it themselves.

@leejet leejet merged commit 862a658 into master Mar 15, 2026
15 checks passed
@Green-Sky
Copy link
Contributor

Green-Sky commented Mar 17, 2026

Put up sd.cpp with the new webui in a free huggingspace sapce.

https://huggingface.co/spaces/Green-Sky/sd.cpp

It is kind of annoying that you have to manually set steps and guidance to 1 for this model.

Oh and an image gen takes almost 20sec.

edit: would be cool if we could get one sponsored with a gpu.

image

@wbruna
Copy link
Contributor

wbruna commented Mar 17, 2026

It is kind of annoying that you have to manually set steps and guidance to 1 for this model.

Yeah, we'd need a way to select the server defaults for steps/guidance/sizes. Fetching the defaults from the server would be tricky, since we can't differentiate between "user explicitly selected 6" from "it's on the default value 6".

One option could be doing like the clip_skip field: set the sliders to 0 or -1 by default, and omit the fields in those cases. Another approach could be adding a foldable section (like the 'generation options') for each control or control group, and only send those values when the controls are visible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants