Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
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 |
-
#
|
30 |
-
|
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"
|
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=
|
95 |
with gr.Column(scale=1):
|
96 |
prompt = gr.Text(
|
97 |
-
label=
|
98 |
-
placeholder="
|
99 |
lines=3,
|
100 |
show_label=False,
|
101 |
container=False,
|
102 |
)
|
103 |
-
enhanceBtn = gr.Button(f"π {
|
104 |
|
105 |
-
with gr.Column(
|
106 |
with gr.Row():
|
107 |
latency = gr.Text(show_label=False)
|
108 |
with gr.Row():
|
109 |
-
seed = gr.Number(label=
|
110 |
-
randomize_seed = gr.Checkbox(label=
|
111 |
with gr.Row():
|
112 |
-
width = gr.Slider(label=
|
113 |
-
height = gr.Slider(label=
|
114 |
-
num_inference_steps = gr.Slider(label=
|
115 |
|
116 |
with gr.Row():
|
117 |
-
gr.Markdown(f"### π {
|
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,
|