Spaces:
ginigen
/
Running on Zero

ginipick commited on
Commit
ea5a353
ยท
verified ยท
1 Parent(s): cb7718b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -12
app.py CHANGED
@@ -8,9 +8,6 @@ translator = translation_pipeline("translation", model="Helsinki-NLP/opus-mt-ko-
8
  # Diffusers ๋ชจ๋ธ ๋กœ๋“œ
9
  from diffusers import DiffusionPipeline
10
 
11
- # -- Stable Diffusion ๊ณ„์—ด ํŒŒ์ดํ”„๋ผ์ธ ์„ค์ • --
12
- # (๋ชจ๋ธ ์˜ˆ์‹œ: black-forest-labs/FLUX.1-schnell -> ๋งˆ์ธ๋“œ๋งต์šฉ์œผ๋กœ ์ปค์Šคํ…€๋œ ๋ชจ๋ธ์ด์ง€๋งŒ,
13
- # ์—ฌ๊ธฐ์„œ๋Š” "์Šคํ† ๋ฆฌ๋ณด๋“œ" ์Šคํƒ€์ผ ํ”„๋กฌํ”„ํŠธ๋„ ์‹œ๋„ ๊ฐ€๋Šฅ)
14
  model_id = "black-forest-labs/FLUX.1-schnell"
15
 
16
  pipe = DiffusionPipeline.from_pretrained(
@@ -18,10 +15,7 @@ pipe = DiffusionPipeline.from_pretrained(
18
  torch_dtype=torch.float32
19
  ).to("cpu") # CPU ์‚ฌ์šฉ
20
 
21
- # ํ•œ๊ธ€ ํ”„๋กฌํ”„ํŠธ๋ฅผ ์˜์–ด๋กœ ๋ณ€ํ™˜ํ•˜๊ธฐ ์œ„ํ•œ ํ—ฌํผ ํ•จ์ˆ˜
22
  def translate_prompt_if_korean(prompt_text: str) -> str:
23
- # ๊ฐ„๋‹จํžˆ, ๋ฌธ์ž์—ด ๋‚ด์— ํ•œ๊ธ€์ด ํฌํ•จ๋˜์–ด ์žˆ๋Š”์ง€ ํ™•์ธ ํ›„ ๋ฒˆ์—ญ
24
- # (์˜์–ด ์ž…๋ ฅ์ผ ๊ฒฝ์šฐ ๋ฒˆ์—ญ์„ ์Šคํ‚ต)
25
  if any("๊ฐ€" <= ch <= "ํžฃ" for ch in prompt_text):
26
  result = translator(prompt_text)
27
  return result[0]['translation_text']
@@ -53,7 +47,6 @@ def generate_storyboard(
53
  ).images[0]
54
  return result
55
 
56
-
57
  # --- ๋น„์ฃผ์–ผ & ์„ธ๋ จ๋œ UI๋ฅผ ์œ„ํ•œ CSS ---
58
  custom_css = """
59
  #title {
@@ -94,7 +87,6 @@ custom_css = """
94
  }
95
  """
96
 
97
- # --- Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ ---
98
  with gr.Blocks(css=custom_css) as demo:
99
  gr.Markdown("<div id='title'>Gini Storyboard</div>")
100
  gr.Markdown("<div id='subtitle'>Generate a hand-drawn style storyboard in black & white film noir or any style you wish!</div>")
@@ -152,7 +144,8 @@ with gr.Blocks(css=custom_css) as demo:
152
 
153
  # ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ
154
  gr.Markdown("### Example Prompt")
155
- with gr.Box(elem_classes="example-box"):
 
156
  example_text = (
157
  "A hand-drawn storyboard style, film noir theme, black and white.\n"
158
  "SCENE 1: A detective enters a dark alley [Frame 1]\n"
@@ -162,25 +155,23 @@ with gr.Blocks(css=custom_css) as demo:
162
  gr.Markdown(f"```\n{example_text}\n```")
163
  example_button = gr.Button("Use Example")
164
 
165
- # ์˜ˆ์ œ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ํ”„๋กฌํ”„ํŠธ์— ๋ฐ˜์˜
166
  def load_example():
167
  return example_text
168
  example_button.click(fn=load_example, outputs=[prompt])
169
 
170
- # ๋ฒ„ํŠผ ํด๋ฆญ & ํ”„๋กฌํ”„ํŠธ Enter ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ
171
  run_button.click(
172
  fn=generate_storyboard,
173
  inputs=[prompt, width, height, num_inference_steps, guidance_scale, seed],
174
  outputs=[result]
175
  )
176
 
 
177
  prompt.submit(
178
  fn=generate_storyboard,
179
  inputs=[prompt, width, height, num_inference_steps, guidance_scale, seed],
180
  outputs=[result]
181
  )
182
 
183
- # ์‹คํ–‰
184
  if __name__ == "__main__":
185
  demo.queue()
186
  demo.launch(server_name="0.0.0.0", server_port=7860, share=False)
 
8
  # Diffusers ๋ชจ๋ธ ๋กœ๋“œ
9
  from diffusers import DiffusionPipeline
10
 
 
 
 
11
  model_id = "black-forest-labs/FLUX.1-schnell"
12
 
13
  pipe = DiffusionPipeline.from_pretrained(
 
15
  torch_dtype=torch.float32
16
  ).to("cpu") # CPU ์‚ฌ์šฉ
17
 
 
18
  def translate_prompt_if_korean(prompt_text: str) -> str:
 
 
19
  if any("๊ฐ€" <= ch <= "ํžฃ" for ch in prompt_text):
20
  result = translator(prompt_text)
21
  return result[0]['translation_text']
 
47
  ).images[0]
48
  return result
49
 
 
50
  # --- ๋น„์ฃผ์–ผ & ์„ธ๋ จ๋œ UI๋ฅผ ์œ„ํ•œ CSS ---
51
  custom_css = """
52
  #title {
 
87
  }
