yagnikposhiya
changed dataset structure & added zip file
96b735e
"""
Author: Yagnik Poshiya
GitHub: @yagnikposhiya
Charotar University of Science and Technology
"""
import os
import shutil
import math
def split_dataset(input_dir, output_dir, files_per_directory):
if not os.path.exists(output_dir):
os.makedirs(output_dir)
files = os.listdir(input_dir)
num_files = len(files)
num_directories = math.ceil(num_files / files_per_directory)
for i in range(num_directories):
start_idx = i * files_per_directory
end_idx = min((i + 1) * files_per_directory, num_files)
subset_files = files[start_idx:end_idx]
directory_name = f"clips_{i}"
directory_path = os.path.join(output_dir, directory_name)
os.makedirs(directory_path)
for file_name in subset_files:
src_file_path = os.path.join(input_dir, file_name)
dest_file_path = os.path.join(directory_path, file_name)
shutil.copy(src_file_path, dest_file_path)
if __name__ == "__main__":
input_directory = "/home/yagnikposhiya/WorkStation/Datasets/SIH/CommonVoiceCorpusHindi15/clips" # Change this to your dataset directory
output_directory = "/home/yagnikposhiya/WorkStation/Datasets/SIH/CommonVoiceCorpusHindi15/clips2" # Change this to your desired output directory
files_per_directory = 10000 # Maximum files per directory
split_dataset(input_directory, output_directory, files_per_directory)