A Discord bot for interacting with diffusion models like Stable Diffusion XL 1.0:
Prerequisites:
-
Clone the repo
git clone [email protected]:hkiang01/diffusion-bot.git
-
Install dependencies
API dependencies
Configure
api\pyproject.toml
. If the GPU version of torch isn't compatible with your machine, change the dependency as follows:# pyproject.toml torch = { version = "^2.0.1" } # cpu # torch = { version = "^2.0.1", source = "cu118" } # gpu
cd api poetry config virtualenvs.in-project true poetry install
bot dependencies
cd ../bot npm install
-
Configure the Discord bot. Follow the instructions for Creating your bot in the Discord developer portal and obtain:
- the application's client id
- the bot's token
Then copy them in a file
.env
, created as a copy of.env.sample
cp .env.sample .env
# bot/.env API_URL=http://localhost:8000 DISCORD_BOT_TOKEN=put_token_here DISCORD_OAUTH2_CLIENT_ID=put_client_id_here
-
Start the API
cd ../api poetry run uvicorn api.main:app --port 8000
-
Start the bot
cd ../bot npm run-script build npm run-script start
-
Follow the instructions for Adding your bot to servers
-
Have fun!
Prerequisites:
-
Install the Dev Containers extension
-
Start the dev container by clicking "Open a Remote Window", then selecting "Reopen in Container"
Note: If you don't have a GPU, comment out the following lines in
.devcontainer/devcontainer.json
:// "runArgs": [ // "--gpus", // "all" // ],
The whole code base is extensible. If you implement another subclass of Model
:
- the API automatically adds it as another model able to be used in the dropdown of
/docs
- the tests in
./api/tests/models/model_test.py
are automacially parameterized such that you can runpredict()
in the debugger without any additional code