{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.7.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":5048,"databundleVersionId":868335,"sourceType":"competition"}],"dockerImageVersionId":30446,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!pip install split-folders","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:48:05.482067Z","iopub.execute_input":"2024-03-24T16:48:05.482484Z","iopub.status.idle":"2024-03-24T16:48:18.557381Z","shell.execute_reply.started":"2024-03-24T16:48:05.482447Z","shell.execute_reply":"2024-03-24T16:48:18.556004Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\nimport splitfolders\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-03-24T16:48:18.559847Z","iopub.execute_input":"2024-03-24T16:48:18.560172Z","iopub.status.idle":"2024-03-24T16:48:18.569833Z","shell.execute_reply.started":"2024-03-24T16:48:18.560141Z","shell.execute_reply":"2024-03-24T16:48:18.568776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Display Data","metadata":{}},{"cell_type":"code","source":"df= pd.read_csv(\"/kaggle/input/state-farm-distracted-driver-detection/driver_imgs_list.csv\")\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:48:18.571144Z","iopub.execute_input":"2024-03-24T16:48:18.571495Z","iopub.status.idle":"2024-03-24T16:48:18.632019Z","shell.execute_reply.started":"2024-03-24T16:48:18.571454Z","shell.execute_reply":"2024-03-24T16:48:18.631012Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:48:18.635410Z","iopub.execute_input":"2024-03-24T16:48:18.636253Z","iopub.status.idle":"2024-03-24T16:48:18.644038Z","shell.execute_reply.started":"2024-03-24T16:48:18.636220Z","shell.execute_reply":"2024-03-24T16:48:18.641225Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import plotly.express as px\n\npx.histogram(df , x=\"classname\" ,  color=\"classname\", title=\"Images By Categories \")","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:48:18.645578Z","iopub.execute_input":"2024-03-24T16:48:18.646033Z","iopub.status.idle":"2024-03-24T16:48:23.565011Z","shell.execute_reply.started":"2024-03-24T16:48:18.645993Z","shell.execute_reply":"2024-03-24T16:48:23.563883Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:48:23.566621Z","iopub.execute_input":"2024-03-24T16:48:23.567096Z","iopub.status.idle":"2024-03-24T16:48:23.594321Z","shell.execute_reply.started":"2024-03-24T16:48:23.567058Z","shell.execute_reply":"2024-03-24T16:48:23.593080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mydata = '/kaggle/input/state-farm-distracted-driver-detection/imgs/train'\nsplitfolders.ratio(mydata, output=\"mydata\",\n    seed=1337, ratio=(.8, .2), group_prefix=None, move=False)","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:48:23.596401Z","iopub.execute_input":"2024-03-24T16:48:23.597232Z","iopub.status.idle":"2024-03-24T16:50:09.564927Z","shell.execute_reply.started":"2024-03-24T16:48:23.597170Z","shell.execute_reply":"2024-03-24T16:50:09.563882Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train = '/kaggle/working/mydata/train'\n\nval = '/kaggle/working/mydata/val'","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:09.566576Z","iopub.execute_input":"2024-03-24T16:50:09.567394Z","iopub.status.idle":"2024-03-24T16:50:09.571968Z","shell.execute_reply.started":"2024-03-24T16:50:09.567349Z","shell.execute_reply":"2024-03-24T16:50:09.570989Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import os\nfrom PIL import Image","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:09.573505Z","iopub.execute_input":"2024-03-24T16:50:09.573972Z","iopub.status.idle":"2024-03-24T16:50:09.584013Z","shell.execute_reply.started":"2024-03-24T16:50:09.573932Z","shell.execute_reply":"2024-03-24T16:50:09.583105Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_label= {'c0': 'Safe driving',\n              'c1': 'Texting - right',\n              'c2': 'Talking on the phone - right', \n              'c3': 'Texting - left', \n              'c4': 'Talking on the phone - left', \n              'c5': 'Operating the radio', \n              'c6': 'Drinking', \n              'c7': 'Reaching behind', \n              'c8': 'Hair and makeup', \n              'c9': 'Talking to passenger'}","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:09.588932Z","iopub.execute_input":"2024-03-24T16:50:09.589656Z","iopub.status.idle":"2024-03-24T16:50:09.595110Z","shell.execute_reply.started":"2024-03-24T16:50:09.589614Z","shell.execute_reply":"2024-03-24T16:50:09.594084Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# fig, axs = plt.subplots(5, 2, figsize=(10,10))\n\nsubdirs = [subdir for subdir in os.listdir(train) if os.path.isdir(os.path.join(train, subdir))]\n\nfig, axs = plt.subplots(5, 2, figsize=(16,12))\n\nfor i, subdir in enumerate(subdirs):\n    file = os.listdir(os.path.join(train, subdir))[0]\n\n    img = Image.open(os.path.join(train, subdir, file))\n    axs[i//2, i%2].imshow(img)\n    axs[i//2, i%2].set_title(f'{class_label[subdir]} ({subdir})')\n    axs[i//2, i%2].axis('off')\n\nplt.tight_layout()\n","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:09.596503Z","iopub.execute_input":"2024-03-24T16:50:09.597133Z","iopub.status.idle":"2024-03-24T16:50:11.227642Z","shell.execute_reply.started":"2024-03-24T16:50:09.597094Z","shell.execute_reply":"2024-03-24T16:50:11.226499Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.preprocessing.image import ImageDataGenerator\n\ntrain_datagen = ImageDataGenerator(rescale=1./255)\ntest_datagen = ImageDataGenerator(rescale=1./255)\n\nbatch_size = 128\n\ntrain_generator = train_datagen.flow_from_directory(\n        train,\n        target_size=(256, 256),\n        batch_size=128)\n\nvalidation_generator = test_datagen.flow_from_directory(\n        val,\n        target_size=(256, 256),\n        batch_size=128)\n     ","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:11.229084Z","iopub.execute_input":"2024-03-24T16:50:11.229446Z","iopub.status.idle":"2024-03-24T16:50:18.619016Z","shell.execute_reply.started":"2024-03-24T16:50:11.229410Z","shell.execute_reply":"2024-03-24T16:50:18.617944Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# CNN Model","metadata":{}},{"cell_type":"code","source":"from keras import layers\nfrom keras import models\n\nCNN_model = models.Sequential()\nCNN_model.add(layers.Conv2D(32, (3, 3), activation='relu',\n                        input_shape=(256, 256, 3)))\nCNN_model.add(layers.MaxPooling2D((2, 2)))\nCNN_model.add(layers.Conv2D(32, (3, 3), activation='relu'))\nCNN_model.add(layers.BatchNormalization())\nCNN_model.add(layers.MaxPooling2D((2, 2)))\n\nCNN_model.add(layers.Conv2D(64, (3, 3), activation='relu'))\nCNN_model.add(layers.MaxPooling2D((2, 2)))\nCNN_model.add(layers.Dropout(0.2))\nCNN_model.add(layers.Conv2D(64, (3, 3), activation='relu'))\nCNN_model.add(layers.BatchNormalization())\nCNN_model.add(layers.MaxPooling2D((2, 2)))\n\nCNN_model.add(layers.Conv2D(128, (3, 3), activation='relu'))\nCNN_model.add(layers.MaxPooling2D((2, 2)))\n\nCNN_model.add(layers.Flatten())\nCNN_model.add(layers.Dense(512, activation='relu'))\nCNN_model.add(layers.Dropout(0.3))\nCNN_model.add(layers.Dense(128, activation='relu'))\nCNN_model.add(layers.Dropout(0.2))\nCNN_model.add(layers.Dense(10, activation='softmax'))","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:18.620502Z","iopub.execute_input":"2024-03-24T16:50:18.621749Z","iopub.status.idle":"2024-03-24T16:50:21.023860Z","shell.execute_reply.started":"2024-03-24T16:50:18.621714Z","shell.execute_reply":"2024-03-24T16:50:21.022718Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CNN_model.summary()","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:21.025411Z","iopub.execute_input":"2024-03-24T16:50:21.025779Z","iopub.status.idle":"2024-03-24T16:50:21.082096Z","shell.execute_reply.started":"2024-03-24T16:50:21.025747Z","shell.execute_reply":"2024-03-24T16:50:21.081074Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CNN_model.compile(optimizer='adam',loss='categorical_crossentropy', metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:21.083601Z","iopub.execute_input":"2024-03-24T16:50:21.084437Z","iopub.status.idle":"2024-03-24T16:50:21.105563Z","shell.execute_reply.started":"2024-03-24T16:50:21.084393Z","shell.execute_reply":"2024-03-24T16:50:21.104522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"CNN_history=  CNN_model.fit(\n              train_generator,\n              epochs=15,\n              batch_size=128,\n              validation_data=validation_generator)\n","metadata":{"execution":{"iopub.status.busy":"2024-03-24T16:50:21.106770Z","iopub.execute_input":"2024-03-24T16:50:21.107046Z","iopub.status.idle":"2024-03-24T17:25:57.769030Z","shell.execute_reply.started":"2024-03-24T16:50:21.107019Z","shell.execute_reply":"2024-03-24T17:25:57.768083Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_loss, val_acc = CNN_model.evaluate(validation_generator)\nval_acc","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:25:57.770826Z","iopub.execute_input":"2024-03-24T17:25:57.771625Z","iopub.status.idle":"2024-03-24T17:26:27.564714Z","shell.execute_reply.started":"2024-03-24T17:25:57.771578Z","shell.execute_reply":"2024-03-24T17:26:27.563612Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"acc = CNN_history.history['accuracy']\nval_acc = CNN_history.history['val_accuracy']\nloss = CNN_history.history['loss']\nval_loss = CNN_history.history['val_loss']\n\nepochs = range(len(acc))\n\nplt.plot(epochs, acc, 'bo', label='Training acc')\nplt.plot(epochs, val_acc, 'b', label='Validation acc')\nplt.title('Training and validation accuracy')\nplt.legend()\n\nplt.figure()\n\nplt.plot(epochs, loss, 'bo', label='Training loss')\nplt.plot(epochs, val_loss, 'b', label='Validation loss')\nplt.title('Training and validation loss')\nplt.legend()\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:26:27.566044Z","iopub.execute_input":"2024-03-24T17:26:27.566322Z","iopub.status.idle":"2024-03-24T17:26:27.997408Z","shell.execute_reply.started":"2024-03-24T17:26:27.566295Z","shell.execute_reply":"2024-03-24T17:26:27.996294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Augmentation","metadata":{}},{"cell_type":"code","source":"from tensorflow.keras.preprocessing.image import ImageDataGenerator\ndatagen = ImageDataGenerator(\n    rescale=1./255,\n    rotation_range=10,\n    width_shift_range=0.05,\n    height_shift_range=0.05,\n    shear_range=0.05,\n    zoom_range=0.05,\n   fill_mode=\"nearest\"\n)\ndatagen_val = ImageDataGenerator(\n    rescale=1./255)","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:26:27.998754Z","iopub.execute_input":"2024-03-24T17:26:27.999078Z","iopub.status.idle":"2024-03-24T17:26:28.280993Z","shell.execute_reply.started":"2024-03-24T17:26:27.999047Z","shell.execute_reply":"2024-03-24T17:26:28.279854Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_generator = datagen.flow_from_directory(\n        train,\n        target_size=(256, 256),\n        batch_size=128)\n\nvalidation_generator = datagen_val.flow_from_directory(\n        val,\n        target_size=(256, 256),\n        batch_size=128)\n\n\n","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:26:28.282385Z","iopub.execute_input":"2024-03-24T17:26:28.282722Z","iopub.status.idle":"2024-03-24T17:26:29.284757Z","shell.execute_reply.started":"2024-03-24T17:26:28.282690Z","shell.execute_reply":"2024-03-24T17:26:29.283575Z"},"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\n\n","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:26:29.286152Z","iopub.execute_input":"2024-03-24T17:26:29.286451Z","iopub.status.idle":"2024-03-24T17:26:29.469151Z","shell.execute_reply.started":"2024-03-24T17:26:29.286423Z","shell.execute_reply":"2024-03-24T17:26:29.468148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\nmodel_aug.compile(optimizer='adam',\n              loss='categorical_crossentropy',\n              metrics=['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:26:29.470506Z","iopub.execute_input":"2024-03-24T17:26:29.470823Z","iopub.status.idle":"2024-03-24T17:26:29.483819Z","shell.execute_reply.started":"2024-03-24T17:26:29.470793Z","shell.execute_reply":"2024-03-24T17:26:29.482811Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"hist_aug=model_aug.fit(\n      train_generator,\n    batch_size=128,\n     # steps_per_epoch=len(train)//128,\n      epochs=15,\n      validation_data=validation_generator)\n      #validation_steps=len(val)//128)\n    \n    ","metadata":{"execution":{"iopub.status.busy":"2024-03-24T17:26:29.485224Z","iopub.execute_input":"2024-03-24T17:26:29.485655Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_loss, val_acc = model_aug.evaluate(validation_generator)\nval_acc","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"acc = hist_aug.history['accuracy']\nval_acc = hist_aug.history['val_accuracy']\nloss = hist_aug.history['loss']\nval_loss = hist_aug.history['val_loss']\n\nepochs = range(len(acc))\n\nplt.plot(epochs, acc, 'bo', label='Training acc')\nplt.plot(epochs, val_acc, 'b', label='Validation acc')\nplt.title('Training and validation accuracy')\nplt.legend()\n\nplt.figure()\n\nplt.plot(epochs, loss, 'bo', label='Training loss')\nplt.plot(epochs, val_loss, 'b', label='Validation loss')\nplt.title('Training and validation loss')\nplt.legend()\n\nplt.show()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Transfer Learning VGG-16","metadata":{}},{"cell_type":"code","source":"import tensorflow as tf\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom tensorflow.keras.applications.vgg16 import preprocess_input\nfrom tensorflow.keras.applications import VGG16","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"datagen = ImageDataGenerator(\n    preprocessing_function= preprocess_input,\n    rotation_range=10,\n    width_shift_range=0.05,\n    height_shift_range=0.05,\n    shear_range=0.05,\n    zoom_range=0.05,\n   fill_mode=\"nearest\",\n    \n)\n\ndatagen_test = ImageDataGenerator(\n    preprocessing_function= preprocess_input\n)\n\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_generator = datagen.flow_from_directory(\n        train,\n        target_size=(256, 256),\n        batch_size=128)\n\nvalidation_generator = datagen_test.flow_from_directory(\n        val,\n        target_size=(256, 256),\n        batch_size=128)\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"conv_VGG = VGG16(\n    include_top=False,\n    weights='imagenet',\n    input_shape=(256, 256, 3)\n)\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"conv_VGG.trainable = False","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"conv_VGG.summary()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_vgg = tf.keras.models.Sequential([\n    conv_VGG,\n    tf.keras.layers.Flatten(),\n    tf.keras.layers.Dense(512, activation='relu'),\n    tf.keras.layers.Dropout(0.3),\n    tf.keras.layers.Dense(128, activation='relu'),\n    tf.keras.layers.Dropout(0.2),\n    tf.keras.layers.Dense(128, activation='relu'),\n    tf.keras.layers.Dense(10, activation='softmax')\n])\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_vgg.summary()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model_vgg.compile(\n    optimizer=tf.keras.optimizers.Adam(),\n    loss='categorical_crossentropy',\n    metrics=['accuracy']\n)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history_vgg=model_vgg.fit(\n    train_generator,\n    batch_size=128,\n     # steps_per_epoch=len(train)//128,\n      epochs=15,\n      validation_data=validation_generator)\n\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_loss, val_acc = model_vgg.evaluate(validation_generator)\nval_acc","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"acc = history_vgg.history['accuracy']\nval_acc = history_vgg.history['val_accuracy']\nloss = history_vgg.history['loss']\nval_loss = history_vgg.history['val_loss']\n\nepochs = range(len(acc))\n\nplt.plot(epochs, acc, 'bo', label='Training acc')\nplt.plot(epochs, val_acc, 'b', label='Validation acc')\nplt.title('Training and validation accuracy')\nplt.legend()\n\nplt.figure()\n\nplt.plot(epochs, loss, 'bo', label='Training loss')\nplt.plot(epochs, val_loss, 'b', label='Validation loss')\nplt.title('Training and validation loss')\nplt.legend()\n\nplt.show()","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# submission","metadata":{}},{"cell_type":"code","source":"datagen_test = ImageDataGenerator(preprocessing_function=preprocess_input)\ntest='/kaggle/input/state-farm-distracted-driver-detection/imgs/.'\n\ntestData = datagen_test.flow_from_directory(test,\n                                            shuffle=False,\n                                            target_size=(256, 256),\n                                            batch_size = 128,\n                                            classes=['test'])\n\npredict_test = model_vgg.predict(testData)\n","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"base_dir = '../input/state-farm-distracted-driver-detection'\ntest_dir = os.path.join(base_dir, 'imgs')","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test=os.path.join(base_dir, \"imgs/test\")\ntest_ids = sorted(os.listdir(test))\nsub_df = pd.DataFrame(columns = ['img','c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9'])\n\nfor i in range(len(predict_test)):\n    sub_df.loc[i, 'img'] = test_ids[i]\n    sub_df.loc[i, 'c0':'c9'] = predict_test[i]\n    \nsub_df.to_csv(\"/kaggle/working/submission.csv\",index=False)","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df.head()","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}