awaited async function
This commit is contained in:
parent
8bcdcba4ab
commit
7a1db5efc1
1 changed files with 5 additions and 12 deletions
|
|
@ -255,12 +255,8 @@ class StableDiffusion(commands.Cog):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
url=f"{url}/sdapi/v1/txt2img"
|
url=f"{url}/sdapi/v1/txt2img"
|
||||||
|
|
||||||
prompt = ctx.message.content.split(" ", maxsplit=1)[1]
|
prompt = ctx.message.content.split(" ", maxsplit=1)[1]
|
||||||
await ctx.send(f"Please be patient this may take some time! Generating: {prompt}.1")
|
key_value_pairs, prompt = await self.extract_key_value_pairs(prompt)
|
||||||
key_value_pairs, prompt = self.extract_key_value_pairs(prompt)
|
|
||||||
await ctx.send(f"Please be patient this may take some time! Generating: {prompt}.2")
|
|
||||||
'''
|
|
||||||
try:
|
try:
|
||||||
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
|
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
|
||||||
with open(neg_prompt_file, 'r') as f:
|
with open(neg_prompt_file, 'r') as f:
|
||||||
|
|
@ -269,11 +265,8 @@ class StableDiffusion(commands.Cog):
|
||||||
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
|
neg_prompt_file = f"{self.db_dir}negative_prompt.txt"
|
||||||
with open(neg_prompt_file, 'w') as f:
|
with open(neg_prompt_file, 'w') as f:
|
||||||
f.writelines("")
|
f.writelines("")
|
||||||
negative_prompt = ""'''
|
|
||||||
negative_prompt = ""
|
negative_prompt = ""
|
||||||
|
await ctx.send(f"Please be patient this may take some time! Generating: {prompt}.")
|
||||||
await ctx.send(f"Please be patient this may take some time! Generating: {prompt}.3")
|
|
||||||
|
|
||||||
payload = {
|
payload = {
|
||||||
"prompt": prompt,
|
"prompt": prompt,
|
||||||
"steps": 25,
|
"steps": 25,
|
||||||
|
|
@ -299,7 +292,7 @@ class StableDiffusion(commands.Cog):
|
||||||
response2 = await resp.json()
|
response2 = await resp.json()
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
await ctx.send("My image generation service may not be running.")
|
await ctx.send("My image generation service may not be running.")
|
||||||
await self.handle_error(error)
|
await self.handle_error(self, error)
|
||||||
|
|
||||||
pnginfo = PngImagePlugin.PngInfo()
|
pnginfo = PngImagePlugin.PngInfo()
|
||||||
pnginfo.add_text("parameters", response2.get("info"))
|
pnginfo.add_text("parameters", response2.get("info"))
|
||||||
|
|
@ -392,7 +385,7 @@ class StableDiffusion(commands.Cog):
|
||||||
await self.handle_error(error)
|
await self.handle_error(error)
|
||||||
print("Couldn't find image.")
|
print("Couldn't find image.")
|
||||||
return
|
return
|
||||||
key_value_pairs, prompt = self.extract_key_value_pairs(prompt)
|
key_value_pairs, prompt = await self.extract_key_value_pairs(prompt)
|
||||||
try:
|
try:
|
||||||
async with self.bot.http_session.get(file_url) as response:
|
async with self.bot.http_session.get(file_url) as response:
|
||||||
imageName = self.working_dir + str(time.time_ns()) + ".png"
|
imageName = self.working_dir + str(time.time_ns()) + ".png"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue