{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"collapsed":true},"cell_type":"code","source":"import os, cv2, random\nimport numpy as np\nimport pandas as pd\n\nimport matplotlib.pyplot as plt\nfrom matplotlib import ticker\nimport seaborn as sns\n%matplotlib inline \n\nfrom keras.models import Sequential\nfrom keras.layers import Input, Dropout, Flatten, Convolution2D, MaxPooling2D, Dense, Activation\nfrom keras.optimizers import RMSprop\nfrom keras.callbacks import ModelCheckpoint, Callback, EarlyStopping\nfrom keras.utils import np_utils","execution_count":2,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","collapsed":true,"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"import cv2                 \nimport numpy as np        \nimport os                  \nfrom random import shuffle \nfrom tqdm import tqdm      \n\nTRAIN_DIR = '../input/dogs-vs-cats-redux-kernels-edition/train'\nTEST_DIR = '../input/dogs-vs-cats-redux-kernels-edition/test'\nIMG_SIZE = 224\nLR = 1e-3\n\nSHORT_LIST_TRAIN = os.listdir(TRAIN_DIR)\nSHORT_LIST_TEST = os.listdir(TEST_DIR)","execution_count":3,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"536520015aeae8323caa55bddac37d93355bca12"},"cell_type":"code","source":"def label_img(img):\n    word_label = img.split('.')[-3]\n    if word_label == 'cat': return [1,0]\n    elif word_label == 'dog': return [0,1]\n    ","execution_count":4,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"8a6b06746de70613d3359076c63f76449b6b1e73"},"cell_type":"code","source":"def create_train_data():\n    training_data = []\n    for img in tqdm(SHORT_LIST_TRAIN):\n        label = label_img(img)\n        path = os.path.join(TRAIN_DIR,img)\n        img = cv2.imread(path,cv2.IMREAD_COLOR )\n        img = cv2.resize(img, (IMG_SIZE,IMG_SIZE))\n        training_data.append([np.array(img),np.array(label)])\n    shuffle(training_data)\n    #np.save('train_data.npy', training_data)\n    return training_data","execution_count":5,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"e1e274f9c7c7752a9a50984fe1fb3845837a2d74"},"cell_type":"code","source":"def process_test_data():\n    testing_data = []\n    for img in tqdm(SHORT_LIST):\n        path = os.path.join(SHORT_LIST_TEST,img)\n        img_num = img.split('.')[0]\n        img = cv2.imread(path,cv2.IMREAD_COLOR )\n        img = cv2.resize(img, (IMG_SIZE,IMG_SIZE))\n        testing_data.append([np.array(img), img_num])\n        \n    shuffle(testing_data)\n    #np.save('test_data.npy', testing_data)\n    return testing_data","execution_count":6,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9be93de3fe2285b8dde3c8fc199224d6eb2c52d8","collapsed":true},"cell_type":"code","source":"train_data = create_train_data()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true,"_uuid":"8c82a091754dbff13dcb34b131efb1097c623507"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}