{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":3362,"databundleVersionId":31148,"sourceType":"competition"}],"dockerImageVersionId":30627,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"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":"2026-09-12T05:14:06.599682Z","iopub.execute_input":"2026-09-12T05:14:06.600454Z","iopub.status.idle":"2026-09-12T05:14:06.606892Z","shell.execute_reply.started":"2026-09-12T05:14:06.600422Z","shell.execute_reply":"2026-09-12T05:14:06.605794Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python --version","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:06.608904Z","iopub.execute_input":"2026-09-12T05:14:06.609172Z","iopub.status.idle":"2026-09-12T05:14:07.66931Z","shell.execute_reply.started":"2026-09-12T05:14:06.609139Z","shell.execute_reply":"2026-09-12T05:14:07.66843Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!uname --all","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:07.670826Z","iopub.execute_input":"2026-09-12T05:14:07.671119Z","iopub.status.idle":"2026-09-12T05:14:08.694776Z","shell.execute_reply.started":"2026-09-12T05:14:07.671094Z","shell.execute_reply":"2026-09-12T05:14:08.693783Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nprint(os.listdir(\"../input\"))\n\nimport zipfile\n\nwith zipfile.ZipFile(\"/kaggle/input/dogs-vs-cats/test1.zip\",\"r\") as z:\n    z.extractall(\".\")\n    \nwith zipfile.ZipFile(\"/kaggle/input/dogs-vs-cats/train.zip\",\"r\") as z:\n    z.extractall(\".\")","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:08.696362Z","iopub.execute_input":"2026-09-12T05:14:08.696693Z","iopub.status.idle":"2026-09-12T05:14:19.324028Z","shell.execute_reply.started":"2026-09-12T05:14:08.696657Z","shell.execute_reply":"2026-09-12T05:14:19.323257Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:19.326048Z","iopub.execute_input":"2026-09-12T05:14:19.326736Z","iopub.status.idle":"2026-09-12T05:14:20.383557Z","shell.execute_reply.started":"2026-09-12T05:14:19.326708Z","shell.execute_reply":"2026-09-12T05:14:20.382143Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:20.385259Z","iopub.execute_input":"2026-09-12T05:14:20.385651Z","iopub.status.idle":"2026-09-12T05:14:21.40607Z","shell.execute_reply.started":"2026-09-12T05:14:20.385616Z","shell.execute_reply":"2026-09-12T05:14:21.405098Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls test1","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:21.407502Z","iopub.execute_input":"2026-09-12T05:14:21.408162Z","iopub.status.idle":"2026-09-12T05:14:22.498048Z","shell.execute_reply.started":"2026-09-12T05:14:21.408133Z","shell.execute_reply":"2026-09-12T05:14:22.497164Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls test1/ | wc -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:22.49944Z","iopub.execute_input":"2026-09-12T05:14:22.499701Z","iopub.status.idle":"2026-09-12T05:14:23.599087Z","shell.execute_reply.started":"2026-09-12T05:14:22.499678Z","shell.execute_reply":"2026-09-12T05:14:23.59825Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls train/ | wc -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:23.600371Z","iopub.execute_input":"2026-09-12T05:14:23.60068Z","iopub.status.idle":"2026-09-12T05:14:24.696457Z","shell.execute_reply.started":"2026-09-12T05:14:23.600654Z","shell.execute_reply":"2026-09-12T05:14:24.695457Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#ls train/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:24.698017Z","iopub.execute_input":"2026-09-12T05:14:24.698344Z","iopub.status.idle":"2026-09-12T05:14:24.702822Z","shell.execute_reply.started":"2026-09-12T05:14:24.698318Z","shell.execute_reply":"2026-09-12T05:14:24.701897Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pwd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:24.70398Z","iopub.execute_input":"2026-09-12T05:14:24.704332Z","iopub.status.idle":"2026-09-12T05:14:24.716128Z","shell.execute_reply.started":"2026-09-12T05:14:24.704309Z","shell.execute_reply":"2026-09-12T05:14:24.715152Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:24.717434Z","iopub.execute_input":"2026-09-12T05:14:24.717925Z","iopub.status.idle":"2026-09-12T05:14:25.73677Z","shell.execute_reply.started":"2026-09-12T05:14:24.717878Z","shell.execute_reply":"2026-09-12T05:14:25.735683Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -U train | head -n 10","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:25.738292Z","iopub.execute_input":"2026-09-12T05:14:25.73859Z","iopub.status.idle":"2026-09-12T05:14:26.833398Z","shell.execute_reply.started":"2026-09-12T05:14:25.738566Z","shell.execute_reply":"2026-09-12T05:14:26.832253Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -U test1 | head -n 10","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:26.838713Z","iopub.execute_input":"2026-09-12T05:14:26.839104Z","iopub.status.idle":"2026-09-12T05:14:27.900021Z","shell.execute_reply.started":"2026-09-12T05:14:26.839078Z","shell.execute_reply":"2026-09-12T05:14:27.898933Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# plot dog photos from the dogs vs cats dataset\nfrom matplotlib import pyplot\n# from matplotlib import pyplot as plt\nfrom matplotlib.image import imread\n# define location of dataset\nfolder = 'train/'\n# plot first few images\nfor i in range(9):\n\t# define subplot\n\tpyplot.subplot(330 + 1 + i)\n\t# define filename\n\tfilename = folder + 'dog.' + str(i) + '.jpg'\n\t# load image pixels\n\timage = imread(filename)\n\t# plot raw pixel data\n\tpyplot.imshow(image)\n# show the figure\npyplot.show()","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:27.901519Z","iopub.execute_input":"2026-09-12T05:14:27.901877Z","iopub.status.idle":"2026-09-12T05:14:28.952795Z","shell.execute_reply.started":"2026-09-12T05:14:27.901843Z","shell.execute_reply":"2026-09-12T05:14:28.952054Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# plot cat photos from the dogs vs cats dataset\nfrom matplotlib import pyplot\nfrom matplotlib.image import imread\n# define location of dataset\nfolder = 'train/'\n# plot first few images\nfor i in range(9):\n\t# define subplot\n\tpyplot.subplot(330 + 1 + i)\n\t# define filename\n\tfilename = folder + 'cat.' + str(i) + '.jpg'\n\t# load image pixels\n\timage = imread(filename)\n\t# plot raw pixel data\n\tpyplot.imshow(image)\n# show the figure\npyplot.show()","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:28.95411Z","iopub.execute_input":"2026-09-12T05:14:28.954507Z","iopub.status.idle":"2026-09-12T05:14:30.066761Z","shell.execute_reply.started":"2026-09-12T05:14:28.954473Z","shell.execute_reply":"2026-09-12T05:14:30.065889Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python --version","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:30.068598Z","iopub.execute_input":"2026-09-12T05:14:30.069093Z","iopub.status.idle":"2026-09-12T05:14:31.122956Z","shell.execute_reply.started":"2026-09-12T05:14:30.069017Z","shell.execute_reply":"2026-09-12T05:14:31.121675Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import tensorflow\nprint(tensorflow.__version__)\n\nimport keras\nprint(keras.__version__)\n\nimport tensorflow.keras\nprint(tensorflow.__version__)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:31.125336Z","iopub.execute_input":"2026-09-12T05:14:31.125749Z","iopub.status.idle":"2026-09-12T05:14:43.207306Z","shell.execute_reply.started":"2026-09-12T05:14:31.125721Z","shell.execute_reply":"2026-09-12T05:14:43.206063Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# load dogs vs cats dataset, reshape and save to a new file\nfrom os import listdir\nfrom numpy import asarray\nfrom numpy import save\nfrom keras.preprocessing.image import load_img\nfrom keras.preprocessing.image import img_to_array","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:43.209357Z","iopub.execute_input":"2026-09-12T05:14:43.209898Z","iopub.status.idle":"2026-09-12T05:14:43.214721Z","shell.execute_reply.started":"2026-09-12T05:14:43.20987Z","shell.execute_reply":"2026-09-12T05:14:43.213599Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"# define location of dataset\nfolder = 'train/'\nphotos, labels = list(), list()\n# enumerate files in the directory\nfor file in listdir(folder):\n\t# determine class\n\toutput = 0.0\n\tif file.startswith('dog'):\n\t\toutput = 1.0\n\t# load image\n\tphoto = load_img(folder + file, target_size=(200, 200))\n\t# convert to numpy array\n\tphoto = img_to_array(photo)\n\t# store\n\tphotos.append(photo)\n\tlabels.append(output)\n# convert to a numpy arrays\nphotos = asarray(photos)\nlabels = asarray(labels)\nprint(photos.shape, labels.shape)\n# save the reshaped photos\nsave('dogs_vs_cats_photos.npy', photos)\nsave('dogs_vs_cats_labels.npy', labels)","metadata":{"execution":{"iopub.status.busy":"2024-01-27T03:36:15.416611Z","iopub.execute_input":"2024-01-27T03:36:15.417128Z","iopub.status.idle":"2024-01-27T03:36:38.886396Z","shell.execute_reply.started":"2024-01-27T03:36:15.417101Z","shell.execute_reply":"2024-01-27T03:36:38.883149Z"}}},{"cell_type":"markdown","source":"# load and confirm the shape\nfrom numpy import load\nphotos = load('dogs_vs_cats_photos.npy')\nlabels = load('dogs_vs_cats_labels.npy')","metadata":{"execution":{"iopub.status.busy":"2024-01-27T03:36:38.88711Z","iopub.status.idle":"2024-01-27T03:36:38.887458Z","shell.execute_reply.started":"2024-01-27T03:36:38.887281Z","shell.execute_reply":"2024-01-27T03:36:38.887296Z"}}},{"cell_type":"code","source":"# organize dataset into a useful structure\nfrom os import makedirs\nfrom os import listdir\nfrom shutil import copyfile\nfrom random import seed\nfrom random import random","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:43.215873Z","iopub.execute_input":"2026-09-12T05:14:43.21627Z","iopub.status.idle":"2026-09-12T05:14:43.236415Z","shell.execute_reply.started":"2026-09-12T05:14:43.216219Z","shell.execute_reply":"2026-09-12T05:14:43.235612Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# create directories\ndataset_home = 'dataset_dogs_vs_cats/'\nsubdirs = ['train/', 'test/'] #test==>validation\nfor subdir in subdirs:\n    # create label subdirectories\n    labeldirs = ['dogs/', 'cats/']\n    for labldir in labeldirs:\n        newdir = dataset_home + subdir + labldir       \n        makedirs(newdir, exist_ok=True)\n        print(newdir)","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:43.237732Z","iopub.execute_input":"2026-09-12T05:14:43.238041Z","iopub.status.idle":"2026-09-12T05:14:43.25087Z","shell.execute_reply.started":"2026-09-12T05:14:43.238018Z","shell.execute_reply":"2026-09-12T05:14:43.249751Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l dataset_dogs_vs_cats/train/dogs/ | wc -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:43.252002Z","iopub.execute_input":"2026-09-12T05:14:43.252556Z","iopub.status.idle":"2026-09-12T05:14:44.287286Z","shell.execute_reply.started":"2026-09-12T05:14:43.25252Z","shell.execute_reply":"2026-09-12T05:14:44.286149Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:44.288834Z","iopub.execute_input":"2026-09-12T05:14:44.289114Z","iopub.status.idle":"2026-09-12T05:14:45.378785Z","shell.execute_reply.started":"2026-09-12T05:14:44.289088Z","shell.execute_reply":"2026-09-12T05:14:45.377539Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l dataset_dogs_vs_cats/train","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:45.380325Z","iopub.execute_input":"2026-09-12T05:14:45.38064Z","iopub.status.idle":"2026-09-12T05:14:46.449773Z","shell.execute_reply.started":"2026-09-12T05:14:45.380614Z","shell.execute_reply":"2026-09-12T05:14:46.448377Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l dataset_dogs_vs_cats/test #validation","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:46.451472Z","iopub.execute_input":"2026-09-12T05:14:46.45194Z","iopub.status.idle":"2026-09-12T05:14:47.490549Z","shell.execute_reply.started":"2026-09-12T05:14:46.451896Z","shell.execute_reply":"2026-09-12T05:14:47.489052Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# seed random number generator\nseed(1337)\n# define ratio of pictures to use for validation\nval_ratio = 0.25 #changable\n# copy training dataset images into subdirectories\nsrc_directory = 'train/'\n\nfor file in listdir(src_directory):\n\tsrc = src_directory + '/' + file\n\tdst_dir = 'train/'\n\tif random() < val_ratio:\n\t\tdst_dir = 'test/'\n\tif file.startswith('cat'):\n\t\tdst = dataset_home + dst_dir + 'cats/'  + file\n\t\tcopyfile(src, dst)\n\telif file.startswith('dog'):\n\t\tdst = dataset_home + dst_dir + 'dogs/'  + file\n\t\tcopyfile(src, dst)","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:47.493565Z","iopub.execute_input":"2026-09-12T05:14:47.493915Z","iopub.status.idle":"2026-09-12T05:14:49.615758Z","shell.execute_reply.started":"2026-09-12T05:14:47.493884Z","shell.execute_reply":"2026-09-12T05:14:49.614832Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(src)\nprint(dst)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:14:49.616922Z","iopub.execute_input":"2026-09-12T05:14:49.617299Z","iopub.status.idle":"2026-09-12T05:14:49.62259Z","shell.execute_reply.started":"2026-09-12T05:14:49.617275Z","shell.execute_reply":"2026-09-12T05:14:49.621542Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!ls -l dataset_dogs_vs_cats/train/dogs | wc -l\n!ls -l dataset_dogs_vs_cats/train/cats | wc -l","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:49.623833Z","iopub.execute_input":"2026-09-12T05:14:49.624398Z","iopub.status.idle":"2026-09-12T05:14:51.869637Z","shell.execute_reply.started":"2026-09-12T05:14:49.624375Z","shell.execute_reply":"2026-09-12T05:14:51.868583Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#validation set\n!ls -l dataset_dogs_vs_cats/test/dogs | wc -l\n!ls -l dataset_dogs_vs_cats/test/cats | wc -l","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:51.87152Z","iopub.execute_input":"2026-09-12T05:14:51.872444Z","iopub.status.idle":"2026-09-12T05:14:54.013811Z","shell.execute_reply.started":"2026-09-12T05:14:51.872403Z","shell.execute_reply":"2026-09-12T05:14:54.012519Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip -q install livelossplot==0.5.5","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:14:54.015402Z","iopub.execute_input":"2026-09-12T05:14:54.015715Z","iopub.status.idle":"2026-09-12T05:15:04.419292Z","shell.execute_reply.started":"2026-09-12T05:14:54.01569Z","shell.execute_reply":"2026-09-12T05:15:04.417723Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from livelossplot import PlotLossesKeras","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:15:04.421062Z","iopub.execute_input":"2026-09-12T05:15:04.421491Z","iopub.status.idle":"2026-09-12T05:15:04.437801Z","shell.execute_reply.started":"2026-09-12T05:15:04.421463Z","shell.execute_reply":"2026-09-12T05:15:04.437037Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Prepare Final Dataset","metadata":{}},{"cell_type":"markdown","source":"# Start tutorial\n# Develop a Baseline CNN Model","metadata":{}},{"cell_type":"code","source":"# https://keras.io/api/applications/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:04.438847Z","iopub.execute_input":"2026-09-12T05:15:04.439116Z","iopub.status.idle":"2026-09-12T05:15:06.087169Z","shell.execute_reply.started":"2026-09-12T05:15:04.439094Z","shell.execute_reply":"2026-09-12T05:15:06.086215Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# baseline model for the dogs vs cats dataset\nimport sys\nfrom matplotlib import pyplot\nfrom keras.utils import to_categorical\nfrom keras.models import Sequential\nfrom keras.layers import Conv2D\nfrom keras.layers import MaxPooling2D\nfrom keras.layers import Dense\nfrom keras.layers import Flatten\nfrom keras.optimizers import SGD\nfrom keras.preprocessing.image import ImageDataGenerator","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:06.08855Z","iopub.execute_input":"2026-09-12T05:15:06.088826Z","iopub.status.idle":"2026-09-12T05:15:06.096117Z","shell.execute_reply.started":"2026-09-12T05:15:06.088767Z","shell.execute_reply":"2026-09-12T05:15:06.095177Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential()\ntype(model)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:06.097571Z","iopub.execute_input":"2026-09-12T05:15:06.097873Z","iopub.status.idle":"2026-09-12T05:15:07.551813Z","shell.execute_reply.started":"2026-09-12T05:15:06.097845Z","shell.execute_reply":"2026-09-12T05:15:07.550986Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential()\n\nmodel.add(Conv2D(32,\n                 (3, 3),\n                 activation='relu',\n                 input_shape=(200, 200, 3)\n                )\n         )\n\nmodel.add(MaxPooling2D((2, 2)))\n\nmodel.add(Flatten())\n\nmodel.add(Dense(128, activation='relu'))\n\nmodel.add(Dense(1, activation='sigmoid'))\n\nprint(model.summary())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:07.552957Z","iopub.execute_input":"2026-09-12T05:15:07.553327Z","iopub.status.idle":"2026-09-12T05:15:07.894637Z","shell.execute_reply.started":"2026-09-12T05:15:07.553302Z","shell.execute_reply":"2026-09-12T05:15:07.893891Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model = Sequential()\n\nmodel.add(Conv2D(32,\n                 (3, 3),\n                 activation='relu',\n                 input_shape=(200, 200, 3)\n                )\n         )\n\nmodel.add(MaxPooling2D((2, 2)))\n\nmodel.add(Flatten())\n\nmodel.add(Dense(128, activation='relu'))\n\nmodel.add(Dense(2, activation='softmax'))\n\nprint(model.summary())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:07.895668Z","iopub.execute_input":"2026-09-12T05:15:07.895985Z","iopub.status.idle":"2026-09-12T05:15:07.960631Z","shell.execute_reply.started":"2026-09-12T05:15:07.895929Z","shell.execute_reply":"2026-09-12T05:15:07.959529Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# define cnn model\ndef define_model_1():\n\tmodel = Sequential()\n\tmodel.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same', input_shape=(200, 200, 3)))\n\tmodel.add(MaxPooling2D((2, 2)))\n\tmodel.add(Flatten())\n\tmodel.add(Dense(128, activation='relu', kernel_initializer='he_uniform'))\n\tmodel.add(Dense(1, activation='sigmoid'))\n\t# compile model\n\topt = SGD(lr=0.001, momentum=0.9)\n\tmodel.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])\n\treturn model","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:07.961829Z","iopub.execute_input":"2026-09-12T05:15:07.962484Z","iopub.status.idle":"2026-09-12T05:15:07.968066Z","shell.execute_reply.started":"2026-09-12T05:15:07.96246Z","shell.execute_reply":"2026-09-12T05:15:07.967058Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_1 = define_model_1()\nprint(model_1.summary())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:07.969478Z","iopub.execute_input":"2026-09-12T05:15:07.96984Z","iopub.status.idle":"2026-09-12T05:15:08.050625Z","shell.execute_reply.started":"2026-09-12T05:15:07.969818Z","shell.execute_reply":"2026-09-12T05:15:08.049579Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# plot diagnostic learning curves\ndef summarize_diagnostics(history):\n    # plot loss\n    pyplot.subplot(211)\n    pyplot.title('Cross Entropy Loss')\n    pyplot.plot(history.history['loss'], color='blue', label='train')\n    pyplot.plot(history.history['val_loss'], color='orange', label='test')\n    # plot accuracy\n    pyplot.subplot(212)\n    pyplot.title('Classification Accuracy')\n    pyplot.plot(history.history['accuracy'], color='blue', label='train')\n    pyplot.plot(history.history['val_accuracy'], color='orange', label='test')\n    pyplot.show()\n    \n    # save plot to file\n    filename = sys.argv[0].split('/')[-1]\n    pyplot.savefig(filename + '_plot.png') \n    pyplot.close()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:08.051827Z","iopub.execute_input":"2026-09-12T05:15:08.052107Z","iopub.status.idle":"2026-09-12T05:15:08.058463Z","shell.execute_reply.started":"2026-09-12T05:15:08.052086Z","shell.execute_reply":"2026-09-12T05:15:08.057534Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# run the test harness for evaluating a model, not recommend to call this function\ndef run_test_harness():\n\t# define model\n\tmodel = define_model()\n\t# create data generator\n\tdatagen = ImageDataGenerator(rescale=1.0/255.0)\n\t# prepare iterators\n\ttrain_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n\t\tclass_mode='binary', batch_size=64, target_size=(200, 200))\n\ttest_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n\t\tclass_mode='binary', batch_size=64, target_size=(200, 200))\n\t# fit model\n\thistory = model.fit_generator(train_it, steps_per_epoch=len(train_it),\n\t\tvalidation_data=test_it, validation_steps=len(test_it), epochs=20, verbose=0)\n\t# evaluate model\n\t_, acc = model.evaluate_generator(test_it, steps=len(test_it), verbose=0)\n\tprint('> %.3f' % (acc * 100.0))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:08.059649Z","iopub.execute_input":"2026-09-12T05:15:08.0605Z","iopub.status.idle":"2026-09-12T05:15:08.071452Z","shell.execute_reply.started":"2026-09-12T05:15:08.060474Z","shell.execute_reply":"2026-09-12T05:15:08.070547Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_1 = define_model_1()\nprint(model_1.summary())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:08.083298Z","iopub.execute_input":"2026-09-12T05:15:08.083685Z","iopub.status.idle":"2026-09-12T05:15:08.1506Z","shell.execute_reply.started":"2026-09-12T05:15:08.083664Z","shell.execute_reply":"2026-09-12T05:15:08.149643Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"datagen = ImageDataGenerator(rescale=1.0/255.0)\ntype(datagen)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:08.151905Z","iopub.execute_input":"2026-09-12T05:15:08.152242Z","iopub.status.idle":"2026-09-12T05:15:08.158925Z","shell.execute_reply.started":"2026-09-12T05:15:08.152199Z","shell.execute_reply":"2026-09-12T05:15:08.158256Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls dataset_dogs_vs_cats/train/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:08.159866Z","iopub.execute_input":"2026-09-12T05:15:08.160747Z","iopub.status.idle":"2026-09-12T05:15:09.219078Z","shell.execute_reply.started":"2026-09-12T05:15:08.160711Z","shell.execute_reply":"2026-09-12T05:15:09.217773Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Hyperparameter => changable\nIMAGE_SIZE = (200, 200)\nBATCH_SIE = 64\nEPOCHS = 20","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:09.220807Z","iopub.execute_input":"2026-09-12T05:15:09.221644Z","iopub.status.idle":"2026-09-12T05:15:09.226011Z","shell.execute_reply.started":"2026-09-12T05:15:09.221615Z","shell.execute_reply":"2026-09-12T05:15:09.225076Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n\t\tclass_mode='binary',\n        batch_size=BATCH_SIE, \n        target_size=IMAGE_SIZE\n)\ntype(train_it)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:09.227397Z","iopub.execute_input":"2026-09-12T05:15:09.227794Z","iopub.status.idle":"2026-09-12T05:15:09.896052Z","shell.execute_reply.started":"2026-09-12T05:15:09.227762Z","shell.execute_reply":"2026-09-12T05:15:09.895204Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"len(train_it), len(train_it.classes), train_it.classes[:10]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:09.897133Z","iopub.execute_input":"2026-09-12T05:15:09.897802Z","iopub.status.idle":"2026-09-12T05:15:09.904683Z","shell.execute_reply.started":"2026-09-12T05:15:09.897776Z","shell.execute_reply":"2026-09-12T05:15:09.903696Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"BATCH_SIZE = 32\nIMAGE_SIZE = (200, 200)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:17:38.686995Z","iopub.execute_input":"2026-09-12T05:17:38.68741Z","iopub.status.idle":"2026-09-12T05:17:38.692788Z","shell.execute_reply.started":"2026-09-12T05:17:38.687378Z","shell.execute_reply":"2026-09-12T05:17:38.691302Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"val_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n\t\tclass_mode='binary',\n        batch_size=BATCH_SIZE,\n        target_size=IMAGE_SIZE\n)\ntype(val_it)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:17:42.664759Z","iopub.execute_input":"2026-09-12T05:17:42.665621Z","iopub.status.idle":"2026-09-12T05:17:42.834372Z","shell.execute_reply.started":"2026-09-12T05:17:42.665587Z","shell.execute_reply":"2026-09-12T05:17:42.833571Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"len(val_it), len(val_it.classes), val_it.classes[-10:]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:17:46.720641Z","iopub.execute_input":"2026-09-12T05:17:46.720977Z","iopub.status.idle":"2026-09-12T05:17:46.727489Z","shell.execute_reply.started":"2026-09-12T05:17:46.720954Z","shell.execute_reply":"2026-09-12T05:17:46.726513Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# fit model\nmodel_1.reset_states()\nhistory_1 = model_1.fit(\n    train_it,\n    steps_per_epoch=len(train_it),\n    validation_data=val_it,\n    validation_steps=len(val_it),\n    epochs=EPOCHS,\n    verbose=2,\n    callbacks = [PlotLossesKeras()]\n    )","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:17:49.472559Z","iopub.execute_input":"2026-09-12T05:17:49.472894Z","iopub.status.idle":"2026-09-12T05:33:30.999478Z","shell.execute_reply.started":"2026-09-12T05:17:49.47287Z","shell.execute_reply":"2026-09-12T05:33:30.998396Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# learning curves\nsummarize_diagnostics(history_1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:34:03.92964Z","iopub.execute_input":"2026-09-12T05:34:03.930425Z","iopub.status.idle":"2026-09-12T05:34:04.260958Z","shell.execute_reply.started":"2026-09-12T05:34:03.930388Z","shell.execute_reply":"2026-09-12T05:34:04.260258Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# evaluate model\n_, acc = model_1.evaluate(val_it, steps=len(val_it), verbose=1)\nprint('> %.3f' % (acc * 100.0))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:34:16.897454Z","iopub.execute_input":"2026-09-12T05:34:16.898164Z","iopub.status.idle":"2026-09-12T05:34:28.174381Z","shell.execute_reply.started":"2026-09-12T05:34:16.89813Z","shell.execute_reply":"2026-09-12T05:34:28.173511Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:34:43.242469Z","iopub.execute_input":"2026-09-12T05:34:43.24346Z","iopub.status.idle":"2026-09-12T05:34:44.317528Z","shell.execute_reply.started":"2026-09-12T05:34:43.243424Z","shell.execute_reply":"2026-09-12T05:34:44.316036Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pwd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:34:46.130446Z","iopub.execute_input":"2026-09-12T05:34:46.131497Z","iopub.status.idle":"2026-09-12T05:34:46.139293Z","shell.execute_reply.started":"2026-09-12T05:34:46.131449Z","shell.execute_reply":"2026-09-12T05:34:46.13823Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import os\nimport pandas as pd\nfrom glob import glob\n\n# Define the image folder path\nimage_folder = '/kaggle/working/test1'\n\n# List all .jpg files in the directory (adjust the pattern if needed)\nimage_files = glob(os.path.join(image_folder, '*.jpg'))\n\n# Check if images were found\nif not image_files:\n    print(\"No images found. Please verify the directory and file extensions.\")\n    \n# Create a DataFrame with the file paths\ndf = pd.DataFrame({'filename': image_files})\n\n# If your use-case doesn't require labels (for example, during testing), you can leave out the label column.\n# Otherwise, if you need a dummy label, you can add one:\n# df['class'] = 'dummy_label'\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:34:55.051096Z","iopub.execute_input":"2026-09-12T05:34:55.051464Z","iopub.status.idle":"2026-09-12T05:34:55.08818Z","shell.execute_reply.started":"2026-09-12T05:34:55.051439Z","shell.execute_reply":"2026-09-12T05:34:55.087414Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.columns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:34:58.145735Z","iopub.execute_input":"2026-09-12T05:34:58.146415Z","iopub.status.idle":"2026-09-12T05:34:58.15411Z","shell.execute_reply.started":"2026-09-12T05:34:58.146382Z","shell.execute_reply":"2026-09-12T05:34:58.153266Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"image_files[:5], type(image_files), len(image_files)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:01.010047Z","iopub.execute_input":"2026-09-12T05:35:01.011232Z","iopub.status.idle":"2026-09-12T05:35:01.017447Z","shell.execute_reply.started":"2026-09-12T05:35:01.011177Z","shell.execute_reply":"2026-09-12T05:35:01.016367Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.describe()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:04.898456Z","iopub.execute_input":"2026-09-12T05:35:04.899325Z","iopub.status.idle":"2026-09-12T05:35:04.94078Z","shell.execute_reply.started":"2026-09-12T05:35:04.89929Z","shell.execute_reply":"2026-09-12T05:35:04.939998Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.loc[1]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:10.20951Z","iopub.execute_input":"2026-09-12T05:35:10.210599Z","iopub.status.idle":"2026-09-12T05:35:10.217097Z","shell.execute_reply.started":"2026-09-12T05:35:10.210544Z","shell.execute_reply":"2026-09-12T05:35:10.216282Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.sample(5)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:14.947067Z","iopub.execute_input":"2026-09-12T05:35:14.947426Z","iopub.status.idle":"2026-09-12T05:35:14.961864Z","shell.execute_reply.started":"2026-09-12T05:35:14.947402Z","shell.execute_reply":"2026-09-12T05:35:14.960735Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df['filename']","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:19.091074Z","iopub.execute_input":"2026-09-12T05:35:19.091886Z","iopub.status.idle":"2026-09-12T05:35:19.099423Z","shell.execute_reply.started":"2026-09-12T05:35:19.091851Z","shell.execute_reply":"2026-09-12T05:35:19.098113Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"IMAGE_SIZE = (200, 200)\n\n# datagen = ImageDataGenerator(rescale=1.0/255.0,\n#                             horizontal_flip=True,)\n# print(IMAGE_SIZE)\n# # prepare iterators\n# train_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n#     class_mode='binary', batch_size=64, target_size=IMAGE_SIZE )\n\n# val_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n#     class_mode='binary', batch_size=64, target_size=IMAGE_SIZE )\n\n# Prediction\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\n\n# Initialize your ImageDataGenerator (modify parameters as needed)\ndatagen_test = ImageDataGenerator(rescale=1./255,\n                                 vertical_flip=True)\n\n# Create the data generator using the DataFrame\ntest_it = datagen_test.flow_from_dataframe(\n    dataframe=df,\n    x_col='filename',\n    y_col=None,            # No labels for testing, so set to None\n    target_size=IMAGE_SIZE,\n    batch_size=64,\n    class_mode=None,       # Since there are no labels\n    # shuffle=True,         # Usually testing data should not be shuffled\n    shuffle=False,\n)\n\ntype(test_it)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:21.546178Z","iopub.execute_input":"2026-09-12T05:35:21.547124Z","iopub.status.idle":"2026-09-12T05:35:21.639089Z","shell.execute_reply.started":"2026-09-12T05:35:21.547092Z","shell.execute_reply":"2026-09-12T05:35:21.638384Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\n\ndef plot_exmaple(images, labels):\n    # Assuming images shape is (64, height, width, channels)\n    fig, axes = plt.subplots(8, 8, figsize=(16, 16))\n    axes = axes.flatten()  # Flatten the 8x8 grid into a 1D array for easy iteration\n\n    for i, ax in enumerate(axes):\n        if i < len(images):\n            ax.imshow(images[i])\n            ax.set_title(str(labels[i]))  # Fixed: set_title instead of title\n            ax.axis(\"off\")  # Turn off axis ticks/labels for clarity\n        else:\n            ax.axis(\"off\")  # Hide unused subplots if images < 64\n\n    plt.tight_layout()\n    plt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:24.658953Z","iopub.execute_input":"2026-09-12T05:35:24.659767Z","iopub.status.idle":"2026-09-12T05:35:24.665867Z","shell.execute_reply.started":"2026-09-12T05:35:24.659734Z","shell.execute_reply":"2026-09-12T05:35:24.664796Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_images, train_labels = train_it.__next__()\nprint(train_images.shape, len(train_labels))\nplot_exmaple(train_images, train_labels)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:28.290132Z","iopub.execute_input":"2026-09-12T05:35:28.291107Z","iopub.status.idle":"2026-09-12T05:35:33.645284Z","shell.execute_reply.started":"2026-09-12T05:35:28.291061Z","shell.execute_reply":"2026-09-12T05:35:33.643766Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"val_images, val_labels = val_it.__next__()\nval_images.shape\nplot_exmaple(val_images, val_labels)\nval_labels[:8]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:45.715864Z","iopub.execute_input":"2026-09-12T05:35:45.716775Z","iopub.status.idle":"2026-09-12T05:35:49.178873Z","shell.execute_reply.started":"2026-09-12T05:35:45.716738Z","shell.execute_reply":"2026-09-12T05:35:49.177889Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def plot_exmaple_test(images, indices):\n    # Assuming images shape is (64, height, width, channels)\n    fig, axes = plt.subplots(8, 8, figsize=(16, 16))\n    axes = axes.flatten()  # Flatten the 8x8 grid into a 1D array for easy iteration\n\n    for i, ax in enumerate(axes):\n        if i < len(images):\n            ax.imshow(images[i])\n            ax.set_title(str(indices[i]))  # ตั้งค่า title ด้วย index จาก list/array indices\n            ax.axis(\"off\")  # Turn off axis ticks/labels for clarity\n        else:\n            ax.axis(\"off\")  # Hide unused subplots if images < 64\n\n    plt.tight_layout()\n    plt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:35:59.554992Z","iopub.execute_input":"2026-09-12T05:35:59.555399Z","iopub.status.idle":"2026-09-12T05:35:59.561689Z","shell.execute_reply.started":"2026-09-12T05:35:59.555366Z","shell.execute_reply":"2026-09-12T05:35:59.560757Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_images = test_it.__next__()  # หรือ next(test_it)\n\n# สร้าง list เลขดัชนีตามจำนวนภาพที่มี\nindices = list(range(len(test_images)))\n\nplot_exmaple_test(test_images, indices)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:36:02.09048Z","iopub.execute_input":"2026-09-12T05:36:02.091259Z","iopub.status.idle":"2026-09-12T05:36:07.389583Z","shell.execute_reply.started":"2026-09-12T05:36:02.091217Z","shell.execute_reply":"2026-09-12T05:36:07.388179Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Predict\npreds = model_1.predict(test_it, verbose=1)\ntype(preds), preds.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:36:07.393635Z","iopub.execute_input":"2026-09-12T05:36:07.394361Z","iopub.status.idle":"2026-09-12T05:36:32.195835Z","shell.execute_reply.started":"2026-09-12T05:36:07.394331Z","shell.execute_reply":"2026-09-12T05:36:32.194585Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"preds[:10]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:36:35.523063Z","iopub.execute_input":"2026-09-12T05:36:35.523902Z","iopub.status.idle":"2026-09-12T05:36:35.531377Z","shell.execute_reply.started":"2026-09-12T05:36:35.523865Z","shell.execute_reply":"2026-09-12T05:36:35.53035Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\n\n\n# 1. สุ่ม index มา 10 ตัวจากชุดข้อมูล\nsample_indices = np.random.choice(len(test_images), size=10, replace=False)\nsample_images = test_images[sample_indices]\n\n# 2. Predict \npredictions = model_1.predict(sample_images)\npredicted_classes = np.argmax(predictions, axis=1)  # ดึง class ที่ได้คะแนนสูงสุด\n\n# 3. แสดงผล 10 ภาพ (ปรับเป็น grid 2x5)\nfig, axes = plt.subplots(2, 5, figsize=(15, 6))\naxes = axes.flatten()\n\nfor i, ax in enumerate(axes):\n    ax.imshow(sample_images[i])\n    # แสดง Index เดิม และ Class ที่ทายได้\n    ax.set_title(f\"Idx: {sample_indices[i]}\\nPred: {predicted_classes[i]}\")\n    ax.axis(\"off\")\n\nplt.tight_layout()\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:36:40.699379Z","iopub.execute_input":"2026-09-12T05:36:40.700431Z","iopub.status.idle":"2026-09-12T05:36:42.057165Z","shell.execute_reply.started":"2026-09-12T05:36:40.700398Z","shell.execute_reply":"2026-09-12T05:36:42.056096Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# end of 2026-09-06\nstop here","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:36:51.755043Z","iopub.execute_input":"2026-09-12T05:36:51.755908Z","iopub.status.idle":"2026-09-12T05:36:51.761267Z","shell.execute_reply.started":"2026-09-12T05:36:51.755875Z","shell.execute_reply":"2026-09-12T05:36:51.760255Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Transfer Learning","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.461841Z","iopub.status.idle":"2026-09-12T05:15:10.462162Z","shell.execute_reply.started":"2026-09-12T05:15:10.462022Z","shell.execute_reply":"2026-09-12T05:15:10.462037Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# define cnn model\ndef define_model():\n\t# load model\n\tmodel = VGG16(include_top=False, input_shape=(224, 224, 3))\n\t# mark loaded layers as not trainable\n\tfor layer in model.layers:\n\t\tlayer.trainable = False\n\t# add new classifier layers\n\tflat1 = Flatten()(model.layers[-1].output)\n\tclass1 = Dense(128, activation='relu', kernel_initializer='he_uniform')(flat1)\n\toutput = Dense(1, activation='sigmoid')(class1)\n\t# define new model\n\tmodel = Model(inputs=model.inputs, outputs=output)\n\t# compile model\n\topt = SGD(lr=0.001, momentum=0.9)\n\tmodel.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])\n\treturn model","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:56:39.999839Z","iopub.execute_input":"2026-09-12T05:56:40.000283Z","iopub.status.idle":"2026-09-12T05:56:40.006994Z","shell.execute_reply.started":"2026-09-12T05:56:40.000248Z","shell.execute_reply":"2026-09-12T05:56:40.005893Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# load model\n# model = VGG16(include_top=False, input_shape=(224, 224, 3))\n# mark loaded layers as not trainable\n# for layer in model.layers:\n#     layer.trainable = False\n\n# print(model.layers[-1].output)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:37:03.876045Z","iopub.execute_input":"2026-09-12T05:37:03.876971Z","iopub.status.idle":"2026-09-12T05:37:03.881511Z","shell.execute_reply.started":"2026-09-12T05:37:03.876935Z","shell.execute_reply":"2026-09-12T05:37:03.880238Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# load model\n# model_16_feature_extractor = VGG16(include_top=False, input_shape=(224, 224, 3))\n# model_16_feature_extractor.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.467997Z","iopub.status.idle":"2026-09-12T05:15:10.468401Z","shell.execute_reply.started":"2026-09-12T05:15:10.468155Z","shell.execute_reply":"2026-09-12T05:15:10.46817Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# for index, layer in enumerate(model_16_feature_extractor.layers):\n# \t\tprint(index, layer.trainable)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.469806Z","iopub.status.idle":"2026-09-12T05:15:10.470101Z","shell.execute_reply.started":"2026-09-12T05:15:10.469956Z","shell.execute_reply":"2026-09-12T05:15:10.469971Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# load model\n# model_16_top = VGG16(include_top=True, input_shape=(224, 224, 3))\n# model_16_top.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.47137Z","iopub.status.idle":"2026-09-12T05:15:10.471772Z","shell.execute_reply.started":"2026-09-12T05:15:10.471566Z","shell.execute_reply":"2026-09-12T05:15:10.471587Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# vgg16 model used for transfer learning on the dogs and cats dataset\nimport sys\nfrom matplotlib import pyplot\nfrom keras.utils import to_categorical\nfrom keras.applications.vgg16 import VGG16\nfrom keras.models import Model\nfrom keras.layers import Dense\nfrom keras.layers import Flatten\nfrom keras.optimizers import SGD\nfrom keras.preprocessing.image import ImageDataGenerator\n\n# define cnn model\ndef define_model():\n\t# load model\n\tmodel = VGG16(include_top=False, input_shape=(224, 224, 3))\n\t# mark loaded layers as not trainable\n\tfor layer in model.layers:\n\t\tlayer.trainable = False\n\t# add new classifier layers\n\tflat1 = Flatten()(model.layers[-1].output)\n\tclass1 = Dense(128, activation='relu', kernel_initializer='he_uniform')(flat1)\n\toutput = Dense(1, activation='sigmoid')(class1)\n\t# define new model\n\tmodel = Model(inputs=model.inputs, outputs=output)\n\t# compile model\n\topt = SGD(lr=0.001, momentum=0.9)\n\tmodel.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])\n\treturn model\n\n# plot diagnostic learning curves\ndef summarize_diagnostics(history):\n\t# plot loss\n\tpyplot.subplot(211)\n\tpyplot.title('Cross Entropy Loss')\n\tpyplot.plot(history.history['loss'], color='blue', label='train')\n\tpyplot.plot(history.history['val_loss'], color='orange', label='test')\n\t# plot accuracy\n\tpyplot.subplot(212)\n\tpyplot.title('Classification Accuracy')\n\tpyplot.plot(history.history['accuracy'], color='blue', label='train')\n\tpyplot.plot(history.history['val_accuracy'], color='orange', label='test')\n\t# save plot to file\n\tfilename = sys.argv[0].split('/')[-1]\n\tpyplot.savefig(filename + '_plot.png')\n\tpyplot.close()\n\n# run the test harness for evaluating a model\ndef run_test_harness():\n\t# define model\n\tmodel = define_model()\n\t# create data generator\n\tdatagen = ImageDataGenerator(featurewise_center=True)\n\t# specify imagenet mean values for centering\n\tdatagen.mean = [123.68, 116.779, 103.939]\n\t# prepare iterator\n\ttrain_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n\t\tclass_mode='binary', batch_size=64, target_size=(224, 224))\n\ttest_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n\t\tclass_mode='binary', batch_size=64, target_size=(224, 224))\n\t# fit model\n\thistory = model.fit_generator(train_it, steps_per_epoch=len(train_it),\n\t\tvalidation_data=test_it, validation_steps=len(test_it), epochs=10, verbose=1)\n\t# evaluate model\n\t_, acc = model.evaluate_generator(test_it, steps=len(test_it), verbose=0)\n\tprint('> %.3f' % (acc * 100.0))\n\t# learning curves\n\tsummarize_diagnostics(history)\n\n# entry point, run the test harness\nrun_test_harness()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:57:07.343435Z","iopub.execute_input":"2026-09-12T05:57:07.344095Z","iopub.status.idle":"2026-09-12T06:16:34.940008Z","shell.execute_reply.started":"2026-09-12T05:57:07.344062Z","shell.execute_reply":"2026-09-12T06:16:34.939129Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# for index, layer in enumerate(vgg16_model.layers):\n#     print(index, layer.name, layer.trainable)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.475359Z","iopub.status.idle":"2026-09-12T05:15:10.475774Z","shell.execute_reply.started":"2026-09-12T05:15:10.475561Z","shell.execute_reply":"2026-09-12T05:15:10.475582Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# for index, layer in enumerate(vgg16_model.layers[-7:]):\n#     print(index, layer.name, layer.trainable)\n    ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.478044Z","iopub.status.idle":"2026-09-12T05:15:10.478525Z","shell.execute_reply.started":"2026-09-12T05:15:10.478286Z","shell.execute_reply":"2026-09-12T05:15:10.478311Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# for index, layer in enumerate(vgg16_model.layers[-7:]):\n#     layer.trainable = True\n#     print(index, layer.name, layer.trainable)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.479486Z","iopub.status.idle":"2026-09-12T05:15:10.479888Z","shell.execute_reply.started":"2026-09-12T05:15:10.479677Z","shell.execute_reply":"2026-09-12T05:15:10.479698Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# for index, layer in enumerate(vgg16_model.layers):\n#     if index >= 15:\n#         layer.trainable = True\n\n# for index, layer in enumerate(vgg16_model.layers):\n#     print(index, layer.name, layer.trainable)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.481206Z","iopub.status.idle":"2026-09-12T05:15:10.48167Z","shell.execute_reply.started":"2026-09-12T05:15:10.481449Z","shell.execute_reply":"2026-09-12T05:15:10.481471Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"id(vgg16_model)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:55:31.001017Z","iopub.execute_input":"2026-09-12T05:55:31.001822Z","iopub.status.idle":"2026-09-12T05:55:31.00738Z","shell.execute_reply.started":"2026-09-12T05:55:31.001789Z","shell.execute_reply":"2026-09-12T05:55:31.006469Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"vgg16_model.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:55:32.622057Z","iopub.execute_input":"2026-09-12T05:55:32.622981Z","iopub.status.idle":"2026-09-12T05:55:32.675456Z","shell.execute_reply.started":"2026-09-12T05:55:32.62294Z","shell.execute_reply":"2026-09-12T05:55:32.674502Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"IMAGE_SIZE = (224, 224)\n\ntrain_it = datagen.flow_from_directory(\n    'dataset_dogs_vs_cats/train/',\n    class_mode='binary',\n    batch_size=BATCH_SIZE,\n    target_size=IMAGE_SIZE\n)\n\nval_it = datagen.flow_from_directory(\n    'dataset_dogs_vs_cats/test/',\n    class_mode='binary',\n    batch_size=BATCH_SIZE,\n    target_size=IMAGE_SIZE\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:55:35.519317Z","iopub.execute_input":"2026-09-12T05:55:35.52031Z","iopub.status.idle":"2026-09-12T05:55:36.229527Z","shell.execute_reply.started":"2026-09-12T05:55:35.520263Z","shell.execute_reply":"2026-09-12T05:55:36.228741Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# fit model\nprint(id(vgg16_model))\nvgg16_model.reset_states()\nvgg16_model_history = vgg16_model.fit(\n    train_it, \n    steps_per_epoch=len(train_it),\n    validation_data=val_it,\n    validation_steps=len(val_it),\n    epochs=3, verbose=1,\n    callbacks = [PlotLossesKeras()]\n    )","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:43:43.432999Z","iopub.execute_input":"2026-09-12T05:43:43.43333Z","iopub.status.idle":"2026-09-12T05:45:03.144003Z","shell.execute_reply.started":"2026-09-12T05:43:43.433304Z","shell.execute_reply":"2026-09-12T05:45:03.141626Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# learning curves\nsummarize_diagnostics(vgg16_model_history)\n\n# evaluate model\n_, acc = vgg16_model.evaluate_generator(val_it, steps=len(val_it), verbose=1)\nprint('Val: > %.3f' % (acc * 100.0))\n\n# evaluate model\n_, acc = vgg16_model.evaluate_generator(test_it, steps=len(test_it), verbose=1)\nprint('Test: > %.3f' % (acc * 100.0))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:46:02.410572Z","iopub.execute_input":"2026-09-12T05:46:02.410904Z","iopub.status.idle":"2026-09-12T05:46:02.442464Z","shell.execute_reply.started":"2026-09-12T05:46:02.410879Z","shell.execute_reply":"2026-09-12T05:46:02.441363Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from keras.applications.inception_v3 import InceptionV3\n\ndef define_model_inceptionv3():\n    # load model\n    model = InceptionV3(include_top=False, input_shape=(299, 299, 3))\n    # mark loaded layers as not trainable\n    for layer in model.layers:\n        layer.trainable = False\n        # layer.trainable = True #try to test\n    \n    # add new classifier layers\n    flat1 = Flatten()(model.layers[-1].output)\n    class1 = Dense(1024, activation='relu', kernel_initializer='he_uniform')(flat1)\n    class2 = Dense(512, activation='relu', kernel_initializer='he_uniform')(class1)\n    class3 = Dense(256, activation='relu', kernel_initializer='he_uniform')(class2)\n    class4 = Dense(128, activation='relu', kernel_initializer='he_uniform')(class3)\n    # output = Dense(1, activation='sigmoid')(flat1)\n    output = Dense(2, activation='softmax')(class4)\n    # define new model\n    model = Model(inputs=model.inputs, outputs=output)\n    # compile model\n    opt = SGD(lr=0.001, momentum=0.9)\n    model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])\n    return model","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:48:08.506258Z","iopub.execute_input":"2026-09-12T05:48:08.50661Z","iopub.status.idle":"2026-09-12T05:48:08.513706Z","shell.execute_reply.started":"2026-09-12T05:48:08.506585Z","shell.execute_reply":"2026-09-12T05:48:08.512635Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_inceptionv3 = define_model_inceptionv3()\nprint(id(model_inceptionv3))\n# model_inceptionv3.summary()","metadata":{"execution":{"iopub.status.busy":"2026-09-12T05:48:11.885896Z","iopub.execute_input":"2026-09-12T05:48:11.886536Z","iopub.status.idle":"2026-09-12T05:48:15.134711Z","shell.execute_reply.started":"2026-09-12T05:48:11.886502Z","shell.execute_reply":"2026-09-12T05:48:15.133738Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nfrom tensorflow.keras import backend as K\n\ntrainable_params = int(np.sum([K.count_params(w) for w in model_inceptionv3.trainable_weights]))\nprint(trainable_params)\n","metadata":{"trusted":true,"scrolled":true,"execution":{"iopub.status.busy":"2026-09-12T05:48:45.578076Z","iopub.execute_input":"2026-09-12T05:48:45.578957Z","iopub.status.idle":"2026-09-12T05:48:45.585776Z","shell.execute_reply.started":"2026-09-12T05:48:45.578917Z","shell.execute_reply":"2026-09-12T05:48:45.584738Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from tensorflow.keras import backend as K\n\nfor w in model_inceptionv3.trainable_weights:\n    print(w.name, K.count_params(w))\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:48:49.802537Z","iopub.execute_input":"2026-09-12T05:48:49.803455Z","iopub.status.idle":"2026-09-12T05:48:49.809386Z","shell.execute_reply.started":"2026-09-12T05:48:49.803421Z","shell.execute_reply":"2026-09-12T05:48:49.808381Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# fit model\nmodel_inceptionv3.reset_states()\nhistory_inceptionv3 = model_inceptionv3.fit(\n    train_it, \n    steps_per_epoch=len(train_it),\n    validation_data=val_it,\n    validation_steps=len(val_it),\n    epochs=3, verbose=1,\n    callbacks = [PlotLossesKeras()]\n    )","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:48:59.179724Z","iopub.execute_input":"2026-09-12T05:48:59.180693Z","iopub.status.idle":"2026-09-12T05:49:00.213623Z","shell.execute_reply.started":"2026-09-12T05:48:59.180656Z","shell.execute_reply":"2026-09-12T05:49:00.212393Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import matplotlib.pyplot as plt\n\ndef plot_images_with_labels(images, labels, train_log, set_label, save=False):\n    \"\"\"\n    Plots a grid of images with their corresponding labels and saves the figure.\n    \n    Args:\n    - images (list or np.array): List of images to be displayed.\n    - labels (np.array): Array of one-hot encoded labels.\n    - train_log (str): The directory or log name to save the plot.\n    - set_label (str): The specific set label (e.g., \"train\", \"validation\", etc.).\n    - config (dict): Configuration dictionary containing image dimensions.\n    \n    Returns:\n    - None: Displays and saves the plot.\n    \"\"\"\n    # Convert one-hot encoded labels to class indices\n    class_indices = labels\n\n    # Create subplots\n    fig, axes = plt.subplots(3, 4, figsize=(14, 10), dpi=120)\n    axes = axes.flatten()\n\n    for img, label_idx, ax in zip(images, class_indices, axes):\n        # Undo any preprocessing (like rescaling for pre-trained models)\n        if np.max(img) == 1:\n            img = img * 255\n\n        # Display the image\n        img_shape = (224, 224, 3)\n        ax.imshow(img.astype(\"uint8\"))\n        # ax.imshow(img)\n\n        # Set the title to the corresponding class label\n        ax.set_title(f\"Label: {label_idx}\", fontsize=18)\n        ax.axis('on')\n\n    # Set the overall title for the figure\n    plot_title = f\"{train_log}-{set_label}\"\n    plt.suptitle(plot_title, fontsize=18)\n\n    # Show the plot\n    plt.show()\n\n    # Save the figure\n    if save:\n        plot_file = os.path.join(train_log, f\"{plot_title}.png\")\n        fig.savefig(plot_file, dpi=120)\n        print(f'Saved {plot_file}')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:49:06.467211Z","iopub.execute_input":"2026-09-12T05:49:06.467607Z","iopub.status.idle":"2026-09-12T05:49:06.476018Z","shell.execute_reply.started":"2026-09-12T05:49:06.467578Z","shell.execute_reply":"2026-09-12T05:49:06.474872Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# plot_images_with_labels(images, labels, \"Dog-Cat\", \"Training\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.498559Z","iopub.status.idle":"2026-09-12T05:15:10.499009Z","shell.execute_reply.started":"2026-09-12T05:15:10.498762Z","shell.execute_reply":"2026-09-12T05:15:10.4988Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# for index, layer in enumerate(model.layers):\n#     print(index, layer.output.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.500945Z","iopub.status.idle":"2026-09-12T05:15:10.501459Z","shell.execute_reply.started":"2026-09-12T05:15:10.501207Z","shell.execute_reply":"2026-09-12T05:15:10.501233Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# # mark loaded layers as not trainable\n# for index, layer in enumerate(model.layers[:15]):\n#     print(index, layer.name, layer.output_shape)\n#     layer.trainable = False\n    \n# for index, layer in enumerate(model.layers[15:]):\n#     print(index, layer.name, layer.output_shape)\n#     layer.trainable = True","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:15:10.502562Z","iopub.status.idle":"2026-09-12T05:15:10.503019Z","shell.execute_reply.started":"2026-09-12T05:15:10.502787Z","shell.execute_reply":"2026-09-12T05:15:10.50281Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# evaluate model\n_, acc = model_inceptionv3.evaluate(test_it, steps=len(test_it), verbose=1)\nprint('> %.3f' % (acc * 100.0))\n# learning curves\n# summarize_diagnostics(history)\n\n# best_model = 'vgg16_model.hdf5'\n# my_model.save(best_model)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:49:10.850825Z","iopub.execute_input":"2026-09-12T05:49:10.851758Z","iopub.status.idle":"2026-09-12T05:49:11.850455Z","shell.execute_reply.started":"2026-09-12T05:49:10.851721Z","shell.execute_reply":"2026-09-12T05:49:11.849258Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"images = test_it.__next__()\nimages.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:49:16.675162Z","iopub.execute_input":"2026-09-12T05:49:16.676126Z","iopub.status.idle":"2026-09-12T05:49:16.79302Z","shell.execute_reply.started":"2026-09-12T05:49:16.676091Z","shell.execute_reply":"2026-09-12T05:49:16.792231Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 5 first img: 1, 0, 1, 1, 0\nimages_to_predict = images[:5]\nimages_to_predict.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:49:19.242668Z","iopub.execute_input":"2026-09-12T05:49:19.24347Z","iopub.status.idle":"2026-09-12T05:49:19.249117Z","shell.execute_reply.started":"2026-09-12T05:49:19.243436Z","shell.execute_reply":"2026-09-12T05:49:19.248247Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"probs = model_inceptionv3.predict(images_to_predict, verbose=1)\nprobs","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-12T05:49:25.378333Z","iopub.execute_input":"2026-09-12T05:49:25.378693Z","iopub.status.idle":"2026-09-12T05:49:25.497427Z","shell.execute_reply.started":"2026-09-12T05:49:25.378666Z","shell.execute_reply":"2026-09-12T05:49:25.496036Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Make Prediction","metadata":{}},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}