Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,9 +6,29 @@ from io import StringIO
|
|
6 |
import plotly.graph_objs as go
|
7 |
from huggingface_hub import HfApi
|
8 |
from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
|
9 |
-
|
10 |
from yall import create_yall
|
|
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
|
14 |
def convert_markdown_table_to_dataframe(md_content):
|
@@ -154,7 +174,9 @@ def main():
|
|
154 |
hide_index=True,
|
155 |
height=len(df) * 37,
|
156 |
)
|
157 |
-
|
|
|
|
|
158 |
# Add a button to export data to CSV
|
159 |
if st.button("Export to CSV"):
|
160 |
# Export the DataFrame to CSV
|
|
|
6 |
import plotly.graph_objs as go
|
7 |
from huggingface_hub import HfApi
|
8 |
from huggingface_hub.utils import RepositoryNotFoundError, RevisionNotFoundError
|
|
|
9 |
from yall import create_yall
|
10 |
+
from functools import cache
|
11 |
|
12 |
+
@cache
|
13 |
+
def cached_model_info(api, model):
|
14 |
+
try:
|
15 |
+
return api.model_info(repo_id=str(model))
|
16 |
+
except (RepositoryNotFoundError, RevisionNotFoundError):
|
17 |
+
return None
|
18 |
+
|
19 |
+
@st.cache
|
20 |
+
def get_model_info(df):
|
21 |
+
api = HfApi()
|
22 |
+
|
23 |
+
for index, row in df.iterrows():
|
24 |
+
model_info = cached_model_info(api, row['Model'].strip())
|
25 |
+
if model_info:
|
26 |
+
df.loc[index, 'Likes'] = model_info.likes
|
27 |
+
df.loc[index, 'Tags'] = ', '.join(model_info.tags)
|
28 |
+
else:
|
29 |
+
df.loc[index, 'Likes'] = -1
|
30 |
+
df.loc[index, 'Tags'] = ''
|
31 |
+
return df
|
32 |
|
33 |
|
34 |
def convert_markdown_table_to_dataframe(md_content):
|
|
|
174 |
hide_index=True,
|
175 |
height=len(df) * 37,
|
176 |
)
|
177 |
+
selected_models = st.multiselect('Select models to compare', df['Model'].unique())
|
178 |
+
comparison_df = df[df['Model'].isin(selected_models)]
|
179 |
+
st.dataframe(comparison_df)
|
180 |
# Add a button to export data to CSV
|
181 |
if st.button("Export to CSV"):
|
182 |
# Export the DataFrame to CSV
|