Spaces:
Runtime error
Runtime error
bharat-raghunathan
commited on
Commit
•
76c789a
1
Parent(s):
6cf43ef
Create initial app
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("bharat-raghunathan/dreambooth_dosa")
|
9 |
+
sd_dreambooth_model._diffusion_model = db_diffusion_model
|
10 |
+
gr.HTML("<h2 style=\"font-size: 2em; font-weight: bold\" align=\"center\">Keras Dreambooth - The Humble Dosa</h2>")
|
11 |
+
gr.HTML("<p style=\"font-size: 14; font-weight: normal\" align=\"left\">This model has been fine-tuned to learn the concept of a dosa.")
|
12 |
+
# generate images
|
13 |
+
def infer(prompt):
|
14 |
+
generated_images = sd_dreambooth_model.text_to_image(
|
15 |
+
prompt
|
16 |
+
)
|
17 |
+
return generated_images
|
18 |
+
|
19 |
+
|
20 |
+
output = gr.Gallery(label="Outputs").style(grid=(2,2))
|
21 |
+
|
22 |
+
gr.Examples(["realistic picture of a man eating a dosa",
|
23 |
+
"realistic picture of a dosa on a plate",
|
24 |
+
"realistic picture of a dosa in a restaurant"
|
25 |
+
],
|
26 |
+
prompt, gallery, generate_images, cache_examples=True)
|
27 |
+
gr.Markdown('Demo created by [Bharat Raghunathan](https://huggingface.co/bharat-raghunathan/)')
|
28 |
+
# pass function, input type for prompt, the output for multiple images
|
29 |
+
gr.Interface(infer, inputs=["text"], outputs=[output]).launch()
|