Spaces:
Sleeping
Sleeping
File size: 3,878 Bytes
90386c8 366cac1 90386c8 f42c13e 90386c8 0f9f215 90386c8 ed37630 f42c13e 90386c8 f42c13e 90386c8 f42c13e 90386c8 0f9f215 90386c8 0f9f215 90386c8 0f9f215 90386c8 f42c13e 90386c8 c0e96c7 90386c8 c0e96c7 90386c8 0f9f215 90386c8 f42c13e 90386c8 f42c13e 90386c8 f42c13e 0f9f215 90386c8 06bbcad 90386c8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
import subprocess
import os
import gradio as gr
import pandas as pd
import time
import threading
from huggingface_hub import HfApi
api = HfApi()
HF_TOKEN = os.getenv('HF_TOKEN')
repo_url = "https://huggingface.co/datasets/Weyaxi/compute-power-leaderboard"
os.system(f"git clone --bare --filter=blob:none {repo_url}")
os.chdir("compute-power-leaderboard.git")
result = subprocess.check_output("git log -1 --pretty=%B", shell=True, universal_newlines=True).replace("Upload", "").replace("/data.csv with huggingface_hub", "").strip().replace(" ", "%20")
os.system(f"wget -Odata.csv https://huggingface.co/datasets/Weyaxi/compute-power-leaderboard/resolve/main/{result}/data.csv")
def clickable(x):
return f'<a target="_blank" href="https://huggingface.co/{x}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{x}</a>'
def apply_headers(df, headers):
tmp = df.copy()
tmp.columns = headers
return tmp
def search(search_text):
if not search_text:
return df
return df[df['👤 Author'].str.contains(search_text, case=False, na=False)]
def restart_space():
time.sleep(36000)
api.restart_space(repo_id="Weyaxi/compute-power-leaderboard", token=HF_TOKEN)
df = pd.read_csv("data.csv")
df_author_copy = df.copy()
df["Author"] = df["Author"].apply(lambda x: clickable(x))
df = df.sort_values(by='TFLOPS', ascending=False)
df['Serial Number'] = [i for i in range(1, len(df)+1)]
df = df[['Serial Number', "Author", "TFLOPS", "Type"]];
df['Type'] = df['Type'].apply(lambda x: f'<img src="https://huggingface.co{x}" width="65" height="75">')
df = apply_headers(df, ["🔢 Serial Number", "👤 Author", "🖥️ TFLOPS", "🏷️ Type"])
desc = f"""
🎯 The Leaderboard aims to track users compute power in Huggingface.
## 📄 Information
🛠️ This leaderboard consists of 4000 users scraped from [🤗 Huggingface Leaderboard](https://huggingface.co/spaces/Weyaxi/huggingface-leaderboard).
These 4000 users have been selected based on their [🤗 Huggingface Leaderboard](https://huggingface.co/spaces/Weyaxi/huggingface-leaderboard) positions:
- 🤖 Top 2250 authors in the models category
- 📊 Top 1100 authors in the datasets category
- 🚀 Top 1100 authors in the spaces category
**Note that the majority of this 4000 users didn't inlclude their compute power.**
## 🤝 I want to see someone here
No problem, you can request to add a user [here](https://huggingface.co/spaces/Weyaxi/compute-power-leaderboard/discussions/1).
There is no critique; please request anyone. The number of users in this leaderboard is limited because scraping 250k user's follower count is challenging. 🙂
## Last Update
⌛ This space information is last updated in **{result.replace("%20", " ")}**.
"""
title = """
<div style="text-align:center">
<h1 id="space-title">🖥️ Compute Power Leaderboard 🖥️</h1>
</div>
"""
with gr.Blocks() as demo:
gr.Markdown("""<h1 align="center" id="space-title">🖥️ Compute Power Leaderboard 🖥️</h1>""")
gr.Markdown("""<h1 align="center" id="space-title"><img src="https://huggingface.co/front/assets/hardware/gpu.png" width="75" height="75" style="display:inline-block;"><img src="https://huggingface.co/front/assets/hardware/apple-silicon.svg" width="75" height="75" style="display:inline-block;"><img src="https://huggingface.co/front/assets/hardware/cpu.png" width="75" height="75" style="display:inline-block;"></h1>""")
gr.Markdown(desc)
with gr.Column(min_width=320):
search_bar = gr.Textbox(placeholder="🔍 Search for a author", show_label=False)
gr_followers = gr.Dataframe(df, interactive=False, datatype=["number", 'markdown', 'number', 'markdown'])
search_bar.submit(fn=search, inputs=search_bar, outputs=gr_followers)
threading.Thread(target=restart_space).start()
demo.launch() |