Update app.py
Browse files
app.py
CHANGED
|
@@ -326,7 +326,7 @@ def create_intervene_part(pipe: HookedStableDiffusionXLPipeline, saes_dict, mean
|
|
| 326 |
return images.images[0]
|
| 327 |
|
| 328 |
@spaces.GPU
|
| 329 |
-
def image_mod(prompt, block_str, brush_index, strength, num_steps, input_image, guidance_scale=None, start_index=None, end_index=None):
|
| 330 |
block = block_str.split(" ")[0]
|
| 331 |
|
| 332 |
mask = (input_image["layers"][0] > 0)[:, :, -1].astype(float)
|
|
@@ -373,7 +373,7 @@ def create_intervene_part(pipe: HookedStableDiffusionXLPipeline, saes_dict, mean
|
|
| 373 |
seed=42,
|
| 374 |
num_inference_steps=int(num_steps),
|
| 375 |
edit_fn= lambda input, output: hook(None, input, output),
|
| 376 |
-
layers_for_edit_fn=[i for i in range(
|
| 377 |
stream="image").images[0]
|
| 378 |
else:
|
| 379 |
|
|
@@ -464,6 +464,9 @@ def create_intervene_part(pipe: HookedStableDiffusionXLPipeline, saes_dict, mean
|
|
| 464 |
with gr.Column(scale=3):
|
| 465 |
with gr.Row():
|
| 466 |
strength = gr.Number(value=10, label="Strength", minimum=-40, maximum=40, elem_id="strength", precision=2)
|
|
|
|
|
|
|
|
|
|
| 467 |
with gr.Row():
|
| 468 |
button = gr.Button('Apply', elem_id="apply_button")
|
| 469 |
|
|
@@ -493,7 +496,7 @@ def create_intervene_part(pipe: HookedStableDiffusionXLPipeline, saes_dict, mean
|
|
| 493 |
num_steps.change(update_index_maxes, [num_steps], [start_index, end_index])
|
| 494 |
|
| 495 |
button.click(image_mod,
|
| 496 |
-
inputs=[prompt_field, block_select, brush_index, strength, num_steps, i_image, start_index, end_index],
|
| 497 |
outputs=o_image)
|
| 498 |
# button_icon.click(feature_icon, inputs=[block_select, brush_index], outputs=o_image)
|
| 499 |
demo.load(image_gen, [prompt_field, num_steps], outputs=[image_state])
|
|
|
|
| 326 |
return images.images[0]
|
| 327 |
|
| 328 |
@spaces.GPU
|
| 329 |
+
def image_mod(prompt, block_str, brush_index, strength, num_steps, input_image, guidance_scale=None, start_index=None, end_index=None, block_start=None, block_end=None):
|
| 330 |
block = block_str.split(" ")[0]
|
| 331 |
|
| 332 |
mask = (input_image["layers"][0] > 0)[:, :, -1].astype(float)
|
|
|
|
| 373 |
seed=42,
|
| 374 |
num_inference_steps=int(num_steps),
|
| 375 |
edit_fn= lambda input, output: hook(None, input, output),
|
| 376 |
+
layers_for_edit_fn=[i for i in range(block_start, block_end)],
|
| 377 |
stream="image").images[0]
|
| 378 |
else:
|
| 379 |
|
|
|
|
| 464 |
with gr.Column(scale=3):
|
| 465 |
with gr.Row():
|
| 466 |
strength = gr.Number(value=10, label="Strength", minimum=-40, maximum=40, elem_id="strength", precision=2)
|
| 467 |
+
with gr.Row():
|
| 468 |
+
block_start = gr.Number(value=18, label="Block start", minimum=0, maximum=57, elem_id="block_start")
|
| 469 |
+
block_finish = gr.Number(value=57, label="Block finish", minimum=0, maximum=57, elem_id="block_start")
|
| 470 |
with gr.Row():
|
| 471 |
button = gr.Button('Apply', elem_id="apply_button")
|
| 472 |
|
|
|
|
| 496 |
num_steps.change(update_index_maxes, [num_steps], [start_index, end_index])
|
| 497 |
|
| 498 |
button.click(image_mod,
|
| 499 |
+
inputs=[prompt_field, block_select, brush_index, strength, num_steps, i_image, start_index, end_index, block_start, block_finish],
|
| 500 |
outputs=o_image)
|
| 501 |
# button_icon.click(feature_icon, inputs=[block_select, brush_index], outputs=o_image)
|
| 502 |
demo.load(image_gen, [prompt_field, num_steps], outputs=[image_state])
|