CultriX commited on
Commit
708e0e9
1 Parent(s): e32d84f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -0
app.py CHANGED
@@ -9,6 +9,11 @@ from io import StringIO
9
  from yall import create_yall
10
  import plotly.graph_objs as go
11
 
 
 
 
 
 
12
  # Function to get model info from Hugging Face API using caching
13
  @cache
14
  def cached_model_info(api, model):
@@ -196,6 +201,16 @@ def main():
196
  if search_query:
197
  df = df[df['Model'].str.contains(search_query, case=False)]
198
 
 
 
 
 
 
 
 
 
 
 
199
  # Display the filtered DataFrame or the entire leaderboard
200
  st.dataframe(
201
  df[['Model'] + score_columns + ['Likes', 'URL']],
 
9
  from yall import create_yall
10
  import plotly.graph_objs as go
11
 
12
+ def calculate_pages(df, items_per_page):
13
+ return -(-len(df) // items_per_page) # Equivalent to math.ceil(len(df) / items_per_page)
14
+
15
+
16
+
17
  # Function to get model info from Hugging Face API using caching
18
  @cache
19
  def cached_model_info(api, model):
 
201
  if search_query:
202
  df = df[df['Model'].str.contains(search_query, case=False)]
203
 
204
+ # Add a selectbox for page selection
205
+ items_per_page = 20
206
+ pages = calculate_pages(df, items_per_page)
207
+ page = st.selectbox("Page", list(range(1, pages + 1)))
208
+
209
+ # Slice the DataFrame based on the selected page
210
+ start = (page - 1) * items_per_page
211
+ end = start + items_per_page
212
+ df = df[start:end]
213
+
214
  # Display the filtered DataFrame or the entire leaderboard
215
  st.dataframe(
216
  df[['Model'] + score_columns + ['Likes', 'URL']],