コード例 #1
0
ファイル: face_cnn.py プロジェクト: NuitNoir/MachineLearning
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.estimator import regression
from tflearn.data_preprocessing import ImagePreprocessing
from tflearn.data_augmentation import ImageAugmentation

# Data loading and preprocessing
from tflearn.datasets import cifar10

# (X, Y), (X_test, Y_test) = cifar10.load_data()
label_num = 5
n_epoch = 500
# n_epoch = 5
batch_size = 96
image_size = (32, 32)
(X, Y), (X_test, Y_test) = ImageReader.read_train_test_images_labels(
    '../imgs/faces02/trimmed', max_label=label_num, resize=image_size)
# import ipdb
# ipdb.set_trace()
X, Y = shuffle(X, Y)
Y = to_categorical(Y, label_num)
Y_test = to_categorical(Y_test, label_num)

# Real-time data preprocessing
img_prep = ImagePreprocessing()
img_prep.add_featurewise_zero_center()
img_prep.add_featurewise_stdnorm()

# Real-time data augmentation
img_aug = ImageAugmentation()
img_aug.add_random_flip_leftright()
img_aug.add_random_rotation(max_angle=25.)