if __name__ == '__main__': path_list = [] path_dic = {} pic_list = [] for file in os.listdir(path): if file.endswith('.jpg') or file.endswith('.JPG') or file.endswith('.PNG') or file.endswith('.png'): pic_list.append(file)
for file in pic_list: file_path = os.path.join(path, file) try: Image.open(file_path)
# for key, value in path_dic.items(): # print(key, value) count = 0 for i in path_dic.values(): for j in path_dic.values(): tmp = Difference(i, j) if tmp <= 5: # print(i, j) # list(dicxx.keys())[list(dicxx.values()).index("001")] var_i = list(path_dic.keys())[list(path_dic.values()).index(i)] var_j = list(path_dic.keys())[list(path_dic.values()).index(j)] if var_i != var_j: print(var_i, var_j) withopen(res_path, 'a') as f: f.write(var_i) f.write(var_j) f.write('\n')