await stable diffusion now
This commit is contained in:
parent
e4b50f175a
commit
b8dfbe88d0
@ -84,19 +84,21 @@ class ActualUtils(commands.Cog):
|
||||
except:
|
||||
ip = "192.168.1.80"
|
||||
|
||||
try:
|
||||
file_path = stable_diffusion.generate_image(ip=ip, port=port, prompt=prompt)
|
||||
await ctx.reply(
|
||||
file=discord.File(
|
||||
file_path,
|
||||
filename="unknown.png",
|
||||
)
|
||||
)
|
||||
os.remove(file_path)
|
||||
except Exception as e:
|
||||
await ctx.reply(
|
||||
"Stable diffusion isnt running right now, sorry.\n%s" % e,
|
||||
# try:
|
||||
file_path = await stable_diffusion.generate_image(
|
||||
ip=ip, port=port, prompt=prompt
|
||||
)
|
||||
await ctx.reply(
|
||||
file=discord.File(
|
||||
file_path,
|
||||
filename="unknown.png",
|
||||
)
|
||||
)
|
||||
os.remove(file_path)
|
||||
# except Exception as e:
|
||||
# await ctx.reply(
|
||||
# "Stable diffusion isnt running right now, sorry.\n%s" % e,
|
||||
# )
|
||||
|
||||
@commands.command(name="trackdays")
|
||||
async def trackdays(self, ctx: commands.Context):
|
||||
|
@ -9,4 +9,5 @@ git+https://github.com/pycord-development/pycord@8df222d86319dd16a5e559585246343
|
||||
requests
|
||||
wikipedia
|
||||
wolframalpha
|
||||
openai
|
||||
openai
|
||||
httpx
|
@ -1,11 +1,12 @@
|
||||
import base64
|
||||
import json
|
||||
import requests
|
||||
import httpx
|
||||
import socket
|
||||
import tempfile
|
||||
|
||||
|
||||
def generate_image(ip, port, prompt):
|
||||
async def generate_image(ip, port, prompt):
|
||||
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",
|
||||
@ -56,8 +57,8 @@ def generate_image(ip, port, prompt):
|
||||
"",
|
||||
],
|
||||
}
|
||||
|
||||
response = requests.post(url, headers=headers, json=json_data)
|
||||
client = httpx.AsyncClient()
|
||||
response = await client.post(url, headers=headers, json=json_data, timeout=60)
|
||||
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