import shutil from pathlib import Path from tqdm.auto import tqdm # filtering file from https://github.com/google-research/google-research/tree/master/seq2act/data_generation with open("./filter_24598.txt", "r") as f: filtered_files = f.read().replace(".json", "").split("\n")[:-1] print("num_filtered:", len(filtered_files)) # make filtered directories Path("captions_filtered").mkdir(exist_ok=True) Path("hierarchies_filtered").mkdir(exist_ok=True) Path("images_filtered").mkdir(exist_ok=True) # copy filtered files into filtered directories for file in tqdm(filtered_files): shutil.copy(f"captions/{file}.txt", "captions_filtered") shutil.copy(f"hierarchies/{file}.json", "hierarchies_filtered") shutil.copy(f"images/{file}.jpg", "images_filtered")