Fixing stable diffusion
This commit is contained in:
parent
81e97e88f2
commit
59e74ae87a
@ -2,6 +2,7 @@ from discord import option
|
||||
from discord.ext import commands
|
||||
import core_utils
|
||||
import discord
|
||||
import os
|
||||
|
||||
|
||||
class StableDiffusion(commands.Cog):
|
||||
@ -10,7 +11,8 @@ class StableDiffusion(commands.Cog):
|
||||
|
||||
@commands.has_role("stable-diffuser")
|
||||
@commands.slash_command(
|
||||
guild_ids=core_utils.my_guilds,
|
||||
# guild_ids=core_utils.my_guilds,
|
||||
guild_ids=None,
|
||||
name="sd",
|
||||
description="Pass a prompt and optional negative prompt to stable diffusion",
|
||||
)
|
||||
@ -29,7 +31,8 @@ class StableDiffusion(commands.Cog):
|
||||
self, ctx: commands.Context, positive_prompt: str, negative_prompt: str
|
||||
):
|
||||
|
||||
if ctx.channel.name == "stable-diffusion":
|
||||
if True:
|
||||
# if ctx.channel.name == "stable-diffusion":
|
||||
import socket
|
||||
import stable_diffusion
|
||||
|
||||
@ -68,7 +71,7 @@ class StableDiffusion(commands.Cog):
|
||||
)
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
await ctx.reply(
|
||||
await ctx.respond(
|
||||
"Stable diffusion isnt running right now, sorry.\n%s" % e,
|
||||
)
|
||||
else:
|
||||
|
@ -18,15 +18,16 @@ async def generate_image(ip, port, positives, negatives, steps):
|
||||
}
|
||||
|
||||
json_data = {
|
||||
"fn_index": 11,
|
||||
"fn_index": 51,
|
||||
"data": [
|
||||
positives,
|
||||
negatives, # Negative Prompt
|
||||
negatives,
|
||||
"None",
|
||||
"None",
|
||||
steps, # Sampling Steps
|
||||
1,
|
||||
# steps,
|
||||
"Euler a",
|
||||
True, # enable face fix
|
||||
True,
|
||||
False,
|
||||
1,
|
||||
1,
|
||||
@ -39,33 +40,34 @@ async def generate_image(ip, port, positives, negatives, steps):
|
||||
False,
|
||||
512,
|
||||
512,
|
||||
True, # Enable highres fix
|
||||
False,
|
||||
0.7, # Denoising Strength
|
||||
True,
|
||||
0.7,
|
||||
0,
|
||||
0,
|
||||
"None",
|
||||
False,
|
||||
False,
|
||||
None,
|
||||
False,
|
||||
"",
|
||||
"Seed",
|
||||
"", # What seed to use
|
||||
"Steps",
|
||||
"",
|
||||
"Nothing",
|
||||
"",
|
||||
True,
|
||||
False,
|
||||
False,
|
||||
None,
|
||||
"",
|
||||
"",
|
||||
],
|
||||
}
|
||||
client = httpx.AsyncClient()
|
||||
response = await client.post(url, headers=headers, json=json_data, timeout=1200)
|
||||
imageb64 = response.json()["data"][0][0].split("data:image/png;base64,")[1]
|
||||
imgdata = base64.b64decode(imageb64)
|
||||
file_path = response.json()["data"][0][0]["name"]
|
||||
|
||||
imgdata = await client.get("http://%s:%s/file=%s" % (ip, port, file_path))
|
||||
file, file_path = tempfile.mkstemp()
|
||||
|
||||
with open(file_path, "wb") as f:
|
||||
f.write(imgdata)
|
||||
f.write(imgdata.content)
|
||||
|
||||
soup = BeautifulSoup(response.json()["data"][2], "html.parser")
|
||||
time_taken = soup.find("p", class_="time").text
|
||||
|
Loading…
x
Reference in New Issue
Block a user