{"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","execution":{"iopub.execute_input":"2023-10-01T19:22:26.327180Z","iopub.status.busy":"2023-10-01T19:22:26.326853Z","iopub.status.idle":"2023-10-01T19:22:27.028419Z","shell.execute_reply":"2023-10-01T19:22:27.027580Z"},"papermill":{"duration":0.710499,"end_time":"2023-10-01T19:22:27.030599","exception":false,"start_time":"2023-10-01T19:22:26.320100","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from fastai.vision.all import *\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:22:27.041878Z","iopub.status.busy":"2023-10-01T19:22:27.041260Z","iopub.status.idle":"2023-10-01T19:22:33.440209Z","shell.execute_reply":"2023-10-01T19:22:33.439235Z"},"papermill":{"duration":6.407337,"end_time":"2023-10-01T19:22:33.443056","exception":false,"start_time":"2023-10-01T19:22:27.035719","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install py7zr\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:22:33.462775Z","iopub.status.busy":"2023-10-01T19:22:33.462376Z","iopub.status.idle":"2023-10-01T19:22:45.299205Z","shell.execute_reply":"2023-10-01T19:22:45.298041Z"},"papermill":{"duration":11.848744,"end_time":"2023-10-01T19:22:45.301353","exception":false,"start_time":"2023-10-01T19:22:33.452609","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from py7zr import unpack_7zarchive\nimport shutil\nshutil.register_unpack_format('7zip',['.7z'],unpack_7zarchive)","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:22:45.314823Z","iopub.status.busy":"2023-10-01T19:22:45.314526Z","iopub.status.idle":"2023-10-01T19:22:45.433924Z","shell.execute_reply":"2023-10-01T19:22:45.433132Z"},"papermill":{"duration":0.128359,"end_time":"2023-10-01T19:22:45.435801","exception":false,"start_time":"2023-10-01T19:22:45.307442","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"shutil.unpack_archive('../input/cifar-10/train.7z', '/kaggle/temp/')\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:22:45.448489Z","iopub.status.busy":"2023-10-01T19:22:45.448246Z","iopub.status.idle":"2023-10-01T19:23:27.200275Z","shell.execute_reply":"2023-10-01T19:23:27.199326Z"},"papermill":{"duration":41.760729,"end_time":"2023-10-01T19:23:27.202436","exception":false,"start_time":"2023-10-01T19:22:45.441707","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T19:23:27.216261Z","iopub.status.busy":"2023-10-01T19:23:27.215330Z","iopub.status.idle":"2023-10-01T19:23:27.263559Z","shell.execute_reply":"2023-10-01T19:23:27.262508Z"},"papermill":{"duration":0.056652,"end_time":"2023-10-01T19:23:27.265239","exception":false,"start_time":"2023-10-01T19:23:27.208587","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T19:23:27.277983Z","iopub.status.busy":"2023-10-01T19:23:27.277737Z","iopub.status.idle":"2023-10-01T19:23:32.468276Z","shell.execute_reply":"2023-10-01T19:23:32.467349Z"},"papermill":{"duration":5.199322,"end_time":"2023-10-01T19:23:32.470390","exception":false,"start_time":"2023-10-01T19:23:27.271068","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T19:23:32.484641Z","iopub.status.busy":"2023-10-01T19:23:32.484366Z","iopub.status.idle":"2023-10-01T19:23:39.734734Z","shell.execute_reply":"2023-10-01T19:23:39.733868Z"},"papermill":{"duration":7.260105,"end_time":"2023-10-01T19:23:39.736783","exception":false,"start_time":"2023-10-01T19:23:32.476678","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir('/kaggle/temp')","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:23:39.750116Z","iopub.status.busy":"2023-10-01T19:23:39.749810Z","iopub.status.idle":"2023-10-01T19:23:39.756756Z","shell.execute_reply":"2023-10-01T19:23:39.755818Z"},"papermill":{"duration":0.015299,"end_time":"2023-10-01T19:23:39.758402","exception":false,"start_time":"2023-10-01T19:23:39.743103","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dls.show_batch()","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:23:39.772094Z","iopub.status.busy":"2023-10-01T19:23:39.771371Z","iopub.status.idle":"2023-10-01T19:23:40.944193Z","shell.execute_reply":"2023-10-01T19:23:40.943199Z"},"papermill":{"duration":1.185561,"end_time":"2023-10-01T19:23:40.950200","exception":false,"start_time":"2023-10-01T19:23:39.764639","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn = vision_learner(dls, resnet50, metrics=accuracy)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:23:40.975441Z","iopub.status.busy":"2023-10-01T19:23:40.975158Z","iopub.status.idle":"2023-10-01T19:23:42.182734Z","shell.execute_reply":"2023-10-01T19:23:42.181810Z"},"papermill":{"duration":1.222801,"end_time":"2023-10-01T19:23:42.184902","exception":false,"start_time":"2023-10-01T19:23:40.962101","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:23:42.211641Z","iopub.status.busy":"2023-10-01T19:23:42.210802Z","iopub.status.idle":"2023-10-01T19:24:11.337132Z","shell.execute_reply":"2023-10-01T19:24:11.336195Z"},"papermill":{"duration":29.141537,"end_time":"2023-10-01T19:24:11.338894","exception":false,"start_time":"2023-10-01T19:23:42.197357","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(10, 3e-3)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:24:11.367825Z","iopub.status.busy":"2023-10-01T19:24:11.367171Z","iopub.status.idle":"2023-10-01T19:32:59.485174Z","shell.execute_reply":"2023-10-01T19:32:59.484110Z"},"papermill":{"duration":528.134495,"end_time":"2023-10-01T19:32:59.487114","exception":false,"start_time":"2023-10-01T19:24:11.352619","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.unfreeze()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:32:59.516535Z","iopub.status.busy":"2023-10-01T19:32:59.516110Z","iopub.status.idle":"2023-10-01T19:32:59.522429Z","shell.execute_reply":"2023-10-01T19:32:59.521621Z"},"papermill":{"duration":0.022755,"end_time":"2023-10-01T19:32:59.524040","exception":false,"start_time":"2023-10-01T19:32:59.501285","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:32:59.551896Z","iopub.status.busy":"2023-10-01T19:32:59.551637Z","iopub.status.idle":"2023-10-01T19:33:18.988942Z","shell.execute_reply":"2023-10-01T19:33:18.987906Z"},"papermill":{"duration":19.453534,"end_time":"2023-10-01T19:33:18.990888","exception":false,"start_time":"2023-10-01T19:32:59.537354","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.fit_one_cycle(5, lr_max=slice(1e-6,3e-5))\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:33:19.021856Z","iopub.status.busy":"2023-10-01T19:33:19.021569Z","iopub.status.idle":"2023-10-01T19:51:58.700171Z","shell.execute_reply":"2023-10-01T19:51:58.699129Z"},"papermill":{"duration":1119.696267,"end_time":"2023-10-01T19:51:58.702129","exception":false,"start_time":"2023-10-01T19:33:19.005862","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#from fastai.callback.fp16 import *\n# learn = vision_learner(dls, resnet18, metrics=accuracy)\n# learn.fine_tune(10, freeze_epochs=3)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:51:58.734356Z","iopub.status.busy":"2023-10-01T19:51:58.733477Z","iopub.status.idle":"2023-10-01T19:51:58.738286Z","shell.execute_reply":"2023-10-01T19:51:58.737474Z"},"papermill":{"duration":0.022895,"end_time":"2023-10-01T19:51:58.739961","exception":false,"start_time":"2023-10-01T19:51:58.717066","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.recorder.plot_loss()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:51:58.770717Z","iopub.status.busy":"2023-10-01T19:51:58.770441Z","iopub.status.idle":"2023-10-01T19:51:59.116998Z","shell.execute_reply":"2023-10-01T19:51:59.116092Z"},"papermill":{"duration":0.364298,"end_time":"2023-10-01T19:51:59.118861","exception":false,"start_time":"2023-10-01T19:51:58.754563","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T19:51:59.153370Z","iopub.status.busy":"2023-10-01T19:51:59.152838Z","iopub.status.idle":"2023-10-01T20:05:05.444561Z","shell.execute_reply":"2023-10-01T20:05:05.443532Z"},"papermill":{"duration":786.311713,"end_time":"2023-10-01T20:05:05.447014","exception":false,"start_time":"2023-10-01T19:51:59.135301","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.save('/kaggle/working/vision')","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:05:05.479806Z","iopub.status.busy":"2023-10-01T20:05:05.479201Z","iopub.status.idle":"2023-10-01T20:05:06.019699Z","shell.execute_reply":"2023-10-01T20:05:06.018761Z"},"papermill":{"duration":0.558722,"end_time":"2023-10-01T20:05:06.021582","exception":false,"start_time":"2023-10-01T20:05:05.462860","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# os.listdir('/kaggle/temp/test/test')","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:05:06.056739Z","iopub.status.busy":"2023-10-01T20:05:06.055835Z","iopub.status.idle":"2023-10-01T20:05:06.060801Z","shell.execute_reply":"2023-10-01T20:05:06.059868Z"},"papermill":{"duration":0.025497,"end_time":"2023-10-01T20:05:06.062797","exception":false,"start_time":"2023-10-01T20:05:06.037300","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(os.listdir('/kaggle/temp/test/test'))","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:05:06.099696Z","iopub.status.busy":"2023-10-01T20:05:06.099389Z","iopub.status.idle":"2023-10-01T20:05:06.263334Z","shell.execute_reply":"2023-10-01T20:05:06.262338Z"},"papermill":{"duration":0.185142,"end_time":"2023-10-01T20:05:06.265279","exception":false,"start_time":"2023-10-01T20:05:06.080137","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T20:05:06.300214Z","iopub.status.busy":"2023-10-01T20:05:06.299395Z","iopub.status.idle":"2023-10-01T20:05:06.502039Z","shell.execute_reply":"2023-10-01T20:05:06.501169Z"},"papermill":{"duration":0.222496,"end_time":"2023-10-01T20:05:06.504265","exception":false,"start_time":"2023-10-01T20:05:06.281769","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_dl=learn.dls.test_dl(new)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:05:06.537152Z","iopub.status.busy":"2023-10-01T20:05:06.536318Z","iopub.status.idle":"2023-10-01T20:05:06.546861Z","shell.execute_reply":"2023-10-01T20:05:06.546072Z"},"papermill":{"duration":0.028949,"end_time":"2023-10-01T20:05:06.548612","exception":false,"start_time":"2023-10-01T20:05:06.519663","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score,y=learn.get_preds(dl=test_dl)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:05:06.580120Z","iopub.status.busy":"2023-10-01T20:05:06.579845Z","iopub.status.idle":"2023-10-01T20:15:08.364679Z","shell.execute_reply":"2023-10-01T20:15:08.363591Z"},"papermill":{"duration":601.803457,"end_time":"2023-10-01T20:15:08.366879","exception":false,"start_time":"2023-10-01T20:05:06.563422","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.401310Z","iopub.status.busy":"2023-10-01T20:15:08.400449Z","iopub.status.idle":"2023-10-01T20:15:08.417489Z","shell.execute_reply":"2023-10-01T20:15:08.416577Z"},"papermill":{"duration":0.035563,"end_time":"2023-10-01T20:15:08.419125","exception":false,"start_time":"2023-10-01T20:15:08.383562","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score = np.argmax(class_score, axis=1)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.452376Z","iopub.status.busy":"2023-10-01T20:15:08.451577Z","iopub.status.idle":"2023-10-01T20:15:08.479841Z","shell.execute_reply":"2023-10-01T20:15:08.479054Z"},"papermill":{"duration":0.047358,"end_time":"2023-10-01T20:15:08.482142","exception":false,"start_time":"2023-10-01T20:15:08.434784","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score[1].item()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.516433Z","iopub.status.busy":"2023-10-01T20:15:08.516189Z","iopub.status.idle":"2023-10-01T20:15:08.521841Z","shell.execute_reply":"2023-10-01T20:15:08.520899Z"},"papermill":{"duration":0.024245,"end_time":"2023-10-01T20:15:08.523504","exception":false,"start_time":"2023-10-01T20:15:08.499259","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.555999Z","iopub.status.busy":"2023-10-01T20:15:08.555766Z","iopub.status.idle":"2023-10-01T20:15:08.561422Z","shell.execute_reply":"2023-10-01T20:15:08.560613Z"},"papermill":{"duration":0.023981,"end_time":"2023-10-01T20:15:08.562968","exception":false,"start_time":"2023-10-01T20:15:08.538987","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classScore=class_score.tolist()","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.596401Z","iopub.status.busy":"2023-10-01T20:15:08.595735Z","iopub.status.idle":"2023-10-01T20:15:08.603073Z","shell.execute_reply":"2023-10-01T20:15:08.602177Z"},"papermill":{"duration":0.026301,"end_time":"2023-10-01T20:15:08.604678","exception":false,"start_time":"2023-10-01T20:15:08.578377","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(classScore)","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.637841Z","iopub.status.busy":"2023-10-01T20:15:08.637242Z","iopub.status.idle":"2023-10-01T20:15:08.643008Z","shell.execute_reply":"2023-10-01T20:15:08.642185Z"},"papermill":{"duration":0.024531,"end_time":"2023-10-01T20:15:08.644639","exception":false,"start_time":"2023-10-01T20:15:08.620108","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.dls.vocab","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.679179Z","iopub.status.busy":"2023-10-01T20:15:08.678383Z","iopub.status.idle":"2023-10-01T20:15:08.684200Z","shell.execute_reply":"2023-10-01T20:15:08.683347Z"},"papermill":{"duration":0.025302,"end_time":"2023-10-01T20:15:08.685856","exception":false,"start_time":"2023-10-01T20:15:08.660554","status":"completed"},"tags":[]},"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'}","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.720222Z","iopub.status.busy":"2023-10-01T20:15:08.719331Z","iopub.status.idle":"2023-10-01T20:15:08.724256Z","shell.execute_reply":"2023-10-01T20:15:08.723421Z"},"papermill":{"duration":0.024222,"end_time":"2023-10-01T20:15:08.725967","exception":false,"start_time":"2023-10-01T20:15:08.701745","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_classes=np.empty(shape=300000,dtype=np.dtype('U20'))","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.777329Z","iopub.status.busy":"2023-10-01T20:15:08.776934Z","iopub.status.idle":"2023-10-01T20:15:08.786672Z","shell.execute_reply":"2023-10-01T20:15:08.785821Z"},"papermill":{"duration":0.045949,"end_time":"2023-10-01T20:15:08.788548","exception":false,"start_time":"2023-10-01T20:15:08.742599","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.823890Z","iopub.status.busy":"2023-10-01T20:15:08.823413Z","iopub.status.idle":"2023-10-01T20:15:08.924815Z","shell.execute_reply":"2023-10-01T20:15:08.923843Z"},"papermill":{"duration":0.12176,"end_time":"2023-10-01T20:15:08.927045","exception":false,"start_time":"2023-10-01T20:15:08.805285","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_classes","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:08.963292Z","iopub.status.busy":"2023-10-01T20:15:08.962385Z","iopub.status.idle":"2023-10-01T20:15:08.968691Z","shell.execute_reply":"2023-10-01T20:15:08.967791Z"},"papermill":{"duration":0.026367,"end_time":"2023-10-01T20:15:08.970351","exception":false,"start_time":"2023-10-01T20:15:08.943984","status":"completed"},"tags":[]},"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)]","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:09.004935Z","iopub.status.busy":"2023-10-01T20:15:09.004228Z","iopub.status.idle":"2023-10-01T20:15:09.332260Z","shell.execute_reply":"2023-10-01T20:15:09.331318Z"},"papermill":{"duration":0.347666,"end_time":"2023-10-01T20:15:09.334260","exception":false,"start_time":"2023-10-01T20:15:08.986594","status":"completed"},"tags":[]},"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":{"execution":{"iopub.execute_input":"2023-10-01T20:15:09.370202Z","iopub.status.busy":"2023-10-01T20:15:09.369906Z","iopub.status.idle":"2023-10-01T20:15:09.760360Z","shell.execute_reply":"2023-10-01T20:15:09.759448Z"},"papermill":{"duration":0.410366,"end_time":"2023-10-01T20:15:09.762112","exception":false,"start_time":"2023-10-01T20:15:09.351746","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission['id']=submission['id'].astype(int)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:09.798166Z","iopub.status.busy":"2023-10-01T20:15:09.797262Z","iopub.status.idle":"2023-10-01T20:15:09.831663Z","shell.execute_reply":"2023-10-01T20:15:09.831062Z"},"papermill":{"duration":0.054469,"end_time":"2023-10-01T20:15:09.833418","exception":false,"start_time":"2023-10-01T20:15:09.778949","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:09.869112Z","iopub.status.busy":"2023-10-01T20:15:09.868459Z","iopub.status.idle":"2023-10-01T20:15:10.181523Z","shell.execute_reply":"2023-10-01T20:15:10.180349Z"},"papermill":{"duration":0.333934,"end_time":"2023-10-01T20:15:10.184245","exception":false,"start_time":"2023-10-01T20:15:09.850311","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"im = Image.open('/kaggle/temp/test/test/134190.png')\nim.to_thumb(254,254)\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T20:15:10.220610Z","iopub.status.busy":"2023-10-01T20:15:10.220310Z","iopub.status.idle":"2023-10-01T20:15:10.227462Z","shell.execute_reply":"2023-10-01T20:15:10.226546Z"},"papermill":{"duration":0.027393,"end_time":"2023-10-01T20:15:10.229127","exception":false,"start_time":"2023-10-01T20:15:10.201734","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}