jackestar
reload dataset and someone missing, added **readme**
1d0a99c
import os
import json
def generate_dataset_info(dataset_dir):
dataset_info = {
"train": {
"size": 0,
"num_examples": 0,
"dataset_name": os.path.basename(dataset_dir)
}
}
num_examples = 0
for class_dir in os.listdir(dataset_dir):
class_path = os.path.join(dataset_dir, class_dir)
if os.path.isdir(class_path) and class_dir != '.git':
num_examples += len([f for f in os.listdir(class_path) if os.path.isfile(os.path.join(class_path, f))])
dataset_info["train"]["num_examples"] = num_examples
dataset_info["train"]["size"] = sum(os.path.getsize(os.path.join(root, f))
for root, _, files in os.walk(dataset_dir)
for f in files if '.git' not in root)
return dataset_info
dataset_dir = './' # Cambia esto a tu ruta del dataset
dataset_info = generate_dataset_info(dataset_dir)
output_file = os.path.join(dataset_dir, 'dataset_infos.json')
with open(output_file, 'w') as f:
json.dump(dataset_info, f, indent=4)
print(f'dataset_infos.json generado en {output_file}')