text_plain_output_2.png application_vnd.jupyter.stderr_output_1.png
from keras.preprocessing import image

import numpy as np # linear algebra

import os

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import numpy as np
import pandas as pd
import os
train_path = '../input/train/train'
test_path = '../input/test/test'
label_frame = pd.read_csv('../input/train.csv')
test_frame = pd.read_csv('../input/sample_submission.csv')
x_train = []
x_test = []
y_train = np.array(label_frame['has_cactus'])
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
for fname in label_frame['id']:
    image_path = os.path.join(train_path, fname)
    pil_image = image.load_img(image_path, target_size=(32, 32, 3))
    np_image = image.img_to_array(pil_image)
    x_train.append(np_image)
for fname in test_frame['id']:
    image_path = os.path.join(test_path, fname)
    pil_image = image.load_img(image_path, target_size=(32, 32, 3))
    np_image = image.img_to_array(pil_image)
    x_test.append(np_image)
x_train = np.array(x_train)
x_train = x_train.astype('float32') / 255
x_test = np.array(x_test)
x_test = x_test.astype('float32') / 255
print(x_train.shape)
print(x_test.shape)