Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,9 +52,10 @@ class MyClient(discord.Client):
|
|
| 52 |
|
| 53 |
async def generate_image(prompt):
|
| 54 |
try:
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
|
|
|
| 58 |
image = Image.open(image_bytes)
|
| 59 |
image_path = "output.png"
|
| 60 |
image.save(image_path)
|
|
@@ -63,6 +64,7 @@ async def generate_image(prompt):
|
|
| 63 |
logging.error(f"Failed to generate image: {str(e)}")
|
| 64 |
return None
|
| 65 |
|
|
|
|
| 66 |
async def send_image(channel, image_path):
|
| 67 |
file = discord.File(image_path)
|
| 68 |
await channel.send(file=file)
|
|
|
|
| 52 |
|
| 53 |
async def generate_image(prompt):
|
| 54 |
try:
|
| 55 |
+
# ์
๋ ฅ์ ๋ํ ๋ชจ๋ธ ํธ์ถ
|
| 56 |
+
response = hf_client.post(inputs={"inputs": prompt})
|
| 57 |
+
image_data = response['images'][0] # ์๋ต์์ ์ด๋ฏธ์ง ๋ฐ์ดํฐ ์ถ์ถ
|
| 58 |
+
image_bytes = io.BytesIO(base64.b64decode(image_data))
|
| 59 |
image = Image.open(image_bytes)
|
| 60 |
image_path = "output.png"
|
| 61 |
image.save(image_path)
|
|
|
|
| 64 |
logging.error(f"Failed to generate image: {str(e)}")
|
| 65 |
return None
|
| 66 |
|
| 67 |
+
|
| 68 |
async def send_image(channel, image_path):
|
| 69 |
file = discord.File(image_path)
|
| 70 |
await channel.send(file=file)
|