def check_files(image_dir):
print("Checking image files in %s" %(image_dir))
files = os.listdir(image_dir)
images = [os.path.join(image_dir, f) for f in files if f.lower().endswith('.jpg')]
good_imgs = []
for img in images:
try:
x = skimage.img_as_float(skimage.io.imread(img)).astype(np.float32)
good_imgs.append(img)
except:
print("Image %s is corrupted and will be removed." %(img))
os.remove(img)
good_files = [img.split(os.sep)[-1] for img in good_imgs]
return good_files
评论列表
文章目录