seawolf2357 commited on
Commit
75b9ca0
1 Parent(s): fc74fc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,7 +3,7 @@ import logging
3
  import os
4
  import asyncio
5
  import subprocess
6
- from huggingface_hub import InferenceApi
7
  import base64
8
  from PIL import Image
9
  import io
@@ -19,7 +19,7 @@ intents.guilds = True
19
  intents.guild_messages = True
20
 
21
  # 추론 API 클라이언트 설정
22
- hf_client = InferenceApi("stabilityai/stable-diffusion-3-medium", token=os.getenv("HF_TOKEN"))
23
 
24
  # 특정 채널 ID
25
  SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
@@ -53,8 +53,8 @@ class MyClient(discord.Client):
53
 
54
  async def generate_image(prompt):
55
  try:
56
- response = hf_client(payload={"inputs": prompt})
57
- image_data = response.get('image') # Assuming the response returns an image key
58
  image_bytes = io.BytesIO(base64.b64decode(image_data))
59
  image = Image.open(image_bytes)
60
  image_path = "output.png"
 
3
  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
 
19
  intents.guild_messages = True
20
 
21
  # 추론 API 클라이언트 설정
22
+ hf_client = InferenceClient(api_token=os.getenv("HF_TOKEN"), model_id="stabilityai/stable-diffusion-3-medium")
23
 
24
  # 특정 채널 ID
25
  SPECIFIC_CHANNEL_ID = int(os.getenv("DISCORD_CHANNEL_ID"))
 
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(base64.b64decode(image_data))
59
  image = Image.open(image_bytes)
60
  image_path = "output.png"