ginipick commited on
Commit
9d8567b
Β·
verified Β·
1 Parent(s): af7c62b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -32
app.py CHANGED
@@ -9,7 +9,7 @@ from diffusers import DiffusionPipeline
9
  from custom_pipeline import FLUXPipelineWithIntermediateOutputs
10
  from transformers import pipeline
11
 
12
- # λ²ˆμ—­ λͺ¨λΈ λ‘œλ“œ
13
  translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
14
 
15
  # Constants
@@ -26,18 +26,18 @@ pipe = FLUXPipelineWithIntermediateOutputs.from_pretrained(
26
  ).to("cuda")
27
  torch.cuda.empty_cache()
28
 
29
- # ν•œκΈ€ 메뉴 이름 dictionary
30
- korean_labels = {
31
- "Generated Image": "μƒμ„±λœ 이미지",
32
- "Prompt": "ν”„λ‘¬ν”„νŠΈ",
33
- "Enhance Image": "이미지 ν–₯상",
34
- "Advanced Options": "κ³ κΈ‰ μ˜΅μ…˜",
35
- "Seed": "μ‹œλ“œ",
36
- "Randomize Seed": "μ‹œλ“œ λ¬΄μž‘μœ„ν™”",
37
- "Width": "λ„ˆλΉ„",
38
- "Height": "높이",
39
- "Inference Steps": "μΆ”λ‘  단계",
40
- "Inspiration Gallery": "영감 가러리"
41
  }
42
 
43
  def translate_if_korean(text):
@@ -66,17 +66,17 @@ def generate_image(prompt, seed=42, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
66
  height=height,
67
  generator=generator
68
  ):
69
- latency = f"처리 μ‹œκ°„: {(time.time()-start_time):.2f} 초"
70
  yield img, seed, latency
71
 
72
- # Example prompts
73
  examples = [
74
- "λ‹¬μ—μ„œ μ•Œμ—μ„œ λΆ€ν™”ν•˜λŠ” μž‘μ€ 우주 비행사",
75
- "μ•ˆλ…•ν•˜μ„Έμš” 세상이라고 쓰인 ν‘œμ§€νŒμ„ λ“€κ³  μžˆλŠ” 고양이",
76
- "λΉ„λ„ˆ μŠˆλ‹ˆμ²Όμ˜ μ• λ‹ˆλ©”μ΄μ…˜ μΌλŸ¬μŠ€νŠΈλ ˆμ΄μ…˜",
77
- "ν•˜λŠ˜μ„ λ‚˜λŠ” μžλ™μ°¨μ™€ λ„€μ˜¨ λΆˆλΉ›μ΄ μžˆλŠ” 미래적인 λ„μ‹œ 풍경",
78
- "κΈ΄ κ°ˆμƒ‰ μ›¨μ΄λΈŒ 머리λ₯Ό 올렀 λ¬Άκ³  μ•ˆκ²½μ„ μ“΄ μ Šμ€ μ—¬μ„±μ˜ 사진. κ·Έλ…€λŠ” 흰 피뢀에 눈과 μž…μˆ μ„ κ°•μ‘°ν•œ μ€μ€ν•œ ν™”μž₯을 ν–ˆμŠ΅λ‹ˆλ‹€. κ·Έλ…€λŠ” 검은색 μƒμ˜λ₯Ό μž…μ—ˆμŠ΅λ‹ˆλ‹€. 배경은 λ„μ‹œ 건물 μ™Έκ΄€μœΌλ‘œ 보이며, 햇빛이 κ·Έλ…€μ˜ 얼꡴에 λ”°λœ»ν•œ 빛을 λΉ„μΆ”κ³  μžˆμŠ΅λ‹ˆλ‹€.",
79
- "μŠ€ν‹°λΈŒ 작슀λ₯Ό μŠ€νƒ€μ›Œμ¦ˆ μ˜ν™” μΊλ¦­ν„°λ‘œ μƒμƒν•΄λ³΄μ„Έμš”"
80
  ]
81
 
