import os import json if __name__ == "__main__": blip2_cases = os.listdir("/gpfs/u/home/LMCG/LMCGljnn/scratch/code/multimodal2/blip2_baseline/blip2_fail_case") kmos2_cases = os.listdir("/gpfs/u/home/LMCG/LMCGljnn/scratch/code/unilm/kosmos-2/kmos2_fail_case") blip2_failed_ids = set([int(c.split("_")[0]) for c in blip2_cases]) kmos2_failed_ids = set([int(c.split("_")[0]) for c in kmos2_cases]) both_failed_ids = list(blip2_failed_ids.intersection(kmos2_failed_ids)) print(both_failed_ids) json.dump(both_failed_ids, open("both_failed_ids.json", "w"), indent=1)