Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
·
756d8b3
1
Parent(s):
2822d34
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,38 +63,8 @@ def get_example():
|
|
| 63 |
100,
|
| 64 |
36,
|
| 65 |
15,
|
| 66 |
-
'+painting',
|
| 67 |
-
10,
|
| 68 |
-
1,
|
| 69 |
'examples/ddpm_a_robot_wearing_a_brown_hoodie_in_a_crowded_street.png',
|
| 70 |
-
|
| 71 |
-
],
|
| 72 |
-
[
|
| 73 |
-
'examples/source_wall_with_framed_photos.jpeg',
|
| 74 |
-
'',
|
| 75 |
-
'',
|
| 76 |
-
100,
|
| 77 |
-
36,
|
| 78 |
-
15,
|
| 79 |
-
'+pink drawings of muffins',
|
| 80 |
-
10,
|
| 81 |
-
1,
|
| 82 |
-
'examples/ddpm_wall_with_framed_photos.png',
|
| 83 |
-
'examples/ddpm_sega_plus_pink_drawings_of_muffins.png'
|
| 84 |
-
],
|
| 85 |
-
[
|
| 86 |
-
'examples/source_an_empty_room_with_concrete_walls.jpg',
|
| 87 |
-
'an empty room with concrete walls',
|
| 88 |
-
'glass walls',
|
| 89 |
-
100,
|
| 90 |
-
36,
|
| 91 |
-
17,
|
| 92 |
-
'+giant elephant',
|
| 93 |
-
10,
|
| 94 |
-
1,
|
| 95 |
-
'examples/ddpm_glass_walls.png',
|
| 96 |
-
'examples/ddpm_sega_glass_walls_gian_elephant.png'
|
| 97 |
-
]]
|
| 98 |
return case
|
| 99 |
|
| 100 |
inversion_map = dict()
|
|
@@ -119,11 +89,8 @@ def invert(input_image,
|
|
| 119 |
inversion_map['latnets'] = latnets
|
| 120 |
inversion_map['zs'] = zs
|
| 121 |
inversion_map['wts'] = wts
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
|
| 126 |
-
return
|
| 127 |
|
| 128 |
def edit(tar_prompt="",
|
| 129 |
steps=100,
|
|
@@ -165,20 +132,22 @@ with gr.Blocks() as demo:
|
|
| 165 |
gr.HTML(intro)
|
| 166 |
with gr.Row():
|
| 167 |
src_prompt = gr.Textbox(lines=1, label="Source Prompt", interactive=True, placeholder="optional: describe the original image")
|
| 168 |
-
tar_prompt = gr.Textbox(lines=1, label="Target Prompt", interactive=True, placeholder="optional: describe the target image
|
| 169 |
|
| 170 |
with gr.Row():
|
| 171 |
input_image = gr.Image(label="Input Image", interactive=True)
|
| 172 |
input_image.style(height=512, width=512)
|
|
|
|
|
|
|
| 173 |
output_image = gr.Image(label=f"Edited Image", interactive=False)
|
| 174 |
output_image.style(height=512, width=512)
|
| 175 |
|
| 176 |
|
| 177 |
with gr.Row():
|
| 178 |
with gr.Column(scale=1, min_width=100):
|
| 179 |
-
invert_button = gr.Button("
|
| 180 |
with gr.Column(scale=1, min_width=100):
|
| 181 |
-
edit_button = gr.Button("
|
| 182 |
|
| 183 |
|
| 184 |
with gr.Accordion("Advanced Options", open=False):
|
|
@@ -215,7 +184,7 @@ with gr.Blocks() as demo:
|
|
| 215 |
top,
|
| 216 |
bottom
|
| 217 |
],
|
| 218 |
-
outputs = [],
|
| 219 |
)
|
| 220 |
|
| 221 |
edit_button.click(
|
|
@@ -239,16 +208,12 @@ with gr.Blocks() as demo:
|
|
| 239 |
# label='Examples',
|
| 240 |
# examples=get_example(),
|
| 241 |
# inputs=[input_image, src_prompt, tar_prompt, steps,
|
| 242 |
-
#
|
| 243 |
# skip,
|
| 244 |
# tar_cfg_scale,
|
| 245 |
-
#
|
| 246 |
-
# sega_edit_guidance,
|
| 247 |
-
# warm_up,
|
| 248 |
-
# # neg_guidance,
|
| 249 |
-
# ddpm_edited_image, sega_edited_image
|
| 250 |
# ],
|
| 251 |
-
# outputs=[
|
| 252 |
# # fn=edit,
|
| 253 |
# # cache_examples=True
|
| 254 |
# )
|
|
|
|
| 63 |
100,
|
| 64 |
36,
|
| 65 |
15,
|
|
|
|
|
|
|
|
|
|
| 66 |
'examples/ddpm_a_robot_wearing_a_brown_hoodie_in_a_crowded_street.png',
|
| 67 |
+
],]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
return case
|
| 69 |
|
| 70 |
inversion_map = dict()
|
|
|
|
| 89 |
inversion_map['latnets'] = latnets
|
| 90 |
inversion_map['zs'] = zs
|
| 91 |
inversion_map['wts'] = wts
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
+
return sample(wt, zs, wts, prompt_tar=src_prompt)
|
| 94 |
|
| 95 |
def edit(tar_prompt="",
|
| 96 |
steps=100,
|
|
|
|
| 132 |
gr.HTML(intro)
|
| 133 |
with gr.Row():
|
| 134 |
src_prompt = gr.Textbox(lines=1, label="Source Prompt", interactive=True, placeholder="optional: describe the original image")
|
| 135 |
+
tar_prompt = gr.Textbox(lines=1, label="Target Prompt", interactive=True, placeholder="optional: describe the target image")
|
| 136 |
|
| 137 |
with gr.Row():
|
| 138 |
input_image = gr.Image(label="Input Image", interactive=True)
|
| 139 |
input_image.style(height=512, width=512)
|
| 140 |
+
inverted_image = gr.Image(label=f"Reconstructed Image", interactive=False)
|
| 141 |
+
inverted_image.style(height=512, width=512)
|
| 142 |
output_image = gr.Image(label=f"Edited Image", interactive=False)
|
| 143 |
output_image.style(height=512, width=512)
|
| 144 |
|
| 145 |
|
| 146 |
with gr.Row():
|
| 147 |
with gr.Column(scale=1, min_width=100):
|
| 148 |
+
invert_button = gr.Button("Invert")
|
| 149 |
with gr.Column(scale=1, min_width=100):
|
| 150 |
+
edit_button = gr.Button("Edit")
|
| 151 |
|
| 152 |
|
| 153 |
with gr.Accordion("Advanced Options", open=False):
|
|
|
|
| 184 |
top,
|
| 185 |
bottom
|
| 186 |
],
|
| 187 |
+
outputs = [inverted_image],
|
| 188 |
)
|
| 189 |
|
| 190 |
edit_button.click(
|
|
|
|
| 208 |
# label='Examples',
|
| 209 |
# examples=get_example(),
|
| 210 |
# inputs=[input_image, src_prompt, tar_prompt, steps,
|
| 211 |
+
# src_cfg_scale,
|
| 212 |
# skip,
|
| 213 |
# tar_cfg_scale,
|
| 214 |
+
# inverted_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
# ],
|
| 216 |
+
# outputs=[inverted_image],
|
| 217 |
# # fn=edit,
|
| 218 |
# # cache_examples=True
|
| 219 |
# )
|