Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
| 1 |
-
|
| 2 |
import streamlit as st
|
| 3 |
from huggingface_hub import HfApi
|
| 4 |
import pandas as pd
|
|
@@ -6,7 +5,7 @@ import pandas as pd
|
|
| 6 |
# Default list of Hugging Face usernames
|
| 7 |
default_users = {
|
| 8 |
"users": [
|
| 9 |
-
"rogerxavier", "jonatasgrosman", "kenshinn", "Csplk", "DavidVivancos",
|
| 10 |
"cdminix", "Jaward", "TuringsSolutions", "Severian", "Wauplin",
|
| 11 |
"phosseini", "Malikeh1375", "gokaygokay", "MoritzLaurer", "mrm8488",
|
| 12 |
"TheBloke", "lhoestq", "xw-eric", "Paul", "Muennighoff",
|
|
@@ -15,24 +14,25 @@ default_users = {
|
|
| 15 |
]
|
| 16 |
}
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
try:
|
| 21 |
-
# Fetch
|
| 22 |
models = api.list_models(author=username)
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
except Exception as e:
|
| 32 |
-
st.error(f"Error fetching
|
| 33 |
-
|
| 34 |
|
| 35 |
-
st.title("Hugging Face
|
| 36 |
|
| 37 |
# Convert the default users list to a string
|
| 38 |
default_users_str = "\n".join(default_users["users"])
|
|
@@ -40,37 +40,54 @@ default_users_str = "\n".join(default_users["users"])
|
|
| 40 |
# Text area with default list of usernames
|
| 41 |
usernames = st.text_area("Enter Hugging Face usernames (one per line):", value=default_users_str, height=300)
|
| 42 |
|
| 43 |
-
if st.button("
|
| 44 |
if usernames:
|
| 45 |
username_list = [username.strip() for username in usernames.split('\n') if username.strip()]
|
| 46 |
results = []
|
| 47 |
|
| 48 |
progress_bar = st.progress(0)
|
| 49 |
for i, username in enumerate(username_list):
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
else:
|
| 63 |
-
|
| 64 |
|
| 65 |
-
st.markdown("### Twitter Profile Links")
|
| 66 |
-
st.markdown(markdown_links)
|
| 67 |
else:
|
| 68 |
st.warning("Please enter at least one username.")
|
| 69 |
|
| 70 |
st.sidebar.markdown("""
|
| 71 |
## How to use:
|
| 72 |
1. The text area is pre-filled with a list of Hugging Face usernames. You can edit this list or add more usernames.
|
| 73 |
-
2. Click '
|
| 74 |
-
3. View the
|
| 75 |
-
4. The progress bar shows the status of
|
| 76 |
""")
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from huggingface_hub import HfApi
|
| 3 |
import pandas as pd
|
|
|
|
| 5 |
# Default list of Hugging Face usernames
|
| 6 |
default_users = {
|
| 7 |
"users": [
|
| 8 |
+
"awacke1", "rogerxavier", "jonatasgrosman", "kenshinn", "Csplk", "DavidVivancos",
|
| 9 |
"cdminix", "Jaward", "TuringsSolutions", "Severian", "Wauplin",
|
| 10 |
"phosseini", "Malikeh1375", "gokaygokay", "MoritzLaurer", "mrm8488",
|
| 11 |
"TheBloke", "lhoestq", "xw-eric", "Paul", "Muennighoff",
|
|
|
|
| 14 |
]
|
| 15 |
}
|
| 16 |
|
| 17 |
+
api = HfApi()
|
| 18 |
+
|
| 19 |
+
def get_user_content(username):
|
| 20 |
try:
|
| 21 |
+
# Fetch models, datasets, and spaces associated with the user
|
| 22 |
models = api.list_models(author=username)
|
| 23 |
+
datasets = api.list_datasets(author=username)
|
| 24 |
+
spaces = api.list_spaces(author=username)
|
| 25 |
+
|
| 26 |
+
return {
|
| 27 |
+
"models": models,
|
| 28 |
+
"datasets": datasets,
|
| 29 |
+
"spaces": spaces
|
| 30 |
+
}
|
| 31 |
except Exception as e:
|
| 32 |
+
st.error(f"Error fetching content for {username}: {str(e)}")
|
| 33 |
+
return None
|
| 34 |
|
| 35 |
+
st.title("Hugging Face User Content Display")
|
| 36 |
|
| 37 |
# Convert the default users list to a string
|
| 38 |
default_users_str = "\n".join(default_users["users"])
|
|
|
|
| 40 |
# Text area with default list of usernames
|
| 41 |
usernames = st.text_area("Enter Hugging Face usernames (one per line):", value=default_users_str, height=300)
|
| 42 |
|
| 43 |
+
if st.button("Show User Content"):
|
| 44 |
if usernames:
|
| 45 |
username_list = [username.strip() for username in usernames.split('\n') if username.strip()]
|
| 46 |
results = []
|
| 47 |
|
| 48 |
progress_bar = st.progress(0)
|
| 49 |
for i, username in enumerate(username_list):
|
| 50 |
+
content = get_user_content(username)
|
| 51 |
+
if content:
|
| 52 |
+
profile_link = f"https://huggingface.co/{username}"
|
| 53 |
+
profile_emoji = "🔗"
|
| 54 |
+
|
| 55 |
+
models = [f"[{model.modelId}](https://huggingface.co/{model.modelId})" for model in content['models']]
|
| 56 |
+
datasets = [f"[{dataset.id}](https://huggingface.co/datasets/{dataset.id})" for dataset in content['datasets']]
|
| 57 |
+
spaces = [f"[{space.id}](https://huggingface.co/spaces/{space.id})" for space in content['spaces']]
|
| 58 |
|
| 59 |
+
results.append({
|
| 60 |
+
"Hugging Face": username,
|
| 61 |
+
"Profile Link": f"[{profile_emoji} Profile]({profile_link})",
|
| 62 |
+
"Models": models,
|
| 63 |
+
"Datasets": datasets,
|
| 64 |
+
"Spaces": spaces
|
| 65 |
+
})
|
| 66 |
+
else:
|
| 67 |
+
results.append({"Hugging Face": username, "Error": "User content not found"})
|
| 68 |
+
progress_bar.progress((i + 1) / len(username_list))
|
| 69 |
|
| 70 |
+
st.markdown("### User Content Overview")
|
| 71 |
+
for result in results:
|
| 72 |
+
if "Error" not in result:
|
| 73 |
+
st.markdown(f"**{result['Hugging Face']}** {result['Profile Link']}")
|
| 74 |
+
st.markdown("**Models:**")
|
| 75 |
+
st.markdown("\n".join(result["Models"]) if result["Models"] else "No models found")
|
| 76 |
+
st.markdown("**Datasets:**")
|
| 77 |
+
st.markdown("\n".join(result["Datasets"]) if result["Datasets"] else "No datasets found")
|
| 78 |
+
st.markdown("**Spaces:**")
|
| 79 |
+
st.markdown("\n".join(result["Spaces"]) if result["Spaces"] else "No spaces found")
|
| 80 |
+
st.markdown("---")
|
| 81 |
else:
|
| 82 |
+
st.warning(f"{result['Hugging Face']}: {result['Error']}")
|
| 83 |
|
|
|
|
|
|
|
| 84 |
else:
|
| 85 |
st.warning("Please enter at least one username.")
|
| 86 |
|
| 87 |
st.sidebar.markdown("""
|
| 88 |
## How to use:
|
| 89 |
1. The text area is pre-filled with a list of Hugging Face usernames. You can edit this list or add more usernames.
|
| 90 |
+
2. Click 'Show User Content'.
|
| 91 |
+
3. View the user's models, datasets, and spaces along with a link to their Hugging Face profile.
|
| 92 |
+
4. The progress bar shows the status of content retrieval.
|
| 93 |
""")
|