app: add hyperlinks to base model on model hub
Browse files
app.py
CHANGED
@@ -61,6 +61,11 @@ def parse_org(hub_id):
|
|
61 |
return "huggingface"
|
62 |
|
63 |
|
|
|
|
|
|
|
|
|
|
|
64 |
df_with_org["org"] = df_with_org["base_model"].apply(parse_org)
|
65 |
df_with_org = df_with_org.dropna(subset=["org"])
|
66 |
|
@@ -108,14 +113,17 @@ def return_base_model_popularity(pipeline=None):
|
|
108 |
df_with_pipeline_info["pipeline"] == pipeline
|
109 |
]
|
110 |
keep_columns = ["base_model", "count"]
|
|
|
111 |
return df_with_pipeline_info[keep_columns].head(50)
|
112 |
|
113 |
|
114 |
def return_base_model_popularity_by_org(pipeline=None):
|
|
|
115 |
df_with_pipeline_info = pd.DataFrame(
|
116 |
{"base_model": base_models, "pipeline": pipeline_tags}
|
117 |
)
|
118 |
df_with_pipeline_info["org"] = df_with_pipeline_info["base_model"].apply(parse_org)
|
|
|
119 |
df_with_pipeline_info = df_with_pipeline_info.dropna(subset=["org"])
|
120 |
df_with_org = df_with_pipeline_info.copy(deep=True)
|
121 |
if pipeline is not None:
|
@@ -154,10 +162,10 @@ with gr.Blocks() as demo:
|
|
154 |
label="Filter rankings by task pipeline",
|
155 |
)
|
156 |
with gr.Accordion("Base model popularity ranking", open=False):
|
157 |
-
df_popularity = gr.DataFrame(return_base_model_popularity(None))
|
158 |
dropdown.change(return_base_model_popularity, dropdown, df_popularity)
|
159 |
with gr.Accordion("Base model popularity ranking by organization", open=False):
|
160 |
-
df_popularity_org = gr.DataFrame(return_base_model_popularity_by_org(None))
|
161 |
dropdown.change(
|
162 |
return_base_model_popularity_by_org, dropdown, df_popularity_org
|
163 |
)
|
|
|
61 |
return "huggingface"
|
62 |
|
63 |
|
64 |
+
def render_model_hub_link(hub_id):
|
65 |
+
link = f"https://huggingface.co/{hub_id}"
|
66 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{hub_id}</a>'
|
67 |
+
|
68 |
+
|
69 |
df_with_org["org"] = df_with_org["base_model"].apply(parse_org)
|
70 |
df_with_org = df_with_org.dropna(subset=["org"])
|
71 |
|
|
|
113 |
df_with_pipeline_info["pipeline"] == pipeline
|
114 |
]
|
115 |
keep_columns = ["base_model", "count"]
|
116 |
+
df_with_pipeline_info["base_model"] = df_with_pipeline_info["base_model"].apply(render_model_hub_link)
|
117 |
return df_with_pipeline_info[keep_columns].head(50)
|
118 |
|
119 |
|
120 |
def return_base_model_popularity_by_org(pipeline=None):
|
121 |
+
referenced_base_models = [f"[`{model}`](https://huggingface.co/{model})" for model in base_models]
|
122 |
df_with_pipeline_info = pd.DataFrame(
|
123 |
{"base_model": base_models, "pipeline": pipeline_tags}
|
124 |
)
|
125 |
df_with_pipeline_info["org"] = df_with_pipeline_info["base_model"].apply(parse_org)
|
126 |
+
df_with_pipeline_info["org"] = df_with_pipeline_info["org"].apply(render_model_hub_link)
|
127 |
df_with_pipeline_info = df_with_pipeline_info.dropna(subset=["org"])
|
128 |
df_with_org = df_with_pipeline_info.copy(deep=True)
|
129 |
if pipeline is not None:
|
|
|
162 |
label="Filter rankings by task pipeline",
|
163 |
)
|
164 |
with gr.Accordion("Base model popularity ranking", open=False):
|
165 |
+
df_popularity = gr.DataFrame(return_base_model_popularity(None), datatype="markdown")
|
166 |
dropdown.change(return_base_model_popularity, dropdown, df_popularity)
|
167 |
with gr.Accordion("Base model popularity ranking by organization", open=False):
|
168 |
+
df_popularity_org = gr.DataFrame(return_base_model_popularity_by_org(None), datatype="markdown")
|
169 |
dropdown.change(
|
170 |
return_base_model_popularity_by_org, dropdown, df_popularity_org
|
171 |
)
|