{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":3362,"databundleVersionId":31148,"sourceType":"competition"}],"dockerImageVersionId":30746,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"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":"2024-08-21T02:07:16.77722Z","iopub.execute_input":"2024-08-21T02:07:16.777835Z","iopub.status.idle":"2024-08-21T02:07:18.414728Z","shell.execute_reply.started":"2024-08-21T02:07:16.777793Z","shell.execute_reply":"2024-08-21T02:07:18.413248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# extracting the compressed dataset\nfrom zipfile import ZipFile\n\ndataset = '/kaggle/input/dogs-vs-cats/train.zip'\n\nwith ZipFile(dataset, 'r') as zip:\n  zip.extractall()\n  print('The dataset is extracted')","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:18.417116Z","iopub.execute_input":"2024-08-21T02:07:18.417756Z","iopub.status.idle":"2024-08-21T02:07:30.562733Z","shell.execute_reply.started":"2024-08-21T02:07:18.417712Z","shell.execute_reply":"2024-08-21T02:07:30.561415Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# counting the number of files in train folder\npath, dirs, files = next(os.walk('/kaggle/working/train'))\nfile_count = len(files)\nprint('Number of images: ', file_count)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:30.564216Z","iopub.execute_input":"2024-08-21T02:07:30.564788Z","iopub.status.idle":"2024-08-21T02:07:30.611447Z","shell.execute_reply.started":"2024-08-21T02:07:30.564744Z","shell.execute_reply":"2024-08-21T02:07:30.609893Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Printing the name of images","metadata":{}},{"cell_type":"code","source":"file_names = os.listdir('/kaggle/working/train')\nprint(file_names)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:30.614664Z","iopub.execute_input":"2024-08-21T02:07:30.615062Z","iopub.status.idle":"2024-08-21T02:07:30.656138Z","shell.execute_reply.started":"2024-08-21T02:07:30.615031Z","shell.execute_reply":"2024-08-21T02:07:30.654578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Importing the Libraries","metadata":{}},{"cell_type":"code","source":"import numpy as np\nfrom PIL import Image\nimport matplotlib.pyplot as plt \nimport matplotlib.image as mpimg\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:30.657714Z","iopub.execute_input":"2024-08-21T02:07:30.658047Z","iopub.status.idle":"2024-08-21T02:07:31.439956Z","shell.execute_reply.started":"2024-08-21T02:07:30.658018Z","shell.execute_reply":"2024-08-21T02:07:31.438604Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Importing the Dependencies","metadata":{}},{"cell_type":"code","source":"# display dog image\nimg = mpimg.imread('/kaggle/working/train/dog.8298.jpg')\nimgplt = plt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:31.441582Z","iopub.execute_input":"2024-08-21T02:07:31.44196Z","iopub.status.idle":"2024-08-21T02:07:31.867034Z","shell.execute_reply.started":"2024-08-21T02:07:31.441928Z","shell.execute_reply":"2024-08-21T02:07:31.865608Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# display cat image\nimg = mpimg.imread('/kaggle/working/train/cat.4352.jpg')\nimgplt = plt.imshow(img)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:31.868535Z","iopub.execute_input":"2024-08-21T02:07:31.868972Z","iopub.status.idle":"2024-08-21T02:07:32.248328Z","shell.execute_reply.started":"2024-08-21T02:07:31.868935Z","shell.execute_reply":"2024-08-21T02:07:32.247019Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_names = os.listdir('/kaggle/working/train')\n\nfor i in range(5):\n\n  name = file_names[i] \n  print(name[0:3])\n\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:32.24999Z","iopub.execute_input":"2024-08-21T02:07:32.250401Z","iopub.status.idle":"2024-08-21T02:07:32.276852Z","shell.execute_reply.started":"2024-08-21T02:07:32.250341Z","shell.execute_reply":"2024-08-21T02:07:32.275675Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"file_names = os.listdir('/kaggle/working/train')\n\ndog_count = 0\ncat_count = 0\n\nfor img_file in file_names:\n\n  name = img_file[0:3]\n\n  if name == 'dog':\n    dog_count += 1\n\n  else:\n    cat_count += 1\n\nprint('Number of dog images =', dog_count)\nprint('Number of cat images =', cat_count)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:32.278595Z","iopub.execute_input":"2024-08-21T02:07:32.27908Z","iopub.status.idle":"2024-08-21T02:07:32.317826Z","shell.execute_reply.started":"2024-08-21T02:07:32.27904Z","shell.execute_reply":"2024-08-21T02:07:32.316386Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Resizing all the images","metadata":{}},{"cell_type":"code","source":"#creating a directory for resized images\nos.mkdir('/kaggle/working/image resize')","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:32.323463Z","iopub.execute_input":"2024-08-21T02:07:32.323865Z","iopub.status.idle":"2024-08-21T02:07:32.330345Z","shell.execute_reply.started":"2024-08-21T02:07:32.323833Z","shell.execute_reply":"2024-08-21T02:07:32.32877Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"original_folder = '/kaggle/working/train/'\nresized_folder = '/kaggle/working/image resize/'\n\nfor i in range(2000):\n\n  filename = os.listdir(original_folder)[i]\n  img_path = original_folder+filename\n\n  img = Image.open(img_path)\n  img = img.resize((224, 224))\n  img = img.convert('RGB')\n\n  newImgPath = resized_folder+filename\n  img.save(newImgPath)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:07:32.331965Z","iopub.execute_input":"2024-08-21T02:07:32.332341Z","iopub.status.idle":"2024-08-21T02:08:15.081398Z","shell.execute_reply.started":"2024-08-21T02:07:32.332312Z","shell.execute_reply":"2024-08-21T02:08:15.080083Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\n\nresized_folder = '/kaggle/working/image resize/'\nprint(os.listdir(resized_folder))\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:08:15.083129Z","iopub.execute_input":"2024-08-21T02:08:15.083777Z","iopub.status.idle":"2024-08-21T02:08:15.093134Z","shell.execute_reply.started":"2024-08-21T02:08:15.083741Z","shell.execute_reply":"2024-08-21T02:08:15.091572Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**Creating labels for resized images of dogs and cats**\n\n**Cat : 0**\n\n**Dog : 1**","metadata":{}},{"cell_type":"code","source":"# creaing a for loop to assign labels\nfilenames = os.listdir('/kaggle/working/image resize/')\n\n\nlabels = []\n\nfor i in range(2000):\n\n  file_name = filenames[i]\n  label = file_name[0:3]\n\n  if label == 'dog':\n    labels.append(1)\n\n  else:\n    labels.append(0)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:05.595116Z","iopub.execute_input":"2024-08-21T02:10:05.596216Z","iopub.status.idle":"2024-08-21T02:10:05.607969Z","shell.execute_reply.started":"2024-08-21T02:10:05.596164Z","shell.execute_reply":"2024-08-21T02:10:05.606442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(filenames[0:5])\nprint(len(filenames))","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:08.142336Z","iopub.execute_input":"2024-08-21T02:10:08.142742Z","iopub.status.idle":"2024-08-21T02:10:08.149237Z","shell.execute_reply.started":"2024-08-21T02:10:08.142712Z","shell.execute_reply":"2024-08-21T02:10:08.147696Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(labels[0:5])\nprint(len(labels))","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:15.022515Z","iopub.execute_input":"2024-08-21T02:10:15.022925Z","iopub.status.idle":"2024-08-21T02:10:15.028879Z","shell.execute_reply.started":"2024-08-21T02:10:15.022895Z","shell.execute_reply":"2024-08-21T02:10:15.027673Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# counting the images of dogs and cats out of 2000 images\nvalues, counts = np.unique(labels, return_counts=True)\nprint(values)\nprint(counts)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:18.162044Z","iopub.execute_input":"2024-08-21T02:10:18.162482Z","iopub.status.idle":"2024-08-21T02:10:18.174032Z","shell.execute_reply.started":"2024-08-21T02:10:18.162446Z","shell.execute_reply":"2024-08-21T02:10:18.172566Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Converting all the resized images to numpy arrays","metadata":{}},{"cell_type":"code","source":"import cv2\nimport glob","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:22.654234Z","iopub.execute_input":"2024-08-21T02:10:22.655306Z","iopub.status.idle":"2024-08-21T02:10:22.959949Z","shell.execute_reply.started":"2024-08-21T02:10:22.655267Z","shell.execute_reply":"2024-08-21T02:10:22.958724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"image_directory = '/kaggle/working/image resize/'\nimage_extension = ['png', 'jpg']\n\nfiles = []\n\n[files.extend(glob.glob(image_directory + '*.' + e)) for e in image_extension]\n\ndog_cat_images = np.asarray([cv2.imread(file) for file in files])","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:24.914831Z","iopub.execute_input":"2024-08-21T02:10:24.915259Z","iopub.status.idle":"2024-08-21T02:10:26.200937Z","shell.execute_reply.started":"2024-08-21T02:10:24.915225Z","shell.execute_reply":"2024-08-21T02:10:26.199407Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(dog_cat_images)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:29.534224Z","iopub.execute_input":"2024-08-21T02:10:29.534666Z","iopub.status.idle":"2024-08-21T02:10:29.545703Z","shell.execute_reply.started":"2024-08-21T02:10:29.534626Z","shell.execute_reply":"2024-08-21T02:10:29.544393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"type(dog_cat_images)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:32.927192Z","iopub.execute_input":"2024-08-21T02:10:32.928393Z","iopub.status.idle":"2024-08-21T02:10:32.936163Z","shell.execute_reply.started":"2024-08-21T02:10:32.928325Z","shell.execute_reply":"2024-08-21T02:10:32.934945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(dog_cat_images.shape)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:34.234098Z","iopub.execute_input":"2024-08-21T02:10:34.234542Z","iopub.status.idle":"2024-08-21T02:10:34.242216Z","shell.execute_reply.started":"2024-08-21T02:10:34.234506Z","shell.execute_reply":"2024-08-21T02:10:34.24059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = dog_cat_images\nY = np.asarray(labels)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:40.779516Z","iopub.execute_input":"2024-08-21T02:10:40.77991Z","iopub.status.idle":"2024-08-21T02:10:40.78598Z","shell.execute_reply.started":"2024-08-21T02:10:40.779882Z","shell.execute_reply":"2024-08-21T02:10:40.784679Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Train Test Split","metadata":{}},{"cell_type":"code","source":"X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2, random_state=2)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:45.182413Z","iopub.execute_input":"2024-08-21T02:10:45.182879Z","iopub.status.idle":"2024-08-21T02:10:45.302972Z","shell.execute_reply.started":"2024-08-21T02:10:45.182843Z","shell.execute_reply":"2024-08-21T02:10:45.301739Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(X.shape, X_train.shape, X_test.shape)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:53.670237Z","iopub.execute_input":"2024-08-21T02:10:53.670656Z","iopub.status.idle":"2024-08-21T02:10:53.677094Z","shell.execute_reply.started":"2024-08-21T02:10:53.670616Z","shell.execute_reply":"2024-08-21T02:10:53.675954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"**1600 : training images**\n\n**400 : test images**","metadata":{}},{"cell_type":"code","source":"# scaling the data\nX_train_scaled = X_train/255\n\nX_test_scaled = X_test/255","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:10:56.57001Z","iopub.execute_input":"2024-08-21T02:10:56.570458Z","iopub.status.idle":"2024-08-21T02:10:57.647655Z","shell.execute_reply.started":"2024-08-21T02:10:56.570422Z","shell.execute_reply":"2024-08-21T02:10:57.646601Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(X_train_scaled)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:11:02.182031Z","iopub.execute_input":"2024-08-21T02:11:02.182465Z","iopub.status.idle":"2024-08-21T02:11:02.200228Z","shell.execute_reply.started":"2024-08-21T02:11:02.182429Z","shell.execute_reply":"2024-08-21T02:11:02.19847Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Building the Neural Network","metadata":{}},{"cell_type":"code","source":"import tensorflow as tf\nimport tensorflow_hub as hub\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:11:14.825724Z","iopub.execute_input":"2024-08-21T02:11:14.826132Z","iopub.status.idle":"2024-08-21T02:11:33.218146Z","shell.execute_reply.started":"2024-08-21T02:11:14.826099Z","shell.execute_reply":"2024-08-21T02:11:33.216578Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install tensorflow-hub","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:19:26.903087Z","iopub.execute_input":"2024-08-21T02:19:26.903531Z","iopub.status.idle":"2024-08-21T02:19:47.042649Z","shell.execute_reply.started":"2024-08-21T02:19:26.903498Z","shell.execute_reply":"2024-08-21T02:19:47.040896Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Load the MobileNetV2 model from TensorFlow Hub\nmobilenet_model = 'https://tfhub.dev/google/tf2-preview/mobilenet_v2/feature_vector/4'\npretrained_model = hub.KerasLayer(mobilenet_model, input_shape=(224, 224, 3), trainable=False)\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:19:49.669722Z","iopub.execute_input":"2024-08-21T02:19:49.670226Z","iopub.status.idle":"2024-08-21T02:19:51.680686Z","shell.execute_reply.started":"2024-08-21T02:19:49.670173Z","shell.execute_reply":"2024-08-21T02:19:51.679498Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install --upgrade tensorflow tensorflow-hub\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:24:02.332162Z","iopub.execute_input":"2024-08-21T02:24:02.332603Z","iopub.status.idle":"2024-08-21T02:25:24.125669Z","shell.execute_reply.started":"2024-08-21T02:24:02.332561Z","shell.execute_reply":"2024-08-21T02:25:24.123497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install --upgrade tensorflow\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:26:00.97168Z","iopub.execute_input":"2024-08-21T02:26:00.972153Z","iopub.status.idle":"2024-08-21T02:27:09.320245Z","shell.execute_reply.started":"2024-08-21T02:26:00.972118Z","shell.execute_reply":"2024-08-21T02:27:09.318769Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nprint(tf.__version__)\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:27:19.728633Z","iopub.execute_input":"2024-08-21T02:27:19.729673Z","iopub.status.idle":"2024-08-21T02:27:19.736898Z","shell.execute_reply.started":"2024-08-21T02:27:19.729626Z","shell.execute_reply":"2024-08-21T02:27:19.735226Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.applications import MobileNetV2\nfrom tensorflow.keras.layers import Dense\n\n# Load MobileNetV2 model without the top layers\nbase_model = MobileNetV2(weights='imagenet', include_top=False, input_shape=(224, 224, 3))\nbase_model.trainable = False  # Freeze the base model\n\n# Build the model\ninputs = tf.keras.Input(shape=(224, 224, 3))\nx = base_model(inputs, training=False)\nx = tf.keras.layers.GlobalAveragePooling2D()(x)\nx = Dense(num_of_classes, activation='softmax')(x)\n\nmodel = tf.keras.Model(inputs=inputs, outputs=x)\n\nmodel.summary()\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:27:22.412685Z","iopub.execute_input":"2024-08-21T02:27:22.41311Z","iopub.status.idle":"2024-08-21T02:27:25.205974Z","shell.execute_reply.started":"2024-08-21T02:27:22.413075Z","shell.execute_reply":"2024-08-21T02:27:25.204631Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(\n    optimizer = 'adam',\n    loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n    metrics = ['acc']\n)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:28:07.196017Z","iopub.execute_input":"2024-08-21T02:28:07.196539Z","iopub.status.idle":"2024-08-21T02:28:07.216788Z","shell.execute_reply.started":"2024-08-21T02:28:07.196504Z","shell.execute_reply":"2024-08-21T02:28:07.215447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.fit(X_train_scaled, Y_train, epochs=5)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:28:33.469753Z","iopub.execute_input":"2024-08-21T02:28:33.470177Z","iopub.status.idle":"2024-08-21T02:31:54.46289Z","shell.execute_reply.started":"2024-08-21T02:28:33.47013Z","shell.execute_reply":"2024-08-21T02:31:54.461502Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"score, acc = model.evaluate(X_test_scaled, Y_test)\nprint('Test Loss =', score)\nprint('Test Accuracy =', acc)","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:33:13.816331Z","iopub.execute_input":"2024-08-21T02:33:13.817539Z","iopub.status.idle":"2024-08-21T02:33:25.108606Z","shell.execute_reply.started":"2024-08-21T02:33:13.817497Z","shell.execute_reply":"2024-08-21T02:33:25.107253Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Predictive System","metadata":{}},{"cell_type":"code","source":"import numpy as np\nimport matplotlib.pyplot as plt\nimport tensorflow as tf\n\n# Load the image\ninput_image_path = input('Path of the image to be predicted: ')\ninput_image = cv2.imread(input_image_path)\n\nif input_image is None:\n    print(f\"Error: Image at path '{input_image_path}' could not be loaded.\")\nelse:\n    # Convert from BGR to RGB\n    input_image_rgb = cv2.cvtColor(input_image, cv2.COLOR_BGR2RGB)\n    \n    # Display the image\n    plt.imshow(input_image_rgb)\n    plt.axis('off')\n    plt.show()\n\n    # Resize and preprocess the image\n    input_image_resize = cv2.resize(input_image, (224, 224))\n    input_image_scaled = input_image_resize / 255.0\n    image_reshaped = np.reshape(input_image_scaled, [1, 224, 224, 3])\n\n    # Make prediction\n    input_prediction = model.predict(image_reshaped)\n    print(input_prediction)\n\n    input_pred_label = np.argmax(input_prediction)\n    print(input_pred_label)\n\n    if input_pred_label == 0:\n        print('The image represents a Cat')\n    else:\n        print('The image represents a Dog')\n","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:37:47.485621Z","iopub.execute_input":"2024-08-21T02:37:47.486127Z","iopub.status.idle":"2024-08-21T02:37:50.527825Z","shell.execute_reply.started":"2024-08-21T02:37:47.486078Z","shell.execute_reply":"2024-08-21T02:37:50.5259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Save the model in HDF5 format\nmodel.save('model.h5')","metadata":{"execution":{"iopub.status.busy":"2024-08-21T02:39:21.136137Z","iopub.execute_input":"2024-08-21T02:39:21.136709Z","iopub.status.idle":"2024-08-21T02:39:21.471909Z","shell.execute_reply.started":"2024-08-21T02:39:21.136673Z","shell.execute_reply":"2024-08-21T02:39:21.470393Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}