Code Monkey home page Code Monkey logo

discord-stable-diffusion's Introduction

Shanghai - AI Powered Art in a Discord Bot!

Any questions or need help? Come hop on by to our Discord server!

Discord Server

Setup

Make sure you have the CUDA Toolkit installed

Clone the repository and enter it

git clone https://github.com/harubaru/discord-stable-diffusion.git
cd discord-stable-diffusion

WINDOWS SETUP

Run setup.bat. If you run into any errors, try running the file as administrator

If you are on a Windows 10 system, run win10patch.bat

Modify the run.bat file, where

  • --model_path is the path to the model (make sure to replace any backslashes with double backslashes),
  • --token= is the token to the Discord bot
  • --hf_token= is your huggingface token (can be found here)

Run the run.bat file

LINUX SETUP

Run ./setup.sh. If you run into any errors, try using sudo ./setup.sh

Modify the run.sh file, where

  • --model_path is the path to the model,
  • --token= is the token to the Discord bot
  • --hf_token= is your huggingface token (can be found here)

Run ./run.sh

Quickstart

Text to Image

To generate an image from text, use the /dream command and include your prompt as the query. There's tons of parameters to play with so go wild!

image

image

Image to Image

To generate an image from another image, use the /dream command and include the init_image and strength parameters. The image needs to be attached to the message.

image

image

(Experimental) Inpainting

To fill in a mask in an image, supply a prompt, the init_image, mask_image and strength parameters. The mask needs to consist of black pixels in a transparent image.

image

discord-stable-diffusion's People

Contributors

btcookies avatar harubaru avatar lim-dul avatar saltaccount avatar yoinked-h avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

discord-stable-diffusion's Issues

KeyError: 'state_dict' from discord-stable-diffusion\src\stablediffusion\ldm\generate.py

I have been following the following steps, using Windows 11 :

  • Installed CUBA Toolkit
  • Cloned the repository through Github Desktop
  • Ran setup.bat and completed the venv installation
  • Modified the run.bat file to fill the model.ckpt location and the Discord bot token
  • Tested /dream command with the following query : "a girl drinking soda"

Seeing the same error KeyError: 'state_dict' after multiple queries attempts, I uninstalled and redone all the above steps. But it's no use: there is still that same error.

Here's what happens from the cmd, and the displayed error on Discord :

Request -- YamakoKiasote#2844 -- Prompt: a girl drinking soda
[2022-11-30 15:20:59] INFO: Global seed set to 1105693868
[2022-11-30 15:20:59] INFO: Global seed set to 1070861717

Loading model from C:\Users\yamak\stable-diffusion\models\Stable-diffusion\model.ckpt
Traceback (most recent call last):
File "C:\Users\yamak\discord-stable-diffusion\src\bot\stablecog.py", line 161, in dream
samples, seed = self.text2image_model.dream(queue_object.prompt, queue_object.steps, False, False, 0.0,
File "C:\Users\yamak\discord-stable-diffusion\src\stablediffusion\text2image_compvis.py", line 64, in dream
results = self.generator.txt2img(prompt=prompt, iterations = 1, steps=ddim_steps, seed=seed, cfg_scale=cfg_scale, ddim_eta=ddim_eta, width=width, height=height, sampler_name=sampler_name, outdir='storage/outputs')
File "C:\Users\yamak\discord-stable-diffusion\src\stablediffusion\ldm\generate.py", line 175, in txt2img
return self.prompt2png(prompt, outdir, **kwargs)
File "C:\Users\yamak\discord-stable-diffusion\src\stablediffusion\ldm\generate.py", line 162, in prompt2png
results = self.prompt2image(prompt, **kwargs)
File "C:\Users\yamak\discord-stable-diffusion\src\stablediffusion\ldm\generate.py", line 263, in prompt2image
self.load_model()
File "C:\Users\yamak\discord-stable-diffusion\src\stablediffusion\ldm\generate.py", line 426, in load_model
model = self._load_model_from_config(config, self.weights)
File "C:\Users\yamak\discord-stable-diffusion\src\stablediffusion\ldm\generate.py", line 538, in _load_model_from_config
sd = pl_sd['state_dict']
KeyError: 'state_dict'

image

In embeds: Embed size exceeds maximum size of 6000

[2023-01-02 11:06:49] ERROR: Task exception was never retrieved
future: <Task finished name='Task-19' coro=<Messageable.send() done, defined at C:\Users\abcsa\OneDrive\Documents\GitHub\discord-stable-diffusion\venv\lib\site-packages\discord\abc.py:1384> exception=HTTPException('400 Bad Request (error code: 50035): Invalid Form Body\nIn embeds: Embed size exceeds maximum size of 6000')>
Traceback (most recent call last):
File "C:\Users\abcsa\OneDrive\Documents\GitHub\discord-stable-diffusion\venv\lib\site-packages\discord\abc.py", line 1606, in send
data = await state.http.send_message(
File "C:\Users\abcsa\OneDrive\Documents\GitHub\discord-stable-diffusion\venv\lib\site-packages\discord\http.py", line 366, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In embeds: Embed size exceeds maximum size of 6000

SyntaxError: invalid syntax on line 2

My friend is trying to run this bot on his Mac M1. However, when trying to run setup.sh, he is plauged with this error:

[friend's user] mare.ai % sudo sh setup.sh
  File "/Users/[friend's name]/Downloads/mare.ai/venv/bin/pip", line 2
    /bin/python3.11
    ^
SyntaxError: invalid syntax

It also always opens a venv folder called venv? instead of venv for some reason, and every time we rename it to venv it just creates a new folder called venv?.
Why could that be? Thanks.

invalid load key, '\x1f'

Getting invalid load key, '\x1f'. I've installed everything as stated in the instructions and I've managed to get the bot working. However, the bot does not create any images. It simply throws an error. I've made sure to have the correct path to the model.

The full error is:
_pickle.UnpicklingError: invalid load key, '\x1f'.

My PC specs:
RTX 3090
64GB RAM
12900K CPU

Support for 4GB cards

With my current system (RX 570 4GB) I can run AUTOMATIC1111/stable-diffusion-webui with their --medvram flag without any issue.

Would it be possible to implement something similar to their --medvram flag?

why compvis instead of diffusers?

Thanks for this source!

I see the stable diffusion backend is recently changed to compvis from diffusers. What is the reason? What is the disadvantage of using diffusers implementation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.