Download data_sampler.py from k-aidios/ACE-Step: direct link, hf CLI and curl.
- Browser
- Download file 572 Bytes
-
https://huggingface.co/spaces/k-aidios/ACE-Step/resolve/97264dea176b5d66ac2bf0bb2ad32285a5d64c2e/data_sampler.py
- Command line
-
hf download hf://spaces/k-aidios/ACE-Step@97264dea176b5d66ac2bf0bb2ad32285a5d64c2e/data_sampler.py
-
curl -L -o data_sampler.py https://huggingface.co/spaces/k-aidios/ACE-Step/resolve/97264dea176b5d66ac2bf0bb2ad32285a5d64c2e/data_sampler.py
572 Bytes
| import json | |
| from pathlib import Path | |
| import random | |
| DEFAULT_ROOT_DIR = "examples/input_params" | |
| class DataSampler: | |
| def __init__(self, root_dir=DEFAULT_ROOT_DIR): | |
| self.root_dir = root_dir | |
| # glob | |
| self.input_params_files = list(Path(self.root_dir).glob("*.json")) | |
| def load_json(self, file_path): | |
| with open(file_path, "r", encoding="utf-8") as f: | |
| return json.load(f) | |
| def sample(self): | |
| json_path = random.choice(self.input_params_files) | |
| json_data = self.load_json(json_path) | |
| return json_data | |