Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
6f62fc3
1
Parent(s):
88f076f
Update app.py
Browse files
app.py
CHANGED
@@ -74,15 +74,21 @@ def edit(input_image,
|
|
74 |
tar_cfg_scale=15,
|
75 |
edit_concept="",
|
76 |
sega_edit_guidance=0,
|
77 |
-
warm_up=
|
78 |
-
neg_guidance=False
|
|
|
|
|
|
|
79 |
offsets=(0,0,0,0)
|
80 |
x0 = load_512(input_image, *offsets, device)
|
81 |
|
82 |
|
83 |
# invert
|
84 |
# wt, zs, wts = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps, cfg_scale_src=src_cfg_scale)
|
85 |
-
wt, zs, wts = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps)
|
|
|
|
|
|
|
86 |
latnets = wts[skip].expand(1, -1, -1, -1)
|
87 |
|
88 |
|
@@ -112,7 +118,7 @@ def edit(input_image,
|
|
112 |
edit_momentum_scale=0.5,
|
113 |
edit_mom_beta=0.6
|
114 |
)
|
115 |
-
sega_out = sem_pipe(prompt=tar_prompt,eta=
|
116 |
num_images_per_prompt=1,
|
117 |
num_inference_steps=steps,
|
118 |
use_ddpm=True, wts=wts, zs=zs[skip:], **editing_args)
|
@@ -160,7 +166,9 @@ with gr.Blocks() as demo:
|
|
160 |
# reconstruction
|
161 |
skip = gr.Slider(minimum=0, maximum=40, value=36, precision=0, label="Skip Steps", interactive=True)
|
162 |
tar_cfg_scale = gr.Slider(minimum=7, maximum=18,value=15, label=f"Guidance Scale", interactive=True)
|
163 |
-
|
|
|
|
|
164 |
# edit
|
165 |
sega_edit_guidance = gr.Slider(value=10, label=f"SEGA Edit Guidance Scale", interactive=True)
|
166 |
# warm_up = gr.Number(value=1, label=f"SEGA Warm-up Steps", interactive=True)
|
@@ -179,9 +187,12 @@ with gr.Blocks() as demo:
|
|
179 |
skip,
|
180 |
tar_cfg_scale,
|
181 |
edit_concept,
|
182 |
-
sega_edit_guidance
|
183 |
# warm_up,
|
184 |
-
# neg_guidance
|
|
|
|
|
|
|
185 |
],
|
186 |
outputs=[ddpm_edited_image, sega_edited_image],
|
187 |
)
|
|
|
74 |
tar_cfg_scale=15,
|
75 |
edit_concept="",
|
76 |
sega_edit_guidance=0,
|
77 |
+
warm_up=1,
|
78 |
+
neg_guidance=False,
|
79 |
+
flip=False,
|
80 |
+
h_shift=0,
|
81 |
+
v_shift=0):
|
82 |
offsets=(0,0,0,0)
|
83 |
x0 = load_512(input_image, *offsets, device)
|
84 |
|
85 |
|
86 |
# invert
|
87 |
# wt, zs, wts = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps, cfg_scale_src=src_cfg_scale)
|
88 |
+
wt, zs, wts = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps)
|
89 |
+
if flip:
|
90 |
+
wt, zs, wts = torch.flip(wt, [0, 1]),torch.flip(zs, [0, 1]),torch.flip(wts, [0, 1])
|
91 |
+
|
92 |
latnets = wts[skip].expand(1, -1, -1, -1)
|
93 |
|
94 |
|
|
|
118 |
edit_momentum_scale=0.5,
|
119 |
edit_mom_beta=0.6
|
120 |
)
|
121 |
+
sega_out = sem_pipe(prompt=tar_prompt,eta=1, latents=latnets, guidance_scale = tar_cfg_scale,
|
122 |
num_images_per_prompt=1,
|
123 |
num_inference_steps=steps,
|
124 |
use_ddpm=True, wts=wts, zs=zs[skip:], **editing_args)
|
|
|
166 |
# reconstruction
|
167 |
skip = gr.Slider(minimum=0, maximum=40, value=36, precision=0, label="Skip Steps", interactive=True)
|
168 |
tar_cfg_scale = gr.Slider(minimum=7, maximum=18,value=15, label=f"Guidance Scale", interactive=True)
|
169 |
+
flip = gr.Checkbox(label="Flip")
|
170 |
+
h_shift = gr.Number(value=0, precision=0, label="Horizontal Shift", interactive=True)
|
171 |
+
v_shift = gr.Number(value=0, precision=0, label="Vertical Shift", interactive=True)
|
172 |
# edit
|
173 |
sega_edit_guidance = gr.Slider(value=10, label=f"SEGA Edit Guidance Scale", interactive=True)
|
174 |
# warm_up = gr.Number(value=1, label=f"SEGA Warm-up Steps", interactive=True)
|
|
|
187 |
skip,
|
188 |
tar_cfg_scale,
|
189 |
edit_concept,
|
190 |
+
sega_edit_guidance,
|
191 |
# warm_up,
|
192 |
+
# neg_guidance,
|
193 |
+
flip,
|
194 |
+
h_shift,
|
195 |
+
v_shift
|
196 |
],
|
197 |
outputs=[ddpm_edited_image, sega_edited_image],
|
198 |
)
|