Standardization

The LAB color space has values from -128 to +128. Since neural networks are sensitive to the scale of input values, we normalize the transformed pixel values from -128 to +128 and bring them within the -1 to +1 range. The same is showcased in the following code snippet:

def prep_data(file_list=[],
dir_path=None,
dim_x=256,
dim_y=256):

#Get images

X = []
for filename in file_list:
X.append(img_to_array(
sp.misc.imresize(
load_img(
dir_path+filename),
(dim_x, dim_y))

)

)
X = np.array(X, dtype=np.float64)
X = 1.0/255*X
return X

Once transformed, we then split the data into train and test sets. For splitting, we utilize train_test_split utility from sklearn.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset