Download check_data.py from FlowVortex/Large-Spectrum-Prediction-Dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.5 kB
-
https://huggingface.co/datasets/FlowVortex/Large-Spectrum-Prediction-Dataset/resolve/503018a8822bb6f149f503c9a6f766c39a273c1b/check_data.py
- Command line
-
hf download hf://datasets/FlowVortex/Large-Spectrum-Prediction-Dataset@503018a8822bb6f149f503c9a6f766c39a273c1b/check_data.py
-
curl -L -o check_data.py https://huggingface.co/datasets/FlowVortex/Large-Spectrum-Prediction-Dataset/resolve/503018a8822bb6f149f503c9a6f766c39a273c1b/check_data.py
1.5 kB
| import os | |
| from os import path | |
| import numpy as np | |
| from datasets import Dataset | |
| from tqdm import tqdm | |
| root_path = "./train/" | |
| data_count = {} | |
| class DataCounter: | |
| def __init__(self, root_path): | |
| self.root_path = root_path | |
| self.data_count = {} | |
| def count_data(self): | |
| for folder in os.listdir(self.root_path): | |
| folder_path = path.join(self.root_path, folder) | |
| self.data_count[folder] = {} | |
| for data in tqdm(os.listdir(folder_path)): | |
| self.data_count[folder][data] = 0 | |
| data_path = path.join(folder_path, data) | |
| print(data_path) | |
| # 读取数据 | |
| dataset = Dataset.load_from_disk(data_path) | |
| dataset.set_format(type="numpy") | |
| for series in dataset: | |
| self.data_count[folder][data] += len(series["target"]) | |
| def show_info(self): | |
| sum_data = 0 | |
| for folder, counts in self.data_count.items(): | |
| count = 0 | |
| for num in counts.values(): | |
| count += num | |
| print(f"{folder}: {count}") | |
| sum_data += count | |
| print(f"Total: {sum_data}") | |
| if __name__ == "__main__": | |
| data_counter = DataCounter(root_path) | |
| data_counter.count_data() | |
| data_counter.show_info() |