Advertisement
yurystanev

lwf dataset

Nov 28th, 2019
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1. # loads images in `./data/*.jpg` into an array as grayscale and save it to the disk -> file://image_data.npy
  2. #        axis: [  0,    1,   2 ] -> https://www.w3resource.com/w3r_images/python-data-type-list-excercise-13.svg
  3. # array shape: [13233, 255, 255]
  4.  
  5. import numpy as np
  6. # from PIL import Image, ImageOps
  7. import glob
  8. from shutil import copyfile
  9. filelist = glob.glob('data/*.jpg')
  10.  
  11. # Images
  12. # X = np.array([np.array(ImageOps.grayscale(Image.open(fname)))
  13. #               for fname in filelist])  # array of images
  14. # np.save('image_data', X)
  15.  
  16. # File Names
  17. # y = np.array([fname.split("/")[1] for fname in filelist])
  18. # np.save('image_names2', y)
  19.  
  20. male_names = np.loadtxt('male_names.txt', dtype='str', delimiter='\n')
  21. female_names = np.loadtxt('female_names.txt', dtype='str', delimiter='\n')
  22.  
  23. for fname in filelist:
  24.     for male in male_names:
  25.         for female in female_names:
  26.             if fname.split("/")[1] == male:
  27.                 copyfile(
  28.                     fname, '/home/$USER/Downloads/lwf_labels_data/male/'+fname.split("/")[1])
  29.                 print(fname.split("/")[1])
  30.             elif fname.split("/")[1] == female:
  31.                 copyfile(
  32.                     fname, '/home/$USER/Downloads/lwf_labels_data/female/'+fname.split("/")[1])
  33.                 print(fname.split("/")[1])
  34.  
  35.  
  36. print("DONE")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement