Spaces:
Runtime error
Runtime error
Commit
·
fe691aa
1
Parent(s):
98b9d34
fixes
Browse files
app.py
CHANGED
@@ -80,7 +80,7 @@ def swap_blip_model_cpu_gpu(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):
|
@@ -108,13 +108,13 @@ def run_editing_quality(image, item_from, item_from_other, item_to, item_to_othe
|
|
108 |
embs_b = torch.load(os.path.join(emb_dir, f"{item_to_selected}.pt"))
|
109 |
edit_dir = (embs_b.mean(0)-embs_a.mean(0)).unsqueeze(0)
|
110 |
rec_pil, edit_pil = pipe_editing(
|
111 |
-
|
112 |
num_inference_steps=ddim_steps,
|
113 |
x_in=inverted_noise.unsqueeze(0),
|
114 |
edit_dir=edit_dir,
|
115 |
guidance_amount=xa_guidance,
|
116 |
guidance_scale=negative_guidance_scale,
|
117 |
-
negative_prompt=
|
118 |
)
|
119 |
return edit_pil[0]
|
120 |
css = '''
|
@@ -157,4 +157,5 @@ Upload an image to edit it. You can try `Fast mode` with prompts, or `Quality mo
|
|
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 |
demo.launch()
|
|
|
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):
|
|
|
108 |
embs_b = torch.load(os.path.join(emb_dir, f"{item_to_selected}.pt"))
|
109 |
edit_dir = (embs_b.mean(0)-embs_a.mean(0)).unsqueeze(0)
|
110 |
rec_pil, edit_pil = pipe_editing(
|
111 |
+
caption,
|
112 |
num_inference_steps=ddim_steps,
|
113 |
x_in=inverted_noise.unsqueeze(0),
|
114 |
edit_dir=edit_dir,
|
115 |
guidance_amount=xa_guidance,
|
116 |
guidance_scale=negative_guidance_scale,
|
117 |
+
negative_prompt=caption # use the unedited prompt for the negative prompt
|
118 |
)
|
119 |
return edit_pil[0]
|
120 |
css = '''
|
|
|
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 |
+
|
161 |
demo.launch()
|