Spaces:
Running
on
Zero
Running
on
Zero
Change model and employ Gradio Blocks for better app layout
Browse files
app.py
CHANGED
|
@@ -9,7 +9,7 @@ import gradio as gr
|
|
| 9 |
hf_api_key = os.environ['HF_API_KEY']
|
| 10 |
|
| 11 |
# Text-to-image endpoint
|
| 12 |
-
get_completion = pipeline("ner", model="
|
| 13 |
|
| 14 |
|
| 15 |
# A helper function to convert the PIL image to base64,
|
|
@@ -25,18 +25,27 @@ def generate(prompt):
|
|
| 25 |
result_image = base64_to_pil(output)
|
| 26 |
return result_image
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
demo.launch(
|
| 40 |
share=True,
|
| 41 |
-
#server_port=int(os.environ['
|
| 42 |
)
|
|
|
|
| 9 |
hf_api_key = os.environ['HF_API_KEY']
|
| 10 |
|
| 11 |
# Text-to-image endpoint
|
| 12 |
+
get_completion = pipeline("ner", model="stable-diffusion-v1-5/stable-diffusion-v1-5")
|
| 13 |
|
| 14 |
|
| 15 |
# A helper function to convert the PIL image to base64,
|
|
|
|
| 25 |
result_image = base64_to_pil(output)
|
| 26 |
return result_image
|
| 27 |
|
| 28 |
+
|
| 29 |
+
with gr.Blocks() as demo:
|
| 30 |
+
gr.Markdown("# Image Generation with Stable Diffusion")
|
| 31 |
+
prompt = gr.Textbox(label="Your prompt")
|
| 32 |
+
|
| 33 |
+
with gr.Row():
|
| 34 |
+
with gr.Column():
|
| 35 |
+
negative_prompt = gr.Textbox(label="Negative prompt")
|
| 36 |
+
steps = gr.Slider(label="Inference Steps", minimum=1, maximum=100, value=25,
|
| 37 |
+
info="In many steps will the denoiser denoise the image?")
|
| 38 |
+
guidance = gr.Slider(label="Guidance Scale", minimum=1, maximum=20, value=7,
|
| 39 |
+
info="Controls how much the text prompt influences the result")
|
| 40 |
+
width = gr.Slider(label="Width", minimum=64, maximum=512, step=64, value=512)
|
| 41 |
+
height = gr.Slider(label="Height", minimum=64, maximum=512, step=64, value=512)
|
| 42 |
+
btn = gr.Button("Submit")
|
| 43 |
+
with gr.Column():
|
| 44 |
+
output = gr.Image(label="Result")
|
| 45 |
+
|
| 46 |
+
btn.click(fn=generate, inputs=[prompt,negative_prompt,steps,guidance,width,height], outputs=[output])
|
| 47 |
|
| 48 |
demo.launch(
|
| 49 |
share=True,
|
| 50 |
+
#server_port=int(os.environ['PORT3'])
|
| 51 |
)
|