Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -30,8 +30,6 @@ def generate_image(prompt, seed=24, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
|
|
| 30 |
seed = random.randint(0, MAX_SEED)
|
| 31 |
generator = torch.Generator().manual_seed(int(float(seed)))
|
| 32 |
|
| 33 |
-
start_time = time.time()
|
| 34 |
-
|
| 35 |
img = pipe.generate_images(
|
| 36 |
prompt=prompt,
|
| 37 |
width=width,
|
|
@@ -39,8 +37,7 @@ def generate_image(prompt, seed=24, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
|
|
| 39 |
num_inference_steps=DEFAULT_INFERENCE_STEPS,
|
| 40 |
generator=generator
|
| 41 |
)
|
| 42 |
-
|
| 43 |
-
return img, seed, latency
|
| 44 |
|
| 45 |
# Example prompts
|
| 46 |
examples = [
|
|
@@ -53,7 +50,6 @@ examples = [
|
|
| 53 |
"A stylish young woman with long, wavy ombre hair and winged eyeliner, posing in front of a neon-lit city skyline at night. She's wearing a sleek black leather jacket over a sparkly crop top and holding up a holographic business card that says 'Invite' in futuristic font. The card reflects the colorful neon lights, creating a cyberpunk aesthetic.",
|
| 54 |
]
|
| 55 |
|
| 56 |
-
|
| 57 |
css = """
|
| 58 |
footer {visibility: hidden;}
|
| 59 |
.container {max-width: 1200px; margin: auto; padding: 20px;}
|
|
@@ -62,7 +58,7 @@ footer {visibility: hidden;}
|
|
| 62 |
border-radius: 10px;
|
| 63 |
padding: 20px;
|
| 64 |
margin-bottom: 20px;
|
| 65 |
-
height:
|
| 66 |
display: flex;
|
| 67 |
flex-direction: column;
|
| 68 |
}
|
|
@@ -93,19 +89,15 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
| 93 |
placeholder="sexy woman & man , under wear, full body, sunday",
|
| 94 |
lines=3,
|
| 95 |
)
|
| 96 |
-
|
| 97 |
-
generateBtn = gr.Button("Generate Image", variant="primary")
|
| 98 |
-
enhanceBtn = gr.Button("Enhance Image", variant="secondary")
|
| 99 |
-
|
| 100 |
-
latency = gr.Text(label="Generation Time")
|
| 101 |
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
with gr.Column(elem_classes="examples-gallery"):
|
| 111 |
gr.Markdown("### Gallery")
|
|
@@ -113,21 +105,14 @@ with gr.Blocks(theme="Nymbo/Nymbo_Theme", css=css) as demo:
|
|
| 113 |
examples=examples,
|
| 114 |
fn=generate_image,
|
| 115 |
inputs=[prompt],
|
| 116 |
-
outputs=[result, seed
|
| 117 |
cache_examples="lazy"
|
| 118 |
)
|
| 119 |
|
| 120 |
-
enhanceBtn.click(
|
| 121 |
-
fn=generate_image,
|
| 122 |
-
inputs=[prompt, seed, width, height],
|
| 123 |
-
outputs=[result, seed, latency],
|
| 124 |
-
show_progress="full",
|
| 125 |
-
)
|
| 126 |
-
|
| 127 |
generateBtn.click(
|
| 128 |
fn=generate_image,
|
| 129 |
inputs=[prompt, seed, width, height, randomize_seed],
|
| 130 |
-
outputs=[result, seed
|
| 131 |
show_progress="full",
|
| 132 |
api_name="GenerateImage",
|
| 133 |
)
|
|
|
|
| 30 |
seed = random.randint(0, MAX_SEED)
|
| 31 |
generator = torch.Generator().manual_seed(int(float(seed)))
|
| 32 |
|
|
|
|
|
|
|
| 33 |
img = pipe.generate_images(
|
| 34 |
prompt=prompt,
|
| 35 |
width=width,
|
|
|
|
| 37 |
num_inference_steps=DEFAULT_INFERENCE_STEPS,
|
| 38 |
generator=generator
|
| 39 |
)
|
| 40 |
+
return img, seed
|
|
|
|
| 41 |
|
| 42 |
# Example prompts
|
| 43 |
examples = [
|
|
|
|
| 50 |
"A stylish young woman with long, wavy ombre hair and winged eyeliner, posing in front of a neon-lit city skyline at night. She's wearing a sleek black leather jacket over a sparkly crop top and holding up a holographic business card that says 'Invite' in futuristic font. The card reflects the colorful neon lights, creating a cyberpunk aesthetic.",
|
| 51 |
]
|
| 52 |
|
|
|
|
| 53 |
css = """
|
| 54 |
footer {visibility: hidden;}
|
| 55 |
.container {max-width: 1200px; margin: auto; padding: 20px;}
|
|
|
|
| 58 |
border-radius: 10px;
|
| 59 |
padding: 20px;
|
| 60 |
margin-bottom: 20px;
|
| 61 |
+
height: 600px; /* 고정된 높이 설정 */
|
| 62 |
display: flex;
|
| 63 |
flex-direction: column;
|
| 64 |
}
|
|
|
|
| 89 |
placeholder="sexy woman & man , under wear, full body, sunday",
|
| 90 |
lines=3,
|
| 91 |
)
|
| 92 |
+
generateBtn = gr.Button("Generate Image", variant="primary")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
|
| 94 |
+
with gr.Column(elem_classes="advanced-options"):
|
| 95 |
+
with gr.Row():
|
| 96 |
+
seed = gr.Number(label="Seed", value=42)
|
| 97 |
+
randomize_seed = gr.Checkbox(label="Randomize Seed", value=True)
|
| 98 |
+
with gr.Row():
|
| 99 |
+
width = gr.Slider(label="Width", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=DEFAULT_WIDTH)
|
| 100 |
+
height = gr.Slider(label="Height", minimum=256, maximum=MAX_IMAGE_SIZE, step=32, value=DEFAULT_HEIGHT)
|
| 101 |
|
| 102 |
with gr.Column(elem_classes="examples-gallery"):
|
| 103 |
gr.Markdown("### Gallery")
|
|
|
|
| 105 |
examples=examples,
|
| 106 |
fn=generate_image,
|
| 107 |
inputs=[prompt],
|
| 108 |
+
outputs=[result, seed],
|
| 109 |
cache_examples="lazy"
|
| 110 |
)
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
generateBtn.click(
|
| 113 |
fn=generate_image,
|
| 114 |
inputs=[prompt, seed, width, height, randomize_seed],
|
| 115 |
+
outputs=[result, seed],
|
| 116 |
show_progress="full",
|
| 117 |
api_name="GenerateImage",
|
| 118 |
)
|