Update get_model_list.py
Browse files- get_model_list.py +47 -0
get_model_list.py
CHANGED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import json
|
2 |
+
import os
|
3 |
+
import requests
|
4 |
+
|
5 |
+
import pandas as pd
|
6 |
+
|
7 |
+
|
8 |
+
def download(filename, url):
|
9 |
+
try:
|
10 |
+
with open(filename) as f:
|
11 |
+
json.load(f)
|
12 |
+
except Exception:
|
13 |
+
os.makedirs(os.path.dirname(filename), exist_ok=True)
|
14 |
+
with open(filename, "wb") as f:
|
15 |
+
r = requests.get(url)
|
16 |
+
f.write(r.content)
|
17 |
+
with open(filename) as f:
|
18 |
+
tmp = json.load(f)
|
19 |
+
return tmp
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
models = [
|
24 |
+
"cardiffnlp/roberta-large-tweet-topic-multi-all",
|
25 |
+
"cardiffnlp/roberta-base-tweet-topic-multi-all",
|
26 |
+
"cardiffnlp/twitter-roberta-base-2019-90m-tweet-topic-multi-all",
|
27 |
+
"cardiffnlp/twitter-roberta-base-dec2020-tweet-topic-multi-all",
|
28 |
+
"cardiffnlp/twitter-roberta-base-dec2021-tweet-topic-multi-all",
|
29 |
+
"cardiffnlp/roberta-large-tweet-topic-multi-2020",
|
30 |
+
"cardiffnlp/roberta-base-tweet-topic-multi-2020",
|
31 |
+
"cardiffnlp/twitter-roberta-base-2019-90m-tweet-topic-multi-2020",
|
32 |
+
"cardiffnlp/twitter-roberta-base-dec2020-tweet-topic-multi-2020",
|
33 |
+
"cardiffnlp/twitter-roberta-base-dec2021-tweet-topic-multi-2020"
|
34 |
+
]
|
35 |
+
|
36 |
+
os.makedirs("metric_files", exists_ok=True)
|
37 |
+
|
38 |
+
metrics = []
|
39 |
+
for i in models:
|
40 |
+
url = f"https://huggingface.co/{i}/raw/main/metric_summary.json"
|
41 |
+
model_url = f"https://huggingface.co/{i}"
|
42 |
+
metric = download(f"metric_files/{os.path.basename(i)}.json", url)
|
43 |
+
metrics.append({"model": f"[{i}]({model_url})" "F1": metric["test/eval_f1"], "F1 (macro)": metric["test/eval_f1_macro"], "Accuracy": metric["test/eval_accuracy"]})
|
44 |
+
|
45 |
+
df = pd.DataFrame(metrics)
|
46 |
+
print(df.to_markdown(index=False))
|
47 |
+
|