Commit
·
1d9d174
1
Parent(s):
c40b1ac
Refactor Gradio interface to improve submission filtering and search functionality; add search button and update layout.
Browse files- gradio_interface.py +30 -29
gradio_interface.py
CHANGED
@@ -148,36 +148,37 @@ with gr.Blocks(title="🌟ImageCLEFmed-MEDVQA-GI 2025 Submissions 🌟") as demo
|
|
148 |
""")
|
149 |
with gr.Tab("View Submissions"):
|
150 |
gr.Markdown("### Submissions Table")
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
)
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
file_input = gr.File(label="Upload JSON", file_types=["json"])
|
167 |
-
upload_output = gr.Textbox(label="Result") # Add this line
|
168 |
-
file_input.upload(add_submission, file_input,
|
169 |
-
upload_output)
|
170 |
-
|
171 |
-
with gr.Tab("Refresh API", visible=False):
|
172 |
-
gr.Interface(
|
173 |
-
api_name="RefreshAPI",
|
174 |
-
fn=refresh_page,
|
175 |
-
inputs=[],
|
176 |
-
outputs="text",
|
177 |
-
title="Refresh API",
|
178 |
-
description="Hidden interface to refresh the API."
|
179 |
)
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
|
183 |
demo.launch()
|
|
|
148 |
""")
|
149 |
with gr.Tab("View Submissions"):
|
150 |
gr.Markdown("### Submissions Table")
|
151 |
+
|
152 |
+
with gr.Row():
|
153 |
+
task_type_dropdown = gr.Dropdown(
|
154 |
+
choices=["all", "task1", "task2"],
|
155 |
+
value="all",
|
156 |
+
label="Task Type",
|
157 |
+
)
|
158 |
+
search_box = gr.Textbox(
|
159 |
+
label="Search by Username",
|
160 |
+
placeholder="Enter a username to search"
|
161 |
+
)
|
162 |
+
search_button = gr.Button("Search")
|
163 |
+
|
164 |
+
output_table = gr.Dataframe(
|
165 |
+
headers=["User", "Task", "Submitted Time"],
|
166 |
+
interactive=False,
|
167 |
+
value=[],
|
168 |
+
scale=5,
|
169 |
)
|
170 |
+
|
171 |
+
def update_table(task, query):
|
172 |
+
return [[s["user"], s["task"], s["submitted_time"]] for s in filter_submissions(task, query)]
|
173 |
+
|
174 |
+
search_button.click(
|
175 |
+
fn=update_table,
|
176 |
+
inputs=[task_type_dropdown, search_box],
|
177 |
+
outputs=output_table
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
)
|
179 |
+
|
180 |
+
demo.load(fn=lambda: [[s["user"], s["task"], s["submitted_time"]] for s in filter_submissions("all", "")],
|
181 |
+
inputs=[],
|
182 |
+
outputs=output_table)
|
183 |
|
184 |
demo.launch()
|