{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow\nfrom keras.layers import Dense, Conv2D\nfrom keras.models import Sequential","metadata":{"execution":{"iopub.status.busy":"2023-06-15T19:25:06.799548Z","iopub.execute_input":"2023-06-15T19:25:06.800789Z","iopub.status.idle":"2023-06-15T19:25:06.80705Z","shell.execute_reply.started":"2023-06-15T19:25:06.800744Z","shell.execute_reply":"2023-06-15T19:25:06.805909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np","metadata":{"execution":{"iopub.status.busy":"2023-06-15T19:25:08.05713Z","iopub.execute_input":"2023-06-15T19:25:08.057515Z","iopub.status.idle":"2023-06-15T19:25:08.062701Z","shell.execute_reply.started":"2023-06-15T19:25:08.057486Z","shell.execute_reply":"2023-06-15T19:25:08.061418Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"data = pd.read_csv('/kaggle/input/state-farm-distracted-driver-detection/driver_imgs_list.csv')\ndf = pd.DataFrame(data)\n\ndf.head()\ndf.shape","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# splitting the train folder into train and validation data, as we don't have any other data that can act as validation data, the test data contains only images, hence it can't be used as validation data","metadata":{}},{"cell_type":"code","source":"!pip install split-folders\nimport splitfolders","metadata":{"execution":{"iopub.status.busy":"2023-06-15T19:31:33.418381Z","iopub.execute_input":"2023-06-15T19:31:33.418761Z","iopub.status.idle":"2023-06-15T19:31:46.409369Z","shell.execute_reply.started":"2023-06-15T19:31:33.418731Z","shell.execute_reply":"2023-06-15T19:31:46.408145Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainDirectory = '/kaggle/input/state-farm-distracted-driver-detection/imgs/train'\nsplitfolders.ratio(trainDirectory, output=\"newDataset\",\n    seed=1337, ratio=(.8, .2), group_prefix=None, move=False)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:01:11.210447Z","iopub.execute_input":"2023-06-15T20:01:11.210851Z","iopub.status.idle":"2023-06-15T20:03:05.291953Z","shell.execute_reply.started":"2023-06-15T20:01:11.210817Z","shell.execute_reply":"2023-06-15T20:03:05.290899Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainDirectory='/kaggle/working/newDataset/train'\nvalidationDirectory='/kaggle/working/newDataset/val'\nos.listdir(trainDirectory), os.listdir(validationDirectory)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:05:49.965838Z","iopub.execute_input":"2023-06-15T20:05:49.966435Z","iopub.status.idle":"2023-06-15T20:05:49.987467Z","shell.execute_reply.started":"2023-06-15T20:05:49.966388Z","shell.execute_reply":"2023-06-15T20:05:49.98491Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(os.listdir('/kaggle/working/newDataset/train/c0')),len(os.listdir('/kaggle/working/newDataset/val/c0'))","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:08:21.871932Z","iopub.execute_input":"2023-06-15T20:08:21.872312Z","iopub.status.idle":"2023-06-15T20:08:21.88271Z","shell.execute_reply.started":"2023-06-15T20:08:21.872281Z","shell.execute_reply":"2023-06-15T20:08:21.881561Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import seaborn as sns\nimport matplotlib.pyplot as plt\nfrom matplotlib.image import imread","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:08:29.286515Z","iopub.execute_input":"2023-06-15T20:08:29.287193Z","iopub.status.idle":"2023-06-15T20:08:29.291969Z","shell.execute_reply.started":"2023-06-15T20:08:29.287162Z","shell.execute_reply":"2023-06-15T20:08:29.291037Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir(trainDirectory+'/c0')[0]","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:08:32.118245Z","iopub.execute_input":"2023-06-15T20:08:32.118597Z","iopub.status.idle":"2023-06-15T20:08:32.126911Z","shell.execute_reply.started":"2023-06-15T20:08:32.11857Z","shell.execute_reply":"2023-06-15T20:08:32.125832Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img=trainDirectory+'/c0/img_80288.jpg'\na=imread(img)\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:08:42.364934Z","iopub.execute_input":"2023-06-15T20:08:42.365295Z","iopub.status.idle":"2023-06-15T20:08:42.376418Z","shell.execute_reply.started":"2023-06-15T20:08:42.365266Z","shell.execute_reply":"2023-06-15T20:08:42.37521Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(a)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:08:49.113063Z","iopub.execute_input":"2023-06-15T20:08:49.11341Z","iopub.status.idle":"2023-06-15T20:08:49.561532Z","shell.execute_reply.started":"2023-06-15T20:08:49.113382Z","shell.execute_reply":"2023-06-15T20:08:49.560617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Creating training data set","metadata":{}},{"cell_type":"code","source":"dim1=[]\ndim2=[]\n\nfor img_file in os.listdir(trainDirectory+ '/c0' ):\n    img=imread(trainDirectory+'/c0/' + img_file)\n    x,y,z=img.shape\n    dim1.append(x)\n    dim2.append(y)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x=np.mean(dim1)\ny=np.mean(dim2)\nprint(x)\nprint(y)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Generating Different images from available images, and categorising them using ImageDataGenerator","metadata":{}},{"cell_type":"code","source":"imageShape=(256,256,3)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:09:02.701388Z","iopub.execute_input":"2023-06-15T20:09:02.701832Z","iopub.status.idle":"2023-06-15T20:09:02.708098Z","shell.execute_reply.started":"2023-06-15T20:09:02.701784Z","shell.execute_reply":"2023-06-15T20:09:02.70548Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.preprocessing.image import ImageDataGenerator","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:09:05.912211Z","iopub.execute_input":"2023-06-15T20:09:05.912599Z","iopub.status.idle":"2023-06-15T20:09:05.917932Z","shell.execute_reply.started":"2023-06-15T20:09:05.912562Z","shell.execute_reply":"2023-06-15T20:09:05.916965Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.applications.vgg16 import preprocess_input\nfrom tensorflow.keras.applications import VGG16","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:09:09.627121Z","iopub.execute_input":"2023-06-15T20:09:09.6275Z","iopub.status.idle":"2023-06-15T20:09:09.632247Z","shell.execute_reply.started":"2023-06-15T20:09:09.627472Z","shell.execute_reply":"2023-06-15T20:09:09.631169Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"trainGenerator=ImageDataGenerator(rescale=1./255,\n                                  rotation_range=20,\n                               width_shift_range=0.1,\n                               height_shift_range=0.1,\n#                                preprocessing_function=preprocess_input,\n                               shear_range=0.1,\n                               zoom_range=0.1,\n                               horizontal_flip=True,)\nvalGenerator=ImageDataGenerator(rescale=1./255,\n#                                 preprocessing_function=preprocess_input\n                               )","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:30:27.950858Z","iopub.execute_input":"2023-06-15T20:30:27.951756Z","iopub.status.idle":"2023-06-15T20:30:27.960023Z","shell.execute_reply.started":"2023-06-15T20:30:27.951692Z","shell.execute_reply":"2023-06-15T20:30:27.958568Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img=trainDirectory+'/c0/img_80288.jpg'\na=imread(img)\nplt.imshow(a)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:30:30.19437Z","iopub.execute_input":"2023-06-15T20:30:30.194781Z","iopub.status.idle":"2023-06-15T20:30:30.967553Z","shell.execute_reply.started":"2023-06-15T20:30:30.194749Z","shell.execute_reply":"2023-06-15T20:30:30.966606Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.imshow(trainGenerator.random_transform(a))\n# imgGenerator.random_transform(a)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:30:34.360765Z","iopub.execute_input":"2023-06-15T20:30:34.36182Z","iopub.status.idle":"2023-06-15T20:30:34.865634Z","shell.execute_reply.started":"2023-06-15T20:30:34.361777Z","shell.execute_reply":"2023-06-15T20:30:34.864603Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"using .flow_from_directory to get the images for training\n\nIn order to use .flow_from_directory, you must organize the images in sub-directories. This is an absolute requirement, otherwise the method won't work. The directories should only contain images of one class, so one folder per class of images.\n\nStructure Needed:\n\n* Image Data Folder\n    * Class 1\n        * 0.jpg\n        * 1.jpg\n        * ...\n    * Class 2\n        * 0.jpg\n        * 1.jpg\n        * ...\n    * ...\n    * Class n","metadata":{}},{"cell_type":"code","source":"augmented_train_data=trainGenerator.flow_from_directory(trainDirectory,\n                                                       target_size=imageShape[:2],\n                                                       batch_size=32,\n                                                       class_mode='categorical'\n                                                       )","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:31:49.871553Z","iopub.execute_input":"2023-06-15T20:31:49.872254Z","iopub.status.idle":"2023-06-15T20:31:50.401618Z","shell.execute_reply.started":"2023-06-15T20:31:49.872219Z","shell.execute_reply":"2023-06-15T20:31:50.400642Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_data=valGenerator.flow_from_directory(validationDirectory,\n                                         target_size=imageShape[:2],\n                                         batch_size=32,\n                                         class_mode='categorical')","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:31:53.838311Z","iopub.execute_input":"2023-06-15T20:31:53.839196Z","iopub.status.idle":"2023-06-15T20:31:53.976682Z","shell.execute_reply.started":"2023-06-15T20:31:53.839163Z","shell.execute_reply":"2023-06-15T20:31:53.975638Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Conv2D, Dense, Flatten, Activation, Dropout, MaxPooling2D","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:31:56.799009Z","iopub.execute_input":"2023-06-15T20:31:56.799398Z","iopub.status.idle":"2023-06-15T20:31:56.806128Z","shell.execute_reply.started":"2023-06-15T20:31:56.799367Z","shell.execute_reply":"2023-06-15T20:31:56.803927Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Creating model","metadata":{}},{"cell_type":"code","source":"model=Sequential()\nmodel.add(Conv2D(filters=32,kernel_size=(3,3),input_shape=imageShape, activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(filters=64,kernel_size=(3,3),input_shape=imageShape, activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Conv2D(filters=64,kernel_size=(3,3),input_shape=imageShape, activation='relu'))\nmodel.add(MaxPooling2D(pool_size=(2,2)))\n\nmodel.add(Flatten())\n\nmodel.add(Dense(512,activation='relu'))\nmodel.add(Dropout(0.4))\n\nmodel.add(Dense(128,activation='relu'))\nmodel.add(Dropout(0.2))\n\nmodel.add(Dense(10,activation='softmax'))\n\nmodel.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])\n\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:33:12.814522Z","iopub.execute_input":"2023-06-15T20:33:12.81555Z","iopub.status.idle":"2023-06-15T20:33:12.930352Z","shell.execute_reply.started":"2023-06-15T20:33:12.815503Z","shell.execute_reply":"2023-06-15T20:33:12.929326Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow.keras.callbacks import EarlyStopping","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:33:15.708937Z","iopub.execute_input":"2023-06-15T20:33:15.709334Z","iopub.status.idle":"2023-06-15T20:33:15.714176Z","shell.execute_reply.started":"2023-06-15T20:33:15.709302Z","shell.execute_reply":"2023-06-15T20:33:15.713104Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"earlyStop=EarlyStopping(monitor='val_loss', patience=2)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T20:33:17.353059Z","iopub.execute_input":"2023-06-15T20:33:17.35594Z","iopub.status.idle":"2023-06-15T20:33:17.360705Z","shell.execute_reply.started":"2023-06-15T20:33:17.355905Z","shell.execute_reply":"2023-06-15T20:33:17.359486Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"results = model.fit(augmented_train_data,epochs=15,\n                             callbacks=[earlyStop],\n                             batch_size=32,\n                             validation_data=val_data)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T22:35:32.051189Z","iopub.execute_input":"2023-06-15T22:35:32.051606Z","iopub.status.idle":"2023-06-15T23:17:22.181237Z","shell.execute_reply.started":"2023-06-15T22:35:32.051574Z","shell.execute_reply":"2023-06-15T23:17:22.180138Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"root = '/kaggle/input/state-farm-distracted-driver-detection/imgs/'\ntestDirectory = '/kaggle/input/state-farm-distracted-driver-detection/imgs/test'\n\ntestGenerator=ImageDataGenerator(rescale=1./255)\ntestData = testGenerator.flow_from_directory(root,\n                                            shuffle=False,\n                                            target_size=(256, 256),\n                                            batch_size = 32,\n                                            classes=['test'])\npredicted=model.predict(testData)\ntest_ids = sorted(os.listdir(testDirectory))\nsub_df = pd.DataFrame(columns = ['img','c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9'])\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T23:38:39.505874Z","iopub.execute_input":"2023-06-15T23:38:39.506245Z","iopub.status.idle":"2023-06-15T23:43:33.28403Z","shell.execute_reply.started":"2023-06-15T23:38:39.506217Z","shell.execute_reply":"2023-06-15T23:43:33.28262Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for i in range(len(predicted)):\n    sub_df.loc[i, 'img'] = test_ids[i]\n    sub_df.loc[i, 'c0':'c9'] = predicted[i]\n    \nsub_df.to_csv(\"/kaggle/working/submission.csv\",index=False)\n\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T23:43:58.801225Z","iopub.execute_input":"2023-06-15T23:43:58.802002Z","iopub.status.idle":"2023-06-15T23:54:56.448799Z","shell.execute_reply.started":"2023-06-15T23:43:58.801955Z","shell.execute_reply":"2023-06-15T23:54:56.447677Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"now making a function that for predictions","metadata":{}},{"cell_type":"code","source":"sub_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-06-15T23:57:26.496874Z","iopub.execute_input":"2023-06-15T23:57:26.497277Z","iopub.status.idle":"2023-06-15T23:57:26.519291Z","shell.execute_reply.started":"2023-06-15T23:57:26.497244Z","shell.execute_reply":"2023-06-15T23:57:26.518191Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras import layers\nfrom keras import models\n\nmodel_aug = models.Sequential()\nmodel_aug.add(layers.Conv2D(32, (3, 3), activation='relu',\n                        input_shape=(256, 256, 3)))\nmodel_aug.add(layers.MaxPooling2D((2, 2)))\n#model_aug.add(layers.Dropout(0.5))\n\nmodel_aug.add(layers.Conv2D(32, (3, 3), activation='relu'))\nmodel_aug.add(layers.BatchNormalization())\nmodel_aug.add(layers.MaxPooling2D((2, 2)))\n#model_aug.add(layers.Dropout(0.2))\n\nmodel_aug.add(layers.Conv2D(64, (3, 3), activation='relu'))\nmodel_aug.add(layers.MaxPooling2D((2, 2)))\nmodel_aug.add(layers.Dropout(0.2))\n\nmodel_aug.add(layers.Conv2D(64, (3, 3), activation='relu'))\nmodel_aug.add(layers.BatchNormalization())\nmodel_aug.add(layers.MaxPooling2D((2, 2)))\n\nmodel_aug.add(layers.Conv2D(128, (3, 3), activation='relu'))\nmodel_aug.add(layers.MaxPooling2D((2, 2)))\n\nmodel_aug.add(layers.Flatten())\nmodel_aug.add(layers.Dense(512, activation='relu'))\nmodel_aug.add(layers.Dropout(0.3))\nmodel_aug.add(layers.Dense(128, activation='relu'))\nmodel_aug.add(layers.Dropout(0.2))\nmodel_aug.add(layers.Dense(10, activation='softmax'))\n\nmodel_aug.compile(optimizer='adam',\n              loss='categorical_crossentropy',\n              metrics=['accuracy'])\n\nhist_aug=model_aug.fit(\n      augmented_train_data,\n    batch_size=32,\n     # steps_per_epoch=len(train)//128,\n      epochs=5,\n      validation_data=val_data)\n      #validation_steps=len(val)//128)","metadata":{"execution":{"iopub.status.busy":"2023-06-15T22:06:07.029397Z","iopub.execute_input":"2023-06-15T22:06:07.030625Z","iopub.status.idle":"2023-06-15T22:32:25.872923Z","shell.execute_reply.started":"2023-06-15T22:06:07.03058Z","shell.execute_reply":"2023-06-15T22:32:25.871788Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2023-06-15T16:46:27.977212Z","iopub.execute_input":"2023-06-15T16:46:27.977576Z","iopub.status.idle":"2023-06-15T16:46:44.099989Z","shell.execute_reply.started":"2023-06-15T16:46:27.977545Z","shell.execute_reply":"2023-06-15T16:46:44.098977Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"execution":{"iopub.status.busy":"2023-06-15T16:48:38.735451Z","iopub.execute_input":"2023-06-15T16:48:38.736559Z","iopub.status.idle":"2023-06-15T16:49:05.563161Z","shell.execute_reply.started":"2023-06-15T16:48:38.736495Z","shell.execute_reply":"2023-06-15T16:49:05.5622Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T16:49:53.693236Z","iopub.execute_input":"2023-06-15T16:49:53.693608Z","iopub.status.idle":"2023-06-15T16:50:07.492419Z","shell.execute_reply.started":"2023-06-15T16:49:53.693578Z","shell.execute_reply":"2023-06-15T16:50:07.491342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T17:16:06.623409Z","iopub.execute_input":"2023-06-15T17:16:06.624281Z","iopub.status.idle":"2023-06-15T17:19:07.738693Z","shell.execute_reply.started":"2023-06-15T17:16:06.624235Z","shell.execute_reply":"2023-06-15T17:19:07.737676Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def predict_image(path):\n    img = tf.keras.utils.load_img(path).resize((100,100))\n    img = np.array(img).reshape((1,100,100,3))\n    y = model.predict(img,verbose=False)\n    return y\n","metadata":{"execution":{"iopub.status.busy":"2023-06-15T15:18:05.431764Z","iopub.execute_input":"2023-06-15T15:18:05.432153Z","iopub.status.idle":"2023-06-15T15:18:05.439034Z","shell.execute_reply.started":"2023-06-15T15:18:05.432124Z","shell.execute_reply":"2023-06-15T15:18:05.43809Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y = model.predict(test_data)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = pd.DataFrame(y)\ndf.columns = ['c0','c1','c2','c3','c4','c5','c6','c7','c8','c9']\nfilepath = [i.split('/')[-1] for i in test_data.file_paths]\ndf1 = pd.DataFrame(filepath)\ndf1.columns = ['img']\ndf = df1.join(df)\ndf.to_csv('/kaggle/working/output.csv',index=False)","metadata":{},"execution_count":null,"outputs":[]}]}