Spaces:
Running
on
Zero
Running
on
Zero
amlpai04
commited on
Commit
·
8fa0da0
1
Parent(s):
13ea8e1
fix col2 col2 in adv tab
Browse files- app/tabs/adv_htrflow_tab.py +53 -42
app/tabs/adv_htrflow_tab.py
CHANGED
@@ -4,15 +4,19 @@ import gradio as gr
|
|
4 |
|
5 |
with gr.Blocks() as adv_htrflow_pipeline:
|
6 |
with gr.Row(variant="panel"):
|
7 |
-
with gr.Column(scale=
|
|
|
8 |
image_mask2 = gr.ImageEditor(
|
9 |
label="Uploaded image",
|
|
|
10 |
interactive=True,
|
11 |
layers=False,
|
12 |
eraser=False,
|
13 |
brush=False,
|
14 |
-
height=
|
15 |
-
|
|
|
|
|
16 |
)
|
17 |
|
18 |
image_mask = gr.Gallery(
|
@@ -23,43 +27,28 @@ with gr.Blocks() as adv_htrflow_pipeline:
|
|
23 |
object_fit="cover",
|
24 |
columns=5,
|
25 |
)
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
)
|
38 |
-
gr.Checkbox(value=True, label="Batch", container=True, scale=0)
|
39 |
-
|
40 |
-
# input_files_format_dropdown = gr.Dropdown(
|
41 |
-
# ["Upload", "Batch", "Crop"],
|
42 |
-
# value="Upload",
|
43 |
-
# multiselect=False,
|
44 |
-
# label="Upload method",
|
45 |
-
# container=False,
|
46 |
-
# scale=0,
|
47 |
-
# interactive=True,
|
48 |
-
# )
|
49 |
|
50 |
with gr.Row():
|
51 |
run_button = gr.Button("Submit", variant="primary", scale=0)
|
52 |
-
cancel_button = gr.Button(
|
|
|
|
|
53 |
d = gr.DownloadButton(
|
54 |
-
"Download the file", visible=
|
55 |
) # TODO: This should be hidden until the run button is clicked
|
56 |
|
57 |
-
|
58 |
-
scale=0
|
59 |
-
) # This is for debugging runnr when run button is clicked and the stop button is clicked
|
60 |
-
|
61 |
-
# TODO: add a upload to hf datasets
|
62 |
-
# TODO: add a hf login button to login to upload datasets
|
63 |
|
64 |
with gr.Column(scale=3):
|
65 |
with gr.Tabs():
|
@@ -69,7 +58,7 @@ with gr.Blocks() as adv_htrflow_pipeline:
|
|
69 |
info="Checkboxgroup should be basedon output structure from htrflow",
|
70 |
)
|
71 |
|
72 |
-
gr.Image()
|
73 |
|
74 |
with gr.Tab("Table"):
|
75 |
pass
|
@@ -77,12 +66,34 @@ with gr.Blocks() as adv_htrflow_pipeline:
|
|
77 |
# TODO add https://www.gradio.app/docs/gradio/highlightedtext and graph of run graph
|
78 |
pass
|
79 |
|
80 |
-
# input_files_format_dropdown.select(lambda: gr.update(visible=True), None, image_mask)
|
81 |
-
|
82 |
def foo():
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
with gr.Blocks() as adv_htrflow_pipeline:
|
6 |
with gr.Row(variant="panel"):
|
7 |
+
with gr.Column(scale=3):
|
8 |
+
|
9 |
image_mask2 = gr.ImageEditor(
|
10 |
label="Uploaded image",
|
11 |
+
sources="upload",
|
12 |
interactive=True,
|
13 |
layers=False,
|
14 |
eraser=False,
|
15 |
brush=False,
|
16 |
+
height=400,
|
17 |
+
transforms="crop",
|
18 |
+
crop_size="16,5",
|
19 |
+
visible=False,
|
20 |
)
|
21 |
|
22 |
image_mask = gr.Gallery(
|
|
|
27 |
object_fit="cover",
|
28 |
columns=5,
|
29 |
)
|
30 |
+
with gr.Row(visible=True) as yaml_pipeline:
|
31 |
+
with gr.Accordion(label="Run Template", open=False):
|
32 |
+
gr.Checkbox(value=True, label="Batch", container=False, scale=0)
|
33 |
+
custom_template_yaml = gr.Code(
|
34 |
+
value="Paste your custom pipeline here",
|
35 |
+
language="yaml",
|
36 |
+
label="yaml",
|
37 |
+
# show_label=False,
|
38 |
+
interactive=True,
|
39 |
+
lines=5,
|
40 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
with gr.Row():
|
43 |
run_button = gr.Button("Submit", variant="primary", scale=0)
|
44 |
+
cancel_button = gr.Button(
|
45 |
+
"stop", variant="stop", scale=0, visible=False
|
46 |
+
)
|
47 |
d = gr.DownloadButton(
|
48 |
+
"Download the file", visible=False, scale=0
|
49 |
) # TODO: This should be hidden until the run button is clicked
|
50 |
|
51 |
+
textbox_ = gr.Textbox(scale=0, visible=False)
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
with gr.Column(scale=3):
|
54 |
with gr.Tabs():
|
|
|
58 |
info="Checkboxgroup should be basedon output structure from htrflow",
|
59 |
)
|
60 |
|
61 |
+
gr.Image(interactive=False)
|
62 |
|
63 |
with gr.Tab("Table"):
|
64 |
pass
|
|
|
66 |
# TODO add https://www.gradio.app/docs/gradio/highlightedtext and graph of run graph
|
67 |
pass
|
68 |
|
|
|
|
|
69 |
def foo():
|
70 |
+
return gr.update(visible=True), "test"
|
71 |
+
|
72 |
+
click_event = run_button.click(
|
73 |
+
fn=foo, inputs=None, outputs=[cancel_button, textbox_]
|
74 |
+
).then(fn=lambda: gr.update(visible=False), inputs=None, outputs=cancel_button)
|
75 |
+
|
76 |
+
cancel_button.click(
|
77 |
+
fn=lambda: gr.update(visible=False),
|
78 |
+
inputs=None,
|
79 |
+
outputs=cancel_button,
|
80 |
+
cancels=[click_event],
|
81 |
+
)
|
82 |
|
83 |
+
image_mask2.upload(
|
84 |
+
fn=None,
|
85 |
+
inputs=None,
|
86 |
+
outputs=None,
|
87 |
+
js="""
|
88 |
+
() => {
|
89 |
+
// Target the button using its attributes
|
90 |
+
const button = document.querySelector('button[aria-label="Transform button"][title="Transform button"]');
|
91 |
+
if (button) {
|
92 |
+
button.click(); // Simulate a click
|
93 |
+
console.log('Transform button clicked.');
|
94 |
+
} else {
|
95 |
+
console.error('Transform button not found.');
|
96 |
+
}
|
97 |
+
}
|
98 |
+
""",
|
99 |
+
).then(fn=lambda: gr.update(crop=None), inputs=None, outputs=image_mask2)
|