File size: 655 Bytes
500fbd7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import os.path as osp
import json


def preprocess_path(path):
    path = osp.expanduser(path)
    path = osp.abspath(path)
    return path


def get_model_url(entry):
    if entry['api'] == 'hf':
        return f'https://huggingface.co/{entry["model"]}'
    return entry.get('url', f'https://localhost/{entry["model"]}')


def read_results(path):
    path = preprocess_path(path)
    file_list = sorted(os.listdir(path))
    results = list()
    for file_name in file_list:
        file_path = osp.join(path, file_name)
        with open(file_path, 'r') as f:
            this = json.load(f)
        results.append(this)
    return results