Spaces:
Paused
Paused
update
Browse files- diffusion_webui/stable_diffusion/__pycache__/__init__.cpython-38.pyc +0 -0
- diffusion_webui/stable_diffusion/__pycache__/img2img_app.cpython-38.pyc +0 -0
- diffusion_webui/stable_diffusion/__pycache__/inpaint_app.cpython-38.pyc +0 -0
- diffusion_webui/stable_diffusion/__pycache__/keras_txt2img.cpython-38.pyc +0 -0
- diffusion_webui/stable_diffusion/__pycache__/text2img_app.cpython-38.pyc +0 -0
- diffusion_webui/stable_diffusion/inpaint_app.py +0 -1
- diffusion_webui/stable_diffusion/keras_txt2img.py +48 -65
diffusion_webui/stable_diffusion/__pycache__/__init__.cpython-38.pyc
DELETED
Binary file (191 Bytes)
|
|
diffusion_webui/stable_diffusion/__pycache__/img2img_app.cpython-38.pyc
DELETED
Binary file (2.55 kB)
|
|
diffusion_webui/stable_diffusion/__pycache__/inpaint_app.cpython-38.pyc
DELETED
Binary file (2.42 kB)
|
|
diffusion_webui/stable_diffusion/__pycache__/keras_txt2img.cpython-38.pyc
DELETED
Binary file (2.79 kB)
|
|
diffusion_webui/stable_diffusion/__pycache__/text2img_app.cpython-38.pyc
DELETED
Binary file (2.74 kB)
|
|
diffusion_webui/stable_diffusion/inpaint_app.py
CHANGED
@@ -8,7 +8,6 @@ stable_inpiant_model_list = [
|
|
8 |
]
|
9 |
|
10 |
stable_prompt_list = ["a photo of a man.", "a photo of a girl."]
|
11 |
-
|
12 |
stable_negative_prompt_list = ["bad, ugly", "deformed"]
|
13 |
|
14 |
|
|
|
8 |
]
|
9 |
|
10 |
stable_prompt_list = ["a photo of a man.", "a photo of a girl."]
|
|
|
11 |
stable_negative_prompt_list = ["bad, ugly", "deformed"]
|
12 |
|
13 |
|
diffusion_webui/stable_diffusion/keras_txt2img.py
CHANGED
@@ -1,51 +1,55 @@
|
|
1 |
import gradio as gr
|
2 |
-
import tensorflow as tf
|
3 |
from huggingface_hub import from_pretrained_keras
|
4 |
from keras_cv import models
|
5 |
from tensorflow import keras
|
6 |
|
7 |
keras_model_list = [
|
8 |
"keras-dreambooth/keras_diffusion_lowpoly_world",
|
9 |
-
"keras-dreambooth/
|
10 |
-
"keras-dreambooth/dreambooth_diffusion_model",
|
11 |
]
|
12 |
|
13 |
stable_prompt_list = [
|
14 |
-
"
|
15 |
-
"
|
16 |
]
|
17 |
|
18 |
stable_negative_prompt_list = ["bad, ugly", "deformed"]
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
def keras_stable_diffusion(
|
22 |
model_path: str,
|
23 |
prompt: str,
|
24 |
negative_prompt: str,
|
25 |
-
|
26 |
-
|
27 |
-
height: int,
|
28 |
-
width: int,
|
29 |
):
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
49 |
|
50 |
|
51 |
def keras_stable_diffusion_app():
|
@@ -68,43 +72,26 @@ def keras_stable_diffusion_app():
|
|
68 |
label="Negative Prompt",
|
69 |
)
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
)
|
87 |
-
|
88 |
-
keras_text2image_height = gr.Slider(
|
89 |
-
minimum=128,
|
90 |
-
maximum=1280,
|
91 |
-
step=32,
|
92 |
-
value=512,
|
93 |
-
label="Image Height",
|
94 |
-
)
|
95 |
-
|
96 |
-
keras_text2image_width = gr.Slider(
|
97 |
-
minimum=128,
|
98 |
-
maximum=1280,
|
99 |
-
step=32,
|
100 |
-
value=512,
|
101 |
-
label="Image Height",
|
102 |
-
)
|
103 |
|
104 |
keras_text2image_predict = gr.Button(value="Generator")
|
105 |
|
106 |
with gr.Column():
|
107 |
-
output_image = gr.Gallery(label="
|
108 |
|
109 |
gr.Examples(
|
110 |
fn=keras_stable_diffusion,
|
@@ -114,8 +101,6 @@ def keras_stable_diffusion_app():
|
|
114 |
keras_text2image_negative_prompt,
|
115 |
keras_text2image_guidance_scale,
|
116 |
keras_text2image_num_inference_step,
|
117 |
-
keras_text2image_height,
|
118 |
-
keras_text2image_width,
|
119 |
],
|
120 |
outputs=[output_image],
|
121 |
examples=[
|
@@ -141,8 +126,6 @@ def keras_stable_diffusion_app():
|
|
141 |
keras_text2image_negative_prompt,
|
142 |
keras_text2image_guidance_scale,
|
143 |
keras_text2image_num_inference_step,
|
144 |
-
keras_text2image_height,
|
145 |
-
keras_text2image_width,
|
146 |
],
|
147 |
outputs=output_image,
|
148 |
)
|
|
|
1 |
import gradio as gr
|
|
|
2 |
from huggingface_hub import from_pretrained_keras
|
3 |
from keras_cv import models
|
4 |
from tensorflow import keras
|
5 |
|
6 |
keras_model_list = [
|
7 |
"keras-dreambooth/keras_diffusion_lowpoly_world",
|
8 |
+
"keras-dreambooth/keras-diffusion-traditional-furniture",
|
|
|
9 |
]
|
10 |
|
11 |
stable_prompt_list = [
|
12 |
+
"photo of lowpoly_world",
|
13 |
+
"photo of traditional_furniture",
|
14 |
]
|
15 |
|
16 |
stable_negative_prompt_list = ["bad, ugly", "deformed"]
|
17 |
|
18 |
+
keras.mixed_precision.set_global_policy("mixed_float16")
|
19 |
+
dreambooth_model = models.StableDiffusion(
|
20 |
+
img_width=512,
|
21 |
+
img_height=512,
|
22 |
+
jit_compile=True,
|
23 |
+
)
|
24 |
+
|
25 |
|
26 |
def keras_stable_diffusion(
|
27 |
model_path: str,
|
28 |
prompt: str,
|
29 |
negative_prompt: str,
|
30 |
+
num_imgs_to_gen: int,
|
31 |
+
num_steps: int,
|
|
|
|
|
32 |
):
|
33 |
+
"""
|
34 |
+
This function is used to generate images using our fine-tuned keras dreambooth stable diffusion model.
|
35 |
+
Args:
|
36 |
+
prompt (str): The text input given by the user based on which images will be generated.
|
37 |
+
num_imgs_to_gen (int): The number of images to be generated using given prompt.
|
38 |
+
num_steps (int): The number of denoising steps
|
39 |
+
Returns:
|
40 |
+
generated_img (List): List of images that were generated using the model
|
41 |
+
"""
|
42 |
+
loaded_diffusion_model = from_pretrained_keras(model_path)
|
43 |
+
dreambooth_model._diffusion_model = loaded_diffusion_model
|
44 |
+
|
45 |
+
generated_img = dreambooth_model.text_to_image(
|
46 |
+
prompt,
|
47 |
+
negative_prompt=negative_prompt,
|
48 |
+
batch_size=num_imgs_to_gen,
|
49 |
+
num_steps=num_steps,
|
50 |
+
)
|
51 |
+
|
52 |
+
return generated_img
|
53 |
|
54 |
|
55 |
def keras_stable_diffusion_app():
|
|
|
72 |
label="Negative Prompt",
|
73 |
)
|
74 |
|
75 |
+
keras_text2image_guidance_scale = gr.Slider(
|
76 |
+
minimum=0.1,
|
77 |
+
maximum=15,
|
78 |
+
step=0.1,
|
79 |
+
value=7.5,
|
80 |
+
label="Guidance Scale",
|
81 |
+
)
|
82 |
+
|
83 |
+
keras_text2image_num_inference_step = gr.Slider(
|
84 |
+
minimum=1,
|
85 |
+
maximum=100,
|
86 |
+
step=1,
|
87 |
+
value=50,
|
88 |
+
label="Num Inference Step",
|
89 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
keras_text2image_predict = gr.Button(value="Generator")
|
92 |
|
93 |
with gr.Column():
|
94 |
+
output_image = gr.Gallery(label="Outputs").style(grid=(1, 2))
|
95 |
|
96 |
gr.Examples(
|
97 |
fn=keras_stable_diffusion,
|
|
|
101 |
keras_text2image_negative_prompt,
|
102 |
keras_text2image_guidance_scale,
|
103 |
keras_text2image_num_inference_step,
|
|
|
|
|
104 |
],
|
105 |
outputs=[output_image],
|
106 |
examples=[
|
|
|
126 |
keras_text2image_negative_prompt,
|
127 |
keras_text2image_guidance_scale,
|
128 |
keras_text2image_num_inference_step,
|
|
|
|
|
129 |
],
|
130 |
outputs=output_image,
|
131 |
)
|