Update app.py
Browse files
app.py
CHANGED
@@ -309,39 +309,27 @@ footer {display: none}
|
|
309 |
}
|
310 |
"""
|
311 |
|
312 |
-
|
313 |
-
prompt_enhancer = pipeline(
|
314 |
-
"text-generation",
|
315 |
-
model="CohereForAI/c4ai-command-r-plus-08-2024",
|
316 |
-
token=HF_TOKEN
|
317 |
-
)
|
318 |
-
except Exception as e:
|
319 |
-
print(f"Error initializing prompt enhancer: {str(e)}")
|
320 |
-
prompt_enhancer = None
|
321 |
|
322 |
def enhance_prompt(prompt: str) -> str:
|
323 |
"""ํ๋กฌํํธ๋ฅผ ์ ๋๋ฉ์ด์
์คํ์ผ๋ก ์ฆ๊ฐ"""
|
324 |
try:
|
325 |
-
if prompt_enhancer is None:
|
326 |
-
return prompt
|
327 |
-
|
328 |
-
base_prompt = f"Convert this into a detailed anime-style image prompt: {prompt}"
|
329 |
-
messages = [{"role": "user", "content": base_prompt}]
|
330 |
-
|
331 |
-
response = prompt_enhancer(messages)
|
332 |
-
enhanced = response[0]['generated_text']
|
333 |
-
|
334 |
# ๊ธฐ๋ณธ ํ์ง ํฅ์ ํ๋กฌํํธ ์ถ๊ฐ
|
335 |
enhancements = [
|
336 |
"masterpiece, best quality, highly detailed",
|
337 |
"anime style, animation style",
|
338 |
"vibrant colors, perfect lighting",
|
339 |
"professional composition",
|
|
|
|
|
340 |
"[trigger]"
|
341 |
]
|
342 |
|
|
|
|
|
|
|
343 |
# ์ต์ข
ํ๋กฌํํธ ๊ตฌ์ฑ
|
344 |
-
final_prompt = f"{
|
345 |
print(f"Enhanced prompt: {final_prompt}")
|
346 |
|
347 |
return final_prompt
|
@@ -349,6 +337,14 @@ def enhance_prompt(prompt: str) -> str:
|
|
349 |
print(f"Prompt enhancement failed: {str(e)}")
|
350 |
return prompt
|
351 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
353 |
gr.HTML("""
|
354 |
<div class="main-title">
|
|
|
309 |
}
|
310 |
"""
|
311 |
|
312 |
+
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
|
314 |
def enhance_prompt(prompt: str) -> str:
|
315 |
"""ํ๋กฌํํธ๋ฅผ ์ ๋๋ฉ์ด์
์คํ์ผ๋ก ์ฆ๊ฐ"""
|
316 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
# ๊ธฐ๋ณธ ํ์ง ํฅ์ ํ๋กฌํํธ ์ถ๊ฐ
|
318 |
enhancements = [
|
319 |
"masterpiece, best quality, highly detailed",
|
320 |
"anime style, animation style",
|
321 |
"vibrant colors, perfect lighting",
|
322 |
"professional composition",
|
323 |
+
"dynamic pose, expressive features",
|
324 |
+
"detailed background, perfect shadows",
|
325 |
"[trigger]"
|
326 |
]
|
327 |
|
328 |
+
# ์ ๋๋ฉ์ด์
์คํ์ผ ํ๋กฌํํธ ๋ณํ
|
329 |
+
anime_style_prompt = f"an animated {prompt}, detailed anime art style"
|
330 |
+
|
331 |
# ์ต์ข
ํ๋กฌํํธ ๊ตฌ์ฑ
|
332 |
+
final_prompt = f"{anime_style_prompt}, {', '.join(enhancements)}"
|
333 |
print(f"Enhanced prompt: {final_prompt}")
|
334 |
|
335 |
return final_prompt
|
|
|
337 |
print(f"Prompt enhancement failed: {str(e)}")
|
338 |
return prompt
|
339 |
|
340 |
+
# ๊ธฐ์กด์ pipeline ์ด๊ธฐํ ๋ถ๋ถ ์ ๊ฑฐ
|
341 |
+
# try:
|
342 |
+
# prompt_enhancer = pipeline(...)
|
343 |
+
# except Exception as e:
|
344 |
+
# print(f"Error initializing prompt enhancer: {str(e)}")
|
345 |
+
# prompt_enhancer = None
|
346 |
+
|
347 |
+
|
348 |
with gr.Blocks(theme=gr.themes.Soft(), css=css) as demo:
|
349 |
gr.HTML("""
|
350 |
<div class="main-title">
|