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"
|
ip = "192.168.1.80"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
file_path = await stable_diffusion.generate_image(
|
original_message = await ctx.reply(
|
||||||
ip=ip, port=port, prompt=prompt
|
"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=discord.File(
|
||||||
file_path,
|
file_path,
|
||||||
filename="unknown.png",
|
filename="unknown.png",
|
||||||
)
|
),
|
||||||
)
|
)
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -163,7 +163,8 @@ def get_help_message(method):
|
|||||||
"Issues a prompt against stable diffusion.\n",
|
"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",
|
"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\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"],
|
"sheeb": ["Returns a picture of a sheeb"],
|
||||||
"source": ["Links you to the git repo with dale-bot's source code"],
|
"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
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
async def generate_image(ip, port, prompt):
|
async def generate_image(ip, port, positives, negatives):
|
||||||
url = "http://" + ip + ":" + port + "/api/predict/"
|
url = "http://" + ip + ":" + port + "/api/predict/"
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:105.0) Gecko/20100101 Firefox/105.0",
|
"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 = {
|
json_data = {
|
||||||
"fn_index": 11,
|
"fn_index": 11,
|
||||||
"data": [
|
"data": [
|
||||||
prompt,
|
positives,
|
||||||
"", # Negative Prompt
|
negatives, # Negative Prompt
|
||||||
"None",
|
"None",
|
||||||
"None",
|
"None",
|
||||||
20, # Sampling Steps
|
20, # Sampling Steps
|
||||||
@ -57,7 +57,7 @@ async def generate_image(ip, port, prompt):
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
client = httpx.AsyncClient()
|
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]
|
imageb64 = response.json()["data"][0][0].split("data:image/png;base64,")[1]
|
||||||
|
|
||||||
imgdata = base64.b64decode(imageb64)
|
imgdata = base64.b64decode(imageb64)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user