await stable diffusion now
This commit is contained in:
parent
e4b50f175a
commit
b8dfbe88d0
@ -84,19 +84,21 @@ class ActualUtils(commands.Cog):
|
|||||||
except:
|
except:
|
||||||
ip = "192.168.1.80"
|
ip = "192.168.1.80"
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
file_path = stable_diffusion.generate_image(ip=ip, port=port, prompt=prompt)
|
file_path = await stable_diffusion.generate_image(
|
||||||
await ctx.reply(
|
ip=ip, port=port, prompt=prompt
|
||||||
file=discord.File(
|
)
|
||||||
file_path,
|
await ctx.reply(
|
||||||
filename="unknown.png",
|
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,
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
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")
|
@commands.command(name="trackdays")
|
||||||
async def trackdays(self, ctx: commands.Context):
|
async def trackdays(self, ctx: commands.Context):
|
||||||
|
@ -10,3 +10,4 @@ requests
|
|||||||
wikipedia
|
wikipedia
|
||||||
wolframalpha
|
wolframalpha
|
||||||
openai
|
openai
|
||||||
|
httpx
|
@ -1,11 +1,12 @@
|
|||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
|
import httpx
|
||||||
import socket
|
import socket
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
def generate_image(ip, port, prompt):
|
async def generate_image(ip, port, prompt):
|
||||||
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",
|
||||||
@ -56,8 +57,8 @@ def generate_image(ip, port, prompt):
|
|||||||
"",
|
"",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
client = httpx.AsyncClient()
|
||||||
response = requests.post(url, headers=headers, json=json_data)
|
response = await client.post(url, headers=headers, json=json_data, timeout=60)
|
||||||
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