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 | |