Skip to content

Instantly share code, notes, and snippets.

@tuttelikz
Created January 20, 2018 09:55
Show Gist options
  • Save tuttelikz/f1b5d25b19cec59422131fa62d22ec65 to your computer and use it in GitHub Desktop.
Save tuttelikz/f1b5d25b19cec59422131fa62d22ec65 to your computer and use it in GitHub Desktop.
Simple gist for opening directory, sorting and writing text
import glob
from PIL import Image
img_dir_path = 'data_cheek/*.jpg'
train_test_filelist = sorted(glob.glob(img_dir_path))
cheek_label_list = [0 if "old" in files else 1 for files in train_test_filelist]
thefile = open('data_cheek.txt', 'w')
for item in cheek_label_list:
thefile.write("%s\n" % item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment