Spaces:
Running
on
Zero
Running
on
Zero
update UI
Browse files
app.py
CHANGED
@@ -693,26 +693,26 @@ def ncut_run(
|
|
693 |
|
694 |
def _ncut_run(*args, **kwargs):
|
695 |
n_ret = kwargs.pop("n_ret", 1)
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
|
700 |
-
|
701 |
|
702 |
-
|
703 |
-
|
704 |
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
ret = ncut_run(*args, **kwargs)
|
714 |
-
ret = list(ret)[:n_ret] + [ret[-1]]
|
715 |
-
return ret
|
716 |
|
717 |
if USE_HUGGINGFACE_ZEROGPU:
|
718 |
@spaces.GPU(duration=30)
|
@@ -1105,9 +1105,9 @@ def run_fn(
|
|
1105 |
|
1106 |
|
1107 |
|
1108 |
-
def make_input_images_section():
|
1109 |
gr.Markdown('### Input Images')
|
1110 |
-
input_gallery = gr.Gallery(value=None, label="Select images", show_label=
|
1111 |
submit_button = gr.Button("🔴 RUN", elem_id="submit_button", variant='primary')
|
1112 |
clear_images_button = gr.Button("🗑️Clear", elem_id='clear_button', variant='stop')
|
1113 |
return input_gallery, submit_button, clear_images_button
|
@@ -1657,11 +1657,10 @@ with demo:
|
|
1657 |
l3_cluster_gallery = gr.Gallery(value=[], label="Recursion #3 Clusters", show_label=True, elem_id="clusters", columns=[2], rows=[4], object_fit="contain", height=600, show_share_button=True, preview=True, interactive=False)
|
1658 |
with gr.Row():
|
1659 |
with gr.Column(scale=5, min_width=200):
|
1660 |
-
input_gallery, submit_button, clear_images_button = make_input_images_section()
|
1661 |
dataset_dropdown, num_images_slider, random_seed_slider, load_images_button = make_dataset_images_section(advanced=True)
|
1662 |
num_images_slider.value = 100
|
1663 |
clear_images_button.visible = False
|
1664 |
-
logging_text = gr.Textbox("Logging information", label="Logging", elem_id="logging", type="text", placeholder="Logging information")
|
1665 |
|
1666 |
with gr.Column(scale=5, min_width=200):
|
1667 |
with gr.Accordion("➡️ Recursion config", open=True):
|
@@ -1681,6 +1680,7 @@ with demo:
|
|
1681 |
] = make_parameters_section()
|
1682 |
num_eig_slider.visible = False
|
1683 |
affinity_focal_gamma_slider.visible = False
|
|
|
1684 |
true_placeholder = gr.Checkbox(label="True placeholder", value=True, elem_id="true_placeholder")
|
1685 |
true_placeholder.visible = False
|
1686 |
false_placeholder = gr.Checkbox(label="False placeholder", value=False, elem_id="false_placeholder")
|
|
|
693 |
|
694 |
def _ncut_run(*args, **kwargs):
|
695 |
n_ret = kwargs.pop("n_ret", 1)
|
696 |
+
try:
|
697 |
+
if torch.cuda.is_available():
|
698 |
+
torch.cuda.empty_cache()
|
699 |
|
700 |
+
ret = ncut_run(*args, **kwargs)
|
701 |
|
702 |
+
if torch.cuda.is_available():
|
703 |
+
torch.cuda.empty_cache()
|
704 |
|
705 |
+
ret = list(ret)[:n_ret] + [ret[-1]]
|
706 |
+
return ret
|
707 |
+
except Exception as e:
|
708 |
+
gr.Error(str(e))
|
709 |
+
if torch.cuda.is_available():
|
710 |
+
torch.cuda.empty_cache()
|
711 |
+
return *(None for _ in range(n_ret)), "Error: " + str(e)
|
712 |
+
|
713 |
+
# ret = ncut_run(*args, **kwargs)
|
714 |
+
# ret = list(ret)[:n_ret] + [ret[-1]]
|
715 |
+
# return ret
|
716 |
|
717 |
if USE_HUGGINGFACE_ZEROGPU:
|
718 |
@spaces.GPU(duration=30)
|
|
|
1105 |
|
1106 |
|
1107 |
|
1108 |
+
def make_input_images_section(rows=1, height="auto"):
|
1109 |
gr.Markdown('### Input Images')
|
1110 |
+
input_gallery = gr.Gallery(value=None, label="Select images", show_label=True, elem_id="images", columns=[3], rows=[rows], object_fit="contain", height=height, type="pil", show_share_button=False)
|
1111 |
submit_button = gr.Button("🔴 RUN", elem_id="submit_button", variant='primary')
|
1112 |
clear_images_button = gr.Button("🗑️Clear", elem_id='clear_button', variant='stop')
|
1113 |
return input_gallery, submit_button, clear_images_button
|
|
|
1657 |
l3_cluster_gallery = gr.Gallery(value=[], label="Recursion #3 Clusters", show_label=True, elem_id="clusters", columns=[2], rows=[4], object_fit="contain", height=600, show_share_button=True, preview=True, interactive=False)
|
1658 |
with gr.Row():
|
1659 |
with gr.Column(scale=5, min_width=200):
|
1660 |
+
input_gallery, submit_button, clear_images_button = make_input_images_section(rows=5, height=1000)
|
1661 |
dataset_dropdown, num_images_slider, random_seed_slider, load_images_button = make_dataset_images_section(advanced=True)
|
1662 |
num_images_slider.value = 100
|
1663 |
clear_images_button.visible = False
|
|
|
1664 |
|
1665 |
with gr.Column(scale=5, min_width=200):
|
1666 |
with gr.Accordion("➡️ Recursion config", open=True):
|
|
|
1680 |
] = make_parameters_section()
|
1681 |
num_eig_slider.visible = False
|
1682 |
affinity_focal_gamma_slider.visible = False
|
1683 |
+
logging_text = gr.Textbox("Logging information", label="Logging", elem_id="logging", type="text", placeholder="Logging information")
|
1684 |
true_placeholder = gr.Checkbox(label="True placeholder", value=True, elem_id="true_placeholder")
|
1685 |
true_placeholder.visible = False
|
1686 |
false_placeholder = gr.Checkbox(label="False placeholder", value=False, elem_id="false_placeholder")
|