88
  """
89
 
 
90
  with gr.Blocks(css=custom_css) as demo:
91
  gr.Markdown("<div id='title'>Gini Storyboard</div>")
92
  gr.Markdown("<div id='subtitle'>Generate a hand-drawn style storyboard in black & white film noir or any style you wish!</div>")
 
144
 
145
  # ์˜ˆ์ œ ํ”„๋กฌํ”„ํŠธ
146
  gr.Markdown("### Example Prompt")
147
+ # โ†“ Box๊ฐ€ ์•„๋‹Œ Group์œผ๋กœ ๋ณ€๊ฒฝ
148
+ with gr.Group(elem_classes="example-box"):
149
  example_text = (
150
  "A hand-drawn storyboard style, film noir theme, black and white.\n"
151
  "SCENE 1: A detective enters a dark alley [Frame 1]\n"
 
155
  gr.Markdown(f"```\n{example_text}\n```")
156
  example_button = gr.Button("Use Example")
157
 
 
158
  def load_example():
159
  return example_text
160
  example_button.click(fn=load_example, outputs=[prompt])
161
 
 
162
  run_button.click(
163
  fn=generate_storyboard,
164
  inputs=[prompt, width, height, num_inference_steps, guidance_scale, seed],
165
  outputs=[result]
166
  )
167
 
168
+ # ์—”ํ„ฐ๋กœ ์ œ์ถœ ์‹œ์—๋„ ์‹คํ–‰
169
  prompt.submit(
170
  fn=generate_storyboard,
171
  inputs=[prompt, width, height, num_inference_steps, guidance_scale, seed],
172
  outputs=[result]
173
  )
174
 
 
175
  if __name__ == "__main__":
176
  demo.queue()
177
  demo.launch(server_name="0.0.0.0", server_port=7860, share=False)