Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -74,15 +74,17 @@ def run_timeline(repo_url: str, threshold: float, multimodal: bool, sim_method:
|
|
| 74 |
|
| 75 |
# βββββββββββββββββββββββββββββ UI ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 76 |
|
|
|
|
| 77 |
CUSTOM_CSS = """
|
| 78 |
#graph_html iframe, #timeline_html iframe {height:85vh !important; width:100% !important; border:none;}
|
| 79 |
"""
|
| 80 |
|
| 81 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
| 82 |
-
gr.Markdown("## π Modular
|
| 83 |
|
| 84 |
-
|
| 85 |
-
|
|
|
|
| 86 |
with gr.Row():
|
| 87 |
timeline_repo_in = gr.Text(value=HF_MAIN_REPO, label="Repo / fork URL")
|
| 88 |
timeline_thresh = gr.Slider(0.50, 0.95, value=0.5, step=0.01, label="Similarity β₯")
|
|
@@ -93,15 +95,20 @@ with gr.Blocks(css=CUSTOM_CSS) as demo:
|
|
| 93 |
timeline_html_out = gr.HTML(elem_id="timeline_html", show_label=False)
|
| 94 |
timeline_json_out = gr.File(label="Download timeline.json")
|
| 95 |
|
| 96 |
-
timeline_btn.click(
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
sim_radio2 = gr.Radio(["jaccard","embedding"], value="jaccard", label="Similarity metric")
|
| 99 |
multi_cb2 = gr.Checkbox(label="Only multimodal models")
|
| 100 |
go_loc = gr.Button("Show LOC growth")
|
| 101 |
loc_html = gr.HTML(show_label=False)
|
| 102 |
go_loc.click(run_loc, [sim_radio2, multi_cb2], loc_html)
|
| 103 |
|
| 104 |
-
with gr.Tab("Dependency Graph"):
|
| 105 |
with gr.Row():
|
| 106 |
repo_in = gr.Text(value=HF_MAIN_REPO, label="Repo / fork URL")
|
| 107 |
thresh = gr.Slider(0.50, 0.95, value=0.5, step=0.01, label="Similarity β₯")
|
|
@@ -112,7 +119,20 @@ with gr.Blocks(css=CUSTOM_CSS) as demo:
|
|
| 112 |
graph_html_out = gr.HTML(elem_id="graph_html", show_label=False)
|
| 113 |
graph_json_out = gr.File(label="Download graph.json")
|
| 114 |
|
| 115 |
-
go_btn.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
if __name__ == "__main__":
|
|
|
|
| 118 |
demo.launch(allowed_paths=["static"])
|
|
|
|
| 74 |
|
| 75 |
# βββββββββββββββββββββββββββββ UI ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 76 |
|
| 77 |
+
|
| 78 |
CUSTOM_CSS = """
|
| 79 |
#graph_html iframe, #timeline_html iframe {height:85vh !important; width:100% !important; border:none;}
|
| 80 |
"""
|
| 81 |
|
| 82 |
with gr.Blocks(css=CUSTOM_CSS) as demo:
|
| 83 |
+
gr.Markdown("## π Modular-candidate explorer for π€ Transformers")
|
| 84 |
|
| 85 |
+
# capture the Tabs as a component so we can control selection
|
| 86 |
+
with gr.Tabs() as tabs:
|
| 87 |
+
with gr.Tab("Chronological Timeline", id="timeline"):
|
| 88 |
with gr.Row():
|
| 89 |
timeline_repo_in = gr.Text(value=HF_MAIN_REPO, label="Repo / fork URL")
|
| 90 |
timeline_thresh = gr.Slider(0.50, 0.95, value=0.5, step=0.01, label="Similarity β₯")
|
|
|
|
| 95 |
timeline_html_out = gr.HTML(elem_id="timeline_html", show_label=False)
|
| 96 |
timeline_json_out = gr.File(label="Download timeline.json")
|
| 97 |
|
| 98 |
+
timeline_btn.click(
|
| 99 |
+
lambda repo, thresh, multi: run_timeline(repo, thresh, multi, "jaccard"),
|
| 100 |
+
[timeline_repo_in, timeline_thresh, timeline_multi_cb],
|
| 101 |
+
[timeline_html_out, timeline_json_out],
|
| 102 |
+
)
|
| 103 |
+
|
| 104 |
+
with gr.Tab("LOC Growth", id="loc"):
|
| 105 |
sim_radio2 = gr.Radio(["jaccard","embedding"], value="jaccard", label="Similarity metric")
|
| 106 |
multi_cb2 = gr.Checkbox(label="Only multimodal models")
|
| 107 |
go_loc = gr.Button("Show LOC growth")
|
| 108 |
loc_html = gr.HTML(show_label=False)
|
| 109 |
go_loc.click(run_loc, [sim_radio2, multi_cb2], loc_html)
|
| 110 |
|
| 111 |
+
with gr.Tab("Dependency Graph", id="graph"):
|
| 112 |
with gr.Row():
|
| 113 |
repo_in = gr.Text(value=HF_MAIN_REPO, label="Repo / fork URL")
|
| 114 |
thresh = gr.Slider(0.50, 0.95, value=0.5, step=0.01, label="Similarity β₯")
|
|
|
|
| 119 |
graph_html_out = gr.HTML(elem_id="graph_html", show_label=False)
|
| 120 |
graph_json_out = gr.File(label="Download graph.json")
|
| 121 |
|
| 122 |
+
go_btn.click(
|
| 123 |
+
lambda repo, thresh, multi: run_graph(repo, thresh, multi, "jaccard"),
|
| 124 |
+
[repo_in, thresh, multi_cb],
|
| 125 |
+
[graph_html_out, graph_json_out],
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
def _select_tab_on_load(req: gr.Request):
|
| 129 |
+
tab = (req.query_params or {}).get("tab")
|
| 130 |
+
if tab in {"timeline", "loc", "graph"}:
|
| 131 |
+
return gr.update(selected=tab)
|
| 132 |
+
return gr.update()
|
| 133 |
+
|
| 134 |
+
demo.load(_select_tab_on_load, outputs=tabs)
|
| 135 |
|
| 136 |
if __name__ == "__main__":
|
| 137 |
+
demo.launch(allowed_paths=["static"])
|
| 138 |
demo.launch(allowed_paths=["static"])
|