openfree commited on
Commit
b885f28
ยท
verified ยท
1 Parent(s): 783b884

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -19
app.py CHANGED
@@ -309,39 +309,27 @@ footer {display: none}
309
  }
310
  """
311
 
312
- try:
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"{enhanced}, {', '.join(enhancements)}"
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">