Spaces:
Sleeping
Sleeping
Vũ Thanh Hà
commited on
Commit
•
ea325e1
0
Parent(s):
Add files via upload
Browse files- 2_hf_repo_info.py +64 -0
2_hf_repo_info.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from huggingface_hub import list_models
|
3 |
+
from datetime import date, timedelta, datetime, timezone
|
4 |
+
import pandas as pd
|
5 |
+
|
6 |
+
|
7 |
+
st.set_page_config(layout="wide")
|
8 |
+
# @st.cache_resource
|
9 |
+
# def get_model_list():
|
10 |
+
# return [model for model in list(list_models(author="hahunavth", filter="emofs2"))]
|
11 |
+
|
12 |
+
def get_ckpt_list(model):
|
13 |
+
files = model.siblings
|
14 |
+
file_names = [file.rfilename for file in files if "pytorch_model" in file.rfilename]
|
15 |
+
return file_names
|
16 |
+
|
17 |
+
|
18 |
+
with st.form("my_form"):
|
19 |
+
_author = st.text_input("Author", "hahunavth")
|
20 |
+
_filter = st.text_input("Slug", "emofs2")
|
21 |
+
submit = st.form_submit_button("Submit")
|
22 |
+
|
23 |
+
models = list(
|
24 |
+
list_models(author=_author, filter=_filter, sort="last_modified", direction=-1)
|
25 |
+
)
|
26 |
+
|
27 |
+
_models = []
|
28 |
+
now = datetime.now(timezone.utc)
|
29 |
+
for model in models:
|
30 |
+
ckpts = get_ckpt_list(model)
|
31 |
+
ckpts_step = [ckpt.replace("pytorch_model.", "").replace(".bin", "") for ckpt in ckpts]
|
32 |
+
ckpts_step = [int(ckpt) for ckpt in ckpts_step if ckpt.isdigit()]
|
33 |
+
ckpts_step.sort()
|
34 |
+
last_ckpt = "{:,}".format(ckpts_step[-1]) if ckpts_step else None
|
35 |
+
diff = None
|
36 |
+
if model.last_modified:
|
37 |
+
now = now.replace(microsecond=0)
|
38 |
+
last_modified = model.last_modified.replace(microsecond=0)
|
39 |
+
diff = now - last_modified
|
40 |
+
diff = str(diff)
|
41 |
+
|
42 |
+
step = model.id.replace('hahunavth/emofs2-exp', '').split('_')[0]
|
43 |
+
_models.append(
|
44 |
+
{
|
45 |
+
"id": model.id,
|
46 |
+
"last_modified": diff,
|
47 |
+
"ckpt_list": last_ckpt,
|
48 |
+
"huggingface": f'https://huggingface.co/{model.id}/tree/main' if model.id else None,
|
49 |
+
"notebook": f"https://www.kaggle.com/code/hahunavth/ess-vlsp2023-train-{step}" if model.id else None,
|
50 |
+
"kaggle": f"/kaggle/repo/vlsp2023-ess/config/exp{step}",
|
51 |
+
}
|
52 |
+
)
|
53 |
+
|
54 |
+
|
55 |
+
df = pd.DataFrame(_models)
|
56 |
+
|
57 |
+
st.dataframe(
|
58 |
+
df,
|
59 |
+
column_config={
|
60 |
+
"huggingface": st.column_config.LinkColumn(),
|
61 |
+
"notebook": st.column_config.LinkColumn(),
|
62 |
+
},
|
63 |
+
use_container_width=True
|
64 |
+
)
|