shivi commited on
Commit
dd84e9d
1 Parent(s): 78491d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -12,17 +12,19 @@ loaded_diffusion_model = from_pretrained_keras("shivi/dreambooth_diffusion_model
12
  dreambooth_model._diffusion_model = loaded_diffusion_model
13
 
14
 
15
- def generate_images(prompt: str, num_imgs_to_gen: int):
16
  """
17
  This function is used to generate images using our fine-tuned keras dreambooth stable diffusion model.
18
  Args:
19
  prompt (str): The text input given by the user based on which images will be generated.
20
  num_imgs_to_gen (int): The number of images to be generated using given prompt.
 
21
  Returns:
22
- all_images (List): List of images that were generated using the model
23
  """
24
  generated_img = dreambooth_model.text_to_image(
25
- prompt, batch_size=num_imgs_to_gen
 
26
  )
27
 
28
  return generated_img
@@ -36,17 +38,18 @@ with gr.Blocks() as demo:
36
  with gr.Column():
37
  prompt = gr.Textbox(label="prompt")
38
  samples = gr.Slider(label="No. of Images",value=1)
 
39
  run = gr.Button(value="Run")
40
  with gr.Column():
41
  gallery = gr.Gallery(show_label=False)
42
 
43
- run.click(generate_images, inputs=[prompt,samples], outputs=gallery)
44
 
45
- gr.Examples([["A flower vase inspired by pink floyd division bell album cover", 1],
46
- ["A pendant in the style of pink floyd division bell album cover",1],
47
- ["A human skull inspired by pink floyd division bell album cover ",1],
48
- ["picture of pink floyd division bell album cover with a starry night on Mars theme", 1]],
49
- [prompt,samples], gallery, generate_images, cache_examples=False)
50
 
51
  gr.Markdown("Some fun examples I created while playing with the model:")
52
  gr.Markdown("![Example 1](sample_outputs/1.png)")
 
12
  dreambooth_model._diffusion_model = loaded_diffusion_model
13
 
14
 
15
+ def generate_images(prompt: str, num_imgs_to_gen: int, num_steps: int):
16
  """
17
  This function is used to generate images using our fine-tuned keras dreambooth stable diffusion model.
18
  Args:
19
  prompt (str): The text input given by the user based on which images will be generated.
20
  num_imgs_to_gen (int): The number of images to be generated using given prompt.
21
+ num_steps (int): The number of denoising steps
22
  Returns:
23
+ generated_img (List): List of images that were generated using the model
24
  """
25
  generated_img = dreambooth_model.text_to_image(
26
+ prompt, batch_size=num_imgs_to_gen,
27
+ num_steps=num_steps,
28
  )
29
 
30
  return generated_img
 
38
  with gr.Column():
39
  prompt = gr.Textbox(label="prompt")
40
  samples = gr.Slider(label="No. of Images",value=1)
41
+ num_steps = gr.Slider(label="Inference Steps",value=50)
42
  run = gr.Button(value="Run")
43
  with gr.Column():
44
  gallery = gr.Gallery(show_label=False)
45
 
46
+ run.click(generate_images, inputs=[prompt,samples, num_steps], outputs=gallery)
47
 
48
+ gr.Examples([["A flower vase inspired by pink floyd division bell album cover", 1,50],
49
+ ["A pendant in the style of pink floyd division bell album cover",1, 50],
50
+ ["A human skull inspired by pink floyd division bell album cover ",1,50],
51
+ ["pink floyd division bell album cover with a starry night on Mars background", 1,50]],
52
+ [prompt,samples,num_steps], gallery, generate_images, cache_examples=False)
53
 
54
  gr.Markdown("Some fun examples I created while playing with the model:")
55
  gr.Markdown("![Example 1](sample_outputs/1.png)")