This is a Discord bot that interfaces with the Automatic1111 API, from this project: https://github.com/AUTOMATIC1111/stable-diffusion-webui
Video showing off the current features: https://www.youtube.com/watch?v=of5MBh3ueMk
go build
--api
(and also --listen
if it is running on a different computer than the bot)../stable_diffusion_bot -token <token> -guild <guild ID> -host <webui host, e.g. http://127.0.0.1:7860>
-host
parameter matches the IP address where the A1111 is running. If the bot is on the same computer, 127.0.0.1
will work.7860
in this example). So, instead of http://127.0.0.1:7860/
, it should be http://127.0.0.1:7860
.The -imagine <new command name>
flag can be used to have the bot use a different command when running, so that it doesn't collide with a Midjourney bot running on the same Discord server.
/imagine_settings
Responds with a message that has buttons to allow updating of the default settings for the /imagine
command.
By default, the size is 512x512. However, if you are running the Stable Diffusion 2.0 768 model, you might want to change this to 768x768.
Choosing an option will cause the bot to update the setting, and edit the message in place, allowing further edits.
/imagine
Creates an image from a text prompt. (e.g. /imagine cute kitten riding a skateboard
)
Available options:
--ar <width>:<height>
(e.g. /imagine cute kitten riding a skateboard --ar 16:9
)8
, to match the expectations of the underlying neural model and SD API.The bot implements a FIFO queue (first in, first out). When a user issues the /imagine
command (or uses an interaction button), they are added to the end of the queue.
The bot then checks the queue every second. If the queue is not empty, and there is nothing currently being processed, it will send the top interaction to the Automatic1111 WebUI API, and then remove it from the queue.
After the Automatic1111 has finished processing the interaction, the bot will then update the reply message with the finished result.
Buttons are added to the Discord response message for interactions like re-roll, variations, and up-scaling.
All image generations are saved into a local SQLite database, so that the parameters of the image can be retrieved later for variations or up-scaling.
Options like aspect ratio are extracted and sanitized from the text prompt, and then the resulting options are stored in the database record for the image generation (for further variations or upscaling):
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
There are lots more features that could be added to this bot, such as:
/imagine
command (like aspect ratio)I'll probably be adding a few of these over time, but any contributions are also welcome.
I like Go a lot better than Python, and for me it's a lot easier to maintain dependencies with Go modules versus running a bunch of different Anaconda environments.
It's also able to be cross-compiled to a wide range of platforms, which is nice.