Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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("merve/dreambooth_diffusion_model")
|
9 |
+
sd_dreambooth_model._diffusion_model = db_diffusion_model
|
10 |
+
|
11 |
+
# generate images
|
12 |
+
def infer(prompt):
|
13 |
+
generated_images = sd_dreambooth_model.text_to_image(
|
14 |
+
prompt
|
15 |
+
)
|
16 |
+
return generated_images
|
17 |
+
|
18 |
+
|
19 |
+
output = gr.Gallery(label="Outputs").style(grid=(2,2))
|
20 |
+
|
21 |
+
# pass function, input type for prompt, the output for multiple images
|
22 |
+
gr.Interface(infer, inputs=["text"], outputs=[output]).launch()
|