merve HF Staff commited on
Commit
99ce383
·
1 Parent(s): 758e3cc

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from huggingface_hub import from_pretrained_keras
2
+ import keras_cv
3
+ import gradio as gr
4
+
5
+
6
+ # prepare model
7
+ resolution = 512
8
+ sd_dreambooth_model = keras_cv.models.StableDiffusion(
9
+ img_width=resolution, img_height=resolution, jit_compile=True,
10
+ )
11
+ db_diffusion_model = from_pretrained_keras("merve/dreambooth_diffusion_model")
12
+ sd_dreambooth_model._diffusion_model = db_diffusion_model
13
+
14
+ # generate images
15
+ def infer(prompt):
16
+ generated_images = sd_dreambooth_model.text_to_image(
17
+ prompt, batch_size=9
18
+ )
19
+ return generated_images
20
+
21
+ output = gr.Gallery(label="Outputs").style(grid=(3,3))
22
+
23
+ # customize interface
24
+ title = "Dreambooth Demo on Dog Images"
25
+ description = "This is a dreambooth model fine-tuned on dog images. To try it, input the concept with {sks dog}."
26
+ gr.Interface(infer, inputs=["text"], outputs=[output]).launch()