Guest User

Untitled

a guest
Jul 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. import os
  2. from shutil import copy
  3. import random
  4. from os import listdir
  5. from os.path import isfile, join
  6.  
  7. path = "C:\\path\\to\\lfw"
  8. folders = [x[0] for x in os.walk(path)]
  9.  
  10. rnd_numbers=[]
  11.  
  12. #Change this number to the number of photos that you have in your Chiquito dataset
  13. num_images=270
  14.  
  15. while(len(rnd_numbers)<270):
  16. num = random.randint(0,len(folders)-1)
  17. if(not (num in rnd_numbers)):
  18. rnd_numbers.append(num)
  19.  
  20. for num in rnd_numbers:
  21. onlyfiles = [f for f in listdir(folders[num]) if isfile(join(folders[num], f))]
  22. image = folders[num]+"\\"+onlyfiles[0]
  23. copy(image,path)
  24.  
  25. print("\n Finished")
Add Comment
Please, Sign In to add comment