{"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-01T18:19:04.547093Z","iopub.status.busy":"2023-10-01T18:19:04.546790Z","iopub.status.idle":"2023-10-01T18:19:05.245521Z","shell.execute_reply":"2023-10-01T18:19:05.244666Z"},"papermill":{"duration":0.707716,"end_time":"2023-10-01T18:19:05.247730","exception":false,"start_time":"2023-10-01T18:19:04.540014","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from fastai.vision.all import *\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:19:05.258915Z","iopub.status.busy":"2023-10-01T18:19:05.258551Z","iopub.status.idle":"2023-10-01T18:19:11.593037Z","shell.execute_reply":"2023-10-01T18:19:11.592159Z"},"papermill":{"duration":6.342217,"end_time":"2023-10-01T18:19:11.595111","exception":false,"start_time":"2023-10-01T18:19:05.252894","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!pip install py7zr\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:19:11.606225Z","iopub.status.busy":"2023-10-01T18:19:11.605973Z","iopub.status.idle":"2023-10-01T18:19:23.707257Z","shell.execute_reply":"2023-10-01T18:19:23.706129Z"},"papermill":{"duration":12.109177,"end_time":"2023-10-01T18:19:23.709500","exception":false,"start_time":"2023-10-01T18:19:11.600323","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-01T18:19:23.722579Z","iopub.status.busy":"2023-10-01T18:19:23.722288Z","iopub.status.idle":"2023-10-01T18:19:23.841752Z","shell.execute_reply":"2023-10-01T18:19:23.840884Z"},"papermill":{"duration":0.1283,"end_time":"2023-10-01T18:19:23.843766","exception":false,"start_time":"2023-10-01T18:19:23.715466","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-01T18:19:23.857181Z","iopub.status.busy":"2023-10-01T18:19:23.856334Z","iopub.status.idle":"2023-10-01T18:20:06.101655Z","shell.execute_reply":"2023-10-01T18:20:06.100803Z"},"papermill":{"duration":42.254171,"end_time":"2023-10-01T18:20:06.103787","exception":false,"start_time":"2023-10-01T18:19:23.849616","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-01T18:20:06.117782Z","iopub.status.busy":"2023-10-01T18:20:06.117217Z","iopub.status.idle":"2023-10-01T18:20:06.161473Z","shell.execute_reply":"2023-10-01T18:20:06.160383Z"},"papermill":{"duration":0.053346,"end_time":"2023-10-01T18:20:06.163313","exception":false,"start_time":"2023-10-01T18:20:06.109967","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-01T18:20:06.176801Z","iopub.status.busy":"2023-10-01T18:20:06.176207Z","iopub.status.idle":"2023-10-01T18:20:11.400323Z","shell.execute_reply":"2023-10-01T18:20:11.399335Z"},"papermill":{"duration":5.233162,"end_time":"2023-10-01T18:20:11.402449","exception":false,"start_time":"2023-10-01T18:20:06.169287","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-01T18:20:11.416981Z","iopub.status.busy":"2023-10-01T18:20:11.416668Z","iopub.status.idle":"2023-10-01T18:20:18.134911Z","shell.execute_reply":"2023-10-01T18:20:18.133965Z"},"papermill":{"duration":6.72815,"end_time":"2023-10-01T18:20:18.137003","exception":false,"start_time":"2023-10-01T18:20:11.408853","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"os.listdir('/kaggle/temp')","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:20:18.150324Z","iopub.status.busy":"2023-10-01T18:20:18.150059Z","iopub.status.idle":"2023-10-01T18:20:18.162899Z","shell.execute_reply":"2023-10-01T18:20:18.162070Z"},"papermill":{"duration":0.021314,"end_time":"2023-10-01T18:20:18.164537","exception":false,"start_time":"2023-10-01T18:20:18.143223","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"dls.show_batch()","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:20:18.178028Z","iopub.status.busy":"2023-10-01T18:20:18.177569Z","iopub.status.idle":"2023-10-01T18:20:19.335143Z","shell.execute_reply":"2023-10-01T18:20:19.334345Z"},"papermill":{"duration":1.170175,"end_time":"2023-10-01T18:20:19.340958","exception":false,"start_time":"2023-10-01T18:20:18.170783","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-01T18:20:19.364984Z","iopub.status.busy":"2023-10-01T18:20:19.364658Z","iopub.status.idle":"2023-10-01T18:20:20.639748Z","shell.execute_reply":"2023-10-01T18:20:20.638852Z"},"papermill":{"duration":1.28966,"end_time":"2023-10-01T18:20:20.641887","exception":false,"start_time":"2023-10-01T18:20:19.352227","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:20:20.668295Z","iopub.status.busy":"2023-10-01T18:20:20.668021Z","iopub.status.idle":"2023-10-01T18:20:49.384058Z","shell.execute_reply":"2023-10-01T18:20:49.382990Z"},"papermill":{"duration":28.732184,"end_time":"2023-10-01T18:20:49.386181","exception":false,"start_time":"2023-10-01T18:20:20.653997","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-01T18:20:49.417585Z","iopub.status.busy":"2023-10-01T18:20:49.416968Z","iopub.status.idle":"2023-10-01T18:29:39.371916Z","shell.execute_reply":"2023-10-01T18:29:39.370895Z"},"papermill":{"duration":529.973026,"end_time":"2023-10-01T18:29:39.373984","exception":false,"start_time":"2023-10-01T18:20:49.400958","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.unfreeze()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:29:39.401965Z","iopub.status.busy":"2023-10-01T18:29:39.401603Z","iopub.status.idle":"2023-10-01T18:29:39.407879Z","shell.execute_reply":"2023-10-01T18:29:39.407054Z"},"papermill":{"duration":0.022394,"end_time":"2023-10-01T18:29:39.409567","exception":false,"start_time":"2023-10-01T18:29:39.387173","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.lr_find()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:29:39.436841Z","iopub.status.busy":"2023-10-01T18:29:39.436075Z","iopub.status.idle":"2023-10-01T18:29:59.656644Z","shell.execute_reply":"2023-10-01T18:29:59.655715Z"},"papermill":{"duration":20.236834,"end_time":"2023-10-01T18:29:59.659054","exception":false,"start_time":"2023-10-01T18:29:39.422220","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-01T18:29:59.711800Z","iopub.status.busy":"2023-10-01T18:29:59.711364Z","iopub.status.idle":"2023-10-01T18:48:42.558616Z","shell.execute_reply":"2023-10-01T18:48:42.557561Z"},"papermill":{"duration":1122.875872,"end_time":"2023-10-01T18:48:42.560754","exception":false,"start_time":"2023-10-01T18:29:59.684882","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-01T18:48:42.590595Z","iopub.status.busy":"2023-10-01T18:48:42.589704Z","iopub.status.idle":"2023-10-01T18:48:42.594514Z","shell.execute_reply":"2023-10-01T18:48:42.593730Z"},"papermill":{"duration":0.021591,"end_time":"2023-10-01T18:48:42.596183","exception":false,"start_time":"2023-10-01T18:48:42.574592","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.recorder.plot_loss()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T18:48:42.626871Z","iopub.status.busy":"2023-10-01T18:48:42.626582Z","iopub.status.idle":"2023-10-01T18:48:42.950872Z","shell.execute_reply":"2023-10-01T18:48:42.949983Z"},"papermill":{"duration":0.342852,"end_time":"2023-10-01T18:48:42.952562","exception":false,"start_time":"2023-10-01T18:48:42.609710","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-01T18:48:42.983557Z","iopub.status.busy":"2023-10-01T18:48:42.982657Z","iopub.status.idle":"2023-10-01T19:01:55.703133Z","shell.execute_reply":"2023-10-01T19:01:55.702176Z"},"papermill":{"duration":792.738492,"end_time":"2023-10-01T19:01:55.705375","exception":false,"start_time":"2023-10-01T18:48:42.966883","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.save('/kaggle/working/vision')","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:01:55.739670Z","iopub.status.busy":"2023-10-01T19:01:55.739345Z","iopub.status.idle":"2023-10-01T19:01:56.280295Z","shell.execute_reply":"2023-10-01T19:01:56.279126Z"},"papermill":{"duration":0.56279,"end_time":"2023-10-01T19:01:56.283528","exception":false,"start_time":"2023-10-01T19:01:55.720738","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# os.listdir('/kaggle/temp/test/test')","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:01:56.360654Z","iopub.status.busy":"2023-10-01T19:01:56.360324Z","iopub.status.idle":"2023-10-01T19:01:56.380742Z","shell.execute_reply":"2023-10-01T19:01:56.379073Z"},"papermill":{"duration":0.066193,"end_time":"2023-10-01T19:01:56.390955","exception":false,"start_time":"2023-10-01T19:01:56.324762","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-01T19:01:56.450123Z","iopub.status.busy":"2023-10-01T19:01:56.449789Z","iopub.status.idle":"2023-10-01T19:01:56.732496Z","shell.execute_reply":"2023-10-01T19:01:56.730373Z"},"papermill":{"duration":0.322475,"end_time":"2023-10-01T19:01:56.735355","exception":false,"start_time":"2023-10-01T19:01:56.412880","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-01T19:01:56.768072Z","iopub.status.busy":"2023-10-01T19:01:56.767785Z","iopub.status.idle":"2023-10-01T19:01:56.980935Z","shell.execute_reply":"2023-10-01T19:01:56.979979Z"},"papermill":{"duration":0.231716,"end_time":"2023-10-01T19:01:56.983019","exception":false,"start_time":"2023-10-01T19:01:56.751303","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-01T19:01:57.016103Z","iopub.status.busy":"2023-10-01T19:01:57.015469Z","iopub.status.idle":"2023-10-01T19:01:57.027722Z","shell.execute_reply":"2023-10-01T19:01:57.026629Z"},"papermill":{"duration":0.030613,"end_time":"2023-10-01T19:01:57.029442","exception":false,"start_time":"2023-10-01T19:01:56.998829","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-01T19:01:57.061083Z","iopub.status.busy":"2023-10-01T19:01:57.060273Z","iopub.status.idle":"2023-10-01T19:11:54.941013Z","shell.execute_reply":"2023-10-01T19:11:54.939941Z"},"papermill":{"duration":597.899118,"end_time":"2023-10-01T19:11:54.943223","exception":false,"start_time":"2023-10-01T19:01:57.044105","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:54.975189Z","iopub.status.busy":"2023-10-01T19:11:54.974708Z","iopub.status.idle":"2023-10-01T19:11:54.993049Z","shell.execute_reply":"2023-10-01T19:11:54.992054Z"},"papermill":{"duration":0.036404,"end_time":"2023-10-01T19:11:54.994764","exception":false,"start_time":"2023-10-01T19:11:54.958360","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-01T19:11:55.026884Z","iopub.status.busy":"2023-10-01T19:11:55.026357Z","iopub.status.idle":"2023-10-01T19:11:55.058058Z","shell.execute_reply":"2023-10-01T19:11:55.057069Z"},"papermill":{"duration":0.049908,"end_time":"2023-10-01T19:11:55.059912","exception":false,"start_time":"2023-10-01T19:11:55.010004","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score[1].item()\n","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:55.092532Z","iopub.status.busy":"2023-10-01T19:11:55.091607Z","iopub.status.idle":"2023-10-01T19:11:55.097777Z","shell.execute_reply":"2023-10-01T19:11:55.096878Z"},"papermill":{"duration":0.024442,"end_time":"2023-10-01T19:11:55.099467","exception":false,"start_time":"2023-10-01T19:11:55.075025","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"class_score","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:55.131783Z","iopub.status.busy":"2023-10-01T19:11:55.130855Z","iopub.status.idle":"2023-10-01T19:11:55.137170Z","shell.execute_reply":"2023-10-01T19:11:55.136281Z"},"papermill":{"duration":0.024229,"end_time":"2023-10-01T19:11:55.138842","exception":false,"start_time":"2023-10-01T19:11:55.114613","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"classScore=class_score.tolist()","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:55.171316Z","iopub.status.busy":"2023-10-01T19:11:55.170242Z","iopub.status.idle":"2023-10-01T19:11:55.178123Z","shell.execute_reply":"2023-10-01T19:11:55.177309Z"},"papermill":{"duration":0.026292,"end_time":"2023-10-01T19:11:55.179772","exception":false,"start_time":"2023-10-01T19:11:55.153480","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"len(classScore)","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:55.212169Z","iopub.status.busy":"2023-10-01T19:11:55.211397Z","iopub.status.idle":"2023-10-01T19:11:55.216929Z","shell.execute_reply":"2023-10-01T19:11:55.216081Z"},"papermill":{"duration":0.023809,"end_time":"2023-10-01T19:11:55.218540","exception":false,"start_time":"2023-10-01T19:11:55.194731","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"learn.dls.vocab","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:55.250656Z","iopub.status.busy":"2023-10-01T19:11:55.250028Z","iopub.status.idle":"2023-10-01T19:11:55.256219Z","shell.execute_reply":"2023-10-01T19:11:55.255299Z"},"papermill":{"duration":0.024284,"end_time":"2023-10-01T19:11:55.257922","exception":false,"start_time":"2023-10-01T19:11:55.233638","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-01T19:11:55.290447Z","iopub.status.busy":"2023-10-01T19:11:55.289826Z","iopub.status.idle":"2023-10-01T19:11:55.294567Z","shell.execute_reply":"2023-10-01T19:11:55.293753Z"},"papermill":{"duration":0.023136,"end_time":"2023-10-01T19:11:55.296243","exception":false,"start_time":"2023-10-01T19:11:55.273107","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-01T19:11:55.328566Z","iopub.status.busy":"2023-10-01T19:11:55.327915Z","iopub.status.idle":"2023-10-01T19:11:55.336087Z","shell.execute_reply":"2023-10-01T19:11:55.335255Z"},"papermill":{"duration":0.026457,"end_time":"2023-10-01T19:11:55.337745","exception":false,"start_time":"2023-10-01T19:11:55.311288","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-01T19:11:55.370856Z","iopub.status.busy":"2023-10-01T19:11:55.369866Z","iopub.status.idle":"2023-10-01T19:11:55.472663Z","shell.execute_reply":"2023-10-01T19:11:55.471747Z"},"papermill":{"duration":0.121714,"end_time":"2023-10-01T19:11:55.474728","exception":false,"start_time":"2023-10-01T19:11:55.353014","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_classes","metadata":{"execution":{"iopub.execute_input":"2023-10-01T19:11:55.508190Z","iopub.status.busy":"2023-10-01T19:11:55.507477Z","iopub.status.idle":"2023-10-01T19:11:55.513954Z","shell.execute_reply":"2023-10-01T19:11:55.513043Z"},"papermill":{"duration":0.025218,"end_time":"2023-10-01T19:11:55.515638","exception":false,"start_time":"2023-10-01T19:11:55.490420","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-01T19:11:55.548421Z","iopub.status.busy":"2023-10-01T19:11:55.547744Z","iopub.status.idle":"2023-10-01T19:11:55.882265Z","shell.execute_reply":"2023-10-01T19:11:55.881323Z"},"papermill":{"duration":0.353593,"end_time":"2023-10-01T19:11:55.884377","exception":false,"start_time":"2023-10-01T19:11:55.530784","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-01T19:11:55.918629Z","iopub.status.busy":"2023-10-01T19:11:55.917538Z","iopub.status.idle":"2023-10-01T19:11:56.308827Z","shell.execute_reply":"2023-10-01T19:11:56.307957Z"},"papermill":{"duration":0.410339,"end_time":"2023-10-01T19:11:56.310592","exception":false,"start_time":"2023-10-01T19:11:55.900253","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-01T19:11:56.345157Z","iopub.status.busy":"2023-10-01T19:11:56.344451Z","iopub.status.idle":"2023-10-01T19:11:56.379656Z","shell.execute_reply":"2023-10-01T19:11:56.378744Z"},"papermill":{"duration":0.054866,"end_time":"2023-10-01T19:11:56.381609","exception":false,"start_time":"2023-10-01T19:11:56.326743","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-01T19:11:56.422305Z","iopub.status.busy":"2023-10-01T19:11:56.421908Z","iopub.status.idle":"2023-10-01T19:11:57.046772Z","shell.execute_reply":"2023-10-01T19:11:57.045538Z"},"papermill":{"duration":0.652431,"end_time":"2023-10-01T19:11:57.049951","exception":false,"start_time":"2023-10-01T19:11:56.397520","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-01T19:11:57.124352Z","iopub.status.busy":"2023-10-01T19:11:57.123858Z","iopub.status.idle":"2023-10-01T19:11:57.134075Z","shell.execute_reply":"2023-10-01T19:11:57.133297Z"},"papermill":{"duration":0.0427,"end_time":"2023-10-01T19:11:57.136379","exception":false,"start_time":"2023-10-01T19:11:57.093679","status":"completed"},"tags":[]},"execution_count":null,"outputs":[]}]}