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,