Spaces:
Running
on
A10G
Running
on
A10G
Linoy Tsaban
commited on
Commit
•
a217b80
1
Parent(s):
7593f04
Update app.py
Browse files
app.py
CHANGED
@@ -138,19 +138,24 @@ def invert_and_reconstruct(
|
|
138 |
|
139 |
|
140 |
x0 = load_512(input_image, device=device)
|
141 |
-
|
142 |
if do_inversion or randomize_seed:
|
143 |
invert and retrieve noise maps and latent
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
do_inversion = False
|
148 |
|
149 |
output = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
150 |
|
151 |
return output, wts, zs, do_inversion
|
152 |
|
153 |
-
|
|
|
|
|
|
|
|
|
|
|
154 |
|
155 |
def edit(input_image,
|
156 |
wts, zs,
|
@@ -249,13 +254,13 @@ with gr.Blocks(css='style.css') as demo:
|
|
249 |
|
250 |
with gr.Row():
|
251 |
tar_prompt = gr.Textbox(lines=1, label="Target Prompt", interactive=True, placeholder="")
|
252 |
-
with gr.Accordion("SEGA Concepts", open=False, visible=
|
253 |
with gr.Column(scale=1):
|
254 |
edit_concept = gr.Textbox(lines=1, label="Enter SEGA Edit Concept", visible = True, interactive=True)
|
255 |
with gr.Column(scale=1):
|
256 |
neg_guidance = gr.Checkbox(label="Negative Guidance", value=False)
|
257 |
-
|
258 |
-
|
259 |
headers=["Concepts", "Negative Guidance"],
|
260 |
datatype=["str", "bool"],
|
261 |
label="SEGA Concepts",
|
@@ -277,7 +282,6 @@ with gr.Blocks(css='style.css') as demo:
|
|
277 |
seed = gr.Number(value=0, precision=0, label="Seed", interactive=True)
|
278 |
randomize_seed = gr.Checkbox(label='Randomize seed', value=False)
|
279 |
with gr.Column():
|
280 |
-
|
281 |
skip = gr.Slider(minimum=0, maximum=40, value=36, label="Skip Steps", interactive=True)
|
282 |
tar_cfg_scale = gr.Slider(minimum=7, maximum=18,value=15, label=f"Guidance Scale", interactive=True)
|
283 |
sega_edit_guidance = gr.Slider(value=10, label=f"SEGA Edit Guidance Scale", interactive=True)
|
@@ -289,6 +293,13 @@ with gr.Blocks(css='style.css') as demo:
|
|
289 |
|
290 |
# gr.Markdown(help_text)
|
291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
invert_button.click(
|
293 |
fn = randomize_seed_fn,
|
294 |
inputs = [seed, randomize_seed],
|
|
|
138 |
|
139 |
|
140 |
x0 = load_512(input_image, device=device)
|
141 |
+
|
142 |
if do_inversion or randomize_seed:
|
143 |
invert and retrieve noise maps and latent
|
144 |
+
zs_tensor, wts_tensor = invert(x0 =x0 , prompt_src=src_prompt, num_diffusion_steps=steps, cfg_scale_src=src_cfg_scale)
|
145 |
+
wts = gr.State(value=wts_tensor)
|
146 |
+
zs = gr.State(value=zs_tensor)
|
147 |
do_inversion = False
|
148 |
|
149 |
output = sample(zs.value, wts.value, prompt_tar=tar_prompt, skip=skip, cfg_scale_tar=tar_cfg_scale)
|
150 |
|
151 |
return output, wts, zs, do_inversion
|
152 |
|
153 |
+
def update_sega_concept_table(edit_concept, neg_guidance, concepts_table):
|
154 |
+
if edit_concept:
|
155 |
+
new_rows = concepts_table.value.append([edit_concept, neg_guidance])
|
156 |
+
new_concepts_table = gr.DataFrame(value=new_rows)
|
157 |
+
return new_concepts_table
|
158 |
+
return concepts_table
|
159 |
|
160 |
def edit(input_image,
|
161 |
wts, zs,
|
|
|
254 |
|
255 |
with gr.Row():
|
256 |
tar_prompt = gr.Textbox(lines=1, label="Target Prompt", interactive=True, placeholder="")
|
257 |
+
with gr.Accordion("SEGA Concepts", open=False, visible=True):
|
258 |
with gr.Column(scale=1):
|
259 |
edit_concept = gr.Textbox(lines=1, label="Enter SEGA Edit Concept", visible = True, interactive=True)
|
260 |
with gr.Column(scale=1):
|
261 |
neg_guidance = gr.Checkbox(label="Negative Guidance", value=False)
|
262 |
+
submit_concept = gr.Button(label="Add Concept")
|
263 |
+
concepts_table = gr.Dataframe(
|
264 |
headers=["Concepts", "Negative Guidance"],
|
265 |
datatype=["str", "bool"],
|
266 |
label="SEGA Concepts",
|
|
|
282 |
seed = gr.Number(value=0, precision=0, label="Seed", interactive=True)
|
283 |
randomize_seed = gr.Checkbox(label='Randomize seed', value=False)
|
284 |
with gr.Column():
|
|
|
285 |
skip = gr.Slider(minimum=0, maximum=40, value=36, label="Skip Steps", interactive=True)
|
286 |
tar_cfg_scale = gr.Slider(minimum=7, maximum=18,value=15, label=f"Guidance Scale", interactive=True)
|
287 |
sega_edit_guidance = gr.Slider(value=10, label=f"SEGA Edit Guidance Scale", interactive=True)
|
|
|
293 |
|
294 |
# gr.Markdown(help_text)
|
295 |
|
296 |
+
|
297 |
+
submit_concept.click(
|
298 |
+
fn = update_sega_concept_table,
|
299 |
+
inputs = [edit_concept, neg_guidance, concepts_table],
|
300 |
+
outputs = [concepts_table]
|
301 |
+
)
|
302 |
+
|
303 |
invert_button.click(
|
304 |
fn = randomize_seed_fn,
|
305 |
inputs = [seed, randomize_seed],
|