Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
·
5079251
1
Parent(s):
17c1f09
Update app.py
Browse files
app.py
CHANGED
@@ -69,10 +69,10 @@ def get_example():
|
|
69 |
],]
|
70 |
return case
|
71 |
|
72 |
-
inversion_map = dict()
|
73 |
|
74 |
-
def
|
75 |
src_prompt ="",
|
|
|
76 |
steps=100,
|
77 |
src_cfg_scale = 3.5,
|
78 |
skip=36,
|
@@ -87,31 +87,16 @@ def invert_and_reconstruct(input_image,
|
|
87 |
x0 = load_512(input_image, left,right, top, bottom, device)
|
88 |
|
89 |
|
90 |
-
# invert
|
91 |
wt, zs, wts = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps, cfg_scale_src=src_cfg_scale)
|
92 |
|
93 |
-
#
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
return sample(wt, zs, wts, prompt_tar=src_prompt)
|
99 |
|
100 |
-
def edit(tar_prompt="",
|
101 |
-
steps=100,
|
102 |
-
skip=36,
|
103 |
-
tar_cfg_scale=15,
|
104 |
-
seed = 0
|
105 |
|
106 |
-
):
|
107 |
-
torch.manual_seed(seed)
|
108 |
-
out = sample(wt=inversion_map['wt'], zs= inversion_map['zs'], wts=inversion_map['wts'], prompt_tar=tar_prompt,
|
109 |
-
cfg_scale_tar=tar_cfg_scale, skip=skip)
|
110 |
-
|
111 |
-
return out
|
112 |
|
113 |
-
def reset():
|
114 |
-
inversion_map.clear()
|
115 |
|
116 |
|
117 |
########
|
@@ -178,13 +163,14 @@ with gr.Blocks() as demo:
|
|
178 |
# gr.Markdown(help_text)
|
179 |
|
180 |
invert_button.click(
|
181 |
-
fn=
|
182 |
inputs=[input_image,
|
183 |
src_prompt,
|
|
|
184 |
steps,
|
185 |
src_cfg_scale,
|
186 |
skip,
|
187 |
-
|
188 |
left,
|
189 |
right,
|
190 |
top,
|
@@ -195,11 +181,17 @@ with gr.Blocks() as demo:
|
|
195 |
|
196 |
edit_button.click(
|
197 |
fn=edit,
|
198 |
-
inputs=[
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
],
|
204 |
outputs=[output_image],
|
205 |
)
|
|
|
69 |
],]
|
70 |
return case
|
71 |
|
|
|
72 |
|
73 |
+
def edit(input_image,
|
74 |
src_prompt ="",
|
75 |
+
tar_prompt="",
|
76 |
steps=100,
|
77 |
src_cfg_scale = 3.5,
|
78 |
skip=36,
|
|
|
87 |
x0 = load_512(input_image, left,right, top, bottom, device)
|
88 |
|
89 |
|
90 |
+
# invert and retrieve noise maps and latent
|
91 |
wt, zs, wts = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps, cfg_scale_src=src_cfg_scale)
|
92 |
|
93 |
+
#
|
94 |
+
output = sample(wt, zs, wts, prompt_tar=tar_prompt)
|
95 |
+
|
96 |
+
return output
|
|
|
|
|
97 |
|
|
|
|
|
|
|
|
|
|
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
|
|
|
|
100 |
|
101 |
|
102 |
########
|
|
|
163 |
# gr.Markdown(help_text)
|
164 |
|
165 |
invert_button.click(
|
166 |
+
fn=edit,
|
167 |
inputs=[input_image,
|
168 |
src_prompt,
|
169 |
+
src_prompt,
|
170 |
steps,
|
171 |
src_cfg_scale,
|
172 |
skip,
|
173 |
+
seed,
|
174 |
left,
|
175 |
right,
|
176 |
top,
|
|
|
181 |
|
182 |
edit_button.click(
|
183 |
fn=edit,
|
184 |
+
inputs=[input_image,
|
185 |
+
src_prompt,
|
186 |
+
tar_prompt,
|
187 |
+
steps,
|
188 |
+
src_cfg_scale,
|
189 |
+
skip,
|
190 |
+
seed,
|
191 |
+
left,
|
192 |
+
right,
|
193 |
+
top,
|
194 |
+
bottom
|
195 |
],
|
196 |
outputs=[output_image],
|
197 |
)
|