DeSinc / SallyBot

AI Chatbot coded in Discord.net C#
MIT License
299 stars 51 forks source link

Option to force a specific Stable Diffusion model #23

Closed Jakoski360 closed 1 year ago

Jakoski360 commented 1 year ago

By default the image generation is handled by the currently selected Stable Diffusion checkpoint in the Web UI, which can cause undesired image generation if the wrong model is selected in the Web UI when SallyBot receives a request.

By specifying the checkpoint name such from the Stable Diffusion web UI this can be overridden in the API request by specifying "sd_model_checkpoint", and the checkpoint name.

image

e.g: { "sd_model_checkpoint", "anything-v3-fp16-pruned.safetensors [d1facd9a2b]" }

This is probably only an issue if multiple image models are used and you're generating images with a different model than SallyBot should use.

Jakoski360 commented 1 year ago

I've left it commented out as it's probably something that doesn't need configuring by default and maybe is best to have as an option.

DeSinc commented 1 year ago

hey did you test this by the way? I'm just testing it now and I have tried every different tag I've found online and none work for this, even placing in normal json + overrides etc. providing model hash, with square brackets as it's laid out in http://localhost:7860/sdapi/v1/sd-models and without as well, and none work. @Jakoski360

Jakoski360 commented 1 year ago

I've had it running on my setup for a while and the override is keeping on the checkpoint marked in the code. For example I've got the MagicalMix checkpoint selected in the web UI: image

In the code it's set up same as the pull request with the Anything v3 checkpoint as override and when making a request via Discord to SallyBot, Stable Diffusion switches to the checkpoint specified in the override and then switches back: image

I used Inspect Element to grab the exact name of the checkpoint from the UI: image

Are you seeing anything in the Stable Diffusion console with the override set to a checkpoint that is different from the one selected in the Web UI? When I was testing it gave a bunch of errors if the checkpoint name wasn't exactly right.

Jakoski360 commented 1 year ago

Ah sorry I've just realised what I've got different in my setup. I've commented out the filter_nsfw line as that key is invalid for override_settings.

With that commented out, and adding "override settings" to the payload, it works: image

image

Checking "override_settings" in the API shows that filter_nsfw isn't in the list of valid options which makes it ignore all overrides:

http://localhost:7860/docs#/default/get_config_sdapi_v1_options_get

Oddly enough the documentation for stable-diffusion-webui actually mentions filter_nsfw but I can't get it to work at all.