Skip to content

Instantly share code, notes, and snippets.

View haoxi911's full-sized avatar
🎯
Focusing

Hao Xi haoxi911

🎯
Focusing
View GitHub Profile
@haoxi911
haoxi911 / rgb_mode.py
Created March 15, 2018 09:05
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)
@haoxi911
haoxi911 / categorize.sh
Created March 15, 2018 09:00
Split images into subfolders on Oxford IIIT Pet dataset
# /bin/sh
# this script categorize image files by moving them into subfolders
# using the name of animals.
for f in *.jpg; do
name=`echo "$f"|sed 's/ -.*//'`
dir=`echo "${name%_*}"|tr '_' ' '| tr '[A-Z]' '[a-z]'`
mkdir -p "$dir"
mv "$f" "$dir"
done