Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import numpy as np
- import cv2
- IMG_SIZE = 200
- def read_images(path):
- dirnames = sorted(os.listdir(path))
- files = [sorted(os.listdir(path+dirnames[i]))
- for i in range(len(dirnames))]
- i = 0
- images = []
- for fs in files:
- tmp_images = []
- for f in fs:
- img = cv2.imread(path +dirnames[i] + "/" + f)
- img = cv2.resize(img, (IMG_SIZE, IMG_SIZE))
- img = img.flatten().astype(np.float32)/255.0
- tmp_images.append(img)
- i = i + 1
- images.append(tmp_images)
- return np.asarray(images)
Add Comment
Please, Sign In to add comment