{"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":"2025-02-14T17:30:02.544423Z","iopub.execute_input":"2025-02-14T17:30:02.545015Z","iopub.status.idle":"2025-02-14T17:30:02.852431Z","shell.execute_reply.started":"2025-02-14T17:30:02.54498Z","shell.execute_reply":"2025-02-14T17:30:02.851379Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!python --version","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:02.854156Z","iopub.execute_input":"2025-02-14T17:30:02.85463Z","iopub.status.idle":"2025-02-14T17:30:03.851428Z","shell.execute_reply.started":"2025-02-14T17:30:02.854594Z","shell.execute_reply":"2025-02-14T17:30:03.850579Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"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":"2025-02-14T17:30:03.852684Z","iopub.execute_input":"2025-02-14T17:30:03.852977Z","iopub.status.idle":"2025-02-14T17:30:12.912427Z","shell.execute_reply.started":"2025-02-14T17:30:03.852951Z","shell.execute_reply":"2025-02-14T17:30:12.911703Z"},"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:12.914873Z","iopub.execute_input":"2025-02-14T17:30:12.915229Z","iopub.status.idle":"2025-02-14T17:30:13.925888Z","shell.execute_reply.started":"2025-02-14T17:30:12.915197Z","shell.execute_reply":"2025-02-14T17:30:13.924765Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:13.927425Z","iopub.execute_input":"2025-02-14T17:30:13.927801Z","iopub.status.idle":"2025-02-14T17:30:14.95778Z","shell.execute_reply.started":"2025-02-14T17:30:13.927765Z","shell.execute_reply":"2025-02-14T17:30:14.956769Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls test1/ | wc -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:14.959708Z","iopub.execute_input":"2025-02-14T17:30:14.960082Z","iopub.status.idle":"2025-02-14T17:30:15.997182Z","shell.execute_reply.started":"2025-02-14T17:30:14.960047Z","shell.execute_reply":"2025-02-14T17:30:15.996261Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls train/ | wc -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:15.998526Z","iopub.execute_input":"2025-02-14T17:30:15.998832Z","iopub.status.idle":"2025-02-14T17:30:17.090012Z","shell.execute_reply.started":"2025-02-14T17:30:15.998787Z","shell.execute_reply":"2025-02-14T17:30:17.089176Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls train/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:17.091579Z","iopub.execute_input":"2025-02-14T17:30:17.091978Z","iopub.status.idle":"2025-02-14T17:30:18.218211Z","shell.execute_reply.started":"2025-02-14T17:30:17.091938Z","shell.execute_reply":"2025-02-14T17:30:18.216804Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# plot dog 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 + '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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:18.219914Z","iopub.execute_input":"2025-02-14T17:30:18.220341Z","iopub.status.idle":"2025-02-14T17:30:19.228631Z","shell.execute_reply.started":"2025-02-14T17:30:18.220298Z","shell.execute_reply":"2025-02-14T17:30:19.227861Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:19.233238Z","iopub.execute_input":"2025-02-14T17:30:19.233593Z","iopub.status.idle":"2025-02-14T17:30:20.142486Z","shell.execute_reply.started":"2025-02-14T17:30:19.233568Z","shell.execute_reply":"2025-02-14T17:30:20.141639Z"}},"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":"2025-02-14T17:30:20.143759Z","iopub.execute_input":"2025-02-14T17:30:20.14401Z","iopub.status.idle":"2025-02-14T17:30:22.886798Z","shell.execute_reply.started":"2025-02-14T17:30:20.143988Z","shell.execute_reply":"2025-02-14T17:30:22.885079Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:22.888147Z","iopub.execute_input":"2025-02-14T17:30:22.888992Z","iopub.status.idle":"2025-02-14T17:30:22.90094Z","shell.execute_reply.started":"2025-02-14T17:30:22.888945Z","shell.execute_reply":"2025-02-14T17:30:22.899901Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:22.902065Z","iopub.execute_input":"2025-02-14T17:30:22.902438Z","iopub.status.idle":"2025-02-14T17:30:22.915063Z","shell.execute_reply.started":"2025-02-14T17:30:22.902398Z","shell.execute_reply":"2025-02-14T17:30:22.913675Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:22.91687Z","iopub.execute_input":"2025-02-14T17:30:22.91741Z","iopub.status.idle":"2025-02-14T17:30:22.925957Z","shell.execute_reply.started":"2025-02-14T17:30:22.917377Z","shell.execute_reply":"2025-02-14T17:30:22.925086Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l dataset_dogs_vs_cats/train/dogs/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:22.926876Z","iopub.execute_input":"2025-02-14T17:30:22.927116Z","iopub.status.idle":"2025-02-14T17:30:24.065849Z","shell.execute_reply.started":"2025-02-14T17:30:22.927096Z","shell.execute_reply":"2025-02-14T17:30:24.064952Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:24.067219Z","iopub.execute_input":"2025-02-14T17:30:24.067509Z","iopub.status.idle":"2025-02-14T17:30:25.077495Z","shell.execute_reply.started":"2025-02-14T17:30:24.067483Z","shell.execute_reply":"2025-02-14T17:30:25.076569Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l dataset_dogs_vs_cats/train","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:25.078704Z","iopub.execute_input":"2025-02-14T17:30:25.078986Z","iopub.status.idle":"2025-02-14T17:30:26.080085Z","shell.execute_reply.started":"2025-02-14T17:30:25.07896Z","shell.execute_reply":"2025-02-14T17:30:26.078956Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls -l dataset_dogs_vs_cats/test","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:26.081571Z","iopub.execute_input":"2025-02-14T17:30:26.08189Z","iopub.status.idle":"2025-02-14T17:30:27.081202Z","shell.execute_reply.started":"2025-02-14T17:30:26.081861Z","shell.execute_reply":"2025-02-14T17:30:27.080284Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:27.082829Z","iopub.execute_input":"2025-02-14T17:30:27.083691Z","iopub.status.idle":"2025-02-14T17:30:30.403869Z","shell.execute_reply.started":"2025-02-14T17:30:27.083649Z","shell.execute_reply":"2025-02-14T17:30:30.403051Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"print(src)\nprint(dst)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:30.404807Z","iopub.execute_input":"2025-02-14T17:30:30.405074Z","iopub.status.idle":"2025-02-14T17:30:30.409805Z","shell.execute_reply.started":"2025-02-14T17:30:30.405053Z","shell.execute_reply":"2025-02-14T17:30:30.408872Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:30.410803Z","iopub.execute_input":"2025-02-14T17:30:30.411121Z","iopub.status.idle":"2025-02-14T17:30:32.555187Z","shell.execute_reply.started":"2025-02-14T17:30:30.411098Z","shell.execute_reply":"2025-02-14T17:30:32.553964Z"}},"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":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:30:32.556882Z","iopub.execute_input":"2025-02-14T17:30:32.557258Z","iopub.status.idle":"2025-02-14T17:30:34.651753Z","shell.execute_reply.started":"2025-02-14T17:30:32.557219Z","shell.execute_reply":"2025-02-14T17:30:34.650876Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip -q install livelossplot==0.5.5","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:19.453841Z","iopub.execute_input":"2025-02-14T17:35:19.454535Z","iopub.status.idle":"2025-02-14T17:35:27.615721Z","shell.execute_reply.started":"2025-02-14T17:35:19.4545Z","shell.execute_reply":"2025-02-14T17:35:27.614404Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from livelossplot import PlotLossesKeras","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:27.618033Z","iopub.execute_input":"2025-02-14T17:35:27.618402Z","iopub.status.idle":"2025-02-14T17:35:27.623272Z","shell.execute_reply.started":"2025-02-14T17:35:27.618367Z","shell.execute_reply":"2025-02-14T17:35:27.622283Z"}},"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":"2025-02-14T17:35:27.624807Z","iopub.execute_input":"2025-02-14T17:35:27.625149Z","iopub.status.idle":"2025-02-14T17:35:27.632571Z","shell.execute_reply.started":"2025-02-14T17:35:27.625119Z","shell.execute_reply":"2025-02-14T17:35:27.631868Z"}},"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":"2025-02-14T17:35:27.634569Z","iopub.execute_input":"2025-02-14T17:35:27.634891Z","iopub.status.idle":"2025-02-14T17:35:27.641596Z","shell.execute_reply.started":"2025-02-14T17:35:27.634861Z","shell.execute_reply":"2025-02-14T17:35:27.640849Z"}},"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":"2025-02-14T17:35:27.642709Z","iopub.execute_input":"2025-02-14T17:35:27.643015Z","iopub.status.idle":"2025-02-14T17:35:27.651628Z","shell.execute_reply.started":"2025-02-14T17:35:27.642988Z","shell.execute_reply":"2025-02-14T17:35:27.65086Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# 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    pyplot.show()\n\tpyplot.close()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:27.652693Z","iopub.execute_input":"2025-02-14T17:35:27.652935Z","iopub.status.idle":"2025-02-14T17:35:27.664795Z","shell.execute_reply.started":"2025-02-14T17:35:27.652914Z","shell.execute_reply":"2025-02-14T17:35:27.663084Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def run_test_harness():\n    # define model\n    model = define_model_1()  # Ensure this is your improved model definition\n    # create data generator with augmentation (if not already included)\n    datagen = ImageDataGenerator(\n        rescale=1.0/255.0,\n        rotation_range=20,\n        width_shift_range=0.2,\n        height_shift_range=0.2,\n        shear_range=0.2,\n        zoom_range=0.2,\n        horizontal_flip=True,\n        fill_mode='nearest'\n    )\n\tprint('> %.3f' % (acc * 100.0))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T19:23:54.04253Z","iopub.execute_input":"2025-02-14T19:23:54.042887Z","iopub.status.idle":"2025-02-14T19:23:54.047908Z","shell.execute_reply.started":"2025-02-14T19:23:54.042856Z","shell.execute_reply":"2025-02-14T19:23:54.046991Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_1 = define_model_1()\nprint(model_1.summary())","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:27.668185Z","iopub.status.idle":"2025-02-14T17:35:27.668498Z","shell.execute_reply.started":"2025-02-14T17:35:27.66835Z","shell.execute_reply":"2025-02-14T17:35:27.668365Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"datagen = ImageDataGenerator(rescale=1.0/255.0)\n\n# prepare iterators\ntrain_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n    class_mode='binary', batch_size=64, target_size=(200, 200))\n\nval_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n    class_mode='binary', batch_size=64, target_size=(200, 200))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:52:42.076323Z","iopub.execute_input":"2025-02-14T17:52:42.077062Z","iopub.status.idle":"2025-02-14T17:52:42.737059Z","shell.execute_reply.started":"2025-02-14T17:52:42.077021Z","shell.execute_reply":"2025-02-14T17:52:42.736368Z"}},"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":"2025-02-14T17:52:42.764049Z","iopub.execute_input":"2025-02-14T17:52:42.764313Z","iopub.status.idle":"2025-02-14T17:52:42.770537Z","shell.execute_reply.started":"2025-02-14T17:52:42.76429Z","shell.execute_reply":"2025-02-14T17:52:42.76966Z"}},"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":"2025-02-14T17:52:44.741981Z","iopub.execute_input":"2025-02-14T17:52:44.74279Z","iopub.status.idle":"2025-02-14T17:52:44.748749Z","shell.execute_reply.started":"2025-02-14T17:52:44.74275Z","shell.execute_reply":"2025-02-14T17:52:44.74773Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"ls ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:27.680504Z","iopub.status.idle":"2025-02-14T17:35:27.68077Z","shell.execute_reply.started":"2025-02-14T17:35:27.680641Z","shell.execute_reply":"2025-02-14T17:35:27.680654Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"pwd","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:27.681604Z","iopub.status.idle":"2025-02-14T17:35:27.681895Z","shell.execute_reply.started":"2025-02-14T17:35:27.681735Z","shell.execute_reply":"2025-02-14T17:35:27.681748Z"}},"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":"2025-02-14T17:35:31.534677Z","iopub.execute_input":"2025-02-14T17:35:31.535533Z","iopub.status.idle":"2025-02-14T17:35:31.569125Z","shell.execute_reply.started":"2025-02-14T17:35:31.535499Z","shell.execute_reply":"2025-02-14T17:35:31.568234Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df[:10]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:31.766702Z","iopub.execute_input":"2025-02-14T17:35:31.767386Z","iopub.status.idle":"2025-02-14T17:35:31.778651Z","shell.execute_reply.started":"2025-02-14T17:35:31.76736Z","shell.execute_reply":"2025-02-14T17:35:31.777836Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Prediction\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\n\n# Initialize your ImageDataGenerator (modify parameters as needed)\ndatagen = ImageDataGenerator(rescale=1./255)\n\n# Create the data generator using the DataFrame\ntest_it = datagen.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=(200, 200),\n    batch_size=64,\n    class_mode=None,       # Since there are no labels\n    shuffle=True          # Usually testing data should not be shuffled\n)\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:32.014402Z","iopub.execute_input":"2025-02-14T17:35:32.015053Z","iopub.status.idle":"2025-02-14T17:35:32.096351Z","shell.execute_reply.started":"2025-02-14T17:35:32.015028Z","shell.execute_reply":"2025-02-14T17:35:32.095725Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_images = test_it.__next__()\ntest_images.shape","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:32.243719Z","iopub.execute_input":"2025-02-14T17:35:32.244246Z","iopub.status.idle":"2025-02-14T17:35:32.355561Z","shell.execute_reply.started":"2025-02-14T17:35:32.244224Z","shell.execute_reply":"2025-02-14T17:35:32.354399Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# Transfer Learning\n# save the final model to file\nfrom keras.applications.vgg16 import VGG16\nfrom keras.applications.xception import Xception\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","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:32.612514Z","iopub.execute_input":"2025-02-14T17:35:32.612773Z","iopub.status.idle":"2025-02-14T17:35:32.617287Z","shell.execute_reply.started":"2025-02-14T17:35:32.61275Z","shell.execute_reply":"2025-02-14T17:35:32.616444Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"xcep_model = Xception(include_top=False, input_shape=(299, 299, 3))\nxcep_model.summary()","metadata":{"execution":{"iopub.status.busy":"2024-01-27T04:11:23.494572Z","iopub.execute_input":"2024-01-27T04:11:23.495217Z","iopub.status.idle":"2024-01-27T04:11:26.579883Z","shell.execute_reply.started":"2024-01-27T04:11:23.495182Z","shell.execute_reply":"2024-01-27T04:11:26.578335Z"}}},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"#Image Augmentatioin\n\nfrom keras.preprocessing.image import ImageDataGenerator\n# create data generator\ndatagen = ImageDataGenerator(\n    rescale=1./255,\n    rotation_range=40,\n    width_shift_range=0.2,\n    height_shift_range=0.2,\n    shear_range=0.2,\n    zoom_range=0.2,\n    horizontal_flip=True,\n    # fill_mode='nearest',\n    fill_mode='reflect',\n)\n# prepare iterator\ntrain_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n    class_mode='binary', batch_size=64, target_size=(224, 224))\ntest_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n    class_mode='binary', batch_size=64, target_size=(224, 224))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:33.472067Z","iopub.execute_input":"2025-02-14T17:35:33.472349Z","iopub.status.idle":"2025-02-14T17:35:34.134462Z","shell.execute_reply.started":"2025-02-14T17:35:33.472325Z","shell.execute_reply":"2025-02-14T17:35:34.133866Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"images, labels = train_it.__next__()\nprint(images.shape, labels.shape)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:34.135877Z","iopub.execute_input":"2025-02-14T17:35:34.136125Z","iopub.status.idle":"2025-02-14T17:35:34.796213Z","shell.execute_reply.started":"2025-02-14T17:35:34.136104Z","shell.execute_reply":"2025-02-14T17:35:34.795408Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"labels","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:34.797368Z","iopub.execute_input":"2025-02-14T17:35:34.798021Z","iopub.status.idle":"2025-02-14T17:35:34.803866Z","shell.execute_reply.started":"2025-02-14T17:35:34.797985Z","shell.execute_reply":"2025-02-14T17:35:34.803067Z"}},"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":"2025-02-14T17:35:34.805698Z","iopub.execute_input":"2025-02-14T17:35:34.805964Z","iopub.status.idle":"2025-02-14T17:35:34.813805Z","shell.execute_reply.started":"2025-02-14T17:35:34.805942Z","shell.execute_reply":"2025-02-14T17:35:34.812975Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plot_images_with_labels(images, labels, \"Dog-Cat\", \"Training\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:34.814958Z","iopub.execute_input":"2025-02-14T17:35:34.815234Z","iopub.status.idle":"2025-02-14T17:35:36.752622Z","shell.execute_reply.started":"2025-02-14T17:35:34.815202Z","shell.execute_reply":"2025-02-14T17:35:36.751662Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# load model\nmodel = VGG16(\n    include_top=False,\n    input_shape=(224, 224, 3)\n    )\nprint(model.summary())\n#model = Xception(include_top=False, input_shape=(299, 299, 3))\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:36.753735Z","iopub.execute_input":"2025-02-14T17:35:36.754023Z","iopub.status.idle":"2025-02-14T17:35:37.181685Z","shell.execute_reply.started":"2025-02-14T17:35:36.753993Z","shell.execute_reply":"2025-02-14T17:35:37.180891Z"}},"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":"2025-02-14T17:35:37.183514Z","iopub.execute_input":"2025-02-14T17:35:37.18378Z","iopub.status.idle":"2025-02-14T17:35:37.188905Z","shell.execute_reply.started":"2025-02-14T17:35:37.183756Z","shell.execute_reply":"2025-02-14T17:35:37.187981Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# mark loaded layers as not trainable\nfor index, layer in enumerate(model.layers[:15]):\n    print(index, layer.name, layer.output_shape)\n    layer.trainable = False\n    \nfor 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":"2025-02-14T17:35:37.190003Z","iopub.execute_input":"2025-02-14T17:35:37.190297Z","iopub.status.idle":"2025-02-14T17:35:37.199187Z","shell.execute_reply.started":"2025-02-14T17:35:37.190274Z","shell.execute_reply":"2025-02-14T17:35:37.198271Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model.layers[-1].output","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:37.20035Z","iopub.execute_input":"2025-02-14T17:35:37.200665Z","iopub.status.idle":"2025-02-14T17:35:37.212Z","shell.execute_reply.started":"2025-02-14T17:35:37.200635Z","shell.execute_reply":"2025-02-14T17:35:37.211076Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# add new classifier layers\nflat1 = Flatten()(model.layers[-1].output)\nclass1 = Dense(128, activation='relu', kernel_initializer='he_uniform')(flat1)\noutput = Dense(1, activation='sigmoid')(class1)\n# define new model\nmy_model = Model(inputs=model.inputs, outputs=output)\n# compile model\nopt = SGD(lr=0.0001, momentum=0.9)\nmy_model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])\nmy_model.summary()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:35:37.213006Z","iopub.execute_input":"2025-02-14T17:35:37.213275Z","iopub.status.idle":"2025-02-14T17:35:37.29189Z","shell.execute_reply.started":"2025-02-14T17:35:37.213244Z","shell.execute_reply":"2025-02-14T17:35:37.291157Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":" # fit model\nmy_model.reset_states()\nhistory = my_model.fit(train_it, \n                    #steps_per_epoch=len(train_it),\n                    validation_data=test_it, \n                    #validation_steps=len(test_it), \n                    epochs=10, verbose=1,\n                    callbacks=[PlotLossesKeras()])\n# evaluate model\n_, acc = model.evaluate_generator(test_it, steps=len(test_it), verbose=1)\nprint('> %.3f' % (acc * 100.0))\n# learning curves\nsummarize_diagnostics(history)\n\nbest_model = 'vgg16_model.hdf5'\nmy_model.save(best_model)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:38:54.955325Z","iopub.status.idle":"2025-02-14T17:38:54.955606Z","shell.execute_reply.started":"2025-02-14T17:38:54.95547Z","shell.execute_reply":"2025-02-14T17:38:54.955484Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"best_model = load_model(best_model)\nbest_model.evaluate(test_it, verbose=1)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:38:54.957425Z","iopub.status.idle":"2025-02-14T17:38:54.957736Z","shell.execute_reply.started":"2025-02-14T17:38:54.957589Z","shell.execute_reply":"2025-02-14T17:38:54.957604Z"}},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":"Make Prediction","metadata":{}},{"cell_type":"code","source":"# make a prediction for a new image.\nfrom keras.preprocessing.image import load_img\nfrom keras.preprocessing.image import img_to_array\nfrom keras.models import load_model\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:38:54.951751Z","iopub.status.idle":"2025-02-14T17:38:54.952117Z","shell.execute_reply.started":"2025-02-14T17:38:54.951955Z","shell.execute_reply":"2025-02-14T17:38:54.95197Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# load and prepare the image\ndef load_image(filename):\n\t# load the image\n\timg = load_img(filename, target_size=(224, 224))\n\t# convert to array\n\timg = img_to_array(img)\n\t# reshape into a single sample with 3 channels\n\timg = img.reshape(1, 224, 224, 3)\n\t# center pixel data\n\timg = img.astype('float32')\n\timg = img - [123.68, 116.779, 103.939]\n\treturn img\n\n# load an image and predict the class\ndef run_example():\n\t# load the image\n\timg = load_image('sample_image.jpg')\n\t# load model\n\tmodel = load_model('final_model.h5')\n\t# predict the class\n\tresult = model.predict(img)\n\tprint(result[0])\n\n# entry point, run the example\nrun_example()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T17:38:54.953634Z","iopub.status.idle":"2025-02-14T17:38:54.953979Z","shell.execute_reply.started":"2025-02-14T17:38:54.953798Z","shell.execute_reply":"2025-02-14T17:38:54.953831Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from tensorflow.keras.callbacks import ReduceLROnPlateau, EarlyStopping\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T19:31:42.388269Z","iopub.execute_input":"2025-02-14T19:31:42.388593Z","iopub.status.idle":"2025-02-14T19:31:42.393022Z","shell.execute_reply.started":"2025-02-14T19:31:42.388567Z","shell.execute_reply":"2025-02-14T19:31:42.39198Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"def run_test_harness():\n\t\n\tmodel = define_model()\n\t\n\tdatagen = ImageDataGenerator(rescale=1.0/255.0)\n\t\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\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=1) \n\t\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":"2025-02-14T19:52:42.289203Z","iopub.execute_input":"2025-02-14T19:52:42.289613Z","iopub.status.idle":"2025-02-14T19:52:42.295378Z","shell.execute_reply.started":"2025-02-14T19:52:42.289583Z","shell.execute_reply":"2025-02-14T19:52:42.294505Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_1 = define_model_1()\nprint(model_1.summary())\n\ndatagen = ImageDataGenerator(rescale=1.0/255.0)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T19:52:55.862458Z","iopub.execute_input":"2025-02-14T19:52:55.862783Z","iopub.status.idle":"2025-02-14T19:52:55.926801Z","shell.execute_reply.started":"2025-02-14T19:52:55.862754Z","shell.execute_reply":"2025-02-14T19:52:55.925995Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_it = datagen.flow_from_directory('dataset_dogs_vs_cats/train/',\n    class_mode='binary', batch_size=64, target_size=(200, 200))\n\nval_it = datagen.flow_from_directory('dataset_dogs_vs_cats/test/',\n    class_mode='binary', batch_size=64, target_size=(200, 200))\n\nlen(train_it), len(train_it.classes), train_it.classes[:10]\n\nlen(val_it), len(val_it.classes), val_it.classes[-10:]","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T19:53:09.800217Z","iopub.execute_input":"2025-02-14T19:53:09.800554Z","iopub.status.idle":"2025-02-14T19:53:10.832361Z","shell.execute_reply.started":"2025-02-14T19:53:09.800524Z","shell.execute_reply":"2025-02-14T19:53:10.831648Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"model_1.reset_states()\nhistory_1 = model_1.fit_generator(\n    train_it, steps_per_epoch=len(train_it),\n    validation_data=val_it, \n    validation_steps=len(val_it),\n    epochs=20,  \n    verbose=1,\n    callbacks=[PlotLossesKeras()]\n)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T19:53:21.159364Z","iopub.execute_input":"2025-02-14T19:53:21.160024Z","iopub.status.idle":"2025-02-14T20:06:42.811895Z","shell.execute_reply.started":"2025-02-14T19:53:21.159992Z","shell.execute_reply":"2025-02-14T20:06:42.810997Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import numpy as np\nimport matplotlib.pyplot as plt\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\n\ntest_datagen = ImageDataGenerator(rescale=1.0/255.0)\n\ntest_generator = test_datagen.flow_from_directory(\n    'dataset_dogs_vs_cats/test/',  \n    class_mode='binary',          \n    batch_size=64,\n    target_size=(200, 200)         \n)\n\ndef random_predict_from_test(test_generator, num_samples_per_class=5):\n    class_0_images, class_0_labels = [], []\n    class_1_images, class_1_labels = [], []\n\n    for i in range(len(test_generator)):\n        images, labels = test_generator[i]\n        \n        for image, label in zip(images, labels):\n            if label == 0 and len(class_0_images) < num_samples_per_class:\n                class_0_images.append(image)\n                class_0_labels.append(label)\n            elif label == 1 and len(class_1_images) < num_samples_per_class:\n                class_1_images.append(image)\n                class_1_labels.append(label)\n            \n            if len(class_0_images) >= num_samples_per_class and len(class_1_images) >= num_samples_per_class:\n                break\n        \n        if len(class_0_images) >= num_samples_per_class and len(class_1_images) >= num_samples_per_class:\n            break\n    \n    images = np.array(class_0_images + class_1_images)\n    labels = np.array(class_0_labels + class_1_labels)\n    \n    predictions = model_1.predict(images)\n    \n    results = []\n    for i, (image, label, prediction) in enumerate(zip(images, labels, predictions)):\n        predicted_class = 1 if prediction >= 0.5 else 0 \n        results.append((test_generator.filenames[i], label, predicted_class, prediction[0], image))\n    \n    return results\n\npredictions = random_predict_from_test(test_generator, num_samples_per_class=5)\n\nfig, axes = plt.subplots(2, 5, figsize=(15, 6))\n\nfor i, (file, label, prediction, prob, image) in enumerate(predictions):\n    row = i // 5  # \n    col = i % 5  \n    \n    axes[row, col].imshow(image)\n    axes[row, col].set_title(f\"True: {'Cat' if label == 0 else 'Dog'}\\nPred: {'Cat' if prediction == 0 else 'Dog'}\\nProb: {prob:.3f}\")\n    axes[row, col].axis('off')\n\nplt.tight_layout()\nplt.show()\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-02-14T20:19:58.469587Z","iopub.execute_input":"2025-02-14T20:19:58.470232Z","iopub.status.idle":"2025-02-14T20:19:59.694877Z","shell.execute_reply.started":"2025-02-14T20:19:58.4702Z","shell.execute_reply":"2025-02-14T20:19:59.694035Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}