Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,13 @@ __all__ = ['block', 'make_clickable_model', 'make_clickable_user', 'get_submissi
|
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
import pandas as pd
|
| 6 |
-
from huggingface_hub import HfApi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
def make_clickable_model(model_name, link=None):
|
| 9 |
if link is None:
|
|
@@ -28,14 +34,15 @@ def get_submissions():
|
|
| 28 |
|
| 29 |
for submission in submissions:
|
| 30 |
# user, model, likes
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
(
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
)
|
| 38 |
-
)
|
| 39 |
|
| 40 |
df = pd.DataFrame(data=leaderboard_models, columns=["User", "Space", "Likes"])
|
| 41 |
df.sort_values(by=["Likes"], ascending=False, inplace=True)
|
|
|
|
| 3 |
|
| 4 |
import gradio as gr
|
| 5 |
import pandas as pd
|
| 6 |
+
from huggingface_hub import HfApi, RepoCard
|
| 7 |
+
|
| 8 |
+
def is_duplicated(space_id:str)->None:
|
| 9 |
+
card = RepoCard.load(space_id, repo_type="space")
|
| 10 |
+
return getattr(card.data, "duplicated_from", None) is not None
|
| 11 |
+
|
| 12 |
+
|
| 13 |
|
| 14 |
def make_clickable_model(model_name, link=None):
|
| 15 |
if link is None:
|
|
|
|
| 34 |
|
| 35 |
for submission in submissions:
|
| 36 |
# user, model, likes
|
| 37 |
+
if not is_duplicated(submission.id)
|
| 38 |
+
user_id = submission.id.split("/")[0]
|
| 39 |
+
leaderboard_models.append(
|
| 40 |
+
(
|
| 41 |
+
make_clickable_user(user_id),
|
| 42 |
+
make_clickable_model(submission.id),
|
| 43 |
+
submission.likes,
|
| 44 |
+
)
|
| 45 |
)
|
|
|
|
| 46 |
|
| 47 |
df = pd.DataFrame(data=leaderboard_models, columns=["User", "Space", "Likes"])
|
| 48 |
df.sort_values(by=["Likes"], ascending=False, inplace=True)
|