Add search
Browse files
app.py
CHANGED
@@ -47,6 +47,17 @@ def refresh():
|
|
47 |
return get_leaderboard_df()
|
48 |
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
leaderboard_df = get_leaderboard_df()
|
51 |
|
52 |
demo = gr.Blocks()
|
@@ -55,10 +66,14 @@ with demo:
|
|
55 |
gr.HTML(TITLE)
|
56 |
with gr.Column():
|
57 |
gr.Markdown(DESCRIPTION, elem_classes="markdown-text")
|
|
|
|
|
58 |
with gr.Group():
|
59 |
leaderboard_table = gr.Dataframe(value=leaderboard_df, wrap=True, height=1000)
|
60 |
with gr.Row():
|
61 |
refresh_button = gr.Button("Refresh")
|
62 |
-
|
|
|
|
|
63 |
|
64 |
demo.launch()
|
|
|
47 |
return get_leaderboard_df()
|
48 |
|
49 |
|
50 |
+
# Function to update the table based on search query
|
51 |
+
def update_table(search_query):
|
52 |
+
df = get_leaderboard_df()
|
53 |
+
if search_query:
|
54 |
+
search_terms = search_query.split(";")
|
55 |
+
search_terms = [term.strip() for term in search_terms]
|
56 |
+
pattern = "|".join(search_terms)
|
57 |
+
df = df[df["Model"].str.contains(pattern, regex=True)]
|
58 |
+
return df
|
59 |
+
|
60 |
+
|
61 |
leaderboard_df = get_leaderboard_df()
|
62 |
|
63 |
demo = gr.Blocks()
|
|
|
66 |
gr.HTML(TITLE)
|
67 |
with gr.Column():
|
68 |
gr.Markdown(DESCRIPTION, elem_classes="markdown-text")
|
69 |
+
with gr.Row():
|
70 |
+
search_bar = gr.Textbox(placeholder="Search for your model...", show_label=False)
|
71 |
with gr.Group():
|
72 |
leaderboard_table = gr.Dataframe(value=leaderboard_df, wrap=True, height=1000)
|
73 |
with gr.Row():
|
74 |
refresh_button = gr.Button("Refresh")
|
75 |
+
|
76 |
+
search_bar.submit(update_table, inputs=[search_bar], outputs=[leaderboard_table])
|
77 |
+
refresh_button.click(refresh, inputs=[], outputs=[leaderboard_table])
|
78 |
|
79 |
demo.launch()
|