Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,13 +17,17 @@ translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
|
|
17 |
# ๊ณ ์ ๋ ๋ค๊ฑฐํฐ๋ธ ํ๋กฌํํธ
|
18 |
negative_prompt = "blur, low quality, bad composition, ugly, disfigured, weird colors, low quality, jpeg artifacts, lowres, grainy, deformed structures, blurry, opaque, low contrast, distorted details, details are low"
|
19 |
|
20 |
-
#
|
21 |
def generate_image(prompt, negative_prompt):
|
22 |
headers = {
|
23 |
"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"
|
24 |
}
|
25 |
data = {
|
26 |
-
"inputs":
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
api_url = "https://api-inference.huggingface.co/models/fluently/Fluently-XL-Final"
|
29 |
response = requests.post(api_url, headers=headers, json=data)
|
@@ -34,19 +38,8 @@ def generate_image(prompt, negative_prompt):
|
|
34 |
logging.error(f"API ์์ฒญ์ ์คํจํ์ต๋๋ค: {response.text}")
|
35 |
return None
|
36 |
|
37 |
-
#
|
38 |
-
def translate_prompt(prompt):
|
39 |
-
logging.debug(f'ํ๋กฌํํธ ๋ฒ์ญ ์ค: {prompt}')
|
40 |
-
translation = translator(prompt, max_length=512)
|
41 |
-
translated_text = translation[0]['translation_text']
|
42 |
-
logging.debug(f'๋ฒ์ญ๋ ํ
์คํธ: {translated_text}')
|
43 |
-
return translated_text
|
44 |
-
|
45 |
-
# ๋์ค์ฝ๋ ๋ด ํด๋์ค
|
46 |
class MyClient(discord.Client):
|
47 |
-
async def on_ready(self):
|
48 |
-
logging.info(f'{self.user}๋ก ๋ก๊ทธ์ธ๋์์ต๋๋ค!')
|
49 |
-
|
50 |
async def on_message(self, message):
|
51 |
if message.author == self.user:
|
52 |
return
|
@@ -72,7 +65,7 @@ class MyClient(discord.Client):
|
|
72 |
# "!image" ๋ช
๋ น์ด๊ฐ ์๋ ๊ฒฝ์ฐ ์๋ด ๋ฉ์์ง ์ ์ก
|
73 |
await message.channel.send('์ฌ๋ฐ๋ฅธ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์. ์) "!image ๊ท์ฌ์ด ๊ณ ์์ด๊ฐ ์ ์ ์๊ณ ์๋ค." ๋ฑ์ผ๋ก ์
๋ ฅํ์๋ฉด ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.')
|
74 |
|
75 |
-
#
|
76 |
if __name__ == "__main__":
|
77 |
discord_token = os.getenv('DISCORD_TOKEN')
|
78 |
discord_client = MyClient(intents=intents)
|
|
|
17 |
# ๊ณ ์ ๋ ๋ค๊ฑฐํฐ๋ธ ํ๋กฌํํธ
|
18 |
negative_prompt = "blur, low quality, bad composition, ugly, disfigured, weird colors, low quality, jpeg artifacts, lowres, grainy, deformed structures, blurry, opaque, low contrast, distorted details, details are low"
|
19 |
|
20 |
+
# ์ด๋ฏธ์ง ์์ฑ ๋ฐ ์๋ต ์ฒ๋ฆฌ ํจ์
|
21 |
def generate_image(prompt, negative_prompt):
|
22 |
headers = {
|
23 |
"Authorization": f"Bearer {os.getenv('HF_TOKEN')}"
|
24 |
}
|
25 |
data = {
|
26 |
+
"inputs": {
|
27 |
+
"prompt": prompt,
|
28 |
+
"negative_prompt": negative_prompt,
|
29 |
+
"num_inference_steps": 50
|
30 |
+
}
|
31 |
}
|
32 |
api_url = "https://api-inference.huggingface.co/models/fluently/Fluently-XL-Final"
|
33 |
response = requests.post(api_url, headers=headers, json=data)
|
|
|
38 |
logging.error(f"API ์์ฒญ์ ์คํจํ์ต๋๋ค: {response.text}")
|
39 |
return None
|
40 |
|
41 |
+
# ๋์ค์ฝ๋ ๋ฉ์์ง ์ด๋ฒคํธ ์ฒ๋ฆฌ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
class MyClient(discord.Client):
|
|
|
|
|
|
|
43 |
async def on_message(self, message):
|
44 |
if message.author == self.user:
|
45 |
return
|
|
|
65 |
# "!image" ๋ช
๋ น์ด๊ฐ ์๋ ๊ฒฝ์ฐ ์๋ด ๋ฉ์์ง ์ ์ก
|
66 |
await message.channel.send('์ฌ๋ฐ๋ฅธ ๋ช
๋ น์ด๋ฅผ ์
๋ ฅํด ์ฃผ์ธ์. ์) "!image ๊ท์ฌ์ด ๊ณ ์์ด๊ฐ ์ ์ ์๊ณ ์๋ค." ๋ฑ์ผ๋ก ์
๋ ฅํ์๋ฉด ์ด๋ฏธ์ง๊ฐ ์์ฑ๋ฉ๋๋ค.')
|
67 |
|
68 |
+
# ๋ด ์คํ
|
69 |
if __name__ == "__main__":
|
70 |
discord_token = os.getenv('DISCORD_TOKEN')
|
71 |
discord_client = MyClient(intents=intents)
|