{"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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\n#import os\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n #   for filename in filenames:\n  #      print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2022-03-30T11:30:16.126072Z","iopub.execute_input":"2022-03-30T11:30:16.12656Z","iopub.status.idle":"2022-03-30T11:30:16.152555Z","shell.execute_reply.started":"2022-03-30T11:30:16.126465Z","shell.execute_reply":"2022-03-30T11:30:16.15177Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport os\nprint(os.listdir(\"../input/happy-whale-and-dolphin\"))\n\n# import warnings\nimport warnings\n# filter warnings\nwarnings.filterwarnings('ignore')\n\n","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:16.153767Z","iopub.execute_input":"2022-03-30T11:30:16.154105Z","iopub.status.idle":"2022-03-30T11:30:17.189867Z","shell.execute_reply.started":"2022-03-30T11:30:16.154077Z","shell.execute_reply":"2022-03-30T11:30:17.189003Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = pd.read_csv(\"../input/happy-whale-and-dolphin/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.191638Z","iopub.execute_input":"2022-03-30T11:30:17.192452Z","iopub.status.idle":"2022-03-30T11:30:17.293253Z","shell.execute_reply.started":"2022-03-30T11:30:17.192406Z","shell.execute_reply":"2022-03-30T11:30:17.2924Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.info()","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.294532Z","iopub.execute_input":"2022-03-30T11:30:17.294778Z","iopub.status.idle":"2022-03-30T11:30:17.327862Z","shell.execute_reply.started":"2022-03-30T11:30:17.294748Z","shell.execute_reply":"2022-03-30T11:30:17.327066Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.describe()","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.329667Z","iopub.execute_input":"2022-03-30T11:30:17.329898Z","iopub.status.idle":"2022-03-30T11:30:17.399328Z","shell.execute_reply.started":"2022-03-30T11:30:17.329869Z","shell.execute_reply":"2022-03-30T11:30:17.398742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.400219Z","iopub.execute_input":"2022-03-30T11:30:17.400692Z","iopub.status.idle":"2022-03-30T11:30:17.406196Z","shell.execute_reply.started":"2022-03-30T11:30:17.400658Z","shell.execute_reply":"2022-03-30T11:30:17.405209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.407486Z","iopub.execute_input":"2022-03-30T11:30:17.408083Z","iopub.status.idle":"2022-03-30T11:30:17.421774Z","shell.execute_reply.started":"2022-03-30T11:30:17.408052Z","shell.execute_reply":"2022-03-30T11:30:17.420897Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.tail()","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.423Z","iopub.execute_input":"2022-03-30T11:30:17.423951Z","iopub.status.idle":"2022-03-30T11:30:17.436994Z","shell.execute_reply.started":"2022-03-30T11:30:17.423905Z","shell.execute_reply":"2022-03-30T11:30:17.436393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.438243Z","iopub.execute_input":"2022-03-30T11:30:17.438731Z","iopub.status.idle":"2022-03-30T11:30:17.458044Z","shell.execute_reply.started":"2022-03-30T11:30:17.438689Z","shell.execute_reply":"2022-03-30T11:30:17.457403Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_train = train[\"individual_id\"]\n# Drop the 'Id' column\nxtrain = train.drop(labels = [\"individual_id\"], axis = 1)\ny_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.459589Z","iopub.execute_input":"2022-03-30T11:30:17.460049Z","iopub.status.idle":"2022-03-30T11:30:17.471601Z","shell.execute_reply.started":"2022-03-30T11:30:17.460008Z","shell.execute_reply":"2022-03-30T11:30:17.47078Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing import image\nfrom keras.applications.imagenet_utils import preprocess_input","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:17.474008Z","iopub.execute_input":"2022-03-30T11:30:17.474248Z","iopub.status.idle":"2022-03-30T11:30:23.17928Z","shell.execute_reply.started":"2022-03-30T11:30:17.474213Z","shell.execute_reply":"2022-03-30T11:30:23.17836Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def prepareImages(train, shape, path):\n    \n    x_train = np.zeros((shape, 100, 100, 3))\n    count = 0\n    \n    for fig in train['image']:\n        \n        #load images into images of size 100x100x3\n        img = image.load_img(\"../input/happy-whale-and-dolphin/\"+path+\"/\"+fig, target_size=(100, 100, 3))\n        x = image.img_to_array(img)\n        x = preprocess_input(x)\n\n        x_train[count] = x\n        if (count%500 == 0):\n            print(\"Processing image: \", count+1, \", \", fig)\n        count += 1\n    \n    return x_train","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:23.180766Z","iopub.execute_input":"2022-03-30T11:30:23.181076Z","iopub.status.idle":"2022-03-30T11:30:23.18913Z","shell.execute_reply.started":"2022-03-30T11:30:23.181033Z","shell.execute_reply":"2022-03-30T11:30:23.188061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train = prepareImages(train, train.shape[0], \"train_images\")","metadata":{"execution":{"iopub.status.busy":"2022-03-30T11:30:23.190552Z","iopub.execute_input":"2022-03-30T11:30:23.19087Z","iopub.status.idle":"2022-03-30T12:47:25.665047Z","shell.execute_reply.started":"2022-03-30T11:30:23.190827Z","shell.execute_reply":"2022-03-30T12:47:25.662949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import cv2\nimport pandas as pd","metadata":{"execution":{"iopub.status.busy":"2022-03-30T12:47:25.670043Z","iopub.execute_input":"2022-03-30T12:47:25.670485Z","iopub.status.idle":"2022-03-30T12:47:26.207384Z","shell.execute_reply.started":"2022-03-30T12:47:25.670405Z","shell.execute_reply":"2022-03-30T12:47:26.20657Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}