Spaces:
Runtime error
Runtime error
Commit
·
861cb49
1
Parent(s):
ac04e7e
Update app.py
Browse files
app.py
CHANGED
@@ -74,13 +74,8 @@ def generate_inversion(prompt, image, num_ddim_steps=50):
|
|
74 |
)
|
75 |
return x_inv[0]
|
76 |
|
77 |
-
def swap_blip_model_cpu_gpu(device_to):
|
78 |
-
if torch.cuda.is_available():
|
79 |
-
blip_model_large.to(device_to)
|
80 |
-
|
81 |
def run_captioning(image):
|
82 |
caption = generate_caption(blip_processor_large, blip_model_large, image).strip()
|
83 |
-
#swap_blip_model_cpu_gpu("cpu")
|
84 |
return caption
|
85 |
|
86 |
def run_editing(image, original_prompt, edit_prompt, ddim_steps=50, xa_guidance=0.1, negative_guidance_scale=5.0):
|
@@ -149,14 +144,17 @@ Upload an image to edit it. You can try `Fast mode` with prompts, or `Quality mo
|
|
149 |
item_to_other = gr.Textbox(visible=False, label="Type what to replace what you identified for")
|
150 |
item_to.change(lambda choice: gr.Dropdown.update(visible=choice=="Other"), item_to, item_to_other)
|
151 |
btn_edit_quality = gr.Button("Edit Image")
|
152 |
-
|
|
|
|
|
|
|
153 |
with gr.Column():
|
154 |
image_output = gr.Image(label="Image with edits",type="pil",shape=(512, 512))
|
155 |
|
156 |
btn_caption.click(fn=run_captioning, inputs=image, outputs=original_prompt)
|
157 |
|
158 |
-
btn_edit_fast.click(fn=run_editing, inputs=[image, original_prompt, edit_prompt], outputs=[image_output])
|
159 |
-
btn_edit_quality.click(fn=run_editing_quality, inputs=[image, item_from, item_from_other, item_to, item_to_other], outputs=[image_output])
|
160 |
gr.Examples(
|
161 |
examples=[
|
162 |
[os.path.join(os.path.dirname(__file__), "assets/test_images/cats/cat_1.png"), "cat", "", "dog", ""],
|
|
|
74 |
)
|
75 |
return x_inv[0]
|
76 |
|
|
|
|
|
|
|
|
|
77 |
def run_captioning(image):
|
78 |
caption = generate_caption(blip_processor_large, blip_model_large, image).strip()
|
|
|
79 |
return caption
|
80 |
|
81 |
def run_editing(image, original_prompt, edit_prompt, ddim_steps=50, xa_guidance=0.1, negative_guidance_scale=5.0):
|
|
|
144 |
item_to_other = gr.Textbox(visible=False, label="Type what to replace what you identified for")
|
145 |
item_to.change(lambda choice: gr.Dropdown.update(visible=choice=="Other"), item_to, item_to_other)
|
146 |
btn_edit_quality = gr.Button("Edit Image")
|
147 |
+
with gr.Accordion(label="Advanced settings", open=False):
|
148 |
+
steps = gr.Slider(minimum=2, maximum=50, step=1, value=50)
|
149 |
+
xa_guidance =gr.Slider(minimum=0.0, maximum=10.0, step=0.05, value=0.1)
|
150 |
+
negative_scale = gr.Slider(minimum=0.0, maximum=20.0, step=0.1, value=5.0)
|
151 |
with gr.Column():
|
152 |
image_output = gr.Image(label="Image with edits",type="pil",shape=(512, 512))
|
153 |
|
154 |
btn_caption.click(fn=run_captioning, inputs=image, outputs=original_prompt)
|
155 |
|
156 |
+
btn_edit_fast.click(fn=run_editing, inputs=[image, original_prompt, edit_prompt, steps, xa_guidance, negative_scale], outputs=[image_output])
|
157 |
+
btn_edit_quality.click(fn=run_editing_quality, inputs=[image, item_from, item_from_other, item_to, item_to_other, steps, xa_guidance, negative_scale], outputs=[image_output])
|
158 |
gr.Examples(
|
159 |
examples=[
|
160 |
[os.path.join(os.path.dirname(__file__), "assets/test_images/cats/cat_1.png"), "cat", "", "dog", ""],
|