82
  css = """
@@ -91,30 +91,30 @@ with gr.Blocks(theme="Yntec/HaleyCH_Theme_Orange", css=css) as demo:
91
 
92
  with gr.Row():
93
  with gr.Column(scale=3):
94
- result = gr.Image(label=korean_labels["Generated Image"], show_label=False, interactive=False)
95
  with gr.Column(scale=1):
96
  prompt = gr.Text(
97
- label=korean_labels["Prompt"],
98
- placeholder="μƒμ„±ν•˜κ³  싢은 이미지λ₯Ό μ„€λͺ…ν•˜μ„Έμš”...",
99
  lines=3,
100
  show_label=False,
101
  container=False,
102
  )
103
- enhanceBtn = gr.Button(f"πŸš€ {korean_labels['Enhance Image']}")
104
 
105
- with gr.Column(korean_labels["Advanced Options"]):
106
  with gr.Row():
107
  latency = gr.Text(show_label=False)
108
  with gr.Row():
109
- seed = gr.Number(label=korean_labels["Seed"], value=42, precision=0)
110
- randomize_seed = gr.Checkbox(label=korean_labels["Randomize Seed"], value=False)
111
  with gr.Row():
112
- width = gr.Slider(label=korean_labels["Width"], minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=DEFAULT_WIDTH)
113
- height = gr.Slider(label=korean_labels["Height"], minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=DEFAULT_HEIGHT)
114
- num_inference_steps = gr.Slider(label=korean_labels["Inference Steps"], minimum=1, maximum=4, step=1, value=DEFAULT_INFERENCE_STEPS)
115
 
116
  with gr.Row():
117
- gr.Markdown(f"### 🌟 {korean_labels['Inspiration Gallery']}")
118
  with gr.Row():
119
  gr.Examples(
120
  examples=examples,
 
9
  from custom_pipeline import FLUXPipelineWithIntermediateOutputs
10
  from transformers import pipeline
11
 
12
+ # Translation model loading
13
  translator = pipeline("translation", model="Helsinki-NLP/opus-mt-ko-en")
14
 
15
  # Constants
 
26
  ).to("cuda")
27
  torch.cuda.empty_cache()
28
 
29
+ # Menu labels dictionary
30
+ english_labels = {
31
+ "Generated Image": "Generated Image",
32
+ "Prompt": "Prompt",
33
+ "Enhance Image": "Enhance Image",
34
+ "Advanced Options": "Advanced Options",
35
+ "Seed": "Seed",
36
+ "Randomize Seed": "Randomize Seed",
37
+ "Width": "Width",
38
+ "Height": "Height",
39
+ "Inference Steps": "Inference Steps",
40
+ "Inspiration Gallery": "Inspiration Gallery"
41
  }
42
 
43
  def translate_if_korean(text):
 
66
  height=height,
67
  generator=generator
68
  ):
69
+ latency = f"Processing Time: {(time.time()-start_time):.2f} seconds"
70
  yield img, seed, latency
71
 
72
+ # Example prompts (keeping one Korean example)
73
  examples = [
74
+ "λΉ„λ„ˆ μŠˆλ‹ˆμ²Όμ˜ μ• λ‹ˆλ©”μ΄μ…˜ μΌλŸ¬μŠ€νŠΈλ ˆμ΄μ…˜", # Keeping this Korean example
75
+ "A steampunk owl wearing Victorian-era clothing and reading a mechanical book",
76
+ "A floating island made of books with waterfalls of knowledge cascading down",
77
+ "A bioluminescent forest where mushrooms glow like neon signs in a cyberpunk city",
78
+ "An ancient temple being reclaimed by nature, with robots performing archaeology",
79
+ "A cosmic coffee shop where baristas are constellations serving drinks made of stardust"
80
  ]
81
 
82
  css = """
 
91
 
92
  with gr.Row():
93
  with gr.Column(scale=3):
94
+ result = gr.Image(label=english_labels["Generated Image"], show_label=False, interactive=False)
95
  with gr.Column(scale=1):
96
  prompt = gr.Text(
97
+ label=english_labels["Prompt"],
98
+ placeholder="Describe the image you want to generate...",
99
  lines=3,
100
  show_label=False,
101
  container=False,
102
  )
103
+ enhanceBtn = gr.Button(f"πŸš€ {english_labels['Enhance Image']}")
104
 
105
+ with gr.Column(english_labels["Advanced Options"]):
106
  with gr.Row():
107
  latency = gr.Text(show_label=False)
108
  with gr.Row():
109
+ seed = gr.Number(label=english_labels["Seed"], value=42, precision=0)
110
+ randomize_seed = gr.Checkbox(label=english_labels["Randomize Seed"], value=False)
111
  with gr.Row():
112
+ width = gr.Slider(label=english_labels["Width"], minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=DEFAULT_WIDTH)
113
+ height = gr.Slider(label=english_labels["Height"], minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=DEFAULT_HEIGHT)
114
+ num_inference_steps = gr.Slider(label=english_labels["Inference Steps"], minimum=1, maximum=4, step=1, value=DEFAULT_INFERENCE_STEPS)
115
 
116
  with gr.Row():
117
+ gr.Markdown(f"### 🌟 {english_labels['Inspiration Gallery']}")
118
  with gr.Row():
119
  gr.Examples(
120
  examples=examples,