|
import streamlit as st |
|
from huggingface_hub import HfApi |
|
import pandas as pd |
|
from concurrent.futures import ThreadPoolExecutor, as_completed |
|
|
|
|
|
default_users = { |
|
"users": [ |
|
"awacke1", "rogerxavier", "jonatasgrosman", "kenshinn", "Csplk", "DavidVivancos", |
|
"cdminix", "Jaward", "TuringsSolutions", "Severian", "Wauplin", |
|
"phosseini", "Malikeh1375", "gokaygokay", "MoritzLaurer", "mrm8488", |
|
"TheBloke", "lhoestq", "xw-eric", "Paul", "Muennighoff", |
|
"ccdv", "haonan-li", "chansung", "lukaemon", "hails", |
|
"pharmapsychotic", "KingNish", "merve", "ameerazam08", "ashleykleynhans" |
|
] |
|
} |
|
|
|
api = HfApi() |
|
|
|
def get_user_content(username): |
|
try: |
|
|
|
models = api.list_models(author=username) |
|
datasets = api.list_datasets(author=username) |
|
spaces = api.list_spaces(author=username) |
|
|
|
return { |
|
"username": username, |
|
"models": models, |
|
"datasets": datasets, |
|
"spaces": spaces |
|
} |
|
except Exception as e: |
|
return {"username": username, "error": str(e)} |
|
|
|
st.title("Hugging Face User Content Display") |
|
|
|
|
|
default_users_str = "\n".join(default_users["users"]) |
|
|
|
|
|
usernames = st.text_area("Enter Hugging Face usernames (one per line):", value=default_users_str, height=300) |
|
|
|
if st.button("Show User Content"): |
|
if usernames: |
|
username_list = [username.strip() for username in usernames.split('\n') if username.strip()] |
|
results = [] |
|
status_bars = {} |
|
|
|
|
|
for username in username_list: |
|
status_bars[username] = st.progress(0, text=f"Fetching data for {username}...") |
|
|
|
def fetch_and_display(username): |
|
content = get_user_content(username) |
|
status_bars[username].progress(100, text=f"Data fetched for {username}") |
|
return content |
|
|
|
|
|
with ThreadPoolExecutor(max_workers=len(username_list)) as executor: |
|
future_to_username = {executor.submit(fetch_and_display, username): username for username in username_list} |
|
for future in as_completed(future_to_username): |
|
result = future.result() |
|
results.append(result) |
|
|
|
st.markdown("### User Content Overview") |
|
for result in results: |
|
username = result["username"] |
|
if "error" not in result: |
|
profile_link = f"https://huggingface.co/{username}" |
|
profile_emoji = "🔗" |
|
|
|
models = [f"[{model.modelId}](https://huggingface.co/{model.modelId})" for model in result['models']] |
|
datasets = [f"[{dataset.id}](https://huggingface.co/datasets/{dataset.id})" for dataset in result['datasets']] |
|
spaces = [f"[{space.id}](https://huggingface.co/spaces/{space.id})" for space in result['spaces']] |
|
|
|
st.markdown(f"**{username}** {profile_emoji} [Profile]({profile_link})") |
|
st.markdown("**Models:**") |
|
st.markdown("\n".join(models) if models else "No models found") |
|
st.markdown("**Datasets:**") |
|
st.markdown("\n".join(datasets) if datasets else "No datasets found") |
|
st.markdown("**Spaces:**") |
|
st.markdown("\n".join(spaces) if spaces else "No spaces found") |
|
st.markdown("---") |
|
else: |
|
st.warning(f"{username}: {result['error']}") |
|
|
|
else: |
|
st.warning("Please enter at least one username.") |
|
|
|
st.sidebar.markdown(""" |
|
## How to use: |
|
1. The text area is pre-filled with a list of Hugging Face usernames. You can edit this list or add more usernames. |
|
2. Click 'Show User Content'. |
|
3. View the user's models, datasets, and spaces along with a link to their Hugging Face profile. |
|
4. The progress bars show the status of content retrieval for each user. |
|
""") |
|
|