I want to add a tqdm bar to the multiprocess data processing procedure: [code]
Private research annotation
Sign in to add a private research label or note.
- User
I want to add a tqdm bar to the multiprocess data processing procedure:
codeif __name__ == "__main__": parser = argparse.ArgumentParser(description="Data Preparation Script") parser.add_argument('--video_folder', type=str, required=True, help="load video.mp4 from this folder") parser.add_argument('--save_folder', type=str, required=True, help="save video.h5 to this folder") parser.add_argument('--meta_file', type=str, required=True, help="load meta data from this file") parser.add_argument('--save_meta', type=str, required=True, help="save new meta data to this file") args = parser.parse_args() # # Load the data_dict # with open(args.meta_file, "r") as file: # data_dict = json.load(file) data_dict = read_json_file_to_list(args.meta_file) data_dict=data_dict[:16] # Set the number of processes (adjust based on your system's capabilities) num_processes = int(os.environ.get('SLURM_CPUS_PER_TASK', 8)) # You can set this to os.cpu_count() or any other number worker_func = partial(process_item, video_folder=args.video_folder, save_folder=args.save_folder) # Create a pool of worker processes with Pool(processes=num_processes) as pool: # Use pool.map to distribute the data_dict items to the worker function results = pool.map(worker_func, data_dict) - Assistant