chrisjcc commited on
Commit
d5037dc
·
verified ·
1 Parent(s): b36b7af

Change model and employ Gradio Blocks for better app layout

Browse files
Files changed (1) hide show
  1. app.py +21 -12
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="rupeshs/LCM-runwayml-stable-diffusion-v1-5")
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
- demo = gr.Interface(fn=generate,
29
- inputs=[gr.Textbox(label="Your prompt")],
30
- outputs=[gr.Image(label="Result")],
31
- title="Image Generation with Stable Diffusion",
32
- description="Generate any image with Stable Diffusion",
33
- allow_flagging="never",
34
- examples=[
35
- "the spirit of a tamagotchi wandering in the city of Vienna",
36
- "a mecha robot in a favela"
37
- ])
 
 
 
 
 
 
 
 
 
38
 
39
  demo.launch(
40
  share=True,
41
- #server_port=int(os.environ['PORT1'])
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
  )