Delete check_data.py
Browse files- check_data.py +0 -62
check_data.py
DELETED
|
@@ -1,62 +0,0 @@
|
|
| 1 |
-
import os
|
| 2 |
-
from os import path
|
| 3 |
-
|
| 4 |
-
import numpy as np
|
| 5 |
-
from datasets import Dataset
|
| 6 |
-
from tqdm import tqdm
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
root_path = "./train/"
|
| 10 |
-
data_count = {}
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
class DataCounter:
|
| 14 |
-
|
| 15 |
-
def __init__(self, root_path):
|
| 16 |
-
|
| 17 |
-
self.root_path = root_path
|
| 18 |
-
self.data_count = {}
|
| 19 |
-
|
| 20 |
-
def count_data(self):
|
| 21 |
-
|
| 22 |
-
for folder in os.listdir(self.root_path):
|
| 23 |
-
|
| 24 |
-
folder_path = path.join(self.root_path, folder)
|
| 25 |
-
|
| 26 |
-
self.data_count[folder] = {}
|
| 27 |
-
|
| 28 |
-
for data in tqdm(os.listdir(folder_path)):
|
| 29 |
-
|
| 30 |
-
self.data_count[folder][data] = 0
|
| 31 |
-
|
| 32 |
-
data_path = path.join(folder_path, data)
|
| 33 |
-
print(data_path)
|
| 34 |
-
# 读取数据
|
| 35 |
-
dataset = Dataset.load_from_disk(data_path)
|
| 36 |
-
dataset.set_format(type="numpy")
|
| 37 |
-
|
| 38 |
-
for series in dataset:
|
| 39 |
-
self.data_count[folder][data] += len(series["target"])
|
| 40 |
-
|
| 41 |
-
def show_info(self):
|
| 42 |
-
|
| 43 |
-
sum_data = 0
|
| 44 |
-
|
| 45 |
-
for folder, counts in self.data_count.items():
|
| 46 |
-
|
| 47 |
-
count = 0
|
| 48 |
-
|
| 49 |
-
for num in counts.values():
|
| 50 |
-
count += num
|
| 51 |
-
|
| 52 |
-
print(f"{folder}: {count}")
|
| 53 |
-
|
| 54 |
-
sum_data += count
|
| 55 |
-
|
| 56 |
-
print(f"Total: {sum_data}")
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
if __name__ == "__main__":
|
| 60 |
-
data_counter = DataCounter(root_path)
|
| 61 |
-
data_counter.count_data()
|
| 62 |
-
data_counter.show_info()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|