Spaces:
Running
on
Zero
Running
on
Zero
root
commited on
Commit
•
5569753
1
Parent(s):
941c8a5
delete buttons
Browse files- app.py +41 -38
- segment.py +1 -1
app.py
CHANGED
@@ -221,6 +221,11 @@ def button_clickable(is_clickable):
|
|
221 |
return gr.Button.update(interactive=is_clickable)
|
222 |
|
223 |
|
|
|
|
|
|
|
|
|
|
|
224 |
import shutil
|
225 |
if os.path.isdir("./example_tmp"):
|
226 |
shutil.rmtree("./example_tmp")
|
@@ -250,13 +255,13 @@ with gr.Blocks() as demo:
|
|
250 |
|
251 |
text_button = gr.Button("Waiting 1.1 to complete",visible = False)
|
252 |
|
253 |
-
load_edit_button = gr.Button("Waiting 1.1 to complete",visible = False)
|
254 |
|
255 |
-
show_segment = gr.Checkbox(label = "Waiting 1.1 to complete",visible = False)
|
256 |
flag = gr.State(False)
|
257 |
-
show_segment.select(show_segmentation,
|
258 |
-
|
259 |
-
|
260 |
#def show_more_buttons():
|
261 |
# return gr.Button("1.2 Load original masks",visible = True), gr.Button("1.2 Load edited masks") , gr.Checkbox(label = "Show Segmentation")
|
262 |
#block_flag.change(show_more_buttons, [], [text_button,load_edit_button,show_segment ])
|
@@ -272,43 +277,43 @@ with gr.Blocks() as demo:
|
|
272 |
inputs = [slider, image_loaded, mask_np_list_updated, mask_label_list],
|
273 |
outputs= [canvas, label]
|
274 |
)
|
275 |
-
add_button = gr.Button("Add")
|
276 |
-
add_button.click( edit_mask_add,
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
save_button2 = gr.Button("Set and Save as edited masks")
|
282 |
-
save_button2.click( save_as_edit_mask,
|
283 |
-
|
284 |
-
|
285 |
|
286 |
-
save_button = gr.Button("Set and Save as original masks")
|
287 |
-
save_button.click( save_as_orig_mask,
|
288 |
-
|
289 |
-
|
290 |
|
291 |
-
back_button = gr.Button("Back to current seg")
|
292 |
-
back_button.click( load_mask_ui,
|
293 |
-
|
294 |
-
|
295 |
|
296 |
-
add_mask_button = gr.Button("Add new empty mask")
|
297 |
-
add_mask_button.click(add_mask,
|
298 |
-
|
299 |
-
|
300 |
|
301 |
|
302 |
segment_button.click(run_segmentation,
|
303 |
[canvas] ,
|
304 |
-
[text_button
|
305 |
text_button.click(load_image_ui, [false] ,
|
306 |
[image_loaded, segmentation, mask_np_list, mask_label_list, canvas, slider] )
|
307 |
|
308 |
-
load_edit_button.click(load_image_ui, [ true] ,
|
309 |
-
|
310 |
|
311 |
-
canvas.upload(image_change, inputs=[], outputs=[text_button
|
312 |
|
313 |
|
314 |
with gr.Tab(label="2 Optimization"):
|
@@ -391,7 +396,7 @@ with gr.Blocks() as demo:
|
|
391 |
|
392 |
with gr.Row():
|
393 |
with gr.Column():
|
394 |
-
canvas_text_edit = gr.Image(value = None, type = "pil", label="Editing results", show_label=True)
|
395 |
# canvas_text_edit = gr.Gallery(label = "Edited results")
|
396 |
|
397 |
with gr.Column():
|
@@ -404,7 +409,7 @@ with gr.Blocks() as demo:
|
|
404 |
edge_thickness = gr.Number(value="10", label="Editing: Edge thickness", interactive= True )
|
405 |
strength = gr.Textbox(value="0.5", label="Editing: Mask strength", interactive= True )
|
406 |
|
407 |
-
add_button = gr.Button("Run Editing")
|
408 |
def run_edit_text_wrapper(
|
409 |
num_tokens,
|
410 |
guidance_scale,
|
@@ -428,7 +433,8 @@ with gr.Blocks() as demo:
|
|
428 |
tgt_prompt = tgt_prompt,
|
429 |
tgt_index = int(tgt_index)
|
430 |
)
|
431 |
-
|
|
|
432 |
|
433 |
add_button.click(run_edit_text_wrapper,
|
434 |
inputs = [num_tokens_global,
|
@@ -439,12 +445,9 @@ with gr.Blocks() as demo:
|
|
439 |
tgt_prompt ,
|
440 |
tgt_index
|
441 |
],
|
442 |
-
outputs = [
|
443 |
)
|
444 |
|
445 |
-
def load_pil_img():
|
446 |
-
from PIL import Image
|
447 |
-
return Image.open("example_tmp/text/out_text_0.png")
|
448 |
|
449 |
load_button = gr.Button("Load results")
|
450 |
load_button.click(load_pil_img,
|
|
|
221 |
return gr.Button.update(interactive=is_clickable)
|
222 |
|
223 |
|
224 |
+
|
225 |
+
def load_pil_img():
|
226 |
+
from PIL import Image
|
227 |
+
return Image.open("example_tmp/text/out_text_0.png")
|
228 |
+
|
229 |
import shutil
|
230 |
if os.path.isdir("./example_tmp"):
|
231 |
shutil.rmtree("./example_tmp")
|
|
|
255 |
|
256 |
text_button = gr.Button("Waiting 1.1 to complete",visible = False)
|
257 |
|
258 |
+
# load_edit_button = gr.Button("Waiting 1.1 to complete",visible = False)
|
259 |
|
260 |
+
# show_segment = gr.Checkbox(label = "Waiting 1.1 to complete",visible = False)
|
261 |
flag = gr.State(False)
|
262 |
+
# show_segment.select(show_segmentation,
|
263 |
+
# [image_loaded, segmentation, flag],
|
264 |
+
# [canvas, flag])
|
265 |
#def show_more_buttons():
|
266 |
# return gr.Button("1.2 Load original masks",visible = True), gr.Button("1.2 Load edited masks") , gr.Checkbox(label = "Show Segmentation")
|
267 |
#block_flag.change(show_more_buttons, [], [text_button,load_edit_button,show_segment ])
|
|
|
277 |
inputs = [slider, image_loaded, mask_np_list_updated, mask_label_list],
|
278 |
outputs= [canvas, label]
|
279 |
)
|
280 |
+
# add_button = gr.Button("Add")
|
281 |
+
# add_button.click( edit_mask_add,
|
282 |
+
# [canvas, image_loaded, slider, mask_np_list_updated] ,
|
283 |
+
# [mask_np_list_updated, canvas]
|
284 |
+
# )
|
285 |
+
|
286 |
+
# save_button2 = gr.Button("Set and Save as edited masks")
|
287 |
+
# save_button2.click( save_as_edit_mask,
|
288 |
+
# [mask_np_list_updated, mask_label_list] ,
|
289 |
+
# [] )
|
290 |
|
291 |
+
# save_button = gr.Button("Set and Save as original masks")
|
292 |
+
# save_button.click( save_as_orig_mask,
|
293 |
+
# [mask_np_list_updated, mask_label_list] ,
|
294 |
+
# [] )
|
295 |
|
296 |
+
# back_button = gr.Button("Back to current seg")
|
297 |
+
# back_button.click( load_mask_ui,
|
298 |
+
# [] ,
|
299 |
+
# [ mask_np_list_updated,mask_label_list] )
|
300 |
|
301 |
+
# add_mask_button = gr.Button("Add new empty mask")
|
302 |
+
# add_mask_button.click(add_mask,
|
303 |
+
# [mask_np_list_updated, mask_label_list] ,
|
304 |
+
# [mask_np_list_updated, mask_label_list] )
|
305 |
|
306 |
|
307 |
segment_button.click(run_segmentation,
|
308 |
[canvas] ,
|
309 |
+
[text_button] )
|
310 |
text_button.click(load_image_ui, [false] ,
|
311 |
[image_loaded, segmentation, mask_np_list, mask_label_list, canvas, slider] )
|
312 |
|
313 |
+
# load_edit_button.click(load_image_ui, [ true] ,
|
314 |
+
# [image_loaded, segmentation, mask_np_list, mask_label_list, canvas, slider] )
|
315 |
|
316 |
+
canvas.upload(image_change, inputs=[], outputs=[text_button])
|
317 |
|
318 |
|
319 |
with gr.Tab(label="2 Optimization"):
|
|
|
396 |
|
397 |
with gr.Row():
|
398 |
with gr.Column():
|
399 |
+
canvas_text_edit = gr.Image(value = None, type = "pil", label="Editing results", show_label=True,visible = True)
|
400 |
# canvas_text_edit = gr.Gallery(label = "Edited results")
|
401 |
|
402 |
with gr.Column():
|
|
|
409 |
edge_thickness = gr.Number(value="10", label="Editing: Edge thickness", interactive= True )
|
410 |
strength = gr.Textbox(value="0.5", label="Editing: Mask strength", interactive= True )
|
411 |
|
412 |
+
add_button = gr.Button("Run Editing (Check Log for Completion)")
|
413 |
def run_edit_text_wrapper(
|
414 |
num_tokens,
|
415 |
guidance_scale,
|
|
|
433 |
tgt_prompt = tgt_prompt,
|
434 |
tgt_index = int(tgt_index)
|
435 |
)
|
436 |
+
run_edit_text()
|
437 |
+
return 0
|
438 |
|
439 |
add_button.click(run_edit_text_wrapper,
|
440 |
inputs = [num_tokens_global,
|
|
|
445 |
tgt_prompt ,
|
446 |
tgt_index
|
447 |
],
|
448 |
+
outputs = [],queue=True,
|
449 |
)
|
450 |
|
|
|
|
|
|
|
451 |
|
452 |
load_button = gr.Button("Load results")
|
453 |
load_button.click(load_pil_img,
|
segment.py
CHANGED
@@ -117,4 +117,4 @@ def run_segmentation(image, name="example_tmp", size = 512, noseg=False):
|
|
117 |
draw_panoptic_segmentation(**panoptic_segmentation, save_folder = save_folder, noseg = noseg, model = model)
|
118 |
print("Finish segment")
|
119 |
#block_flag += 1
|
120 |
-
return gr.Button.update("1.2 Load original masks",visible = True)
|
|
|
117 |
draw_panoptic_segmentation(**panoptic_segmentation, save_folder = save_folder, noseg = noseg, model = model)
|
118 |
print("Finish segment")
|
119 |
#block_flag += 1
|
120 |
+
return gr.Button.update("1.2 Load original masks",visible = True)#, gr.Button.update("1.2 Load edited masks",visible = True), gr.Checkbox.update(label = "Show Segmentation",visible = True)
|