INNER CODE UNIT · Python
idx
MITDeepLearning/introtodeeplearning · mitdeeplearning/lab2.py:104
idx = np.argsort(prob)[::-1]
most_prob_inds = self.pos_train_inds[idx[: 10 * n : 10]]
return (self.images[most_prob_inds, ...] / 255.0).astype(np.float32)
def get_all_train_faces(self):
return self.images[self.pos_train_inds]
def get_test_faces(channels_last=True):
cwd = os.path.dirname(__file__)
images = {"LF": [], "LM": [], "DF": [], "DM": []}
for key in images.keys():
files = glob.glob(os.path.join(cwd, "data", "faces", key, "*.png"))
for file in sorted(files):
image = cv2.resize(cv2.imread(file), (64, 64))[:, :, ::-1] / 255.0
if not channels_last:
image = np.transpose(image, (2, 0, 1))
images[key].append(image)