import os
dataset_root_path = '' #数据集地址
imglist = os.listdir(dataset_root_path)
d = 0
for item in imglist:
if item.endswith('.jpg'):
if item and f'{item[:-4]}.json' in imglist:
print(d)
d+=1
else:
c = dataset_root_path + item
os.remove(c)