File size: 642 Bytes
e90fa51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from utils_display import model_info
from data_utils import load_infer_results
from tqdm import tqdm 
import json 

length_info = {}

for model_name in tqdm(list(model_info.keys())): 
    result = load_infer_results(model_name)
    lens = []
    for item in result:
        o = item["output"]
        if type(o) == list:
            L = len(o[0].strip())
        else:
            L = len(o.strip())
        if L > 0:
            lens.append(L)
    avg_len = sum(lens) / len(lens)
    print(f"{model_name}: {avg_len}")
    length_info[model_name] = avg_len

with open("model_len_info.json", "w") as f:
    json.dump(length_info, f, indent=2)