Skip to content

Latest commit

 

History

History
119 lines (80 loc) · 3.33 KB

README.md

File metadata and controls

119 lines (80 loc) · 3.33 KB

Diffusion Bot

A Discord bot for interacting with diffusion models like Stable Diffusion XL 1.0:

the statue of david

Getting started

Local

Prerequisites:

  1. Clone the repo

    git clone [email protected]:hkiang01/diffusion-bot.git
  2. 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
  3. 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
  4. Start the API

    cd ../api
    poetry run uvicorn api.main:app --port 8000
  5. Start the bot

    cd ../bot
    npm run-script build
    npm run-script start
  6. Follow the instructions for Adding your bot to servers

  7. Have fun!

Dev Container

Prerequisites:

  1. Install the Dev Containers extension

  2. 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"
    // ],
    

Adding more models

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 run predict() in the debugger without any additional code