How to check if there corrupt data in your image dataset
Sun Oct 09 2022 17:26:47 GMT+0000 (Coordinated Universal Time)
Saved by
@DiegoEraso
#python
import os
from PIL import Image
folder_path = //folder_images # maybe could be better if theres no subdirectories
extensions = []
for fldr in os.listdir(folder_path):
sub_folder_path = os.path.join(folder_path, fldr)
for filee in os.listdir(sub_folder_path):
file_path = os.path.join(sub_folder_path, filee)
print('** Path: {} **'.format(file_path), end="\r", flush=True)
im = Image.open(file_path)
rgb_im = im.convert('RGB')
if filee.split('.')[1] not in extensions:
extensions.append(filee.split('.')[1])
content_copyCOPY
Comments