from keras.models import Sequential, load_model
from keras.layers import Dense, Convolution2D, MaxPooling2D, UpSampling2D
from sklearn.metrics import mean_squared_error

sys.path.append(modelsPath)
from importStuffLoadData import loadData

# Save time
timeStr = time.strftime('%Y%m%d_%H%M%S')

nbClasses = 1
#date = '2016_08_19'
date = '2016_11_03'

[origImRows, origImCols, (trainImages, trainResults), (valImages, valResults), (testImages, testResults), fullTestImages] = loadData(nbClasses, date)
valData = (valImages, valResults)

os.chdir(basePath)

# TODO: KL transform
# TODO: Covariance Equalization

# imresize
imRows = 64
imCols = 64

newTrainImages = np.zeros((trainImages.shape[0], imRows, imCols, 1))
for i in range(trainImages.shape[0]):
	newTrainImages[i] = imresize(trainImages[i].reshape(origImRows, origImCols), (imRows, imCols)).reshape(imRows, imCols, 1)/255.0
コード例 #2
0
from importStuffLoadData import loadData

from keras.models import Sequential, load_model
from keras.layers import Dense, Activation, Convolution2D, MaxPooling2D, Flatten

# Save time
timeStr = time.strftime('%Y%m%d_%H%M%S')

nbClasses = 1
#date = '2016_08_19'
date = '2016_11_03'

[
    origImRows, origImCols, origImChannels, (trainImages, trainResults),
    (valImages, valResults), (testImages, testResults), fullTestImages
] = loadData(nbClasses, date)
valData = (valImages, valResults)

os.chdir(basePath)
'''
[imRows, imCols, (trainImages, trainResults), trainImagesMean, valData, (testImages, testResults), fulltestImages] = loadData(nbClasses, date)


# Find trainnImagesMean
trainImagesMean = trainImages.mean(axis=0)

# Save trainImagesMean
trainImagesMeanFileName = basePath+'trainImagesMean_'+timeStr+'.npy'
np.save(trainImagesMeanFileName, trainImagesMean)
print "saved " + trainImagesMeanFileName