jackestar commited on
Commit
8a4b1fa
1 Parent(s): 36b074a

Add dataset_infos.json and script builder

Browse files
Files changed (2) hide show
  1. dataset_infos.json +6 -0
  2. script.py +33 -0
dataset_infos.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "train": {
3
+ "size": 2465529,
4
+ "num_examples": 865,
5
+ }
6
+ }
script.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+
4
+ def generate_dataset_info(dataset_dir):
5
+ dataset_info = {
6
+ "train": {
7
+ "size": 0,
8
+ "num_examples": 0,
9
+ "dataset_name": os.path.basename(dataset_dir)
10
+ }
11
+ }
12
+
13
+ num_examples = 0
14
+ for class_dir in os.listdir(dataset_dir):
15
+ class_path = os.path.join(dataset_dir, class_dir)
16
+ if os.path.isdir(class_path) and class_dir != '.git':
17
+ num_examples += len([f for f in os.listdir(class_path) if os.path.isfile(os.path.join(class_path, f))])
18
+
19
+ dataset_info["train"]["num_examples"] = num_examples
20
+ dataset_info["train"]["size"] = sum(os.path.getsize(os.path.join(root, f))
21
+ for root, _, files in os.walk(dataset_dir)
22
+ for f in files if '.git' not in root)
23
+
24
+ return dataset_info
25
+
26
+ dataset_dir = './' # Cambia esto a tu ruta del dataset
27
+ dataset_info = generate_dataset_info(dataset_dir)
28
+
29
+ output_file = os.path.join(dataset_dir, 'dataset_infos.json')
30
+ with open(output_file, 'w') as f:
31
+ json.dump(dataset_info, f, indent=4)
32
+
33
+ print(f'dataset_infos.json generado en {output_file}')