Spaces:
Running on Zero
Running on Zero
Download data_sampler.py from ACE-Music/ACE-Step: direct link, hf CLI and curl.
- Browser
- Download file 572 Bytes
-
https://huggingface.co/spaces/ACE-Music/ACE-Step/resolve/refs%2Fpr%2F2/data_sampler.py
- Command line
-
hf download hf://spaces/ACE-Music/ACE-Step@refs/pr/2/data_sampler.py
-
curl -L -o data_sampler.py https://huggingface.co/spaces/ACE-Music/ACE-Step/resolve/refs%2Fpr%2F2/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 | |