Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -158,6 +158,10 @@ def load_pil_img():
|
|
158 |
from PIL import Image
|
159 |
return Image.open("example_tmp/text/out_text_0.png")
|
160 |
|
|
|
|
|
|
|
|
|
161 |
import shutil
|
162 |
if os.path.isdir("./example_tmp"):
|
163 |
shutil.rmtree("./example_tmp")
|
@@ -186,9 +190,7 @@ with gr.Blocks() as demo:
|
|
186 |
with gr.Row():
|
187 |
with gr.Column():
|
188 |
canvas = gr.Image(value = "./img.png", type="numpy", label="Draw Mask", show_label=True, height=LENGTH, width=LENGTH, interactive=True)
|
189 |
-
gr.Markdown("""<p style="text-align: left; font-size: 16px">Each image requires a single segmentation and optimization operation.\
|
190 |
-
Afterwards, you can modify the mask ID and prompt for image editing. \n
|
191 |
-
The D-edit link is: https://arxiv.org/abs/2403.04880v2"</p>""")
|
192 |
|
193 |
with gr.Column():
|
194 |
result_info0 = gr.Text(label="Response")
|
@@ -312,6 +314,11 @@ with gr.Blocks() as demo:
|
|
312 |
gr.Info('Image editing completed.')
|
313 |
return load_pil_img()
|
314 |
|
|
|
|
|
|
|
|
|
|
|
315 |
|
316 |
canvas.upload(image_change, inputs=[], outputs=[slider,add_button2])
|
317 |
add_button.click(run_optimization_wrapper,
|
|
|
158 |
from PIL import Image
|
159 |
return Image.open("example_tmp/text/out_text_0.png")
|
160 |
|
161 |
+
def change_image(impath):
|
162 |
+
return gr.Image(value = impath, type="numpy", height=LENGTH, width=LENGTH, interactive=True)
|
163 |
+
|
164 |
+
|
165 |
import shutil
|
166 |
if os.path.isdir("./example_tmp"):
|
167 |
shutil.rmtree("./example_tmp")
|
|
|
190 |
with gr.Row():
|
191 |
with gr.Column():
|
192 |
canvas = gr.Image(value = "./img.png", type="numpy", label="Draw Mask", show_label=True, height=LENGTH, width=LENGTH, interactive=True)
|
193 |
+
gr.Markdown("""<p style="text-align: left; font-size: 16px">Each image requires a single segmentation and optimization operation.\nAfterwards, you can modify the mask ID and prompt for image editing. \nThe D-edit link is: https://arxiv.org/abs/2403.04880v2"</p>""")
|
|
|
|
|
194 |
|
195 |
with gr.Column():
|
196 |
result_info0 = gr.Text(label="Response")
|
|
|
314 |
gr.Info('Image editing completed.')
|
315 |
return load_pil_img()
|
316 |
|
317 |
+
example_inps = [['./img.png'],['./img2.png']]
|
318 |
+
gr.Examples(examples=example_inps, inputs=[img_path],
|
319 |
+
label='examples', cache_examples='lazy', outputs=[output_image],
|
320 |
+
fn=change_image)
|
321 |
+
|
322 |
|
323 |
canvas.upload(image_change, inputs=[], outputs=[slider,add_button2])
|
324 |
add_button.click(run_optimization_wrapper,
|