seawolf2357
commited on
Commit
•
ec26fa2
1
Parent(s):
75b9ca0
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import os
|
|
4 |
import asyncio
|
5 |
import subprocess
|
6 |
from huggingface_hub import InferenceClient
|
7 |
-
import base64
|
8 |
from PIL import Image
|
9 |
import io
|
10 |
|
@@ -19,7 +18,7 @@ intents.guilds = True
|
|
19 |
intents.guild_messages = True
|
20 |
|
21 |
# 추론 API 클라이언트 설정
|
22 |
-
hf_client = InferenceClient(
|
23 |
|
24 |
# 특정 채널 ID
|
25 |
SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
|
@@ -53,9 +52,9 @@ class MyClient(discord.Client):
|
|
53 |
|
54 |
async def generate_image(prompt):
|
55 |
try:
|
56 |
-
response = hf_client(inputs={"inputs": prompt})
|
57 |
image_data = response['images'][0] # Assuming the response contains image data
|
58 |
-
image_bytes = io.BytesIO(
|
59 |
image = Image.open(image_bytes)
|
60 |
image_path = "output.png"
|
61 |
image.save(image_path)
|
|
|
4 |
import asyncio
|
5 |
import subprocess
|
6 |
from huggingface_hub import InferenceClient
|
|
|
7 |
from PIL import Image
|
8 |
import io
|
9 |
|
|
|
18 |
intents.guild_messages = True
|
19 |
|
20 |
# 추론 API 클라이언트 설정
|
21 |
+
hf_client = InferenceClient(token=os.getenv("HF_TOKEN"))
|
22 |
|
23 |
# 특정 채널 ID
|
24 |
SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
|
|
|
52 |
|
53 |
async def generate_image(prompt):
|
54 |
try:
|
55 |
+
response = hf_client(inputs={"inputs": prompt}, model_id="stabilityai/stable-diffusion-3-medium")
|
56 |
image_data = response['images'][0] # Assuming the response contains image data
|
57 |
+
image_bytes = io.BytesIO(image_data)
|
58 |
image = Image.open(image_bytes)
|
59 |
image_path = "output.png"
|
60 |
image.save(image_path)
|