stable-diffusion-telegram-bot

command module
v0.0.0-...-14a899b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2023 License: MIT Imports: 32 Imported by: 0

README

Stable Diffusion Telegram Bot

This is a Telegram Bot frontend for rendering images with Stable Diffusion.

The bot displays the progress and further information during processing by responding to the message with the prompt. Requests are queued, only one gets processed at a time.

The bot uses the Telegram Bot API. Rendered images are not saved on disk. Tested on Linux, but should be able to run on other operating systems.

Compiling

You'll need Go installed on your computer. Install a recent package of golang. Then:

go get github.com/nonoo/stable-diffusion-telegram-bot
go install github.com/nonoo/stable-diffusion-telegram-bot

This will typically install stable-diffusion-telegram-bot into $HOME/go/bin.

Or just enter go build in the cloned Git source repo directory.

Prerequisites

Create a Telegram bot using BotFather and get the bot's token.

Running

You can get the available command line arguments with -h. Mandatory arguments are:

  • -bot-token: set this to your Telegram bot's token
  • -sd-webui-path: set this to the path of webui start script from the Stable Diffusion directory

Set your Telegram user ID as an admin with the -admin-user-ids argument. Admins will get a message when the bot starts.

Other user/group IDs can be set with the -allowed-user-ids and -allowed-group-ids arguments. IDs should be separated by commas.

You can get Telegram user IDs by writing a message to the bot and checking the app's log, as it logs all incoming messages.

All command line arguments can be set through OS environment variables. Note that using a command line argument overwrites a setting by the environment variable. Available OS environment variables are:

  • BOT_TOKEN
  • STABLE_DIFFUSION_WEBUI_PATH
  • ALLOWED_USERIDS
  • ADMIN_USERIDS
  • ALLOWED_GROUPIDS
  • DELAYED_SD_START
  • DEFAULT_MODEL
  • DEFAULT_SAMPLER
  • DEFAULT_WIDTH
  • DEFAULT_HEIGHT
  • DEFAULT_WIDTH_SDXL
  • DEFAULT_HEIGHT_SDXL

Supported commands

  • /sd - render images using supplied prompt
  • /sdcancel - cancel ongoing request
  • /sdmodels - list available models
  • /sdsamplers - list available samplers
  • /sdembeddings - list available embeddings
  • /sdloras - list available LoRAs
  • /sdupscalers - list available upscalers
  • /sdvaes - list available VAEs
  • /sdsmi - get the output of nvidia-smi
  • /sdhelp - print help

You can also use the ! command character instead of /.

You don't need to enter the /sd command if you send a prompt to the bot using a private chat.

Setting render parameters

You can use the following -attr val assignments at the end of the prompt:

  • -seed/s - set seed
  • -width/w - set output image width
  • -height/h - set output image height
  • -steps/t - set the number of steps
  • -outcnt/o - set count of output images
  • -png - upload PNGs instead of JPEGs
  • -cfg/c - set CFG scale
  • -sampler/r - set sampler, get valid values with /sdsamplers
  • -model/m - set model, get valid values with /sdmodels
  • -upscale/u - upscale output image with ratio
  • -upscaler - set upscaler method, get valid values with /sdupscalers
  • -hr - enable highres mode and set upscale ratio
  • -hr-denoisestrength/hrd - set highres mode denoise strength
  • -hr-upscaler/hru - set highres mode upscaler, get valid values with /sdupscalers
  • -hr-steps/hrt - set the number of highres mode second pass steps

Example prompt with attributes: laughing santa with beer -s 1 -o 1

Enter negative prompts in the second line of your message (use Shift+Enter). Example:

laughing santa with beer
tree -s 1 -o 1

If you need to use spaces in sampler and upscaler names, then enclose them in double quotes.

The default resolution is 512x512. If the currently used model's name ends with "sdxl" then the bot increases the resolution to 1024.

Donations

If you find this bot useful then buy me a beer. :)

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL