mlabonne commited on
Commit
9c40f3c
1 Parent(s): f1db0a9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -41,7 +41,7 @@ def get_model_info(df):
41
  api = HfApi()
42
 
43
  # Initialize new columns for likes and tags
44
- df[''] = None
45
  df['Tags'] = None
46
 
47
  # Iterate through DataFrame rows
@@ -49,11 +49,11 @@ def get_model_info(df):
49
  model = row['Model'].strip()
50
  try:
51
  model_info = api.model_info(repo_id=str(model))
52
- df.loc[index, ''] = model_info.likes
53
  df.loc[index, 'Tags'] = ', '.join(model_info.tags)
54
 
55
  except (RepositoryNotFoundError, RevisionNotFoundError):
56
- df.loc[index, ''] = -1
57
  df.loc[index, 'Tags'] = ''
58
 
59
  return df
@@ -122,13 +122,24 @@ def main():
122
 
123
  # Concatenate the DataFrames
124
  if dfs_to_concat:
125
- df = pd.concat(dfs_to_concat, ignore_index=True)
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  # Sort values
128
  df = df.sort_values(by='Average', ascending=False)
129
 
130
  # Display the DataFrame
131
- st.dataframe(df[['Model'] + score_columns + ['']], use_container_width=True)
132
 
133
  # Full-width plot for the first category
134
  create_bar_chart(df, score_columns[0])
 
41
  api = HfApi()
42
 
43
  # Initialize new columns for likes and tags
44
+ df['Likes'] = None
45
  df['Tags'] = None
46
 
47
  # Iterate through DataFrame rows
 
49
  model = row['Model'].strip()
50
  try:
51
  model_info = api.model_info(repo_id=str(model))
52
+ df.loc[index, 'Likes'] = model_info.likes
53
  df.loc[index, 'Tags'] = ', '.join(model_info.tags)
54
 
55
  except (RepositoryNotFoundError, RevisionNotFoundError):
56
+ df.loc[index, 'Likes'] = -1
57
  df.loc[index, 'Tags'] = ''
58
 
59
  return df
 
122
 
123
  # Concatenate the DataFrames
124
  if dfs_to_concat:
125
+ df = pd.concat(
126
+ dfs_to_concat,
127
+ column_config={
128
+ "Likes": st.column_config.NumberColumn(
129
+ "Likes",
130
+ help="Number of likes on Hugging Face",
131
+ format="%d ❤️",
132
+ ),
133
+ "URL": st.column_config.LinkColumn("App URL"),
134
+ },
135
+ hide_index=True,
136
+ )
137
 
138
  # Sort values
139
  df = df.sort_values(by='Average', ascending=False)
140
 
141
  # Display the DataFrame
142
+ st.dataframe(df[['Model'] + score_columns + ['Likes', 'URL']], use_container_width=True)
143
 
144
  # Full-width plot for the first category
145
  create_bar_chart(df, score_columns[0])