kolaslab commited on
Commit
4348906
·
verified ·
1 Parent(s): 15531e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -51
app.py CHANGED
@@ -12,12 +12,12 @@ from collections import Counter
12
 
13
  st.set_page_config(page_title="HF Contributions", layout="wide", initial_sidebar_state="expanded")
14
 
15
- # Set custom sidebar width
16
  st.markdown("""
17
  <style>
18
  [data-testid="stSidebar"] {
19
- min-width: 450px !important;
20
- max-width: 550px !important;
21
  }
22
  </style>
23
  """, unsafe_allow_html=True)
@@ -278,12 +278,10 @@ with st.spinner("Loading trending accounts..."):
278
  with st.sidebar:
279
  st.title("👤 Contributor")
280
 
281
- # Create tabs for Spaces and Models rankings
282
- tab1, tab2, tab3, tab4 = st.tabs([
283
  "SPACES TOP 30",
284
- "SPACES TOP 100",
285
- "MODELS TOP 30",
286
- "MODELS TOP 100"
287
  ])
288
 
289
  with tab1:
@@ -302,8 +300,9 @@ with st.sidebar:
302
  # Create the overall ranking dataframe
303
  overall_data = []
304
  for idx, username in enumerate(trending_accounts[:100]):
305
- spaces_position = spaces_rank.get(username, "-")
306
- models_position = models_rank.get(username, "-")
 
307
  overall_data.append([username, spaces_position, models_position])
308
 
309
  ranking_data_overall = pd.DataFrame(
@@ -363,46 +362,6 @@ with st.sidebar:
363
  plt.tight_layout()
364
  st.pyplot(fig)
365
 
366
- with tab2:
367
- # Show trending accounts list by Models
368
- st.subheader("🧠 Top 100 by Models")
369
-
370
- # Display the top 100 accounts list
371
- st.markdown("### Models Contributors Ranking")
372
-
373
- # Create a data frame for the table
374
- if top_owners_models:
375
- ranking_data_models = pd.DataFrame(top_owners_models[:100], columns=["Contributor", "Models Count"])
376
- ranking_data_models.index = ranking_data_models.index + 1 # Start index from 1 for ranking
377
-
378
- st.dataframe(
379
- ranking_data_models,
380
- column_config={
381
- "Contributor": st.column_config.TextColumn("Contributor"),
382
- "Models Count": st.column_config.NumberColumn("Models Count (based on top 500 models)", format="%d")
383
- },
384
- use_container_width=True,
385
- hide_index=False
386
- )
387
-
388
- # Add stats expander with visualization
389
- with st.expander("View Top 30 Models Contributors Chart"):
390
- # Create a bar chart for top 30 contributors
391
- if top_owners_models:
392
- chart_data = pd.DataFrame(top_owners_models[:30], columns=["Owner", "Models Count"])
393
-
394
- fig, ax = plt.subplots(figsize=(10, 8))
395
- bars = ax.barh(chart_data["Owner"], chart_data["Models Count"])
396
-
397
- # Add color gradient to bars
398
- for i, bar in enumerate(bars):
399
- bar.set_color(plt.cm.plasma(i/len(bars))) # Use a different colormap for models
400
-
401
- ax.set_title("Top 30 Contributors by Number of Models")
402
- ax.set_xlabel("Number of Models")
403
- plt.tight_layout()
404
- st.pyplot(fig)
405
-
406
  # Display trending accounts selection dropdown
407
  st.subheader("Select Contributor")
408
  selected_trending = st.selectbox(
@@ -414,7 +373,7 @@ with st.sidebar:
414
 
415
  # Custom account input option
416
  st.markdown("<div style='text-align: center; margin: 10px 0;'>OR</div>", unsafe_allow_html=True)
417
- custom = st.text_input("", placeholder="Enter custom username/org")
418
 
419
  # Set username based on selection or custom input
420
  if custom.strip():
 
12
 
13
  st.set_page_config(page_title="HF Contributions", layout="wide", initial_sidebar_state="expanded")
14
 
15
+ # Set custom sidebar width - UPDATED to 40% of the screen
16
  st.markdown("""
17
  <style>
18
  [data-testid="stSidebar"] {
19
+ min-width: 40vw !important;
20
+ max-width: 40vw !important;
21
  }
22
  </style>
23
  """, unsafe_allow_html=True)
 
278
  with st.sidebar:
279
  st.title("👤 Contributor")
280
 
281
+ # Create tabs for Spaces and Models rankings - ONLY SHOWING FIRST TWO TABS
282
+ tab1, tab2 = st.tabs([
283
  "SPACES TOP 30",
284
+ "SPACES TOP 100"
 
 
285
  ])
286
 
287
  with tab1:
 
300
  # Create the overall ranking dataframe
301
  overall_data = []
302
  for idx, username in enumerate(trending_accounts[:100]):
303
+ # Use strings for all rankings to avoid type conversion issues
304
+ spaces_position = str(spaces_rank.get(username, "-"))
305
+ models_position = str(models_rank.get(username, "-"))
306
  overall_data.append([username, spaces_position, models_position])
307
 
308
  ranking_data_overall = pd.DataFrame(
 
362
  plt.tight_layout()
363
  st.pyplot(fig)
364
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  # Display trending accounts selection dropdown
366
  st.subheader("Select Contributor")
367
  selected_trending = st.selectbox(
 
373
 
374
  # Custom account input option
375
  st.markdown("<div style='text-align: center; margin: 10px 0;'>OR</div>", unsafe_allow_html=True)
376
+ custom = st.text_input("Enter username/org", label_visibility="collapsed")
377
 
378
  # Set username based on selection or custom input
379
  if custom.strip():