A Discord bot that performs image upscaling using various super-resolution models. Users can easily upload images to this bot and have them upscaled with the model of their choice.
- Supports multiple super-resolution models through spandrel
- Configurable settings for VRAM usage and processing limits
- Supports both .pth and .safetensors model formats
- Implements a customizable queuing system for handling multiple upscale requests
- Automatically adjusts tile size based on available VRAM
- Resize an image with typical scaling filters
- Fuzzy model name matching
- Alpha channel handling options: upscale, resize, or discard
- Detailed image information retrieval
- Python 3.9 or higher
- CUDA-capable GPU
- Discord Bot Token
- Terminal program
nvidia-smi
installed on your system
-
Clone this repository:
git clone https://github.com/Kim2091/upscale-bot.git cd upscale-bot
-
Install the latest PyTorch CUDA version for your system here: https://pytorch.org/get-started/locally/
-
Install the other required dependencies:
pip install -r requirements.txt
-
Install ImageMagick
-
Open the
config.ini
file in the project root directory and replaceYOUR_DISCORD_BOT_TOKEN
andYOUR_DISCORD_USER_ID
with your actual Discord bot token and user ID. Set this up at https://discord.com/developers/- The bot needs the
bot
scope (and maybeapplications.commands
), then:- Send Messages
- Attach Files
- View Channels
- Use Slash Commands (maybe)
- The bot needs the
-
Place your models (.pth or .safetensors files) in the directory specified by
ModelPath
in the config file.
-
Start the bot:
python upscale-bot.py
-
In a Discord channel where the bot is present, use the following commands:
-
To upscale an image:
--upscale <model_name>
Attach the image you want to upscale when sending this command.
-
To list available models:
--models
-
To resize an image:
--resize <scale_factor> <method>
-
To get detailed information about an image:
--info
Attach the image or provide an image URL when sending this command.
-
You can adjust various settings in the config.ini
file:
Precision
: Can be 'auto', 'fp16', 'bf16', or 'fp32'DefaultTileSize
andMaxTileSize
: Control the tile size for processing large imagesMaxTotalPixels
: Maximum allowed input image size (width * height)VRAMSafetyMultiplier
andAvailableVRAMUsageFraction
: Fine-tune VRAM usageThreadPoolWorkers
: Number of worker threads for processingMaxConcurrentUpscales
: Maximum number of concurrent upscale operationsUpscaleTimeout
andOtherStepTimeout
: Timeouts for upscaling and other operationsDefaultAlphaHandling
: Default method for handling alpha channels
- Never share your Discord bot token.
- The bot implements basic input validation.
- This bot uses the Spandrel library for loading and handling models.
- Thanks to @the-database for the benchmarks contained in
vram_data_bffp16.md
&vram_data_fp32.md
- Thanks to the Discord.py team for their excellent Discord API wrapper.
- The bot uses Wand (ImageMagick) for additional image processing capabilities.