Walmart-the-bag commited on
Commit
3eb0af5
β€’
1 Parent(s): b559275

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -9
app.py CHANGED
@@ -1,6 +1,6 @@
1
  from diffusers import StableDiffusionXLPipeline
2
  import torch
3
- from gradio import Interface, Image
4
  import gradio as gr
5
  import spaces
6
 
@@ -9,16 +9,23 @@ pipe = StableDiffusionXLPipeline.from_pretrained(model_id, torch_dtype=torch.flo
9
  pipe = pipe.to("cuda")
10
 
11
  @spaces.GPU()
12
- def text_to_image(prompt, progress=gr.Progress(track_tqdm=True)):
13
- image = pipe(prompt).images [0]
14
- return image
15
 
16
 
17
  gradio_interface = Interface(
18
- fn=text_to_image,
19
- inputs="text",
20
- outputs=Image(type="pil", show_download_button=True),
21
- examples=[["person running"]],
22
- theme=gr.themes.Soft()
 
 
 
 
 
 
 
23
  )
24
  gradio_interface.launch()
 
1
  from diffusers import StableDiffusionXLPipeline
2
  import torch
3
+ from gradio import Interface, Image, Dropdown, Slider
4
  import gradio as gr
5
  import spaces
6
 
 
9
  pipe = pipe.to("cuda")
10
 
11
  @spaces.GPU()
12
+ def text_to_image(prompt, negative_prompt, steps, guidance_scale):
13
+ image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=guidance_scale).images[0]
14
+ return image
15
 
16
 
17
  gradio_interface = Interface(
18
+ fn=text_to_image,
19
+ inputs=[
20
+ gr.Textbox(label="Prompt", lines=2, placeholder="Enter your prompt here..."),
21
+ gr.Textbox(label="Negative Prompt", lines=2, placeholder="What to exclude from the image..."),
22
+ gr.Slider(minimum=1, maximum=100, value=50, label="Steps", step=1),
23
+ gr.Slider(minimum=1, maximum=20, value=7.5, label="Guidance Scale", step=0.1)
24
+ ],
25
+ outputs=Image(type="pil", show_download_button=True),
26
+ examples=[
27
+ ["magical kitten, 4k, high quality, (masterpiece)"]
28
+ ],
29
+ theme=gr.themes.Soft()
30
  )
31
  gradio_interface.launch()