PicAIsso is an open-source StableDiffusion implementation for generating AI art using an API and a Discord Bot.
π Imagine self-hosting your own MidJourney Discord bot, but with a different name and a different art style.
You can self-host the API and the Discord bot on your own machine or on a server.
OR
You can use my own self-hosted API and Discord bot. Add the bot to your Discord server and start generating art! π
Click here to invite the bot to your server. Note: The bot is currently hosted on my own workstation, so it might be offline sometimes. > Note 2: I'm saving all the generated images on my S3 bucket, these images will be used to create a dataset available for free on Hugging Face.
For self-hosting instructions, keep reading the README. π
- Docker installed
- NVIDIA GPU with at least 12GB of VRAM (with a batch size of 1)
- NVIDIA drivers installed + NVIDIA Container Toolkit installed
If you want to contribute to the project, please read the CONTRIBUTING.md file. It will help you to setup your development environment.
- Clone the repository
git clone https://github.com/chainyo/picaisso.git
-
Create your own
.env
file for the API and update the values with your own.Follow the
.env.template
comments. -
Create your own
.env
file for the Discord Bot and update the values with your own.Follow the
.env.template
comments. The Discord bot application installation process is explained if you follow the link in the.env.template
file. -
(Optional) If you want to store the generated images, there is a S3 bucket configuration in the
.env
file. You can create your own S3 bucket and update the values with your own. Leave the values empty if you don't want to use S3.
There are two steps:
- Deploy the API
- Deploy the Discord Bot
Warning: Be sure to be in the root folder of the project before running the Docker commands.
docker network create picaisso
- Build the Docker image
docker build -t picaisso-api:latest -f docker/api/Dockerfile .
You should see the built image in your Docker images list, you can check it with the following command:
docker images
- Run the Docker container
docker run -d \
--gpus all \
--network picaisso \
-p 7681:7681 \
-v ${HOME}/.cache:/root/.cache \
--restart unless-stopped \
--name picaisso-api \
picaisso-api:latest
- Test the API
The API should be running on port 7681
of your machine. It can take a few minutes to start, because the model has
to be downloaded and loaded on the first run. Because we are using the ${HOME}/.cache
folder as a mounted volume, the model will be downloaded only once and will be reused on the next runs.
Once the API is running, you can test it by going to http://localhost:7681/
in your web browser.
You should see the landing page of the API.
Click on the Docs
button to see the API documentation and test the /generate
endpoint. Check the Usage section for more details.
Trouble shooting: use the docker logs picaisso-api
command to see the logs of the container.
- Build the Docker image
docker build -t picaisso-bot:latest -f docker/bot/Dockerfile .
- Run the Docker container
docker run -d \
--restart unless-stopped \
--network picaisso \
--name picaisso-bot \
picaisso-bot:latest
If you successfully created the Discord bot application, you just need to invite it to your server. You can find the invite link in the OAuth2
section of your Discord bot application.
(See the tutorial link in the .env.template
file.)
Note: Server Members Intent must be enabled on the Discord bot (under the Bot
section):
Mine is live! π
You can use the project in three different ways:
- Use the API documentation to generate images (Starter apprentice level π€, be better than that)
- Use the API endpoint to generate images (Dev guru level π§ββοΈ)
- Use the Discord bot to generate images (Discord bro level π€)
For testing purposes, you can use the API documentation to generate images and validate everything is working
as expected. You can find the API documentation at http://localhost:7681/docs
when the API is running.
- Click on the
Authorize
button and enter your API key in theValue
field.
- Use the
generate
endpoint to generate an image.
2.1. Click on the Try it out
button.
2.2. Enter the parameters you want to use to generate the image.
-
prompt: any text you want to use to generate the image.
-
author: the name of the author of the image. Used for s3 storage only, you can let string.
2.3. Enter the
Execute
button and wait for the image to be generated.
You can download the image by right-clicking on the image and selecting Save image as...
.
You can use the API endpoint to generate images in your own application.
You can use the same logic used by the Discord bot to generate images. You can find the code in the bot.py
file.
You can use the Discord bot to generate images in your Discord server.
-
Start by typing
/art
in any channel of your Discord server. -
The bot will ask you to enter the prompt you want to use to generate the image.
-
Enter the prompt you want to use to generate the image.
- The bot will tell you the job is in progress and will send you the image when it's done.
Enjoy the result! π
If you have any questions or issues, feel free to open an issue or contact me on Twitter, Discord (ChainYo#3610) or via email ([email protected]).
If you like the project, please consider giving it a βοΈ and share it with your friends.
Buy me a book π if you want to support my work.