Created
March 15, 2018 09:05
-
-
Save haoxi911/c75b65a421620b7f8cb0523c3cd069f1 to your computer and use it in GitHub Desktop.
Remove invalid images from Oxford IIIT Pet dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
import os | |
path = os.getcwd() | |
for folder in os.listdir(path): | |
if os.path.isdir(os.path.join(path, folder)): | |
for file in os.listdir(os.path.join(path, folder)): | |
extension = file.split('.')[-1] | |
if extension == 'jpg': | |
fileLoc = os.path.join(path, folder)+'/'+file | |
img = Image.open(fileLoc) | |
if img.mode != 'RGB': | |
os.remove(fileLoc) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
need to remove these two as well:
chihuahua_121
beagle_116