Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,16 @@ from huggingface_hub import from_pretrained_keras
|
|
2 |
import keras_cv
|
3 |
import gradio as gr
|
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
def generate_images(prompt: str, num_imgs_to_gen: int):
|
6 |
"""
|
7 |
This function is used to generate images using our fine-tuned keras dreambooth stable diffusion model.
|
@@ -11,13 +21,6 @@ def generate_images(prompt: str, num_imgs_to_gen: int):
|
|
11 |
Returns:
|
12 |
all_images (List): List of images that were generated using the model
|
13 |
"""
|
14 |
-
resolution = 512
|
15 |
-
dreambooth_model = keras_cv.models.StableDiffusion(
|
16 |
-
img_width=resolution, img_height=resolution, jit_compile=True,
|
17 |
-
)
|
18 |
-
loaded_diffusion_model = from_pretrained_keras("shivi/dreambooth_diffusion_model")
|
19 |
-
dreambooth_model._diffusion_model = loaded_diffusion_model
|
20 |
-
|
21 |
generated_img = dreambooth_model.text_to_image(
|
22 |
prompt, batch_size=num_imgs_to_gen
|
23 |
)
|
@@ -46,6 +49,6 @@ with gr.Blocks() as demo:
|
|
46 |
[prompt,samples], gallery, generate_images, cache_examples=False)
|
47 |
|
48 |
gr.Markdown("Some fun examples I created while playing with the model:")
|
49 |
-
gr.
|
50 |
|
51 |
-
demo.launch(debug=True)
|
|
|
2 |
import keras_cv
|
3 |
import gradio as gr
|
4 |
|
5 |
+
|
6 |
+
## load model
|
7 |
+
resolution = 512
|
8 |
+
dreambooth_model = keras_cv.models.StableDiffusion(
|
9 |
+
img_width=resolution, img_height=resolution, jit_compile=True,
|
10 |
+
)
|
11 |
+
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.
|
|
|
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 |
)
|
|
|
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)")
|
53 |
|
54 |
+
demo.launch(debug=True)
|