Guest User

Untitled

a guest
Nov 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import os
  2. import numpy as np
  3. import cv2
  4.  
  5. IMG_SIZE = 200
  6.  
  7.  
  8. def read_images(path):
  9. dirnames = sorted(os.listdir(path))
  10. files = [sorted(os.listdir(path+dirnames[i]))
  11. for i in range(len(dirnames))]
  12. i = 0
  13. images = []
  14. for fs in files:
  15. tmp_images = []
  16. for f in fs:
  17. img = cv2.imread(path +dirnames[i] + "/" + f)
  18. img = cv2.resize(img, (IMG_SIZE, IMG_SIZE))
  19. img = img.flatten().astype(np.float32)/255.0
  20. tmp_images.append(img)
  21. i = i + 1
  22. images.append(tmp_images)
  23.  
  24. return np.asarray(images)
Add Comment
Please, Sign In to add comment