{"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.31375","exception":false,"start_time":"2023-10-06T10:31:59.628474","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T18:06:05.631527Z","iopub.execute_input":"2023-10-17T18:06:05.631811Z","iopub.status.idle":"2023-10-17T18:06:05.927630Z","shell.execute_reply.started":"2023-10-17T18:06:05.631789Z","shell.execute_reply":"2023-10-17T18:06:05.926835Z"},"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.05807","exception":false,"start_time":"2023-10-06T10:32:00.32028","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T18:06:05.928899Z","iopub.execute_input":"2023-10-17T18:06:05.929271Z","iopub.status.idle":"2023-10-17T18:06:10.511497Z","shell.execute_reply.started":"2023-10-17T18:06:05.929249Z","shell.execute_reply":"2023-10-17T18:06:10.510773Z"},"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.06481","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T18:06:10.512465Z","iopub.execute_input":"2023-10-17T18:06:10.512696Z","iopub.status.idle":"2023-10-17T18:06:21.490338Z","shell.execute_reply.started":"2023-10-17T18:06:10.512674Z","shell.execute_reply":"2023-10-17T18:06:21.489297Z"},"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-17T18:06:21.492408Z","iopub.execute_input":"2023-10-17T18:06:21.492649Z","iopub.status.idle":"2023-10-17T18:06:21.610576Z","shell.execute_reply.started":"2023-10-17T18:06:21.492629Z","shell.execute_reply":"2023-10-17T18:06:21.609903Z"},"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-17T18:06:21.611529Z","iopub.execute_input":"2023-10-17T18:06:21.611747Z","iopub.status.idle":"2023-10-17T18:07:02.375142Z","shell.execute_reply.started":"2023-10-17T18:06:21.611729Z","shell.execute_reply":"2023-10-17T18:07:02.373572Z"},"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-17T18:07:02.376907Z","iopub.execute_input":"2023-10-17T18:07:02.377433Z","iopub.status.idle":"2023-10-17T18:07:02.441173Z","shell.execute_reply.started":"2023-10-17T18:07:02.377393Z","shell.execute_reply":"2023-10-17T18:07:02.440182Z"},"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-17T18:07:02.442608Z","iopub.execute_input":"2023-10-17T18:07:02.443236Z","iopub.status.idle":"2023-10-17T18:07:08.004545Z","shell.execute_reply.started":"2023-10-17T18:07:02.443201Z","shell.execute_reply":"2023-10-17T18:07:08.003823Z"},"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-17T18:07:08.005703Z","iopub.execute_input":"2023-10-17T18:07:08.005929Z","iopub.status.idle":"2023-10-17T18:07:13.843059Z","shell.execute_reply.started":"2023-10-17T18:07:08.005911Z","shell.execute_reply":"2023-10-17T18:07:13.842350Z"},"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-17T18:07:13.844218Z","iopub.execute_input":"2023-10-17T18:07:13.844449Z","iopub.status.idle":"2023-10-17T18:07:13.850132Z","shell.execute_reply.started":"2023-10-17T18:07:13.844430Z","shell.execute_reply":"2023-10-17T18:07:13.849461Z"},"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-17T18:07:13.852839Z","iopub.execute_input":"2023-10-17T18:07:13.853165Z","iopub.status.idle":"2023-10-17T18:07:14.928684Z","shell.execute_reply.started":"2023-10-17T18:07:13.853143Z","shell.execute_reply":"2023-10-17T18:07:14.928092Z"},"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-17T18:07:14.929377Z","iopub.execute_input":"2023-10-17T18:07:14.929587Z","iopub.status.idle":"2023-10-17T18:07:16.013734Z","shell.execute_reply.started":"2023-10-17T18:07:14.929560Z","shell.execute_reply":"2023-10-17T18:07:16.013016Z"},"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-17T18:07:16.014761Z","iopub.execute_input":"2023-10-17T18:07:16.014972Z","iopub.status.idle":"2023-10-17T18:07:42.670420Z","shell.execute_reply.started":"2023-10-17T18:07:16.014955Z","shell.execute_reply":"2023-10-17T18:07:42.669785Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(20, 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-17T18:42:39.057485Z","iopub.execute_input":"2023-10-17T18:42:39.058021Z","iopub.status.idle":"2023-10-17T19:37:49.786844Z","shell.execute_reply.started":"2023-10-17T18:42:39.057985Z","shell.execute_reply":"2023-10-17T19:37:49.785964Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.unfreeze()","metadata":{"papermill":{"duration":0.023875,"end_time":"2023-10-06T12:03:06.238","exception":false,"start_time":"2023-10-06T12:03:06.214125","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T19:40:22.013134Z","iopub.execute_input":"2023-10-17T19:40:22.013449Z","iopub.status.idle":"2023-10-17T19:40:22.019382Z","shell.execute_reply.started":"2023-10-17T19:40:22.013429Z","shell.execute_reply":"2023-10-17T19:40:22.018716Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(20, 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-17T19:40:25.452476Z","iopub.execute_input":"2023-10-17T19:40:25.452770Z","iopub.status.idle":"2023-10-17T19:40:41.640609Z","shell.execute_reply.started":"2023-10-17T19:40:25.452747Z","shell.execute_reply":"2023-10-17T19:40:41.638375Z"},"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-17T19:40:52.445450Z","iopub.execute_input":"2023-10-17T19:40:52.445852Z","iopub.status.idle":"2023-10-17T19:40:52.677396Z","shell.execute_reply.started":"2023-10-17T19:40:52.445827Z","shell.execute_reply":"2023-10-17T19:40:52.676761Z"},"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-17T19:40:58.931572Z","iopub.execute_input":"2023-10-17T19:40:58.931872Z","iopub.status.idle":"2023-10-17T19:53:42.494472Z","shell.execute_reply.started":"2023-10-17T19:40:58.931850Z","shell.execute_reply":"2023-10-17T19:53:42.493708Z"},"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-17T20:02:10.686286Z","iopub.execute_input":"2023-10-17T20:02:10.686592Z","iopub.status.idle":"2023-10-17T20:02:11.556221Z","shell.execute_reply.started":"2023-10-17T20:02:10.686573Z","shell.execute_reply":"2023-10-17T20:02:11.554344Z"},"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-17T20:02:14.106643Z","iopub.execute_input":"2023-10-17T20:02:14.106936Z","iopub.status.idle":"2023-10-17T20:02:14.272644Z","shell.execute_reply.started":"2023-10-17T20:02:14.106915Z","shell.execute_reply":"2023-10-17T20:02:14.272005Z"},"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-17T20:02:18.763978Z","iopub.execute_input":"2023-10-17T20:02:18.764572Z","iopub.status.idle":"2023-10-17T20:02:18.966207Z","shell.execute_reply.started":"2023-10-17T20:02:18.764546Z","shell.execute_reply":"2023-10-17T20:02:18.965548Z"},"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-17T20:02:24.196822Z","iopub.execute_input":"2023-10-17T20:02:24.197204Z","iopub.status.idle":"2023-10-17T20:02:24.208204Z","shell.execute_reply.started":"2023-10-17T20:02:24.197089Z","shell.execute_reply":"2023-10-17T20:02:24.207493Z"},"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.74558","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T20:02:26.372146Z","iopub.execute_input":"2023-10-17T20:02:26.372429Z","iopub.status.idle":"2023-10-17T20:11:32.059781Z","shell.execute_reply.started":"2023-10-17T20:02:26.372410Z","shell.execute_reply":"2023-10-17T20:11:32.058830Z"},"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.08849","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T20:11:38.510948Z","iopub.execute_input":"2023-10-17T20:11:38.511290Z","iopub.status.idle":"2023-10-17T20:11:38.527239Z","shell.execute_reply.started":"2023-10-17T20:11:38.511263Z","shell.execute_reply":"2023-10-17T20:11:38.526634Z"},"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-17T20:11:44.179375Z","iopub.execute_input":"2023-10-17T20:11:44.179964Z","iopub.status.idle":"2023-10-17T20:11:44.316605Z","shell.execute_reply.started":"2023-10-17T20:11:44.179939Z","shell.execute_reply":"2023-10-17T20:11:44.314971Z"},"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-17T20:11:48.585404Z","iopub.execute_input":"2023-10-17T20:11:48.585705Z","iopub.status.idle":"2023-10-17T20:11:48.590662Z","shell.execute_reply.started":"2023-10-17T20:11:48.585682Z","shell.execute_reply":"2023-10-17T20:11:48.590082Z"},"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-17T20:11:51.150768Z","iopub.execute_input":"2023-10-17T20:11:51.151059Z","iopub.status.idle":"2023-10-17T20:11:51.156149Z","shell.execute_reply.started":"2023-10-17T20:11:51.151038Z","shell.execute_reply":"2023-10-17T20:11:51.155593Z"},"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-17T20:11:53.568954Z","iopub.execute_input":"2023-10-17T20:11:53.569262Z","iopub.status.idle":"2023-10-17T20:11:53.575930Z","shell.execute_reply.started":"2023-10-17T20:11:53.569239Z","shell.execute_reply":"2023-10-17T20:11:53.575334Z"},"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-17T20:11:56.645018Z","iopub.execute_input":"2023-10-17T20:11:56.645337Z","iopub.status.idle":"2023-10-17T20:11:56.649998Z","shell.execute_reply.started":"2023-10-17T20:11:56.645315Z","shell.execute_reply":"2023-10-17T20:11:56.649401Z"},"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-17T20:11:59.688705Z","iopub.execute_input":"2023-10-17T20:11:59.688985Z","iopub.status.idle":"2023-10-17T20:11:59.693814Z","shell.execute_reply.started":"2023-10-17T20:11:59.688964Z","shell.execute_reply":"2023-10-17T20:11:59.693288Z"},"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-17T20:12:02.652394Z","iopub.execute_input":"2023-10-17T20:12:02.652688Z","iopub.status.idle":"2023-10-17T20:12:02.656521Z","shell.execute_reply.started":"2023-10-17T20:12:02.652667Z","shell.execute_reply":"2023-10-17T20:12:02.655922Z"},"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-17T20:12:06.070189Z","iopub.execute_input":"2023-10-17T20:12:06.070474Z","iopub.status.idle":"2023-10-17T20:12:06.077680Z","shell.execute_reply.started":"2023-10-17T20:12:06.070454Z","shell.execute_reply":"2023-10-17T20:12:06.077029Z"},"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.50091","status":"completed"},"tags":[],"execution":{"iopub.status.busy":"2023-10-17T20:12:09.631722Z","iopub.execute_input":"2023-10-17T20:12:09.632016Z","iopub.status.idle":"2023-10-17T20:12:09.741981Z","shell.execute_reply.started":"2023-10-17T20:12:09.631995Z","shell.execute_reply":"2023-10-17T20:12:09.741370Z"},"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-17T20:12:16.650030Z","iopub.execute_input":"2023-10-17T20:12:16.650339Z","iopub.status.idle":"2023-10-17T20:12:16.655249Z","shell.execute_reply.started":"2023-10-17T20:12:16.650318Z","shell.execute_reply":"2023-10-17T20:12:16.654562Z"},"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-17T20:12:19.392880Z","iopub.execute_input":"2023-10-17T20:12:19.393226Z","iopub.status.idle":"2023-10-17T20:12:19.729331Z","shell.execute_reply.started":"2023-10-17T20:12:19.393198Z","shell.execute_reply":"2023-10-17T20:12:19.728673Z"},"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-17T20:12:22.571265Z","iopub.execute_input":"2023-10-17T20:12:22.571836Z","iopub.status.idle":"2023-10-17T20:12:22.947064Z","shell.execute_reply.started":"2023-10-17T20:12:22.571811Z","shell.execute_reply":"2023-10-17T20:12:22.946455Z"},"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-17T20:12:29.060240Z","iopub.execute_input":"2023-10-17T20:12:29.060524Z","iopub.status.idle":"2023-10-17T20:12:29.096077Z","shell.execute_reply.started":"2023-10-17T20:12:29.060503Z","shell.execute_reply":"2023-10-17T20:12:29.095380Z"},"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-17T20:12:34.487160Z","iopub.execute_input":"2023-10-17T20:12:34.487441Z","iopub.status.idle":"2023-10-17T20:12:34.814935Z","shell.execute_reply.started":"2023-10-17T20:12:34.487422Z","shell.execute_reply":"2023-10-17T20:12:34.813776Z"},"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-17T20:12:37.364656Z","iopub.execute_input":"2023-10-17T20:12:37.365273Z","iopub.status.idle":"2023-10-17T20:12:37.374150Z","shell.execute_reply.started":"2023-10-17T20:12:37.365246Z","shell.execute_reply":"2023-10-17T20:12:37.373516Z"},"trusted":true},"execution_count":null,"outputs":[]}]}