{"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":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","papermill":{"duration":0.685276,"end_time":"2023-10-06T10:32:00.313750","exception":false,"start_time":"2023-10-06T10:31:59.628474","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:30:41.283487Z","iopub.execute_input":"2023-10-07T04:30:41.283918Z","iopub.status.idle":"2023-10-07T04:30:41.770098Z","shell.execute_reply.started":"2023-10-07T04:30:41.283879Z","shell.execute_reply":"2023-10-07T04:30:41.769210Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from fastai.vision.all import *\n","metadata":{"papermill":{"duration":8.73779,"end_time":"2023-10-06T10:32:09.058070","exception":false,"start_time":"2023-10-06T10:32:00.320280","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:30:42.844712Z","iopub.execute_input":"2023-10-07T04:30:42.845339Z","iopub.status.idle":"2023-10-07T04:30:47.051698Z","shell.execute_reply.started":"2023-10-07T04:30:42.845299Z","shell.execute_reply":"2023-10-07T04:30:47.049388Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install py7zr\n","metadata":{"papermill":{"duration":11.394407,"end_time":"2023-10-06T10:32:20.459217","exception":false,"start_time":"2023-10-06T10:32:09.064810","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:30:47.056904Z","iopub.execute_input":"2023-10-07T04:30:47.059124Z","iopub.status.idle":"2023-10-07T04:31:01.837938Z","shell.execute_reply.started":"2023-10-07T04:30:47.059085Z","shell.execute_reply":"2023-10-07T04:31:01.836666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from py7zr import unpack_7zarchive\nimport shutil\nshutil.register_unpack_format('7zip',['.7z'],unpack_7zarchive)","metadata":{"papermill":{"duration":0.133281,"end_time":"2023-10-06T10:32:20.600533","exception":false,"start_time":"2023-10-06T10:32:20.467252","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:31:01.842696Z","iopub.execute_input":"2023-10-07T04:31:01.845167Z","iopub.status.idle":"2023-10-07T04:31:02.006150Z","shell.execute_reply.started":"2023-10-07T04:31:01.845128Z","shell.execute_reply":"2023-10-07T04:31:02.005160Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shutil.unpack_archive('../input/cifar-10/train.7z', '/kaggle/temp/')","metadata":{"papermill":{"duration":44.807504,"end_time":"2023-10-06T10:33:05.415771","exception":false,"start_time":"2023-10-06T10:32:20.608267","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:31:02.011558Z","iopub.execute_input":"2023-10-07T04:31:02.013644Z","iopub.status.idle":"2023-10-07T04:32:12.274265Z","shell.execute_reply.started":"2023-10-07T04:31:02.013610Z","shell.execute_reply":"2023-10-07T04:32:12.273167Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_labels = pd.read_csv(\"../input/cifar-10/trainLabels.csv\", header=\"infer\")\n\nclasses = train_labels['label'].unique()\nprint(classes)","metadata":{"papermill":{"duration":4.430049,"end_time":"2023-10-06T10:33:09.860085","exception":false,"start_time":"2023-10-06T10:33:05.430036","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:12.275666Z","iopub.execute_input":"2023-10-07T04:32:12.276203Z","iopub.status.idle":"2023-10-07T04:32:12.321739Z","shell.execute_reply.started":"2023-10-07T04:32:12.276163Z","shell.execute_reply":"2023-10-07T04:32:12.320884Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"if not os.path.exists(\"/kaggle/temp/valid\"):\n    os.mkdir(\"/kaggle/temp/valid\")\n    \nparent_path_train = \"/kaggle/temp/train\"\nparent_path_valid = \"/kaggle/temp/valid\"\n# parent_path_test = \"/kaggle/temp/test\"\n\nfor class1 in classes:\n    path_train = os.path.join(parent_path_train,class1)\n    if not os.path.exists(path_train):\n        os.mkdir(path_train)\n    path_valid = os.path.join(parent_path_valid,class1)\n    if not os.path.exists(path_valid):\n        os.mkdir(path_valid)\nfor (int_ind,row) in train_labels.iterrows():\n    id = str(row[\"id\"])+\".png\"\n    source_path = os.path.join(parent_path_train,id)\n    \n    p=np.random.random()\n    if p<=0.8:\n        target_path = os.path.join(parent_path_train,row[\"label\"],id)\n        os.replace(source_path, target_path)\n    else:\n        target_path = os.path.join(parent_path_valid,row[\"label\"],id)\n        os.replace(source_path, target_path)","metadata":{"papermill":{"duration":6.198115,"end_time":"2023-10-06T10:33:16.079764","exception":false,"start_time":"2023-10-06T10:33:09.881649","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:12.325409Z","iopub.execute_input":"2023-10-07T04:32:12.327704Z","iopub.status.idle":"2023-10-07T04:32:23.703281Z","shell.execute_reply.started":"2023-10-07T04:32:12.327669Z","shell.execute_reply":"2023-10-07T04:32:23.702255Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dls=ImageDataLoaders.from_folder(path='/kaggle/temp',\n                            train='train', valid='valid',item_tfms=Resize(224),bs=64)","metadata":{"papermill":{"duration":6.308295,"end_time":"2023-10-06T10:33:22.395756","exception":false,"start_time":"2023-10-06T10:33:16.087461","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:23.707780Z","iopub.execute_input":"2023-10-07T04:32:23.709894Z","iopub.status.idle":"2023-10-07T04:32:33.870004Z","shell.execute_reply.started":"2023-10-07T04:32:23.709861Z","shell.execute_reply":"2023-10-07T04:32:33.868982Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir('/kaggle/temp')","metadata":{"papermill":{"duration":0.023322,"end_time":"2023-10-06T10:33:22.426547","exception":false,"start_time":"2023-10-06T10:33:22.403225","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:33.874942Z","iopub.execute_input":"2023-10-07T04:32:33.877123Z","iopub.status.idle":"2023-10-07T04:32:33.888740Z","shell.execute_reply.started":"2023-10-07T04:32:33.877087Z","shell.execute_reply":"2023-10-07T04:32:33.887831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dls.show_batch()","metadata":{"papermill":{"duration":1.178839,"end_time":"2023-10-06T10:33:23.612915","exception":false,"start_time":"2023-10-06T10:33:22.434076","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:33.895034Z","iopub.execute_input":"2023-10-07T04:32:33.897344Z","iopub.status.idle":"2023-10-07T04:32:35.602049Z","shell.execute_reply.started":"2023-10-07T04:32:33.897313Z","shell.execute_reply":"2023-10-07T04:32:35.601059Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn = vision_learner(dls, resnet50, metrics=accuracy)","metadata":{"papermill":{"duration":1.184105,"end_time":"2023-10-06T10:33:24.810066","exception":false,"start_time":"2023-10-06T10:33:23.625961","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:35.603794Z","iopub.execute_input":"2023-10-07T04:32:35.604503Z","iopub.status.idle":"2023-10-07T04:32:36.617309Z","shell.execute_reply.started":"2023-10-07T04:32:35.604466Z","shell.execute_reply":"2023-10-07T04:32:36.616259Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()","metadata":{"papermill":{"duration":28.668711,"end_time":"2023-10-06T10:33:53.492402","exception":false,"start_time":"2023-10-06T10:33:24.823691","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:32:36.619036Z","iopub.execute_input":"2023-10-07T04:32:36.619700Z","iopub.status.idle":"2023-10-07T04:33:04.512179Z","shell.execute_reply.started":"2023-10-07T04:32:36.619668Z","shell.execute_reply":"2023-10-07T04:33:04.511162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(35, 3e-3)  # First training cycle with 40 epochs\n","metadata":{"papermill":{"duration":5352.692738,"end_time":"2023-10-06T12:03:06.199371","exception":false,"start_time":"2023-10-06T10:33:53.506633","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T04:33:04.516872Z","iopub.execute_input":"2023-10-07T04:33:04.518964Z","iopub.status.idle":"2023-10-07T06:46:57.644244Z","shell.execute_reply.started":"2023-10-07T04:33:04.518927Z","shell.execute_reply":"2023-10-07T06:46:57.643189Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.unfreeze()","metadata":{"papermill":{"duration":0.023875,"end_time":"2023-10-06T12:03:06.238000","exception":false,"start_time":"2023-10-06T12:03:06.214125","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T06:46:57.646340Z","iopub.execute_input":"2023-10-07T06:46:57.646982Z","iopub.status.idle":"2023-10-07T06:46:57.653872Z","shell.execute_reply.started":"2023-10-07T06:46:57.646946Z","shell.execute_reply":"2023-10-07T06:46:57.652923Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(30, lr_max=slice(1e-6, 3e-5))  # Second training cycle with 30 epochs\n","metadata":{"papermill":{"duration":5641.027537,"end_time":"2023-10-06T13:37:22.980131","exception":false,"start_time":"2023-10-06T12:03:21.952594","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T07:14:10.910502Z","iopub.execute_input":"2023-10-07T07:14:10.910985Z","iopub.status.idle":"2023-10-07T09:38:33.096008Z","shell.execute_reply.started":"2023-10-07T07:14:10.910948Z","shell.execute_reply":"2023-10-07T09:38:33.094909Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.recorder.plot_loss()","metadata":{"papermill":{"duration":0.614345,"end_time":"2023-10-06T13:37:23.610171","exception":false,"start_time":"2023-10-06T13:37:22.995826","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:38:33.098352Z","iopub.execute_input":"2023-10-07T09:38:33.099306Z","iopub.status.idle":"2023-10-07T09:38:33.853661Z","shell.execute_reply.started":"2023-10-07T09:38:33.099269Z","shell.execute_reply":"2023-10-07T09:38:33.852761Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shutil.unpack_archive('/kaggle/input/cifar-10/test.7z','/kaggle/temp/test')\nshutil.unregister_unpack_format('7zip')","metadata":{"papermill":{"duration":809.045625,"end_time":"2023-10-06T13:50:52.671876","exception":false,"start_time":"2023-10-06T13:37:23.626251","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:38:33.855100Z","iopub.execute_input":"2023-10-07T09:38:33.855645Z","iopub.status.idle":"2023-10-07T09:51:54.271897Z","shell.execute_reply.started":"2023-10-07T09:38:33.855612Z","shell.execute_reply":"2023-10-07T09:51:54.270894Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.save('/kaggle/working/vision')","metadata":{"papermill":{"duration":0.555604,"end_time":"2023-10-06T13:50:53.244315","exception":false,"start_time":"2023-10-06T13:50:52.688711","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:51:54.275725Z","iopub.execute_input":"2023-10-07T09:51:54.276066Z","iopub.status.idle":"2023-10-07T09:51:54.850002Z","shell.execute_reply.started":"2023-10-07T09:51:54.276041Z","shell.execute_reply":"2023-10-07T09:51:54.849044Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(os.listdir('/kaggle/temp/test/test'))","metadata":{"papermill":{"duration":0.164037,"end_time":"2023-10-06T13:50:53.424575","exception":false,"start_time":"2023-10-06T13:50:53.260538","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:51:54.851567Z","iopub.execute_input":"2023-10-07T09:51:54.851925Z","iopub.status.idle":"2023-10-07T09:51:55.003630Z","shell.execute_reply.started":"2023-10-07T09:51:54.851892Z","shell.execute_reply":"2023-10-07T09:51:55.002707Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"path='/kaggle/temp/test/test'\nf=os.listdir(path)\nnew=[str(path)+'/'+s for s in f]","metadata":{"papermill":{"duration":0.213351,"end_time":"2023-10-06T13:50:53.653985","exception":false,"start_time":"2023-10-06T13:50:53.440634","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:51:55.004898Z","iopub.execute_input":"2023-10-07T09:51:55.005876Z","iopub.status.idle":"2023-10-07T09:51:55.205408Z","shell.execute_reply.started":"2023-10-07T09:51:55.005845Z","shell.execute_reply":"2023-10-07T09:51:55.204453Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dl=learn.dls.test_dl(new)","metadata":{"papermill":{"duration":0.046684,"end_time":"2023-10-06T13:50:53.716526","exception":false,"start_time":"2023-10-06T13:50:53.669842","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:51:55.207008Z","iopub.execute_input":"2023-10-07T09:51:55.207675Z","iopub.status.idle":"2023-10-07T09:51:55.221444Z","shell.execute_reply.started":"2023-10-07T09:51:55.207643Z","shell.execute_reply":"2023-10-07T09:51:55.220482Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score,y=learn.get_preds(dl=test_dl)","metadata":{"papermill":{"duration":609.326302,"end_time":"2023-10-06T14:01:03.071882","exception":false,"start_time":"2023-10-06T13:50:53.745580","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T09:51:55.222644Z","iopub.execute_input":"2023-10-07T09:51:55.222979Z","iopub.status.idle":"2023-10-07T10:02:17.348065Z","shell.execute_reply.started":"2023-10-07T09:51:55.222947Z","shell.execute_reply":"2023-10-07T10:02:17.346833Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score","metadata":{"papermill":{"duration":0.038852,"end_time":"2023-10-06T14:01:03.127342","exception":false,"start_time":"2023-10-06T14:01:03.088490","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.349866Z","iopub.execute_input":"2023-10-07T10:02:17.350582Z","iopub.status.idle":"2023-10-07T10:02:17.370147Z","shell.execute_reply.started":"2023-10-07T10:02:17.350547Z","shell.execute_reply":"2023-10-07T10:02:17.369112Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score = np.argmax(class_score, axis=1)","metadata":{"papermill":{"duration":0.047377,"end_time":"2023-10-06T14:01:03.190935","exception":false,"start_time":"2023-10-06T14:01:03.143558","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.375398Z","iopub.execute_input":"2023-10-07T10:02:17.375665Z","iopub.status.idle":"2023-10-07T10:02:17.402930Z","shell.execute_reply.started":"2023-10-07T10:02:17.375644Z","shell.execute_reply":"2023-10-07T10:02:17.401983Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score[1].item()","metadata":{"papermill":{"duration":0.02554,"end_time":"2023-10-06T14:01:03.232417","exception":false,"start_time":"2023-10-06T14:01:03.206877","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.404451Z","iopub.execute_input":"2023-10-07T10:02:17.405016Z","iopub.status.idle":"2023-10-07T10:02:17.411437Z","shell.execute_reply.started":"2023-10-07T10:02:17.404984Z","shell.execute_reply":"2023-10-07T10:02:17.410466Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score","metadata":{"papermill":{"duration":0.0259,"end_time":"2023-10-06T14:01:03.274213","exception":false,"start_time":"2023-10-06T14:01:03.248313","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.412709Z","iopub.execute_input":"2023-10-07T10:02:17.413501Z","iopub.status.idle":"2023-10-07T10:02:17.422530Z","shell.execute_reply.started":"2023-10-07T10:02:17.413472Z","shell.execute_reply":"2023-10-07T10:02:17.421522Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classScore=class_score.tolist()","metadata":{"papermill":{"duration":0.026506,"end_time":"2023-10-06T14:01:03.316828","exception":false,"start_time":"2023-10-06T14:01:03.290322","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.424018Z","iopub.execute_input":"2023-10-07T10:02:17.424729Z","iopub.status.idle":"2023-10-07T10:02:17.434567Z","shell.execute_reply.started":"2023-10-07T10:02:17.424691Z","shell.execute_reply":"2023-10-07T10:02:17.433667Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(classScore)","metadata":{"papermill":{"duration":0.024796,"end_time":"2023-10-06T14:01:03.358197","exception":false,"start_time":"2023-10-06T14:01:03.333401","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.435985Z","iopub.execute_input":"2023-10-07T10:02:17.436636Z","iopub.status.idle":"2023-10-07T10:02:17.446132Z","shell.execute_reply.started":"2023-10-07T10:02:17.436606Z","shell.execute_reply":"2023-10-07T10:02:17.445119Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.dls.vocab","metadata":{"papermill":{"duration":0.025844,"end_time":"2023-10-06T14:01:03.400329","exception":false,"start_time":"2023-10-06T14:01:03.374485","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.447425Z","iopub.execute_input":"2023-10-07T10:02:17.447978Z","iopub.status.idle":"2023-10-07T10:02:17.457660Z","shell.execute_reply.started":"2023-10-07T10:02:17.447950Z","shell.execute_reply":"2023-10-07T10:02:17.456512Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classes={0:'airplane',1:'automobile',2:'bird',3:'cat',4:'deer',5:'dog',6:'frog',7:'horse',8:'ship',9:'truck'}\n","metadata":{"papermill":{"duration":0.024354,"end_time":"2023-10-06T14:01:03.440872","exception":false,"start_time":"2023-10-06T14:01:03.416518","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.459553Z","iopub.execute_input":"2023-10-07T10:02:17.460223Z","iopub.status.idle":"2023-10-07T10:02:17.465861Z","shell.execute_reply.started":"2023-10-07T10:02:17.460193Z","shell.execute_reply":"2023-10-07T10:02:17.464981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_classes=np.empty(shape=300000,dtype=np.dtype('U20'))\n","metadata":{"papermill":{"duration":0.027536,"end_time":"2023-10-06T14:01:03.484548","exception":false,"start_time":"2023-10-06T14:01:03.457012","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.467382Z","iopub.execute_input":"2023-10-07T10:02:17.467960Z","iopub.status.idle":"2023-10-07T10:02:17.481824Z","shell.execute_reply.started":"2023-10-07T10:02:17.467910Z","shell.execute_reply":"2023-10-07T10:02:17.480816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ind=0\nfor i in (classScore):\n    predicted_classes[ind]=classes[i]\n    ind=ind+1","metadata":{"papermill":{"duration":0.111937,"end_time":"2023-10-06T14:01:03.612847","exception":false,"start_time":"2023-10-06T14:01:03.500910","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.483315Z","iopub.execute_input":"2023-10-07T10:02:17.484317Z","iopub.status.idle":"2023-10-07T10:02:17.640326Z","shell.execute_reply.started":"2023-10-07T10:02:17.484284Z","shell.execute_reply":"2023-10-07T10:02:17.639356Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_classes","metadata":{"papermill":{"duration":0.027236,"end_time":"2023-10-06T14:01:03.656529","exception":false,"start_time":"2023-10-06T14:01:03.629293","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.641666Z","iopub.execute_input":"2023-10-07T10:02:17.642532Z","iopub.status.idle":"2023-10-07T10:02:17.649461Z","shell.execute_reply.started":"2023-10-07T10:02:17.642498Z","shell.execute_reply":"2023-10-07T10:02:17.648402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"directory = '/kaggle/temp/test/test'\nImageId = [ (''.join(filter(str.isdigit, name ))) for name in os.listdir(directory)]\n","metadata":{"papermill":{"duration":0.412608,"end_time":"2023-10-06T14:01:04.085261","exception":false,"start_time":"2023-10-06T14:01:03.672653","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.651005Z","iopub.execute_input":"2023-10-07T10:02:17.651645Z","iopub.status.idle":"2023-10-07T10:02:17.984686Z","shell.execute_reply.started":"2023-10-07T10:02:17.651614Z","shell.execute_reply":"2023-10-07T10:02:17.983705Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission  = pd.DataFrame({\n    \"id\": ImageId,\n    \"label\": predicted_classes\n})\n# submission.sort_values(by=[\"ImageId\"], inplace = True)\nsubmission.to_csv(\"submission.csv\", index=False)\ndisplay(submission.head(3))\ndisplay(submission.tail(3))","metadata":{"papermill":{"duration":0.402444,"end_time":"2023-10-06T14:01:04.504668","exception":false,"start_time":"2023-10-06T14:01:04.102224","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:17.986225Z","iopub.execute_input":"2023-10-07T10:02:17.986561Z","iopub.status.idle":"2023-10-07T10:02:18.385323Z","shell.execute_reply.started":"2023-10-07T10:02:17.986529Z","shell.execute_reply":"2023-10-07T10:02:18.384383Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['id']=submission['id'].astype(int)","metadata":{"papermill":{"duration":0.055634,"end_time":"2023-10-06T14:01:04.578013","exception":false,"start_time":"2023-10-06T14:01:04.522379","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:18.386534Z","iopub.execute_input":"2023-10-07T10:02:18.387445Z","iopub.status.idle":"2023-10-07T10:02:18.423961Z","shell.execute_reply.started":"2023-10-07T10:02:18.387411Z","shell.execute_reply":"2023-10-07T10:02:18.422843Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)","metadata":{"papermill":{"duration":0.34066,"end_time":"2023-10-06T14:01:04.935521","exception":false,"start_time":"2023-10-06T14:01:04.594861","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:18.425551Z","iopub.execute_input":"2023-10-07T10:02:18.426237Z","iopub.status.idle":"2023-10-07T10:02:18.782965Z","shell.execute_reply.started":"2023-10-07T10:02:18.426199Z","shell.execute_reply":"2023-10-07T10:02:18.781643Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"im = Image.open('/kaggle/temp/test/test/134190.png')\nim.to_thumb(254,254)","metadata":{"papermill":{"duration":0.027522,"end_time":"2023-10-06T14:01:04.980089","exception":false,"start_time":"2023-10-06T14:01:04.952567","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-07T10:02:18.784921Z","iopub.execute_input":"2023-10-07T10:02:18.785939Z","iopub.status.idle":"2023-10-07T10:02:18.795222Z","shell.execute_reply.started":"2023-10-07T10:02:18.785903Z","shell.execute_reply":"2023-10-07T10:02:18.794148Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.016899,"end_time":"2023-10-06T14:01:05.013393","exception":false,"start_time":"2023-10-06T14:01:04.996494","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.016642,"end_time":"2023-10-06T14:01:05.046871","exception":false,"start_time":"2023-10-06T14:01:05.030229","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.017508,"end_time":"2023-10-06T14:01:05.081211","exception":false,"start_time":"2023-10-06T14:01:05.063703","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"papermill":{"duration":0.016843,"end_time":"2023-10-06T14:01:05.114832","exception":false,"start_time":"2023-10-06T14:01:05.097989","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}