Spaces:
Running
Running
Download utils.py from KUIS-AI/Cetvel: direct link, hf CLI and curl.
- Browser
- Download file 655 Bytes
-
https://huggingface.co/spaces/KUIS-AI/Cetvel/resolve/main/utils.py
- Command line
-
hf download hf://spaces/KUIS-AI/Cetvel/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/KUIS-AI/Cetvel/resolve/main/utils.py
655 Bytes
| 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 | |