import json with open("./reformat_test.json", "r") as f: test = json.load(f) with open("./reformat_val.json", "r") as f: val = json.load(f) print(len(test), len(val)) test_keys = set([(x["img0"], x["img1"]) for x in test]) | set([(x["img1"], x["img0"]) for x in test]) val_keys = set([(x["img0"], x["img1"]) for x in val]) | set([(x["img1"], x["img0"]) for x in val]) intersection = test_keys & val_keys print(len(intersection)) # new_val = [] # for x in val: # k1 = (x["img0"], x["img1"]) # k2 = (x["img1"], x["img0"]) # if k1 in intersection or k2 in intersection: # continue # new_val.append(x) # print(len(new_val)) # with open("./reformat_val.json", "w") as f: # json.dump(new_val, f)