Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -27,4 +27,26 @@ def generate_image_sd(prompt: str, negative_prompt: str, guidance_scale: float,
|
|
| 27 |
raise RuntimeError("No image was returned from the generation pipeline.")
|
| 28 |
|
| 29 |
print(f"Image generated in {end_time - start_time:.2f} seconds.")
|
| 30 |
-
return image
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
raise RuntimeError("No image was returned from the generation pipeline.")
|
| 28 |
|
| 29 |
print(f"Image generated in {end_time - start_time:.2f} seconds.")
|
| 30 |
+
return image
|
| 31 |
+
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 32 |
+
with gr.Row():
|
| 33 |
+
with gr.Column(scale=1):
|
| 34 |
+
prompt = gr.Textbox(label="Prompt", placeholder="A beautiful futuristic city skyline at night")
|
| 35 |
+
neg_prompt = gr.Textbox(label="Negative Prompt", placeholder="blurry, distorted, watermark")
|
| 36 |
+
guidance = gr.Slider(1.0, 15.0, value=7.5, step=0.5, label="Guidance Scale")
|
| 37 |
+
steps = gr.Slider(10, 50, value=25, step=1, label="Inference Steps")
|
| 38 |
+
generate_btn = gr.Button("Generate Image")
|
| 39 |
+
|
| 40 |
+
with gr.Column(scale=1):
|
| 41 |
+
output_image = gr.Image(label="Generated Image", type="pil")
|
| 42 |
+
|
| 43 |
+
generate_btn.click(
|
| 44 |
+
fn=generate_image_sd,
|
| 45 |
+
inputs=[prompt, neg_prompt, guidance, steps],
|
| 46 |
+
outputs=output_image
|
| 47 |
+
)
|
| 48 |
+
|
| 49 |
+
if __name__ == "__main__":
|
| 50 |
+
if not image_generator_pipe:
|
| 51 |
+
print("WARNING: Image generator pipeline is not available. UI will launch, but generation will fail.")
|
| 52 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|