{"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-14T16:24:34.962958Z","iopub.execute_input":"2023-06-14T16:24:34.963533Z","iopub.status.idle":"2023-06-14T16:24:35.011276Z","shell.execute_reply.started":"2023-06-14T16:24:34.963486Z","shell.execute_reply":"2023-06-14T16:24:35.009793Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import shutil\nimport zipfile","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:25:05.454136Z","iopub.execute_input":"2023-06-14T16:25:05.454588Z","iopub.status.idle":"2023-06-14T16:25:05.460419Z","shell.execute_reply.started":"2023-06-14T16:25:05.454557Z","shell.execute_reply":"2023-06-14T16:25:05.459049Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path_train_zip  = '/kaggle/input/dogs-vs-cats/train.zip' \npath_test_zip  = '/kaggle/input/dogs-vs-cats/test1.zip'\npath_train_target  = '/kaggle/working/'\npath_test_target  = '/kaggle/working/'","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:25:32.793396Z","iopub.execute_input":"2023-06-14T16:25:32.793838Z","iopub.status.idle":"2023-06-14T16:25:32.799943Z","shell.execute_reply.started":"2023-06-14T16:25:32.793798Z","shell.execute_reply":"2023-06-14T16:25:32.798627Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with zipfile.ZipFile(path_test_zip,'r') as zip_loc:\n    zip_loc.extractall(path_test_target)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:25:55.494925Z","iopub.execute_input":"2023-06-14T16:25:55.495352Z","iopub.status.idle":"2023-06-14T16:26:01.822075Z","shell.execute_reply.started":"2023-06-14T16:25:55.495320Z","shell.execute_reply":"2023-06-14T16:26:01.820994Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_test = os.listdir('/kaggle/working/test1')\nlen(file_test)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:26:19.625438Z","iopub.execute_input":"2023-06-14T16:26:19.625898Z","iopub.status.idle":"2023-06-14T16:26:19.647122Z","shell.execute_reply.started":"2023-06-14T16:26:19.625866Z","shell.execute_reply":"2023-06-14T16:26:19.645704Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"with zipfile.ZipFile(path_train_zip,'r') as zip_loc:\n    zip_loc.extractall(path_train_target)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:26:41.610433Z","iopub.execute_input":"2023-06-14T16:26:41.610926Z","iopub.status.idle":"2023-06-14T16:26:53.838213Z","shell.execute_reply.started":"2023-06-14T16:26:41.610887Z","shell.execute_reply":"2023-06-14T16:26:53.836832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train = os.listdir('/kaggle/working/train')\nlen(file_train)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:26:59.256358Z","iopub.execute_input":"2023-06-14T16:26:59.256796Z","iopub.status.idle":"2023-06-14T16:26:59.285636Z","shell.execute_reply.started":"2023-06-14T16:26:59.256765Z","shell.execute_reply":"2023-06-14T16:26:59.284257Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dir_cat = os.path.join(path_train_target, 'train', 'cat')\ndir_dog = os.path.join(path_train_target, 'train', 'dog')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:27:21.930263Z","iopub.execute_input":"2023-06-14T16:27:21.930751Z","iopub.status.idle":"2023-06-14T16:27:21.937503Z","shell.execute_reply.started":"2023-06-14T16:27:21.930714Z","shell.execute_reply":"2023-06-14T16:27:21.935876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs(dir_cat, exist_ok=True)\nos.makedirs(dir_dog, exist_ok=True)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:27:40.104960Z","iopub.execute_input":"2023-06-14T16:27:40.105391Z","iopub.status.idle":"2023-06-14T16:27:40.111828Z","shell.execute_reply.started":"2023-06-14T16:27:40.105360Z","shell.execute_reply":"2023-06-14T16:27:40.110537Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_cat = os.listdir('/kaggle/working/train/cat')\nlen(file_train_cat)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:28:07.127468Z","iopub.execute_input":"2023-06-14T16:28:07.127893Z","iopub.status.idle":"2023-06-14T16:28:07.135625Z","shell.execute_reply.started":"2023-06-14T16:28:07.127861Z","shell.execute_reply":"2023-06-14T16:28:07.134485Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_dog = os.listdir('/kaggle/working/train/dog')\nlen(file_train_dog)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:28:21.610388Z","iopub.execute_input":"2023-06-14T16:28:21.610858Z","iopub.status.idle":"2023-06-14T16:28:21.620544Z","shell.execute_reply.started":"2023-06-14T16:28:21.610825Z","shell.execute_reply":"2023-06-14T16:28:21.619185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dir_image = os.path.join(path_train_target, 'train')\n\nfor filename in os.listdir(dir_image):\n    if filename.startswith('cat.'):\n        src = os.path.join(dir_image, filename)\n        dst = os.path.join(dir_cat, filename)\n        os.rename(src, dst)\n    elif filename.startswith('dog.'):\n        src = os.path.join(dir_image, filename)\n        dst = os.path.join(dir_dog, filename)\n        os.rename(src, dst)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:28:42.552984Z","iopub.execute_input":"2023-06-14T16:28:42.553411Z","iopub.status.idle":"2023-06-14T16:28:43.409334Z","shell.execute_reply.started":"2023-06-14T16:28:42.553382Z","shell.execute_reply":"2023-06-14T16:28:43.408298Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_cat = os.listdir('/kaggle/working/train/cat')\nlen(file_train_cat)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:28:58.024916Z","iopub.execute_input":"2023-06-14T16:28:58.025354Z","iopub.status.idle":"2023-06-14T16:28:58.042414Z","shell.execute_reply.started":"2023-06-14T16:28:58.025324Z","shell.execute_reply":"2023-06-14T16:28:58.041082Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_dog = os.listdir('/kaggle/working/train/dog')\nlen(file_train_dog)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:29:13.820180Z","iopub.execute_input":"2023-06-14T16:29:13.820653Z","iopub.status.idle":"2023-06-14T16:29:13.837774Z","shell.execute_reply.started":"2023-06-14T16:29:13.820619Z","shell.execute_reply":"2023-06-14T16:29:13.836178Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train = os.listdir('/kaggle/working/train')\nlen(file_train)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:29:31.501920Z","iopub.execute_input":"2023-06-14T16:29:31.502367Z","iopub.status.idle":"2023-06-14T16:29:31.511803Z","shell.execute_reply.started":"2023-06-14T16:29:31.502333Z","shell.execute_reply":"2023-06-14T16:29:31.510520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"original = '/kaggle/working/test1/'\nnew = '/kaggle/working/validation/'","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:29:50.493010Z","iopub.execute_input":"2023-06-14T16:29:50.493439Z","iopub.status.idle":"2023-06-14T16:29:50.499093Z","shell.execute_reply.started":"2023-06-14T16:29:50.493409Z","shell.execute_reply":"2023-06-14T16:29:50.497777Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.rename(original, new)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:30:05.293945Z","iopub.execute_input":"2023-06-14T16:30:05.294394Z","iopub.status.idle":"2023-06-14T16:30:05.300514Z","shell.execute_reply.started":"2023-06-14T16:30:05.294364Z","shell.execute_reply":"2023-06-14T16:30:05.299463Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_val = os.listdir('/kaggle/working/validation')\nlen(file_val)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:30:21.612507Z","iopub.execute_input":"2023-06-14T16:30:21.612950Z","iopub.status.idle":"2023-06-14T16:30:21.629770Z","shell.execute_reply.started":"2023-06-14T16:30:21.612917Z","shell.execute_reply":"2023-06-14T16:30:21.628567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_files = [filename for filename in os.listdir(os.path.join(new))]","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:30:40.207151Z","iopub.execute_input":"2023-06-14T16:30:40.207631Z","iopub.status.idle":"2023-06-14T16:30:40.224300Z","shell.execute_reply.started":"2023-06-14T16:30:40.207595Z","shell.execute_reply":"2023-06-14T16:30:40.222226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_move = int(len(val_files) * 0.20)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:30:54.109698Z","iopub.execute_input":"2023-06-14T16:30:54.110138Z","iopub.status.idle":"2023-06-14T16:30:54.116205Z","shell.execute_reply.started":"2023-06-14T16:30:54.110108Z","shell.execute_reply":"2023-06-14T16:30:54.114603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import random","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:31:08.850223Z","iopub.execute_input":"2023-06-14T16:31:08.850680Z","iopub.status.idle":"2023-06-14T16:31:08.855689Z","shell.execute_reply.started":"2023-06-14T16:31:08.850649Z","shell.execute_reply":"2023-06-14T16:31:08.854624Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"random_val_files = random.sample(val_files, num_move)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:31:23.998074Z","iopub.execute_input":"2023-06-14T16:31:23.998557Z","iopub.status.idle":"2023-06-14T16:31:24.007042Z","shell.execute_reply.started":"2023-06-14T16:31:23.998519Z","shell.execute_reply":"2023-06-14T16:31:24.006005Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_target  = '/kaggle/working/test/'","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:31:53.392724Z","iopub.execute_input":"2023-06-14T16:31:53.393169Z","iopub.status.idle":"2023-06-14T16:31:53.399321Z","shell.execute_reply.started":"2023-06-14T16:31:53.393137Z","shell.execute_reply":"2023-06-14T16:31:53.398088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.makedirs(test_target, exist_ok=True)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:32:05.469049Z","iopub.execute_input":"2023-06-14T16:32:05.469507Z","iopub.status.idle":"2023-06-14T16:32:05.475039Z","shell.execute_reply.started":"2023-06-14T16:32:05.469459Z","shell.execute_reply":"2023-06-14T16:32:05.473826Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_test = os.listdir('/kaggle/working/test')\nlen(file_test)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:32:27.024003Z","iopub.execute_input":"2023-06-14T16:32:27.024412Z","iopub.status.idle":"2023-06-14T16:32:27.032871Z","shell.execute_reply.started":"2023-06-14T16:32:27.024383Z","shell.execute_reply":"2023-06-14T16:32:27.031741Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_values = os.listdir('/kaggle/working/train')\nlen(file_train_values)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:32:44.386145Z","iopub.execute_input":"2023-06-14T16:32:44.386581Z","iopub.status.idle":"2023-06-14T16:32:44.395090Z","shell.execute_reply.started":"2023-06-14T16:32:44.386549Z","shell.execute_reply":"2023-06-14T16:32:44.393805Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_validation_values = os.listdir('/kaggle/working/validation')\nlen(file_validation_values)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:32:56.913430Z","iopub.execute_input":"2023-06-14T16:32:56.913901Z","iopub.status.idle":"2023-06-14T16:32:56.929708Z","shell.execute_reply.started":"2023-06-14T16:32:56.913870Z","shell.execute_reply":"2023-06-14T16:32:56.928209Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_cat_values = os.listdir('/kaggle/working/train/cat')\nlen(file_train_cat_values)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:33:31.803480Z","iopub.execute_input":"2023-06-14T16:33:31.803907Z","iopub.status.idle":"2023-06-14T16:33:31.819993Z","shell.execute_reply.started":"2023-06-14T16:33:31.803875Z","shell.execute_reply":"2023-06-14T16:33:31.818595Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_train_dog_values = os.listdir('/kaggle/working/train/dog')\nlen(file_train_dog_values)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:33:46.206497Z","iopub.execute_input":"2023-06-14T16:33:46.206928Z","iopub.status.idle":"2023-06-14T16:33:46.222746Z","shell.execute_reply.started":"2023-06-14T16:33:46.206894Z","shell.execute_reply":"2023-06-14T16:33:46.221343Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for filename in random_val_files:\n    src1 = os.path.join(new, filename)\n    dst1 = os.path.join(test_target, filename)\n    shutil.copy(src1, dst1)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:34:04.573093Z","iopub.execute_input":"2023-06-14T16:34:04.573605Z","iopub.status.idle":"2023-06-14T16:34:04.968032Z","shell.execute_reply.started":"2023-06-14T16:34:04.573568Z","shell.execute_reply":"2023-06-14T16:34:04.967017Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_test = os.listdir('/kaggle/working/test')\nlen(file_test)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:34:20.096323Z","iopub.execute_input":"2023-06-14T16:34:20.096749Z","iopub.status.idle":"2023-06-14T16:34:20.108621Z","shell.execute_reply.started":"2023-06-14T16:34:20.096718Z","shell.execute_reply":"2023-06-14T16:34:20.107536Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%pip install tensorflow\nimport tensorflow as tf","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:34:51.421907Z","iopub.execute_input":"2023-06-14T16:34:51.422360Z","iopub.status.idle":"2023-06-14T16:35:16.902255Z","shell.execute_reply.started":"2023-06-14T16:34:51.422327Z","shell.execute_reply":"2023-06-14T16:35:16.900412Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow import keras","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:36:04.366698Z","iopub.execute_input":"2023-06-14T16:36:04.367821Z","iopub.status.idle":"2023-06-14T16:36:04.375112Z","shell.execute_reply.started":"2023-06-14T16:36:04.367766Z","shell.execute_reply":"2023-06-14T16:36:04.373677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from 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 (Conv2D, MaxPooling2D, AveragePooling2D, BatchNormalization, Dropout,Flatten, Dense, Input)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:36:24.436772Z","iopub.execute_input":"2023-06-14T16:36:24.437211Z","iopub.status.idle":"2023-06-14T16:36:24.980313Z","shell.execute_reply.started":"2023-06-14T16:36:24.437179Z","shell.execute_reply":"2023-06-14T16:36:24.978381Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier = Sequential()","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:36:48.125630Z","iopub.execute_input":"2023-06-14T16:36:48.126088Z","iopub.status.idle":"2023-06-14T16:36:48.258924Z","shell.execute_reply.started":"2023-06-14T16:36:48.126055Z","shell.execute_reply":"2023-06-14T16:36:48.257332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(Conv2D(32, (3, 3), input_shape = (64, 64, 3), activation = 'relu'))","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:37:04.448110Z","iopub.execute_input":"2023-06-14T16:37:04.448585Z","iopub.status.idle":"2023-06-14T16:37:04.531818Z","shell.execute_reply.started":"2023-06-14T16:37:04.448551Z","shell.execute_reply":"2023-06-14T16:37:04.530373Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(MaxPooling2D(pool_size = (2, 2)))","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:37:19.644806Z","iopub.execute_input":"2023-06-14T16:37:19.645248Z","iopub.status.idle":"2023-06-14T16:37:19.657783Z","shell.execute_reply.started":"2023-06-14T16:37:19.645215Z","shell.execute_reply":"2023-06-14T16:37:19.656652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(Conv2D(32, (3, 3), activation = 'relu'))","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:37:32.081308Z","iopub.execute_input":"2023-06-14T16:37:32.081847Z","iopub.status.idle":"2023-06-14T16:37:32.110077Z","shell.execute_reply.started":"2023-06-14T16:37:32.081807Z","shell.execute_reply":"2023-06-14T16:37:32.108804Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(MaxPooling2D(pool_size = (2, 2)))","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:37:46.271782Z","iopub.execute_input":"2023-06-14T16:37:46.272190Z","iopub.status.idle":"2023-06-14T16:37:46.286790Z","shell.execute_reply.started":"2023-06-14T16:37:46.272162Z","shell.execute_reply":"2023-06-14T16:37:46.285189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(Flatten())","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:37:59.373226Z","iopub.execute_input":"2023-06-14T16:37:59.374393Z","iopub.status.idle":"2023-06-14T16:37:59.390234Z","shell.execute_reply.started":"2023-06-14T16:37:59.374338Z","shell.execute_reply":"2023-06-14T16:37:59.389006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(Dense(units = 128, activation = 'relu'))","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:38:12.708704Z","iopub.execute_input":"2023-06-14T16:38:12.709121Z","iopub.status.idle":"2023-06-14T16:38:12.746589Z","shell.execute_reply.started":"2023-06-14T16:38:12.709090Z","shell.execute_reply":"2023-06-14T16:38:12.745253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.add(Dense(units = 1, activation = 'sigmoid'))","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:38:25.297333Z","iopub.execute_input":"2023-06-14T16:38:25.297819Z","iopub.status.idle":"2023-06-14T16:38:25.323736Z","shell.execute_reply.started":"2023-06-14T16:38:25.297784Z","shell.execute_reply":"2023-06-14T16:38:25.322491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:38:39.681602Z","iopub.execute_input":"2023-06-14T16:38:39.682052Z","iopub.status.idle":"2023-06-14T16:38:39.704599Z","shell.execute_reply.started":"2023-06-14T16:38:39.682016Z","shell.execute_reply":"2023-06-14T16:38:39.702947Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_datagen = ImageDataGenerator(rescale = 1./255, shear_range = 0.2, zoom_range = 0.2, horizontal_flip = True)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:38:54.654380Z","iopub.execute_input":"2023-06-14T16:38:54.654816Z","iopub.status.idle":"2023-06-14T16:38:54.660670Z","shell.execute_reply.started":"2023-06-14T16:38:54.654786Z","shell.execute_reply":"2023-06-14T16:38:54.659362Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"validation_datagen = ImageDataGenerator(rescale = 1./255)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:39:09.103796Z","iopub.execute_input":"2023-06-14T16:39:09.104295Z","iopub.status.idle":"2023-06-14T16:39:09.109474Z","shell.execute_reply.started":"2023-06-14T16:39:09.104263Z","shell.execute_reply":"2023-06-14T16:39:09.108503Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_set = train_datagen.flow_from_directory('/kaggle/working/train', target_size = (64, 64), batch_size = 32, class_mode = 'binary')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:39:33.326697Z","iopub.execute_input":"2023-06-14T16:39:33.327327Z","iopub.status.idle":"2023-06-14T16:39:34.093735Z","shell.execute_reply.started":"2023-06-14T16:39:33.327279Z","shell.execute_reply":"2023-06-14T16:39:34.092558Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"validation_set = validation_datagen.flow_from_directory('/kaggle/working/validation/', target_size = (64, 64), batch_size = 32, class_mode = 'binary')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:40:05.935558Z","iopub.execute_input":"2023-06-14T16:40:05.935988Z","iopub.status.idle":"2023-06-14T16:40:06.055859Z","shell.execute_reply.started":"2023-06-14T16:40:05.935957Z","shell.execute_reply":"2023-06-14T16:40:06.054695Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classifier.fit(training_set, steps_per_epoch = 8000, epochs = 5, validation_data = validation_set, validation_steps = 2000)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:45:59.746550Z","iopub.execute_input":"2023-06-14T16:45:59.747046Z","iopub.status.idle":"2023-06-14T16:48:21.806605Z","shell.execute_reply.started":"2023-06-14T16:45:59.747011Z","shell.execute_reply":"2023-06-14T16:48:21.805104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import numpy as np\nfrom tensorflow.keras.preprocessing import image\nfrom IPython.display import Image","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:48:44.339835Z","iopub.execute_input":"2023-06-14T16:48:44.340305Z","iopub.status.idle":"2023-06-14T16:48:44.347142Z","shell.execute_reply.started":"2023-06-14T16:48:44.340271Z","shell.execute_reply":"2023-06-14T16:48:44.345740Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_test = os.listdir('/kaggle/working/test')\nlen(file_test)","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:56:16.926814Z","iopub.execute_input":"2023-06-14T16:56:16.927281Z","iopub.status.idle":"2023-06-14T16:56:16.937490Z","shell.execute_reply.started":"2023-06-14T16:56:16.927246Z","shell.execute_reply":"2023-06-14T16:56:16.936062Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir('/kaggle/working/test')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:49:35.893954Z","iopub.execute_input":"2023-06-14T16:49:35.894405Z","iopub.status.idle":"2023-06-14T16:49:35.925880Z","shell.execute_reply.started":"2023-06-14T16:49:35.894373Z","shell.execute_reply":"2023-06-14T16:49:35.924666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image = image.load_img('test/4703.jpg', target_size = (64, 64))\ntest_image = image.img_to_array(test_image)\ntest_image = np.expand_dims(test_image, axis = 0)\nresult = classifier.predict(test_image)\ntraining_set.class_indices\n\nif result[0][0] == 1:\n    prediction = 'Cachorro'\nelse:\n    prediction = 'Gato'\n\n    \nprint(\"Isso é um: \", prediction)\n    \nImage(filename='test/4703.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T17:00:03.119081Z","iopub.execute_input":"2023-06-14T17:00:03.119546Z","iopub.status.idle":"2023-06-14T17:00:03.213778Z","shell.execute_reply.started":"2023-06-14T17:00:03.119508Z","shell.execute_reply":"2023-06-14T17:00:03.212511Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image = image.load_img('test/6795.jpg', target_size = (64, 64))\ntest_image = image.img_to_array(test_image)\ntest_image = np.expand_dims(test_image, axis = 0)\nresult = classifier.predict(test_image)\ntraining_set.class_indices\n\nif result[0][0] == 1:\n    prediction = 'Cachorro'\nelse:\n    prediction = 'Gato'\n\n\nprint(\"Isso é um: \", prediction)\n    \nImage(filename='test/6795.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:59:45.518146Z","iopub.execute_input":"2023-06-14T16:59:45.518637Z","iopub.status.idle":"2023-06-14T16:59:45.608133Z","shell.execute_reply.started":"2023-06-14T16:59:45.518602Z","shell.execute_reply":"2023-06-14T16:59:45.606433Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image = image.load_img('test/9805.jpg', target_size = (64, 64))\ntest_image = image.img_to_array(test_image)\ntest_image = np.expand_dims(test_image, axis = 0)\nresult = classifier.predict(test_image)\ntraining_set.class_indices\n\nif result[0][0] == 1:\n    prediction = 'Cachorro'\nelse:\n    prediction = 'Gato'\n\n\nprint(\"Isso é um: \", prediction)\n    \nImage(filename='test/9805.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:59:25.951305Z","iopub.execute_input":"2023-06-14T16:59:25.951765Z","iopub.status.idle":"2023-06-14T16:59:26.044026Z","shell.execute_reply.started":"2023-06-14T16:59:25.951735Z","shell.execute_reply":"2023-06-14T16:59:26.042761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image = image.load_img('test/12254.jpg', target_size = (64, 64))\ntest_image = image.img_to_array(test_image)\ntest_image = np.expand_dims(test_image, axis = 0)\nresult = classifier.predict(test_image)\ntraining_set.class_indices\n\nif result[0][0] == 1:\n    prediction = 'Cachorro'\nelse:\n    prediction = 'Gato'\n\nprint(\"Isso é um: \", prediction)\n    \nImage(filename='test/12254.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:58:59.360195Z","iopub.execute_input":"2023-06-14T16:58:59.360718Z","iopub.status.idle":"2023-06-14T16:58:59.486996Z","shell.execute_reply.started":"2023-06-14T16:58:59.360684Z","shell.execute_reply":"2023-06-14T16:58:59.485437Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image = image.load_img('test/3402.jpg', target_size = (64, 64))\ntest_image = image.img_to_array(test_image)\ntest_image = np.expand_dims(test_image, axis = 0)\nresult = classifier.predict(test_image)\ntraining_set.class_indices\n\nif result[0][0] == 1:\n    prediction = 'Cachorro'\nelse:\n    prediction = 'Gato'\n\n\nprint(\"Isso é um: \", prediction)    \n    \nImage(filename='test/3402.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:58:34.591974Z","iopub.execute_input":"2023-06-14T16:58:34.592648Z","iopub.status.idle":"2023-06-14T16:58:34.711808Z","shell.execute_reply.started":"2023-06-14T16:58:34.592600Z","shell.execute_reply":"2023-06-14T16:58:34.710729Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_image = image.load_img('test/2700.jpg', target_size = (64, 64))\ntest_image = image.img_to_array(test_image)\ntest_image = np.expand_dims(test_image, axis = 0)\nresult = classifier.predict(test_image)\ntraining_set.class_indices\n\nif result[0][0] == 1:\n    prediction = 'Cachorro'\nelse:\n    prediction = 'Gato'\n    \n\nprint(\"Isso é um: \", prediction)\n\nImage(filename='test/2700.jpg')","metadata":{"execution":{"iopub.status.busy":"2023-06-14T16:58:05.418242Z","iopub.execute_input":"2023-06-14T16:58:05.418737Z","iopub.status.idle":"2023-06-14T16:58:05.522217Z","shell.execute_reply.started":"2023-06-14T16:58:05.418699Z","shell.execute_reply":"2023-06-14T16:58:05.520962Z"},"trusted":true},"execution_count":null,"outputs":[]}]}