File size: 3,922 Bytes
9774217
 
 
 
 
 
 
0bedbaa
9774217
 
 
 
 
 
 
 
0bedbaa
 
 
9774217
0bedbaa
c2bed9a
0bedbaa
 
 
 
 
 
 
 
9774217
0bedbaa
 
9774217
0bedbaa
9774217
 
 
 
 
 
 
0bedbaa
9774217
 
 
 
 
 
0bedbaa
 
 
 
 
 
 
 
9774217
0bedbaa
 
 
 
 
 
 
 
 
 
9774217
0bedbaa
 
 
 
 
 
 
 
 
 
 
9774217
0bedbaa
9774217
 
 
 
 
 
 
0bedbaa
 
 
c2bed9a
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
import streamlit as st
from huggingface_hub import HfApi
import pandas as pd

# Default list of Hugging Face usernames
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:
        # Fetch models, datasets, and spaces associated with the user
        models = api.list_models(author=username)
        datasets = api.list_datasets(author=username)
        spaces = api.list_spaces(author=username)
        
        return {
            "models": models,
            "datasets": datasets,
            "spaces": spaces
        }
    except Exception as e:
        st.error(f"Error fetching content for {username}: {str(e)}")
        return None

st.title("Hugging Face User Content Display")

# Convert the default users list to a string
default_users_str = "\n".join(default_users["users"])

# Text area with default list of usernames
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 = []

        progress_bar = st.progress(0)
        for i, username in enumerate(username_list):
            content = get_user_content(username)
            if content:
                profile_link = f"https://huggingface.co/{username}"
                profile_emoji = "🔗"
                
                models = [f"[{model.modelId}](https://huggingface.co/{model.modelId})" for model in content['models']]
                datasets = [f"[{dataset.id}](https://huggingface.co/datasets/{dataset.id})" for dataset in content['datasets']]
                spaces = [f"[{space.id}](https://huggingface.co/spaces/{space.id})" for space in content['spaces']]

                results.append({
                    "Hugging Face": username,
                    "Profile Link": f"[{profile_emoji} Profile]({profile_link})",
                    "Models": models,
                    "Datasets": datasets,
                    "Spaces": spaces
                })
            else:
                results.append({"Hugging Face": username, "Error": "User content not found"})
            progress_bar.progress((i + 1) / len(username_list))

        st.markdown("### User Content Overview")
        for result in results:
            if "Error" not in result:
                st.markdown(f"**{result['Hugging Face']}** {result['Profile Link']}")
                st.markdown("**Models:**")
                st.markdown("\n".join(result["Models"]) if result["Models"] else "No models found")
                st.markdown("**Datasets:**")
                st.markdown("\n".join(result["Datasets"]) if result["Datasets"] else "No datasets found")
                st.markdown("**Spaces:**")
                st.markdown("\n".join(result["Spaces"]) if result["Spaces"] else "No spaces found")
                st.markdown("---")
            else:
                st.warning(f"{result['Hugging Face']}: {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 bar shows the status of content retrieval.
""")