bharat-raghunathan commited on
Commit
01a0214
1 Parent(s): eb998ed

Reduce to one example, add mixed prec + jit compile

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -1,9 +1,12 @@
1
  from huggingface_hub import from_pretrained_keras
2
  from keras_cv import models
3
  import gradio as gr
 
 
 
4
 
5
  sd_dreambooth_model = models.StableDiffusion(
6
- img_width=512, img_height=512
7
  )
8
  db_diffusion_model = from_pretrained_keras("keras-dreambooth/dreambooth_dosa")
9
  sd_dreambooth_model._diffusion_model = db_diffusion_model
@@ -17,7 +20,7 @@ def generate_images(prompt, negative_prompt, num_imgs_to_gen, num_steps, guidanc
17
  num_steps=num_steps,
18
  unconditional_guidance_scale=guidance_scale
19
  )
20
- return generated_images
21
 
22
  with gr.Blocks() as demo:
23
  gr.HTML("<h2 style=\"font-size: 2em; font-weight: bold\" align=\"center\">Keras Dreambooth - The Humble Dosa</h2>")
@@ -35,10 +38,7 @@ with gr.Blocks() as demo:
35
 
36
  run.click(fn=generate_images, inputs=[prompt, negative_prompt, samples, num_steps, guidance_scale], outputs=gallery)
37
 
38
- gr.Examples([["realistic picture of a man eating a bhr dosa", "home", 1, 50, 7.5],
39
- ["realistic picture of a bhr dosa on a plate", "chutney", 1, 50, 7.5],
40
- ["realistic picture of a bhr dosa in a restaurant", "sambar", 1, 50, 7.5],
41
- ],
42
  [prompt, negative_prompt, samples, num_steps, guidance_scale], gallery, generate_images, cache_examples=True)
43
  gr.Markdown('Demo created by [Bharat Raghunathan](https://huggingface.co/bharat-raghunathan/)')
44
  # pass function, input type for prompt, the output for multiple images
 
1
  from huggingface_hub import from_pretrained_keras
2
  from keras_cv import models
3
  import gradio as gr
4
+ from tensorflow import keras
5
+
6
+ keras.mixed_precision.set_global_policy("mixed_float16")
7
 
8
  sd_dreambooth_model = models.StableDiffusion(
9
+ img_width=512, img_height=512, jit_compile=True
10
  )
11
  db_diffusion_model = from_pretrained_keras("keras-dreambooth/dreambooth_dosa")
12
  sd_dreambooth_model._diffusion_model = db_diffusion_model
 
20
  num_steps=num_steps,
21
  unconditional_guidance_scale=guidance_scale
22
  )
23
+ return generated_images
24
 
25
  with gr.Blocks() as demo:
26
  gr.HTML("<h2 style=\"font-size: 2em; font-weight: bold\" align=\"center\">Keras Dreambooth - The Humble Dosa</h2>")
 
38
 
39
  run.click(fn=generate_images, inputs=[prompt, negative_prompt, samples, num_steps, guidance_scale], outputs=gallery)
40
 
41
+ gr.Examples([["realistic picture of a bhr dosa in a restaurant", "sambar", 1, 50, 7.5]],
 
 
 
42
  [prompt, negative_prompt, samples, num_steps, guidance_scale], gallery, generate_images, cache_examples=True)
43
  gr.Markdown('Demo created by [Bharat Raghunathan](https://huggingface.co/bharat-raghunathan/)')
44
  # pass function, input type for prompt, the output for multiple images