Skip to content

Instantly share code, notes, and snippets.

@haoxi911
Created March 15, 2018 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haoxi911/c75b65a421620b7f8cb0523c3cd069f1 to your computer and use it in GitHub Desktop.
Save haoxi911/c75b65a421620b7f8cb0523c3cd069f1 to your computer and use it in GitHub Desktop.
Remove invalid images from Oxford IIIT Pet dataset
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)
@mayujie
Copy link

mayujie commented Dec 14, 2021

need to remove these two as well:
chihuahua_121
beagle_116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment