{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.status.busy":"2021-10-25T11:22:10.732016Z","iopub.execute_input":"2021-10-25T11:22:10.732358Z","iopub.status.idle":"2021-10-25T11:22:10.739119Z","shell.execute_reply.started":"2021-10-25T11:22:10.732297Z","shell.execute_reply":"2021-10-25T11:22:10.738227Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nfrom keras import layers\nfrom keras.layers import Input, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D\nfrom keras.layers import AveragePooling2D, MaxPooling2D, Dropout, GlobalMaxPooling2D, GlobalAveragePooling2D\nfrom keras.models import Model\nfrom keras.preprocessing import image\nfrom keras.utils import layer_utils\nfrom keras.utils.data_utils import get_file\nfrom keras.applications.imagenet_utils import preprocess_input\nimport pydot\nfrom IPython.display import SVG\nfrom keras.utils.vis_utils import model_to_dot\nfrom keras.utils import plot_model\nfrom keras.utils import to_categorical\nimport matplotlib.pyplot as plt \nfrom random import shuffle\nnp.set_printoptions(suppress=True)\n#np.set_printoptions(threshold=np.inf)","metadata":{"_uuid":"915ddeac4d7cc8a1523cf8261e8b9130bab38f4a","execution":{"iopub.status.busy":"2021-10-25T11:22:26.941442Z","iopub.execute_input":"2021-10-25T11:22:26.941724Z","iopub.status.idle":"2021-10-25T11:22:26.948296Z","shell.execute_reply.started":"2021-10-25T11:22:26.941678Z","shell.execute_reply":"2021-10-25T11:22:26.947307Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import zipfile\n\nwith zipfile.ZipFile('../input/test.zip','r') as z:\n    z.extractall('.')\n    \nwith zipfile.ZipFile('../input/train.zip','r') as z:\n    z.extractall('.')\n","metadata":{"execution":{"iopub.status.busy":"2021-10-25T11:24:29.049163Z","iopub.execute_input":"2021-10-25T11:24:29.049476Z","iopub.status.idle":"2021-10-25T11:24:45.446739Z","shell.execute_reply.started":"2021-10-25T11:24:29.049418Z","shell.execute_reply":"2021-10-25T11:24:45.446041Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMG_SIZE = 120\nX_Train_orig = []\nY_Train_orig = []\nfor i in os.listdir('/kaggle/working/train/'):\n    label = i.split('.')[-3]\n    if label == 'cat':\n        label = 0\n    elif label == 'dog':\n        label = 1\n    img = cv2.imread('/kaggle/working/train/'+i, cv2.IMREAD_COLOR)\n    img = cv2.resize(img,(IMG_SIZE,IMG_SIZE), interpolation=cv2.INTER_CUBIC)\n    #img = img / 255\n    X_Train_orig.append([np.array(img), np.array(label)])\n\nnp.save('Training_Data.npy', X_Train_orig)","metadata":{"_uuid":"f3b68753e0732708180d300fada74ce3f4d374aa","execution":{"iopub.status.busy":"2021-10-25T11:26:23.624718Z","iopub.execute_input":"2021-10-25T11:26:23.624994Z","iopub.status.idle":"2021-10-25T11:27:17.255791Z","shell.execute_reply.started":"2021-10-25T11:26:23.624940Z","shell.execute_reply":"2021-10-25T11:27:17.254978Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shuffle(X_Train_orig)","metadata":{"_uuid":"57117442faa3e8505d8352914056eefe18818d91","execution":{"iopub.status.busy":"2021-10-25T11:27:22.043572Z","iopub.execute_input":"2021-10-25T11:27:22.043844Z","iopub.status.idle":"2021-10-25T11:27:22.076893Z","shell.execute_reply.started":"2021-10-25T11:27:22.043796Z","shell.execute_reply":"2021-10-25T11:27:22.076183Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = np.array([i[0] for i in X_Train_orig]).reshape(-1,IMG_SIZE,IMG_SIZE,3)\nY = np.array([i[1] for i in X_Train_orig])","metadata":{"_uuid":"252c1bdc4906c04df7181e5df23e61c47f4cce96","execution":{"iopub.status.busy":"2021-10-25T11:27:22.733424Z","iopub.execute_input":"2021-10-25T11:27:22.733702Z","iopub.status.idle":"2021-10-25T11:27:23.465586Z","shell.execute_reply.started":"2021-10-25T11:27:22.733655Z","shell.execute_reply":"2021-10-25T11:27:23.464880Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\nX_train, X_val, Y_train, Y_val = train_test_split(X, Y, test_size = 0.1)","metadata":{"_uuid":"d91fb23ee9689f792adb9973bd483ae3c6bc0faf","execution":{"iopub.status.busy":"2021-10-25T11:27:24.956239Z","iopub.execute_input":"2021-10-25T11:27:24.956570Z","iopub.status.idle":"2021-10-25T11:27:26.489788Z","shell.execute_reply.started":"2021-10-25T11:27:24.956515Z","shell.execute_reply":"2021-10-25T11:27:26.488770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print('Shape of X_train is :', X_train.shape)\nprint('Shape of Y_train is :', Y_train.shape)\nprint('Shape of X_val is :', X_val.shape)\nprint('Shape of Y_val is :', Y_val.shape)","metadata":{"_uuid":"3650249df7955cab4983d03f4252a02489409185","execution":{"iopub.status.busy":"2021-10-25T11:27:26.494254Z","iopub.execute_input":"2021-10-25T11:27:26.496435Z","iopub.status.idle":"2021-10-25T11:27:26.505964Z","shell.execute_reply.started":"2021-10-25T11:27:26.496366Z","shell.execute_reply":"2021-10-25T11:27:26.505090Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt \nplt.figure(figsize=(20,20))   # to fix a shape for each image print\nfor i in range(50):          # using a for loop to display a number of images\n    plt.subplot(5, 10, i+1) # we need to use this function to print an array of pictures \n    plt.imshow(X_val[i,:,:,:]) # this will call the images from train set one by one\n    plt.title('DOG' if Y_val[i] == 1 else 'CAT')  # Lets also look into the labels \n    plt.axis('off') ","metadata":{"_uuid":"2ba6838f1f1e4b7e33c9e35c7807ce128094015b","execution":{"iopub.status.busy":"2021-10-25T11:27:26.842161Z","iopub.execute_input":"2021-10-25T11:27:26.842846Z","iopub.status.idle":"2021-10-25T11:27:29.706409Z","shell.execute_reply.started":"2021-10-25T11:27:26.842787Z","shell.execute_reply":"2021-10-25T11:27:29.705567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def Keras_Model(input_shape):    \n    \n    X_input = Input(input_shape)\n    \n    # First Layer\n    X = Conv2D(64, (3, 3), strides = (1, 1), padding = 'same', name = 'conv0')(X_input) \n    X = BatchNormalization(axis = 3, name = 'bn0')(X)\n    X = Activation('relu')(X) \n    \n    X = Conv2D(64, (3, 3), strides = (1, 1), padding = 'same', name = 'conv1')(X) \n    X = BatchNormalization(axis = 3, name = 'bn1')(X)\n    X = Activation('relu')(X)\n    \n    X = MaxPooling2D((3, 3), name='max_pool_0')(X)\n    X = Dropout(0.3)(X)\n    \n    # Second Layer\n    X = Conv2D(128, (3, 3), strides = (1, 1), padding = 'same', name = 'conv3')(X) \n    X = BatchNormalization(axis = 3, name = 'bn3')(X)\n    X = Activation('relu')(X)\n    \n    X = Conv2D(128, (3, 3), strides = (1, 1), padding = 'same', name = 'conv4')(X) \n    X = BatchNormalization(axis = 3, name = 'bn4')(X)\n    X = Activation('relu')(X)\n    \n    X = Conv2D(128, (3, 3), strides = (1, 1), padding = 'same', name = 'conv5')(X) \n    X = BatchNormalization(axis = 3, name = 'bn5')(X)\n    X = Activation('relu')(X)\n     \n    X = MaxPooling2D((3, 3), name='max_pool_1')(X)\n    X = Dropout(0.3)(X)\n    \n    # Fourth Convolutional Layer\n    X = Conv2D(256, (3, 3), strides = (1, 1), padding = 'same', name = 'conv6')(X) \n    X = BatchNormalization(axis = 3, name = 'bn6')(X)\n    X = Activation('relu')(X)\n    \n    X = Conv2D(256, (3, 3), strides = (1, 1), padding = 'same', name = 'conv7')(X) \n    X = BatchNormalization(axis = 3, name = 'bn7')(X)\n    X = Activation('relu')(X)\n    \n    X = Conv2D(256, (3, 3), strides = (1, 1), padding = 'same', name = 'conv8')(X) \n    X = BatchNormalization(axis = 3, name = 'bn8')(X)\n    X = Activation('relu')(X)\n\n \n    X = MaxPooling2D((3, 3), name='max_pool_2')(X)\n    X = Dropout(0.3)(X)\n    \n    X = Conv2D(512, (3, 3), strides = (1, 1), padding = 'same', name = 'conv10')(X) \n    X = BatchNormalization(axis = 3, name = 'bn10')(X)\n    X = Activation('relu')(X)\n    \n    X = Conv2D(512, (3, 3), strides = (1, 1), padding = 'same', name = 'conv11')(X) \n    X = BatchNormalization(axis = 3, name = 'bn11')(X)\n    X = Activation('relu')(X)\n    \n    X = Conv2D(512, (3, 3), strides = (1, 1), padding = 'same', name = 'conv12')(X) \n    X = BatchNormalization(axis = 3, name = 'bn12')(X)\n    X = Activation('relu')(X)\n\n    \n    X = MaxPooling2D((3, 3), name='max_pool_3')(X)\n    X = Dropout(0.3)(X)\n    \n    # Flatten the data.\n    X = Flatten()(X)\n    # Dense Layer\n    X = Dense(4096, activation='relu', name='fc1')(X)\n    X = Dropout(0.5)(X)\n    X = Dense(1024, activation='relu', name='fc2')(X)\n    X = Dropout(0.5)(X)\n    X = Dense(256, activation='relu', name='fc3')(X)\n    # Using softmax function to get the output\n    X = Dense(1, activation='sigmoid', name='fc4')(X)\n    \n    model = Model(inputs = X_input, outputs = X, name='model')\n    \n    return model","metadata":{"_uuid":"130838688d5b7e0cb66e3e6936f9a7042f62a2d3","execution":{"iopub.status.busy":"2021-10-25T11:27:29.707406Z","iopub.execute_input":"2021-10-25T11:27:29.707643Z","iopub.status.idle":"2021-10-25T11:27:29.728375Z","shell.execute_reply.started":"2021-10-25T11:27:29.707605Z","shell.execute_reply":"2021-10-25T11:27:29.727696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Keras_Model = Keras_Model(X_train.shape[1:4])","metadata":{"_uuid":"f8ca985f73d74c07d9b9b7c8f3b73b4f41643f93","execution":{"iopub.status.busy":"2021-10-25T11:27:30.787014Z","iopub.execute_input":"2021-10-25T11:27:30.787297Z","iopub.status.idle":"2021-10-25T11:27:33.545678Z","shell.execute_reply.started":"2021-10-25T11:27:30.787240Z","shell.execute_reply":"2021-10-25T11:27:33.544999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.optimizers import Adam\nepochs = 100\nbatch_size = 64\nlrate = 0.001\ndecay = lrate/epochs\noptimizer = Adam(lr=lrate, epsilon=1e-08, decay = decay)","metadata":{"_uuid":"3738ac4a4e7b8fb7dd2ad230c9f733237203aaac","execution":{"iopub.status.busy":"2021-10-25T11:27:34.018680Z","iopub.execute_input":"2021-10-25T11:27:34.019065Z","iopub.status.idle":"2021-10-25T11:27:34.041343Z","shell.execute_reply.started":"2021-10-25T11:27:34.018993Z","shell.execute_reply":"2021-10-25T11:27:34.040721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Keras_Model.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])","metadata":{"_uuid":"2c7e680adbf89ea985de03ba05ebaebaaa5b077a","execution":{"iopub.status.busy":"2021-10-25T11:27:36.005112Z","iopub.execute_input":"2021-10-25T11:27:36.005430Z","iopub.status.idle":"2021-10-25T11:27:36.038315Z","shell.execute_reply.started":"2021-10-25T11:27:36.005353Z","shell.execute_reply":"2021-10-25T11:27:36.037699Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.callbacks import ReduceLROnPlateau\nlearning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', \n                                            patience=1, \n                                            verbose=1, \n                                            factor=0.5, \n                                            min_lr=0.0000001)","metadata":{"_uuid":"8ed853eff65ed21eb0cc72eb46933d830b4d192a","execution":{"iopub.status.busy":"2021-10-25T11:27:38.534677Z","iopub.execute_input":"2021-10-25T11:27:38.534963Z","iopub.status.idle":"2021-10-25T11:27:38.541634Z","shell.execute_reply.started":"2021-10-25T11:27:38.534913Z","shell.execute_reply":"2021-10-25T11:27:38.540547Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.callbacks import ModelCheckpoint, Callback, EarlyStopping\nearly_stopping = EarlyStopping(monitor='val_loss', patience=3, verbose=1, mode='auto')","metadata":{"_uuid":"8a59c0ba29efd8d758aa122222f4787b711e0800","execution":{"iopub.status.busy":"2021-10-25T11:31:19.810836Z","iopub.execute_input":"2021-10-25T11:31:19.811449Z","iopub.status.idle":"2021-10-25T11:31:19.816665Z","shell.execute_reply.started":"2021-10-25T11:31:19.811129Z","shell.execute_reply":"2021-10-25T11:31:19.815360Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = Keras_Model.fit(x = X_train, y = Y_train, batch_size = batch_size, \n                        epochs=epochs, verbose=1, \n                        validation_data = (X_val, Y_val),\n                          shuffle = True, \n                          steps_per_epoch= None, validation_steps=None,\n                                  callbacks=[learning_rate_reduction, early_stopping] )","metadata":{"_uuid":"33d59bcc39c4a474f1696555e6f82101727eeb0c","execution":{"iopub.status.busy":"2021-10-25T11:31:20.163120Z","iopub.execute_input":"2021-10-25T11:31:20.163404Z","iopub.status.idle":"2021-10-25T11:39:00.255763Z","shell.execute_reply.started":"2021-10-25T11:31:20.163338Z","shell.execute_reply":"2021-10-25T11:39:00.255129Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds = Keras_Model.evaluate(X_train, Y_train)\nprint (\"Loss = \" + str(preds[0]))\nprint (\"Train set Accuracy = \" + str(preds[1]))","metadata":{"_uuid":"459602bc76cc1966a0f017f7ad5a0ac22c05caae","execution":{"iopub.status.busy":"2021-10-25T11:39:00.257026Z","iopub.execute_input":"2021-10-25T11:39:00.257294Z","iopub.status.idle":"2021-10-25T11:39:15.717911Z","shell.execute_reply.started":"2021-10-25T11:39:00.257238Z","shell.execute_reply":"2021-10-25T11:39:15.717344Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"preds_val = Keras_Model.evaluate(X_val, Y_val)\nprint (\"Loss = \" + str(preds_val[0]))\nprint (\"Validation Set Accuracy = \" + str(preds_val[1]))","metadata":{"_uuid":"c0a25e3afbc805f2bf3fdcba48a671dce68c3544","execution":{"iopub.status.busy":"2021-10-25T11:39:15.720201Z","iopub.execute_input":"2021-10-25T11:39:15.720653Z","iopub.status.idle":"2021-10-25T11:39:17.672321Z","shell.execute_reply.started":"2021-10-25T11:39:15.720600Z","shell.execute_reply":"2021-10-25T11:39:17.671622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history_dict = history.history\nhistory_dict.keys()","metadata":{"_uuid":"3798d66e9c624f98b1f83462d849e8b1b8d73ec1","execution":{"iopub.status.busy":"2021-10-25T11:39:17.676356Z","iopub.execute_input":"2021-10-25T11:39:17.678428Z","iopub.status.idle":"2021-10-25T11:39:17.688983Z","shell.execute_reply.started":"2021-10-25T11:39:17.678359Z","shell.execute_reply":"2021-10-25T11:39:17.688186Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_loss = history_dict['val_loss']\nval_acc = history_dict['val_acc']\nloss = history_dict['loss']\nacc = history_dict['acc']\nepochs = range(1,len(history_dict['val_loss'])+1)","metadata":{"_uuid":"36f0df8ccfd64876915bb3524ce5ade194e7ba3d","execution":{"iopub.status.busy":"2021-10-25T11:39:17.692202Z","iopub.execute_input":"2021-10-25T11:39:17.692739Z","iopub.status.idle":"2021-10-25T11:39:17.698459Z","shell.execute_reply.started":"2021-10-25T11:39:17.692685Z","shell.execute_reply":"2021-10-25T11:39:17.697824Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(epochs,acc,'b-')\nplt.title('Accuracy of Model')\nplt.xlabel('epochs')\nplt.ylabel('Accuracy')\n\nplt.plot(epochs,val_acc,'b-', color = 'red')\nplt.title('Accuracy of Model')\nplt.xlabel('epochs')\nplt.ylabel('Accuracy')\nplt.show()","metadata":{"_uuid":"391dd25d33d15a17da3ace56d44a91639fbab50b","scrolled":true,"execution":{"iopub.status.busy":"2021-10-25T11:39:17.699642Z","iopub.execute_input":"2021-10-25T11:39:17.699900Z","iopub.status.idle":"2021-10-25T11:39:17.893973Z","shell.execute_reply.started":"2021-10-25T11:39:17.699847Z","shell.execute_reply":"2021-10-25T11:39:17.892964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.plot(epochs,loss,'b-')\nplt.title('loss function')\nplt.xlabel('epochs')\nplt.ylabel('Loss')\n\nplt.plot(epochs,val_loss,'b-', color = 'red')\nplt.title('loss function')\nplt.xlabel('epochs')\nplt.ylabel('val_loss')\nplt.show()","metadata":{"_uuid":"f617e562701a140372075c8159c31947f3b90bb7","execution":{"iopub.status.busy":"2021-10-25T11:39:17.899272Z","iopub.execute_input":"2021-10-25T11:39:17.901943Z","iopub.status.idle":"2021-10-25T11:39:18.080428Z","shell.execute_reply.started":"2021-10-25T11:39:17.899576Z","shell.execute_reply":"2021-10-25T11:39:18.079422Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_val_probability = Keras_Model.predict(X_val, batch_size=64)","metadata":{"_uuid":"9c1e62b41eca359540b11ad6404a16d8f1784a3d","execution":{"iopub.status.busy":"2021-10-25T11:39:18.081665Z","iopub.execute_input":"2021-10-25T11:39:18.081935Z","iopub.status.idle":"2021-10-25T11:39:19.910768Z","shell.execute_reply.started":"2021-10-25T11:39:18.081889Z","shell.execute_reply":"2021-10-25T11:39:19.910024Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"Y_val_pred_label = np.round(predicted_val_probability)\nl = []\nfor i in range(len(Y_val_pred_label)):\n    if Y_val[i] != Y_val_pred_label[i]:\n        l.append(i)","metadata":{"_uuid":"16b5c003ab117486c42bdde80f25c1e41ead387d","execution":{"iopub.status.busy":"2021-10-25T11:39:19.913286Z","iopub.execute_input":"2021-10-25T11:39:19.913847Z","iopub.status.idle":"2021-10-25T11:39:19.925333Z","shell.execute_reply.started":"2021-10-25T11:39:19.913794Z","shell.execute_reply":"2021-10-25T11:39:19.924691Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"m = []\nfor t in l:\n    if predicted_val_probability[t] >= 0.99:\n        m.append(t)\n    elif predicted_val_probability[t] < 0.01:\n        m.append(t)\n    ","metadata":{"_uuid":"420a62d80b6556b910d8d8119173d8e56b3e9b37","execution":{"iopub.status.busy":"2021-10-25T11:39:19.927866Z","iopub.execute_input":"2021-10-25T11:39:19.928873Z","iopub.status.idle":"2021-10-25T11:39:19.937172Z","shell.execute_reply.started":"2021-10-25T11:39:19.928813Z","shell.execute_reply":"2021-10-25T11:39:19.936351Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(m)","metadata":{"_uuid":"f0c136df87aef4f01625808ef79fc6ee25959fa7","execution":{"iopub.status.busy":"2021-10-25T11:39:19.939348Z","iopub.execute_input":"2021-10-25T11:39:19.939887Z","iopub.status.idle":"2021-10-25T11:39:19.947875Z","shell.execute_reply.started":"2021-10-25T11:39:19.939746Z","shell.execute_reply":"2021-10-25T11:39:19.947021Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize=(35,35))\nc = 1\nfor i in m[:]:\n    plt.subplot(10,5, c)\n    plt.imshow(X_val[i])\n    plt.title('DOG:{}\\nTrue label:{}'.format(predicted_val_probability[i], Y_val[i])\n              if predicted_val_probability[i]>= 0.5 else 'CAT:{}\\nTrue label:{}'.format(predicted_val_probability[i],Y_val[i]))\n    plt.axis('off')\n    c = c+1","metadata":{"_uuid":"e2e6144870ed37a0766ef8005eccef28526c2af6","execution":{"iopub.status.busy":"2021-10-25T11:39:19.949418Z","iopub.execute_input":"2021-10-25T11:39:19.949799Z","iopub.status.idle":"2021-10-25T11:39:21.769846Z","shell.execute_reply.started":"2021-10-25T11:39:19.949735Z","shell.execute_reply":"2021-10-25T11:39:21.769160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_Test_orig = []\nfor i in os.listdir('/kaggle/working/test/'):\n    label = i.split('.')[-2]\n    img = cv2.imread('/kaggle/working/test/'+i, cv2.IMREAD_COLOR)\n    img = cv2.resize(img,(IMG_SIZE,IMG_SIZE), interpolation = cv2.INTER_CUBIC)\n    #img = img / 255\n    X_Test_orig.append([np.array(img), np.array(label)])\n\nnp.save('Test_Data.npy', X_Train_orig)","metadata":{"_uuid":"c25765553e1db2d44ebcb91fcb7b981a00603be8","execution":{"iopub.status.busy":"2021-10-25T11:40:36.768310Z","iopub.execute_input":"2021-10-25T11:40:36.768628Z","iopub.status.idle":"2021-10-25T11:41:10.062264Z","shell.execute_reply.started":"2021-10-25T11:40:36.768577Z","shell.execute_reply":"2021-10-25T11:41:10.061361Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test = np.array([i[0] for i in X_Test_orig]).reshape(-1,IMG_SIZE, IMG_SIZE, 3)\nLabel = np.array([i[1] for i in X_Test_orig])","metadata":{"_uuid":"076a820fa95d5987acf8ac655460c2e694e9bfb4","execution":{"iopub.status.busy":"2021-10-25T11:41:10.063545Z","iopub.execute_input":"2021-10-25T11:41:10.063825Z","iopub.status.idle":"2021-10-25T11:41:10.459917Z","shell.execute_reply.started":"2021-10-25T11:41:10.063769Z","shell.execute_reply":"2021-10-25T11:41:10.458922Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_test = X_test / 255","metadata":{"_uuid":"29fb0a8ed8e1de26575c8d1748a10155f104eab8","execution":{"iopub.status.busy":"2021-10-25T11:41:10.461230Z","iopub.execute_input":"2021-10-25T11:41:10.461548Z","iopub.status.idle":"2021-10-25T11:41:13.812607Z","shell.execute_reply.started":"2021-10-25T11:41:10.461501Z","shell.execute_reply":"2021-10-25T11:41:13.811806Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes = Keras_Model.predict(X_test, batch_size = batch_size)","metadata":{"_uuid":"eb8b4ac08954ebc942a4f158aae441b5df88c532","execution":{"iopub.status.busy":"2021-10-25T11:41:13.813774Z","iopub.execute_input":"2021-10-25T11:41:13.814038Z","iopub.status.idle":"2021-10-25T11:41:22.398693Z","shell.execute_reply.started":"2021-10-25T11:41:13.813997Z","shell.execute_reply":"2021-10-25T11:41:22.397797Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"prediction = pd.DataFrame()\nprediction['id'] = Label\nprediction['label'] = classes\n\nprediction.to_csv('submission.csv', index = False)","metadata":{"_uuid":"187383744f503a192f31139351b4280f54379827","execution":{"iopub.status.busy":"2021-10-25T11:41:22.399895Z","iopub.execute_input":"2021-10-25T11:41:22.400159Z","iopub.status.idle":"2021-10-25T11:41:22.675367Z","shell.execute_reply.started":"2021-10-25T11:41:22.400115Z","shell.execute_reply":"2021-10-25T11:41:22.674694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}