Add support for negative promts, also extend timeout to 5 minutes, also post that you're working on the image and then edit the message with the file upload
This commit is contained in:
parent
9e5876af16
commit
148465cfde
@ -85,14 +85,22 @@ class ActualUtils(commands.Cog):
|
||||
ip = "192.168.1.80"
|
||||
|
||||
try:
|
||||
file_path = await stable_diffusion.generate_image(
|
||||
ip=ip, port=port, prompt=prompt
|
||||
original_message = await ctx.reply(
|
||||
"Please be patient, I'm generating your image"
|
||||
)
|
||||
await ctx.reply(
|
||||
negatives = ""
|
||||
if ";" in prompt:
|
||||
positives = prompt.split(";")[0]
|
||||
negatives = prompt.split(";")[1]
|
||||
file_path = await stable_diffusion.generate_image(
|
||||
ip=ip, port=port, positives=positives, negatives=negatives
|
||||
)
|
||||
await original_message.edit(
|
||||
content="",
|
||||
file=discord.File(
|
||||
file_path,
|
||||
filename="unknown.png",
|
||||
)
|
||||
),
|
||||
)
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
|
@ -163,7 +163,8 @@ def get_help_message(method):
|
||||
"Issues a prompt against stable diffusion.\n",
|
||||
"For help with writing useful prompts, check out this article:\n\nhttps://github.com/AUTOMATIC1111/stable-diffusion-webui/wiki/Features#prompt-editing\n",
|
||||
"\n\nHere is a list of artists the the AI is able to understand https://rentry.org/artists_sd-v1-4",
|
||||
"\n\nUsage: !sd A picture of a woman sitting by a bridge with blonde hair, wearing a black dress",
|
||||
'\nAlso supports adding negatives (things you want the AI to leave out). Denote negatives by splitting the prompt with a ";"',
|
||||
"\n\nUsage: !sd A picture of a woman sitting by a bridge with blonde hair, wearing a black dress; ugly, out of focus, weird hands",
|
||||
],
|
||||
"sheeb": ["Returns a picture of a sheeb"],
|
||||
"source": ["Links you to the git repo with dale-bot's source code"],
|
||||
|
0
app/requirements.txt
Executable file → Normal file
0
app/requirements.txt
Executable file → Normal file
@ -5,7 +5,7 @@ import socket
|
||||
import tempfile
|
||||
|
||||
|
||||
async def generate_image(ip, port, prompt):
|
||||
async def generate_image(ip, port, positives, negatives):
|
||||
url = "http://" + ip + ":" + port + "/api/predict/"
|
||||
headers = {
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0",
|
||||
@ -18,8 +18,8 @@ async def generate_image(ip, port, prompt):
|
||||
json_data = {
|
||||
"fn_index": 11,
|
||||
"data": [
|
||||
prompt,
|
||||
"", # Negative Prompt
|
||||
positives,
|
||||
negatives, # Negative Prompt
|
||||
"None",
|
||||
"None",
|
||||
20, # Sampling Steps
|
||||
@ -57,7 +57,7 @@ async def generate_image(ip, port, prompt):
|
||||
],
|
||||
}
|
||||
client = httpx.AsyncClient()
|
||||
response = await client.post(url, headers=headers, json=json_data, timeout=120)
|
||||
response = await client.post(url, headers=headers, json=json_data, timeout=300)
|
||||
imageb64 = response.json()["data"][0][0].split("data:image/png;base64,")[1]
|
||||
|
||||
imgdata = base64.b64decode(imageb64)
|
||||
|
Loading…
x
Reference in New Issue
Block a user