{"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","execution":{"iopub.status.busy":"2022-08-13T17:05:35.895404Z","iopub.execute_input":"2022-08-13T17:05:35.896059Z","iopub.status.idle":"2022-08-13T17:05:56.133753Z","shell.execute_reply.started":"2022-08-13T17:05:35.895970Z","shell.execute_reply":"2022-08-13T17:05:56.132833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from keras.layers import Dense,Dropout,Input,MaxPooling2D,ZeroPadding2D,Conv2D,Flatten\nfrom keras.models import Sequential\n#from keras.losses import categorical_crossentropy\n#from keras.optimizers import Adam,SGD\nfrom keras.preprocessing.image import img_to_array,load_img,ImageDataGenerator\n#from keras.utils import to_categorical\n\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\npd.options.display.max_colwidth=150","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:05:56.135159Z","iopub.execute_input":"2022-08-13T17:05:56.135522Z","iopub.status.idle":"2022-08-13T17:06:01.455769Z","shell.execute_reply.started":"2022-08-13T17:05:56.135483Z","shell.execute_reply":"2022-08-13T17:06:01.454742Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1=pd.read_csv('/kaggle/input/dog-breed-identification/labels.csv')\ndf1.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:01.457137Z","iopub.execute_input":"2022-08-13T17:06:01.458098Z","iopub.status.idle":"2022-08-13T17:06:01.501169Z","shell.execute_reply.started":"2022-08-13T17:06:01.458051Z","shell.execute_reply":"2022-08-13T17:06:01.499221Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"img_file='/kaggle/input/dog-breed-identification/train/'","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:01.503166Z","iopub.execute_input":"2022-08-13T17:06:01.503505Z","iopub.status.idle":"2022-08-13T17:06:01.508832Z","shell.execute_reply.started":"2022-08-13T17:06:01.503475Z","shell.execute_reply":"2022-08-13T17:06:01.507776Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=df1.assign(img_path=lambda x: img_file + x['id'] +'.jpg')\ndf.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:01.510627Z","iopub.execute_input":"2022-08-13T17:06:01.511340Z","iopub.status.idle":"2022-08-13T17:06:01.533220Z","shell.execute_reply.started":"2022-08-13T17:06:01.511300Z","shell.execute_reply":"2022-08-13T17:06:01.532294Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.breed.value_counts()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:01.534795Z","iopub.execute_input":"2022-08-13T17:06:01.535182Z","iopub.status.idle":"2022-08-13T17:06:01.548206Z","shell.execute_reply.started":"2022-08-13T17:06:01.535144Z","shell.execute_reply":"2022-08-13T17:06:01.547029Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ax=pd.value_counts(df['breed'],ascending=True).plot(kind='barh',fontsize=\"40\",title=\"Class Distribution\",figsize=(50,100))\nax.set(xlabel=\"Images per class\", ylabel=\"Classes\")\nax.yaxis.label.set_size(40)\nax.xaxis.label.set_size(40)\nax.title.set_size(60)\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:01.550641Z","iopub.execute_input":"2022-08-13T17:06:01.551115Z","iopub.status.idle":"2022-08-13T17:06:05.303891Z","shell.execute_reply.started":"2022-08-13T17:06:01.551076Z","shell.execute_reply":"2022-08-13T17:06:05.302985Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_dir = '/kaggle/input/dog-breed-identification/train'\ntest_dir = '/kaggle/input/dog-breed-identification/test'","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.305237Z","iopub.execute_input":"2022-08-13T17:06:05.306033Z","iopub.status.idle":"2022-08-13T17:06:05.311328Z","shell.execute_reply.started":"2022-08-13T17:06:05.305992Z","shell.execute_reply":"2022-08-13T17:06:05.310150Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from os.path import join\n\ntrain_img_fpaths = [join(train_dir, f) for f in os.listdir(train_dir)]\ntest_img_fpaths = [join(test_dir, f) for f in os.listdir(test_dir)]\n\ntrain_size = len(train_img_fpaths)\ntest_size = len(test_img_fpaths)\n\ntrain_size,test_size","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.313153Z","iopub.execute_input":"2022-08-13T17:06:05.313806Z","iopub.status.idle":"2022-08-13T17:06:05.368052Z","shell.execute_reply.started":"2022-08-13T17:06:05.313764Z","shell.execute_reply":"2022-08-13T17:06:05.367036Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train = pd.read_csv('/kaggle/input/dog-breed-identification/labels.csv')\ndf_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.372125Z","iopub.execute_input":"2022-08-13T17:06:05.373006Z","iopub.status.idle":"2022-08-13T17:06:05.393500Z","shell.execute_reply.started":"2022-08-13T17:06:05.372963Z","shell.execute_reply":"2022-08-13T17:06:05.392533Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(df_train.breed.unique())","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.394849Z","iopub.execute_input":"2022-08-13T17:06:05.395928Z","iopub.status.idle":"2022-08-13T17:06:05.403677Z","shell.execute_reply.started":"2022-08-13T17:06:05.395881Z","shell.execute_reply":"2022-08-13T17:06:05.402653Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train.rename(columns = {\"breed\": \"label\"}, inplace = True)\ndf_train[\"id\"] = df_train[\"id\"].apply(lambda x: x+\".\"+\"jpg\")\ndf_train.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.406566Z","iopub.execute_input":"2022-08-13T17:06:05.407874Z","iopub.status.idle":"2022-08-13T17:06:05.424010Z","shell.execute_reply.started":"2022-08-13T17:06:05.407834Z","shell.execute_reply":"2022-08-13T17:06:05.422914Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_files = os.listdir(test_dir)\ndf_test = pd.DataFrame({\"id\": test_files, \"label\": \"boston_bull\"})\ndf_test.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.425716Z","iopub.execute_input":"2022-08-13T17:06:05.426476Z","iopub.status.idle":"2022-08-13T17:06:05.445309Z","shell.execute_reply.started":"2022-08-13T17:06:05.426386Z","shell.execute_reply":"2022-08-13T17:06:05.444414Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_gen = ImageDataGenerator(rescale = 1./255, validation_split = 0.2)\ntrain_generator = train_data_gen.flow_from_dataframe(df_train, train_dir, x_col = 'id', y_col = 'label', subset = 'training',\n                                                     color_mode = 'rgb', class_mode = 'categorical', target_size = (299, 299),\n                                                     batch_size = 32, shuffle = True, seed = 123)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:05.446880Z","iopub.execute_input":"2022-08-13T17:06:05.447243Z","iopub.status.idle":"2022-08-13T17:06:10.006290Z","shell.execute_reply.started":"2022-08-13T17:06:05.447207Z","shell.execute_reply":"2022-08-13T17:06:10.005201Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"val_data_generator = ImageDataGenerator(rescale = 1./255, validation_split = 0.2)\nvalidation_generator = val_data_generator.flow_from_dataframe(df_train, train_dir, x_col = 'id', y_col = 'label',\n                                                              subset = 'validation', color_mode = 'rgb',\n                                                              class_mode = 'categorical', target_size = (299, 299),\n                                                              batch_size = 32, shuffle = True, seed = 123)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:10.007773Z","iopub.execute_input":"2022-08-13T17:06:10.008798Z","iopub.status.idle":"2022-08-13T17:06:10.109122Z","shell.execute_reply.started":"2022-08-13T17:06:10.008757Z","shell.execute_reply":"2022-08-13T17:06:10.108061Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import PIL.Image\nfrom PIL import ImageOps\ndef image_preocessing(path):\n    image = PIL.Image.open(path)\n    size = (299, 299)\n    image = ImageOps.fit(image, size, PIL.Image.ANTIALIAS)\n    image_array = np.asarray(image)\n    \n    return image_array","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:10.110485Z","iopub.execute_input":"2022-08-13T17:06:10.111085Z","iopub.status.idle":"2022-08-13T17:06:10.118188Z","shell.execute_reply.started":"2022-08-13T17:06:10.111046Z","shell.execute_reply":"2022-08-13T17:06:10.117274Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df_train_aux = df_train.copy()\ndf_train_aux['img_path'] = train_dir + '/' + df_train_aux['id']\ndf_train_aux","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:10.119696Z","iopub.execute_input":"2022-08-13T17:06:10.120225Z","iopub.status.idle":"2022-08-13T17:06:10.140534Z","shell.execute_reply.started":"2022-08-13T17:06:10.120188Z","shell.execute_reply":"2022-08-13T17:06:10.139457Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dogs = []\nlabel_names=[]\n\nfor i in range(0, len(df_train_aux)):\n    label = df_train_aux.iloc[i,1]\n    filename = df_train_aux.iloc[i,2]\n    image = image_preocessing(filename)\n    dogs.append(image)\n    label_names.append(label)\n    \nprint(np.shape(label_names))\nprint(np.shape(dogs))","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:06:10.142184Z","iopub.execute_input":"2022-08-13T17:06:10.142844Z","iopub.status.idle":"2022-08-13T17:08:30.500648Z","shell.execute_reply.started":"2022-08-13T17:06:10.142802Z","shell.execute_reply":"2022-08-13T17:08:30.499510Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"plt.figure(figsize = (15,15))\nfor i in range(9):\n    plt.subplot(330 + 1 + i)\n    image = dogs\n    plt.imshow(image[i])\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:08:30.502063Z","iopub.execute_input":"2022-08-13T17:08:30.503022Z","iopub.status.idle":"2022-08-13T17:08:31.727303Z","shell.execute_reply.started":"2022-08-13T17:08:30.502988Z","shell.execute_reply":"2022-08-13T17:08:31.726352Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from tensorflow import keras\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator\nfrom tensorflow.keras.preprocessing import image\nfrom tensorflow.keras.models import Sequential, load_model, Model\nfrom tensorflow.keras.layers import Dense, Conv2D, MaxPooling2D, Flatten, Dropout\nfrom tensorflow.keras.optimizers import Adam\nfrom tensorflow.keras.applications.inception_resnet_v2 import InceptionResNetV2, preprocess_input","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:08:31.728777Z","iopub.execute_input":"2022-08-13T17:08:31.729383Z","iopub.status.idle":"2022-08-13T17:08:31.744843Z","shell.execute_reply.started":"2022-08-13T17:08:31.729344Z","shell.execute_reply":"2022-08-13T17:08:31.743693Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model = Sequential()\nmodel.add(Conv2D(32, kernel_size = (3, 3), activation = 'relu', input_shape=(299, 299, 3)))\nmodel.add(MaxPooling2D(pool_size = (2, 2)))\nmodel.add(Conv2D(64, kernel_size = (3,3), activation = 'relu'))\nmodel.add(MaxPooling2D(pool_size = (2, 2)))\nmodel.add(Conv2D(128, kernel_size = (3,3), activation = 'relu'))\nmodel.add(Flatten())\nmodel.add(Dense(40, activation = 'relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(20, activation = 'relu'))\nmodel.add(Dropout(0.2))\nmodel.add(Dense(len(list(train_generator.class_indices.keys())), activation = 'softmax'))\nmodel.summary()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:08:31.746655Z","iopub.execute_input":"2022-08-13T17:08:31.747435Z","iopub.status.idle":"2022-08-13T17:08:34.701877Z","shell.execute_reply.started":"2022-08-13T17:08:31.747287Z","shell.execute_reply":"2022-08-13T17:08:34.697949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.compile(loss = 'categorical_crossentropy', optimizer = Adam(), metrics = ['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:08:34.703529Z","iopub.execute_input":"2022-08-13T17:08:34.703932Z","iopub.status.idle":"2022-08-13T17:08:34.719710Z","shell.execute_reply.started":"2022-08-13T17:08:34.703892Z","shell.execute_reply":"2022-08-13T17:08:34.718732Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"callbacks_list = [\n    keras.callbacks.ModelCheckpoint(filepath = 'my_model.h5',monitor = 'val_loss', save_best_only = True, verbose = 1),\n    keras.callbacks.EarlyStopping(monitor = 'val_loss', patience = 10,verbose = 1)\n]","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:08:34.721742Z","iopub.execute_input":"2022-08-13T17:08:34.722144Z","iopub.status.idle":"2022-08-13T17:08:34.727677Z","shell.execute_reply.started":"2022-08-13T17:08:34.722101Z","shell.execute_reply":"2022-08-13T17:08:34.726562Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(train_generator,\n                    steps_per_epoch = train_generator.samples // 128,\n                    epochs = 5,\n                    callbacks = callbacks_list,\n                    validation_data = validation_generator,\n                    verbose = 1,\n                    validation_steps = validation_generator.samples // 128)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:08:34.729879Z","iopub.execute_input":"2022-08-13T17:08:34.730362Z","iopub.status.idle":"2022-08-13T17:10:29.885971Z","shell.execute_reply.started":"2022-08-13T17:08:34.730322Z","shell.execute_reply":"2022-08-13T17:10:29.884376Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"base_model = InceptionResNetV2(weights = 'imagenet', include_top = False, input_shape = ((299,299, 3)))\n\nx = base_model.output\nx = Flatten()(x)\nx = Dense(100, activation = 'relu')(x)\npredictions = Dense(len(list(train_generator.class_indices.keys())), activation = 'softmax',\n                    kernel_initializer = 'random_uniform')(x)\n\nmodel = Model(inputs = base_model.input, outputs = predictions)\n\n# Freezing pretrained layers\nfor layer in base_model.layers:\n    layer.trainable = False\n\noptimizer = Adam()\nmodel.compile(optimizer=  optimizer,loss = 'categorical_crossentropy',metrics = ['accuracy'])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:10:29.892832Z","iopub.execute_input":"2022-08-13T17:10:29.896316Z","iopub.status.idle":"2022-08-13T17:10:37.180748Z","shell.execute_reply.started":"2022-08-13T17:10:29.896240Z","shell.execute_reply":"2022-08-13T17:10:37.179721Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"callbacks_list = [\n    keras.callbacks.ModelCheckpoint(filepath = 'my_model.h5',monitor = 'val_loss', save_best_only = True, verbose = 1),\n    keras.callbacks.EarlyStopping(monitor = 'val_loss', patience = 10,verbose = 1)\n]","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:10:37.182175Z","iopub.execute_input":"2022-08-13T17:10:37.182584Z","iopub.status.idle":"2022-08-13T17:10:37.192444Z","shell.execute_reply.started":"2022-08-13T17:10:37.182543Z","shell.execute_reply":"2022-08-13T17:10:37.191342Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"history = model.fit(train_generator,\n                    steps_per_epoch = train_generator.samples // 128,\n                    epochs = 10,\n                    callbacks = callbacks_list,\n                    validation_data = validation_generator,\n                    verbose = 1,\n                    validation_steps = validation_generator.samples // 128)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:10:37.195328Z","iopub.execute_input":"2022-08-13T17:10:37.195916Z","iopub.status.idle":"2022-08-13T17:15:07.356916Z","shell.execute_reply.started":"2022-08-13T17:10:37.195879Z","shell.execute_reply":"2022-08-13T17:15:07.355798Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_data_gen = ImageDataGenerator(preprocessing_function = preprocess_input)\ntest_generator = test_data_gen.flow_from_dataframe(df_test, test_dir, x_col = 'id', y_col = 'label', color_mode = 'rgb',\n                                                   class_mode = 'categorical', target_size = (299, 299), batch_size = 32, shuffle = False,\n                                                   seed = 123)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:15:07.363112Z","iopub.execute_input":"2022-08-13T17:15:07.363659Z","iopub.status.idle":"2022-08-13T17:15:12.472378Z","shell.execute_reply.started":"2022-08-13T17:15:07.363626Z","shell.execute_reply":"2022-08-13T17:15:12.471244Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"arr=model.predict(test_generator)\narr","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:15:12.474019Z","iopub.execute_input":"2022-08-13T17:15:12.474445Z","iopub.status.idle":"2022-08-13T17:17:18.545795Z","shell.execute_reply.started":"2022-08-13T17:15:12.474405Z","shell.execute_reply":"2022-08-13T17:17:18.544338Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ar= arr.argmax(axis = -1)\nar","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:18.547471Z","iopub.execute_input":"2022-08-13T17:17:18.547928Z","iopub.status.idle":"2022-08-13T17:17:18.559255Z","shell.execute_reply.started":"2022-08-13T17:17:18.547885Z","shell.execute_reply":"2022-08-13T17:17:18.557894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission = pd.read_csv('/kaggle/input/dog-breed-identification/sample_submission.csv')\nsubmission.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:18.560901Z","iopub.execute_input":"2022-08-13T17:17:18.561680Z","iopub.status.idle":"2022-08-13T17:17:19.128400Z","shell.execute_reply.started":"2022-08-13T17:17:18.561521Z","shell.execute_reply":"2022-08-13T17:17:19.127172Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dir_files = os.listdir(test_dir)\ntest_gen_files = test_generator.filenames\nsubmission_files = submission[\"id\"]\nlen(submission_files)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.129932Z","iopub.execute_input":"2022-08-13T17:17:19.131175Z","iopub.status.idle":"2022-08-13T17:17:19.146586Z","shell.execute_reply.started":"2022-08-13T17:17:19.131130Z","shell.execute_reply":"2022-08-13T17:17:19.145529Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission_files","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.148113Z","iopub.execute_input":"2022-08-13T17:17:19.148793Z","iopub.status.idle":"2022-08-13T17:17:19.158708Z","shell.execute_reply.started":"2022-08-13T17:17:19.148752Z","shell.execute_reply":"2022-08-13T17:17:19.156709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"m = {}\nl = len(test_gen_files)\nfor i in range(l):\n    m[test_gen_files[i]] = arr[i] ","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.160608Z","iopub.execute_input":"2022-08-13T17:17:19.161301Z","iopub.status.idle":"2022-08-13T17:17:19.175398Z","shell.execute_reply.started":"2022-08-13T17:17:19.161234Z","shell.execute_reply":"2022-08-13T17:17:19.174031Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"labels = (train_generator.class_indices)\nlabels = list(labels.keys())","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.179272Z","iopub.execute_input":"2022-08-13T17:17:19.179616Z","iopub.status.idle":"2022-08-13T17:17:19.187172Z","shell.execute_reply.started":"2022-08-13T17:17:19.179587Z","shell.execute_reply":"2022-08-13T17:17:19.186120Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ypreds_sync = []\nfor f in submission_files:\n    ypreds_sync.append(m[f+\".jpg\"])","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.189328Z","iopub.execute_input":"2022-08-13T17:17:19.189847Z","iopub.status.idle":"2022-08-13T17:17:19.202934Z","shell.execute_reply.started":"2022-08-13T17:17:19.189807Z","shell.execute_reply":"2022-08-13T17:17:19.201887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df = pd.DataFrame(data = ypreds_sync, columns = labels)\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.204775Z","iopub.execute_input":"2022-08-13T17:17:19.205409Z","iopub.status.idle":"2022-08-13T17:17:19.731602Z","shell.execute_reply.started":"2022-08-13T17:17:19.205368Z","shell.execute_reply":"2022-08-13T17:17:19.730316Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df[\"id\"] = submission_files\n\ncols = test_df.columns.tolist()\ncols = cols[-1:] + cols[:-1]\ntest_df = test_df[cols]\ntest_df.head()","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.733608Z","iopub.execute_input":"2022-08-13T17:17:19.734054Z","iopub.status.idle":"2022-08-13T17:17:19.772993Z","shell.execute_reply.started":"2022-08-13T17:17:19.734008Z","shell.execute_reply":"2022-08-13T17:17:19.771844Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(test_df)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.774857Z","iopub.execute_input":"2022-08-13T17:17:19.775326Z","iopub.status.idle":"2022-08-13T17:17:19.800867Z","shell.execute_reply.started":"2022-08-13T17:17:19.775278Z","shell.execute_reply":"2022-08-13T17:17:19.799339Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df.to_csv('submissiondog.csv',index=None)","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:19.802589Z","iopub.execute_input":"2022-08-13T17:17:19.803507Z","iopub.status.idle":"2022-08-13T17:17:21.082124Z","shell.execute_reply.started":"2022-08-13T17:17:19.803462Z","shell.execute_reply":"2022-08-13T17:17:21.081091Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv(\"submissiondog.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-08-13T17:17:21.083699Z","iopub.execute_input":"2022-08-13T17:17:21.084099Z","iopub.status.idle":"2022-08-13T17:17:21.346708Z","shell.execute_reply.started":"2022-08-13T17:17:21.084056Z","shell.execute_reply":"2022-08-13T17:17:21.345607Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"5 -6 kutto ka print kar do photo and predictions","metadata":{}}]}