{"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\nimport os\nfor 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":"2023-06-26T09:27:16.965539Z","iopub.execute_input":"2023-06-26T09:27:16.966242Z","iopub.status.idle":"2023-06-26T09:27:17.007432Z","shell.execute_reply.started":"2023-06-26T09:27:16.966202Z","shell.execute_reply":"2023-06-26T09:27:17.006396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# https://www.kaggle.com/code/pranayrishith16/is-it-dog-or-cat","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport random\nimport os\nimport zipfile\nimport seaborn as sns\n\n\nfrom tensorflow.keras.utils import load_img\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom sklearn.model_selection import train_test_split\nfrom tensorflow.keras import Sequential, Model\nfrom tensorflow.keras.layers import (\n    Conv2D, MaxPooling2D, AveragePooling2D, BatchNormalization, Dropout,Flatten, Dense, Input)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"IMAGE_H = 150\nIMAGE_W = 150\nIMAGE_C = 3","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Unzipping the train file\n\nziplocation = '/kaggle/input/dogs-vs-cats/train.zip'\ndestination = '/kaggle/working/train_images/'\n\nos.makedirs(destination,exist_ok=True)\n\nwith zipfile.ZipFile(ziplocation,'r') as zip_ref:\n    zip_ref.extractall(destination)","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Create a dataframe with id and type¶","metadata":{}},{"cell_type":"code","source":"images = os.listdir('/kaggle/working/train_images/train/')\ncate = []\nfor image in images:\n    temp = image.split('.')[0]\n    if temp.lower() == 'cat':\n        cate.append('cat')\n    else:\n        cate.append('dog')\n        \ndf = pd.DataFrame({\n    'image':images,\n    'type':cate\n})\n\ndf.head()","metadata":{},"execution_count":null,"outputs":[]}]}