Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -287,15 +287,20 @@ def get_trending_accounts_with_commits(limit=100):
|
|
287 |
progress_text.empty()
|
288 |
progress_bar.empty()
|
289 |
|
290 |
-
# Sort by score (
|
291 |
user_stats.sort(key=lambda x: x["score"], reverse=True)
|
292 |
|
293 |
# Extract rankings
|
294 |
trending_authors = [stat["username"] for stat in user_stats[:limit]]
|
295 |
|
296 |
-
# Create
|
297 |
-
spaces_rank_data = [(stat["username"], stat["spaces"]) for stat in user_stats if stat["spaces"] > 0]
|
298 |
-
|
|
|
|
|
|
|
|
|
|
|
299 |
|
300 |
return trending_authors, spaces_rank_data, models_rank_data, user_stats[:limit]
|
301 |
|
@@ -824,8 +829,8 @@ with st.sidebar:
|
|
824 |
)
|
825 |
|
826 |
with tab2:
|
827 |
-
# Show
|
828 |
-
st.markdown('<div class="subheader"><h3>🚀 Spaces
|
829 |
|
830 |
# Create a data frame for the Spaces table with medals for top 3
|
831 |
if top_owners_spaces:
|
@@ -855,8 +860,8 @@ with st.sidebar:
|
|
855 |
hide_index=False
|
856 |
)
|
857 |
|
858 |
-
# Display
|
859 |
-
st.markdown('<div class="subheader"><h3>🧠 Models
|
860 |
|
861 |
# Create a data frame for the Models table with medals for top 3
|
862 |
if top_owners_models:
|
@@ -934,11 +939,11 @@ if username:
|
|
934 |
# Create a header card with contributor info
|
935 |
header_col1, header_col2 = st.columns([1, 2])
|
936 |
with header_col1:
|
937 |
-
|
938 |
st.markdown(f'<div style="background-color: #E3F2FD; padding: 20px; border-radius: 10px; border-left: 5px solid #1E88E5;">'
|
939 |
f'<h2 style="color: #1E88E5;">👤 {username}</h2>'
|
940 |
f'<p style="font-size: 16px;">Analyzing contributions for {selected_year}</p>'
|
941 |
-
f'<p style="font-size: 14px; font-weight: bold;">{
|
942 |
f'<p><a href="https://huggingface.co/{username}" target="_blank" style="color: #1E88E5; font-weight: bold;">View Profile</a></p>'
|
943 |
f'</div>', unsafe_allow_html=True)
|
944 |
|
@@ -947,7 +952,7 @@ if username:
|
|
947 |
st.markdown(f'<div style="background-color: #F3E5F5; padding: 20px; border-radius: 10px; border-left: 5px solid #9C27B0;">'
|
948 |
f'<h3 style="color: #9C27B0;">About This Analysis</h3>'
|
949 |
f'<p>This dashboard analyzes {username}\'s contributions to Hugging Face in {selected_year}, including models, datasets, and spaces.</p>'
|
950 |
-
f'<p style="font-style: italic; font-size: 12px;">*
|
951 |
f'</div>', unsafe_allow_html=True)
|
952 |
|
953 |
with st.spinner(f"Fetching detailed contribution data for {username}..."):
|
|
|
287 |
progress_text.empty()
|
288 |
progress_bar.empty()
|
289 |
|
290 |
+
# Sort by score (commits only) for overall ranking
|
291 |
user_stats.sort(key=lambda x: x["score"], reverse=True)
|
292 |
|
293 |
# Extract rankings
|
294 |
trending_authors = [stat["username"] for stat in user_stats[:limit]]
|
295 |
|
296 |
+
# Create separate rankings sorted by spaces and models count
|
297 |
+
spaces_rank_data = [(stat["username"], stat["spaces"]) for stat in user_stats if stat["spaces"] > 0]
|
298 |
+
spaces_rank_data.sort(key=lambda x: x[1], reverse=True) # Sort by spaces count
|
299 |
+
spaces_rank_data = spaces_rank_data[:limit]
|
300 |
+
|
301 |
+
models_rank_data = [(stat["username"], stat["models"]) for stat in user_stats if stat["models"] > 0]
|
302 |
+
models_rank_data.sort(key=lambda x: x[1], reverse=True) # Sort by models count
|
303 |
+
models_rank_data = models_rank_data[:limit]
|
304 |
|
305 |
return trending_authors, spaces_rank_data, models_rank_data, user_stats[:limit]
|
306 |
|
|
|
829 |
)
|
830 |
|
831 |
with tab2:
|
832 |
+
# Show accounts sorted by Spaces count
|
833 |
+
st.markdown('<div class="subheader"><h3>🚀 Top 50 by Spaces Count</h3></div>', unsafe_allow_html=True)
|
834 |
|
835 |
# Create a data frame for the Spaces table with medals for top 3
|
836 |
if top_owners_spaces:
|
|
|
860 |
hide_index=False
|
861 |
)
|
862 |
|
863 |
+
# Display accounts sorted by Models count
|
864 |
+
st.markdown('<div class="subheader"><h3>🧠 Top 50 by Models Count</h3></div>', unsafe_allow_html=True)
|
865 |
|
866 |
# Create a data frame for the Models table with medals for top 3
|
867 |
if top_owners_models:
|
|
|
939 |
# Create a header card with contributor info
|
940 |
header_col1, header_col2 = st.columns([1, 2])
|
941 |
with header_col1:
|
942 |
+
commits_display = f"Est. Commits: {user_stat['estimated_commits']}" if user_stat else "Est. Commits: N/A"
|
943 |
st.markdown(f'<div style="background-color: #E3F2FD; padding: 20px; border-radius: 10px; border-left: 5px solid #1E88E5;">'
|
944 |
f'<h2 style="color: #1E88E5;">👤 {username}</h2>'
|
945 |
f'<p style="font-size: 16px;">Analyzing contributions for {selected_year}</p>'
|
946 |
+
f'<p style="font-size: 14px; font-weight: bold;">{commits_display}</p>'
|
947 |
f'<p><a href="https://huggingface.co/{username}" target="_blank" style="color: #1E88E5; font-weight: bold;">View Profile</a></p>'
|
948 |
f'</div>', unsafe_allow_html=True)
|
949 |
|
|
|
952 |
st.markdown(f'<div style="background-color: #F3E5F5; padding: 20px; border-radius: 10px; border-left: 5px solid #9C27B0;">'
|
953 |
f'<h3 style="color: #9C27B0;">About This Analysis</h3>'
|
954 |
f'<p>This dashboard analyzes {username}\'s contributions to Hugging Face in {selected_year}, including models, datasets, and spaces.</p>'
|
955 |
+
f'<p style="font-style: italic; font-size: 12px;">* Overall rankings are based on total commit count. Space/Model rankings are based on repository count.</p>'
|
956 |
f'</div>', unsafe_allow_html=True)
|
957 |
|
958 |
with st.spinner(f"Fetching detailed contribution data for {username}..."):
|