Update app.py
Browse files
app.py
CHANGED
@@ -721,7 +721,8 @@ with st.sidebar:
|
|
721 |
# Create a mapping from username to Spaces and Models rankings
|
722 |
spaces_rank = {owner: idx+1 for idx, (owner, _) in enumerate(top_owners_spaces)}
|
723 |
models_rank = {owner: idx+1 for idx, (owner, _) in enumerate(top_owners_models)}
|
724 |
-
|
|
|
725 |
overall_data = []
|
726 |
for idx, username in enumerate(trending_accounts[:100]):
|
727 |
# Add trophy emojis for top 3
|
@@ -729,21 +730,20 @@ with st.sidebar:
|
|
729 |
if idx == 0:
|
730 |
rank_display = "π " # Gold trophy for 1st place
|
731 |
elif idx == 1:
|
732 |
-
rank_display = "
|
733 |
elif idx == 2:
|
734 |
-
rank_display = "
|
735 |
-
|
|
|
736 |
spaces_position = str(spaces_rank.get(username, "-"))
|
737 |
models_position = str(models_rank.get(username, "-"))
|
738 |
overall_data.append([f"{rank_display}{username}", spaces_position, models_position])
|
739 |
-
|
740 |
ranking_data_overall = pd.DataFrame(
|
741 |
overall_data,
|
742 |
columns=["Contributor", "Spaces Rank", "Models Rank"]
|
743 |
)
|
744 |
ranking_data_overall.index = ranking_data_overall.index + 1 # Start index from 1 for ranking
|
745 |
-
|
746 |
-
|
747 |
|
748 |
st.dataframe(
|
749 |
ranking_data_overall,
|
@@ -760,9 +760,22 @@ with st.sidebar:
|
|
760 |
# Show trending accounts by Spaces & Models
|
761 |
st.markdown('<div class="subheader"><h3>π Spaces Leaders</h3></div>', unsafe_allow_html=True)
|
762 |
|
763 |
-
# Create a data frame for the table
|
764 |
if top_owners_spaces:
|
765 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
766 |
ranking_data_spaces.index = ranking_data_spaces.index + 1 # Start index from 1 for ranking
|
767 |
|
768 |
st.dataframe(
|
@@ -775,12 +788,25 @@ with st.sidebar:
|
|
775 |
hide_index=False
|
776 |
)
|
777 |
|
778 |
-
# Display the top Models accounts list
|
779 |
st.markdown('<div class="subheader"><h3>π§ Models Leaders</h3></div>', unsafe_allow_html=True)
|
780 |
|
781 |
-
# Create a data frame for the Models table
|
782 |
if top_owners_models:
|
783 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
784 |
ranking_data_models.index = ranking_data_models.index + 1 # Start index from 1 for ranking
|
785 |
|
786 |
st.dataframe(
|
@@ -1150,4 +1176,4 @@ else:
|
|
1150 |
f'<img src="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg" style="width: 200px; margin-bottom: 30px;">'
|
1151 |
f'<h2>Welcome to Hugging Face Contributions Dashboard</h2>'
|
1152 |
f'<p style="font-size: 1.2rem;">Please select a contributor from the sidebar to view their activity.</p>'
|
1153 |
-
f'</div>', unsafe_allow_html=True)
|
|
|
721 |
# Create a mapping from username to Spaces and Models rankings
|
722 |
spaces_rank = {owner: idx+1 for idx, (owner, _) in enumerate(top_owners_spaces)}
|
723 |
models_rank = {owner: idx+1 for idx, (owner, _) in enumerate(top_owners_models)}
|
724 |
+
|
725 |
+
# Create the overall ranking dataframe with trophies for top 3
|
726 |
overall_data = []
|
727 |
for idx, username in enumerate(trending_accounts[:100]):
|
728 |
# Add trophy emojis for top 3
|
|
|
730 |
if idx == 0:
|
731 |
rank_display = "π " # Gold trophy for 1st place
|
732 |
elif idx == 1:
|
733 |
+
rank_display = "π " # Silver trophy for 2nd place
|
734 |
elif idx == 2:
|
735 |
+
rank_display = "π " # Bronze trophy for 3rd place
|
736 |
+
|
737 |
+
# Use strings for all rankings to avoid type conversion issues
|
738 |
spaces_position = str(spaces_rank.get(username, "-"))
|
739 |
models_position = str(models_rank.get(username, "-"))
|
740 |
overall_data.append([f"{rank_display}{username}", spaces_position, models_position])
|
741 |
+
|
742 |
ranking_data_overall = pd.DataFrame(
|
743 |
overall_data,
|
744 |
columns=["Contributor", "Spaces Rank", "Models Rank"]
|
745 |
)
|
746 |
ranking_data_overall.index = ranking_data_overall.index + 1 # Start index from 1 for ranking
|
|
|
|
|
747 |
|
748 |
st.dataframe(
|
749 |
ranking_data_overall,
|
|
|
760 |
# Show trending accounts by Spaces & Models
|
761 |
st.markdown('<div class="subheader"><h3>π Spaces Leaders</h3></div>', unsafe_allow_html=True)
|
762 |
|
763 |
+
# Create a data frame for the Spaces table with medals for top 3
|
764 |
if top_owners_spaces:
|
765 |
+
spaces_data = []
|
766 |
+
for idx, (owner, count) in enumerate(top_owners_spaces[:50]):
|
767 |
+
# Add medal emojis for top 3
|
768 |
+
rank_display = ""
|
769 |
+
if idx == 0:
|
770 |
+
rank_display = "π₯ " # Gold medal for 1st place
|
771 |
+
elif idx == 1:
|
772 |
+
rank_display = "π₯ " # Silver medal for 2nd place
|
773 |
+
elif idx == 2:
|
774 |
+
rank_display = "π₯ " # Bronze medal for 3rd place
|
775 |
+
|
776 |
+
spaces_data.append([f"{rank_display}{owner}", count])
|
777 |
+
|
778 |
+
ranking_data_spaces = pd.DataFrame(spaces_data, columns=["Contributor", "Spaces Count"])
|
779 |
ranking_data_spaces.index = ranking_data_spaces.index + 1 # Start index from 1 for ranking
|
780 |
|
781 |
st.dataframe(
|
|
|
788 |
hide_index=False
|
789 |
)
|
790 |
|
791 |
+
# Display the top Models accounts list with medals for top 3
|
792 |
st.markdown('<div class="subheader"><h3>π§ Models Leaders</h3></div>', unsafe_allow_html=True)
|
793 |
|
794 |
+
# Create a data frame for the Models table with medals for top 3
|
795 |
if top_owners_models:
|
796 |
+
models_data = []
|
797 |
+
for idx, (owner, count) in enumerate(top_owners_models[:50]):
|
798 |
+
# Add medal emojis for top 3
|
799 |
+
rank_display = ""
|
800 |
+
if idx == 0:
|
801 |
+
rank_display = "π₯ " # Gold medal for 1st place
|
802 |
+
elif idx == 1:
|
803 |
+
rank_display = "π₯ " # Silver medal for 2nd place
|
804 |
+
elif idx == 2:
|
805 |
+
rank_display = "π₯ " # Bronze medal for 3rd place
|
806 |
+
|
807 |
+
models_data.append([f"{rank_display}{owner}", count])
|
808 |
+
|
809 |
+
ranking_data_models = pd.DataFrame(models_data, columns=["Contributor", "Models Count"])
|
810 |
ranking_data_models.index = ranking_data_models.index + 1 # Start index from 1 for ranking
|
811 |
|
812 |
st.dataframe(
|
|
|
1176 |
f'<img src="https://huggingface.co/datasets/huggingface/brand-assets/resolve/main/hf-logo.svg" style="width: 200px; margin-bottom: 30px;">'
|
1177 |
f'<h2>Welcome to Hugging Face Contributions Dashboard</h2>'
|
1178 |
f'<p style="font-size: 1.2rem;">Please select a contributor from the sidebar to view their activity.</p>'
|
1179 |
+
f'</div>', unsafe_allow_html=True)
|