ellypaws / stable-diffusion-discord-bot

A Discord bot, written in Go, that interfaces with the Automatic 1111's API interface.
MIT License
9 stars 0 forks source link

How to change default settings? #11

Closed LeonWGal closed 1 month ago

LeonWGal commented 1 month ago

image I changed the bot settings to 1 image, but the bot still generates only 4 images. Is it possible to manually change these parameters (also change the resolution to more than 768, change the sampler to a different default and checkpoint

ellypaws commented 1 month ago

The batch size/batch count gets automatically computed to generate 4 images, but this can be removed by changing the code in https://github.com/ellypaws/stable-diffusion-discord-bot/blob/e27c71d4967392d2980cfd3c4d2da674dd224df7/queue/stable_diffusion/components.go#L185-L241

diff --git a/queue/stable_diffusion/components.go b/queue/stable_diffusion/components.go
index a22f5c8..3a4640a 100644
--- a/queue/stable_diffusion/components.go
+++ b/queue/stable_diffusion/components.go
@@ -194,21 +194,7 @@ func (q *SDQueue) components() map[string]queue.Handler {
                return handlers.ErrorEphemeral(s, i.Interaction, "error parsing batch count", err)
            }

-           var batchSizeInt int
-
-           // calculate the corresponding batch size
-           switch batchCountInt {
-           case 1:
-               batchSizeInt = 4
-           case 2:
-               batchSizeInt = 2
-           case 4:
-               batchSizeInt = 1
-           default:
-               return fmt.Errorf("unknown batch count: %v", batchCountInt)
-           }
-
-           return q.processImagineBatchSetting(s, i, batchCountInt, batchSizeInt)
+           return q.processImagineBatchSetting(s, i, batchCountInt, q.botDefaultSettings.BatchSize)
        },

        BatchSizeSelect: func(s *discordgo.Session, i *discordgo.InteractionCreate) error {
@@ -223,21 +209,7 @@ func (q *SDQueue) components() map[string]queue.Handler {
                return handlers.ErrorEphemeral(s, i.Interaction, "error parsing batch size", err)
            }

-           var batchCountInt int
-
-           // calculate the corresponding batch count
-           switch batchSizeInt {
-           case 1:
-               batchCountInt = 4
-           case 2:
-               batchCountInt = 2
-           case 4:
-               batchCountInt = 1
-           default:
-               return handlers.ErrorEphemeral(s, i.Interaction, fmt.Errorf("unknown batch size: %v", batchSizeInt))
-           }
-
-           return q.processImagineBatchSetting(s, i, batchCountInt, batchSizeInt)
+           return q.processImagineBatchSetting(s, i, q.botDefaultSettings.BatchCount, batchSizeInt)
        },

        RerollButton:  q.processImagineReroll,