Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -59,7 +59,7 @@ def load_image_ui(load_edit, input_folder="example_tmp"):
|
|
59 |
print("!!", len(mask_np_list))
|
60 |
max_val = len(mask_np_list)-1
|
61 |
sliderup = gr.Slider(value = 0, minimum=0, maximum=max_val, step=1, interactive=True)
|
62 |
-
return image, segmentation, mask_np_list, mask_label_list, image, sliderup
|
63 |
except:
|
64 |
print("Image folder invalid: The folder should contain image.png")
|
65 |
return None, None, None, None, None, None
|
@@ -176,7 +176,7 @@ if os.path.isdir("./example_tmp"):
|
|
176 |
|
177 |
from segment import run_segmentation
|
178 |
|
179 |
-
|
180 |
|
181 |
with gr.Blocks() as demo:
|
182 |
image = gr.State() # store mask
|
@@ -210,7 +210,7 @@ with gr.Blocks() as demo:
|
|
210 |
with gr.Column():
|
211 |
result_info0 = gr.Text(label="Response")
|
212 |
gr.Markdown("""<p style="text-align: center; font-size: 20px">Edit Mask (Optional)</p>""")
|
213 |
-
slider.
|
214 |
label = gr.Textbox()
|
215 |
slider.release(slider_release,
|
216 |
inputs = [slider, image_loaded, mask_np_list_updated, mask_label_list],
|
@@ -220,8 +220,6 @@ with gr.Blocks() as demo:
|
|
220 |
segment_button.click(run_segmentation,
|
221 |
[canvas] ,
|
222 |
[text_button, result_info0] )
|
223 |
-
text_button.click(load_image_ui, [false] ,
|
224 |
-
[image_loaded, segmentation, mask_np_list, mask_label_list, canvas, slider] )
|
225 |
|
226 |
|
227 |
canvas.upload(image_change, inputs=[], outputs=[text_button])
|
@@ -307,7 +305,7 @@ with gr.Blocks() as demo:
|
|
307 |
gr.Markdown("""<p style="text-align: center; font-size: 20px">Editing setting (SD)</p>""")
|
308 |
|
309 |
tgt_prompt = gr.Textbox(value="White bag", label="Editing: Text prompt", interactive= True )
|
310 |
-
|
311 |
#tgt_index = gr.Number(value="0", label="Editing: Object index", interactive= True )
|
312 |
guidance_scale = gr.Textbox(value="6", label="Editing: CFG guidance scale", interactive= True )
|
313 |
num_sampling_steps = gr.Number(value="50", label="Editing: Sampling steps", interactive= True )
|
@@ -348,12 +346,23 @@ with gr.Blocks() as demo:
|
|
348 |
strength ,
|
349 |
edge_thickness,
|
350 |
tgt_prompt ,
|
351 |
-
|
352 |
],
|
353 |
outputs = [canvas_text_edit],queue=True,
|
354 |
)
|
355 |
|
356 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
357 |
|
358 |
|
359 |
|
|
|
59 |
print("!!", len(mask_np_list))
|
60 |
max_val = len(mask_np_list)-1
|
61 |
sliderup = gr.Slider(value = 0, minimum=0, maximum=max_val, step=1, interactive=True)
|
62 |
+
return image, segmentation, mask_np_list, mask_label_list, image, sliderup, sliderup
|
63 |
except:
|
64 |
print("Image folder invalid: The folder should contain image.png")
|
65 |
return None, None, None, None, None, None
|
|
|
176 |
|
177 |
from segment import run_segmentation
|
178 |
|
179 |
+
|
180 |
|
181 |
with gr.Blocks() as demo:
|
182 |
image = gr.State() # store mask
|
|
|
210 |
with gr.Column():
|
211 |
result_info0 = gr.Text(label="Response")
|
212 |
gr.Markdown("""<p style="text-align: center; font-size: 20px">Edit Mask (Optional)</p>""")
|
213 |
+
slider = gr.Slider(0, 20, step=1, label = 'mask id', interactive=False)
|
214 |
label = gr.Textbox()
|
215 |
slider.release(slider_release,
|
216 |
inputs = [slider, image_loaded, mask_np_list_updated, mask_label_list],
|
|
|
220 |
segment_button.click(run_segmentation,
|
221 |
[canvas] ,
|
222 |
[text_button, result_info0] )
|
|
|
|
|
223 |
|
224 |
|
225 |
canvas.upload(image_change, inputs=[], outputs=[text_button])
|
|
|
305 |
gr.Markdown("""<p style="text-align: center; font-size: 20px">Editing setting (SD)</p>""")
|
306 |
|
307 |
tgt_prompt = gr.Textbox(value="White bag", label="Editing: Text prompt", interactive= True )
|
308 |
+
slider2 = gr.Slider(0, 20, step=1, label = 'mask id', interactive=False)
|
309 |
#tgt_index = gr.Number(value="0", label="Editing: Object index", interactive= True )
|
310 |
guidance_scale = gr.Textbox(value="6", label="Editing: CFG guidance scale", interactive= True )
|
311 |
num_sampling_steps = gr.Number(value="50", label="Editing: Sampling steps", interactive= True )
|
|
|
346 |
strength ,
|
347 |
edge_thickness,
|
348 |
tgt_prompt ,
|
349 |
+
slider2
|
350 |
],
|
351 |
outputs = [canvas_text_edit],queue=True,
|
352 |
)
|
353 |
|
354 |
+
slider.change(
|
355 |
+
lambda x: x,
|
356 |
+
inputs=[slider],
|
357 |
+
outputs=[slider2]
|
358 |
+
)
|
359 |
+
slider2.change(
|
360 |
+
lambda x: x,
|
361 |
+
inputs=[slider2],
|
362 |
+
outputs=[slider]
|
363 |
+
)
|
364 |
+
text_button.click(load_image_ui, [false] ,
|
365 |
+
[image_loaded, segmentation, mask_np_list, mask_label_list, canvas, slider, slider2] )
|
366 |
|
367 |
|
368 |
|