Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
rom 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-bioshock")
|
9 |
+
sd_dreambooth_model._diffusion_model = db_diffusion_model
|
10 |
+
|
11 |
+
# generate images
|
12 |
+
def infer(prompt, negative_prompt, num_imgs_to_gen, num_steps, guidance_scale):
|
13 |
+
generated_images = sd_dreambooth_model.text_to_image(
|
14 |
+
prompt,
|
15 |
+
negative_prompt=negative_prompt,
|
16 |
+
batch_size=num_imgs_to_gen,
|
17 |
+
num_steps=num_steps,
|
18 |
+
unconditional_guidance_scale=guidance_scale
|
19 |
+
)
|
20 |
+
return generated_images
|
21 |
+
|
22 |
+
|
23 |
+
# output = gr.Gallery(label="Outputs").style(grid=(2,2))
|
24 |
+
|
25 |
+
# pass function, input type for prompt, the output for multiple images
|
26 |
+
gr.Interface(
|
27 |
+
infer, [
|
28 |
+
gr.Textbox(label="Positive Prompt", value="a highly detailed photo of sks bskscnry"),
|
29 |
+
gr.Textbox(label="Negative Prompt", value="ugly, low quality"),
|
30 |
+
gr.Slider(label='Number of gen image', minimum=1, maximum=4, value=2, step=1),
|
31 |
+
gr.Slider(label="Inference Steps",value=50),
|
32 |
+
gr.Number(label='Guidance scale', value=7.5),
|
33 |
+
], [
|
34 |
+
gr.Gallery(show_label=False),
|
35 |
+
],
|
36 |
+
title="Dreambooth Teddy",
|
37 |
+
description = "This is a dreambooth model fine-tuned on images of Bioshock sceneries. To play with the demo, input the concept with {sks bskscnry}.",
|
38 |
+
examples = [["a highly detailed photo of sks bskscnry", "", 2, 50, 7.5]],
|
39 |
+
).launch()
|