{"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-17T11:39:56.413777Z","iopub.execute_input":"2023-10-17T11:39:56.414176Z","iopub.status.idle":"2023-10-17T11:39:56.902998Z","shell.execute_reply.started":"2023-10-17T11:39:56.414138Z","shell.execute_reply":"2023-10-17T11:39:56.902104Z"},"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-17T11:39:56.907418Z","iopub.execute_input":"2023-10-17T11:39:56.909598Z","iopub.status.idle":"2023-10-17T11:40:03.469144Z","shell.execute_reply.started":"2023-10-17T11:39:56.909550Z","shell.execute_reply":"2023-10-17T11:40:03.468180Z"},"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-17T11:40:03.473601Z","iopub.execute_input":"2023-10-17T11:40:03.475756Z","iopub.status.idle":"2023-10-17T11:40:22.863860Z","shell.execute_reply.started":"2023-10-17T11:40:03.475717Z","shell.execute_reply":"2023-10-17T11:40:22.862677Z"},"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-17T11:40:22.870059Z","iopub.execute_input":"2023-10-17T11:40:22.872183Z","iopub.status.idle":"2023-10-17T11:40:23.066600Z","shell.execute_reply.started":"2023-10-17T11:40:22.872148Z","shell.execute_reply":"2023-10-17T11:40:23.065654Z"},"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-17T11:40:23.071050Z","iopub.execute_input":"2023-10-17T11:40:23.073138Z","iopub.status.idle":"2023-10-17T11:41:34.242082Z","shell.execute_reply.started":"2023-10-17T11:40:23.073105Z","shell.execute_reply":"2023-10-17T11:41:34.241086Z"},"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-17T11:41:34.243509Z","iopub.execute_input":"2023-10-17T11:41:34.244146Z","iopub.status.idle":"2023-10-17T11:41:34.334890Z","shell.execute_reply.started":"2023-10-17T11:41:34.244114Z","shell.execute_reply":"2023-10-17T11:41:34.333852Z"},"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-17T11:41:34.341657Z","iopub.execute_input":"2023-10-17T11:41:34.343968Z","iopub.status.idle":"2023-10-17T11:41:43.934521Z","shell.execute_reply.started":"2023-10-17T11:41:34.343934Z","shell.execute_reply":"2023-10-17T11:41:43.933505Z"},"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-17T11:41:43.939046Z","iopub.execute_input":"2023-10-17T11:41:43.941161Z","iopub.status.idle":"2023-10-17T11:41:54.019673Z","shell.execute_reply.started":"2023-10-17T11:41:43.941129Z","shell.execute_reply":"2023-10-17T11:41:54.018664Z"},"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-17T11:41:54.024324Z","iopub.execute_input":"2023-10-17T11:41:54.026471Z","iopub.status.idle":"2023-10-17T11:41:54.038185Z","shell.execute_reply.started":"2023-10-17T11:41:54.026437Z","shell.execute_reply":"2023-10-17T11:41:54.037119Z"},"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-17T11:41:54.045873Z","iopub.execute_input":"2023-10-17T11:41:54.047944Z","iopub.status.idle":"2023-10-17T11:41:55.774484Z","shell.execute_reply.started":"2023-10-17T11:41:54.047913Z","shell.execute_reply":"2023-10-17T11:41:55.773480Z"},"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-17T11:41:55.775541Z","iopub.execute_input":"2023-10-17T11:41:55.775859Z","iopub.status.idle":"2023-10-17T11:41:57.538377Z","shell.execute_reply.started":"2023-10-17T11:41:55.775829Z","shell.execute_reply":"2023-10-17T11:41:57.537416Z"},"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-17T11:41:57.543069Z","iopub.execute_input":"2023-10-17T11:41:57.545199Z","iopub.status.idle":"2023-10-17T11:42:28.880644Z","shell.execute_reply.started":"2023-10-17T11:41:57.545166Z","shell.execute_reply":"2023-10-17T11:42:28.879638Z"},"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-17T11:42:28.885014Z","iopub.execute_input":"2023-10-17T11:42:28.887104Z","iopub.status.idle":"2023-10-17T13:26:26.802676Z","shell.execute_reply.started":"2023-10-17T11:42:28.887071Z","shell.execute_reply":"2023-10-17T13:26:26.801528Z"},"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-17T13:26:26.804772Z","iopub.execute_input":"2023-10-17T13:26:26.805147Z","iopub.status.idle":"2023-10-17T13:26:26.812057Z","shell.execute_reply.started":"2023-10-17T13:26:26.805112Z","shell.execute_reply":"2023-10-17T13:26:26.811024Z"},"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-17T13:26:26.813805Z","iopub.execute_input":"2023-10-17T13:26:26.814376Z","iopub.status.idle":"2023-10-17T15:19:01.611300Z","shell.execute_reply.started":"2023-10-17T13:26:26.814344Z","shell.execute_reply":"2023-10-17T15:19:01.610180Z"},"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-17T15:19:01.613400Z","iopub.execute_input":"2023-10-17T15:19:01.614109Z","iopub.status.idle":"2023-10-17T15:19:02.301255Z","shell.execute_reply.started":"2023-10-17T15:19:01.614072Z","shell.execute_reply":"2023-10-17T15:19:02.300340Z"},"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-17T15:19:02.302671Z","iopub.execute_input":"2023-10-17T15:19:02.303238Z","iopub.status.idle":"2023-10-17T15:32:10.700549Z","shell.execute_reply.started":"2023-10-17T15:19:02.303204Z","shell.execute_reply":"2023-10-17T15:32:10.699518Z"},"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-17T15:32:10.701843Z","iopub.execute_input":"2023-10-17T15:32:10.702151Z","iopub.status.idle":"2023-10-17T15:32:11.465077Z","shell.execute_reply.started":"2023-10-17T15:32:10.702121Z","shell.execute_reply":"2023-10-17T15:32:11.464072Z"},"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-17T15:32:11.466409Z","iopub.execute_input":"2023-10-17T15:32:11.467067Z","iopub.status.idle":"2023-10-17T15:32:11.619565Z","shell.execute_reply.started":"2023-10-17T15:32:11.467033Z","shell.execute_reply":"2023-10-17T15:32:11.618555Z"},"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-17T15:32:11.620906Z","iopub.execute_input":"2023-10-17T15:32:11.621800Z","iopub.status.idle":"2023-10-17T15:32:11.822796Z","shell.execute_reply.started":"2023-10-17T15:32:11.621767Z","shell.execute_reply":"2023-10-17T15:32:11.821849Z"},"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-17T15:32:11.824328Z","iopub.execute_input":"2023-10-17T15:32:11.825030Z","iopub.status.idle":"2023-10-17T15:32:11.836269Z","shell.execute_reply.started":"2023-10-17T15:32:11.824999Z","shell.execute_reply":"2023-10-17T15:32:11.835352Z"},"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-17T15:32:11.837381Z","iopub.execute_input":"2023-10-17T15:32:11.837719Z","iopub.status.idle":"2023-10-17T15:42:21.850485Z","shell.execute_reply.started":"2023-10-17T15:32:11.837686Z","shell.execute_reply":"2023-10-17T15:42:21.849352Z"},"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-17T15:42:21.852195Z","iopub.execute_input":"2023-10-17T15:42:21.852773Z","iopub.status.idle":"2023-10-17T15:42:21.875292Z","shell.execute_reply.started":"2023-10-17T15:42:21.852739Z","shell.execute_reply":"2023-10-17T15:42:21.874408Z"},"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-17T15:42:21.876536Z","iopub.execute_input":"2023-10-17T15:42:21.880178Z","iopub.status.idle":"2023-10-17T15:42:21.928600Z","shell.execute_reply.started":"2023-10-17T15:42:21.880141Z","shell.execute_reply":"2023-10-17T15:42:21.927609Z"},"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-17T15:42:21.929730Z","iopub.execute_input":"2023-10-17T15:42:21.930659Z","iopub.status.idle":"2023-10-17T15:42:21.937915Z","shell.execute_reply.started":"2023-10-17T15:42:21.930627Z","shell.execute_reply":"2023-10-17T15:42:21.936983Z"},"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-17T15:42:21.939143Z","iopub.execute_input":"2023-10-17T15:42:21.940085Z","iopub.status.idle":"2023-10-17T15:42:21.950331Z","shell.execute_reply.started":"2023-10-17T15:42:21.940056Z","shell.execute_reply":"2023-10-17T15:42:21.949465Z"},"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-17T15:42:21.951942Z","iopub.execute_input":"2023-10-17T15:42:21.952611Z","iopub.status.idle":"2023-10-17T15:42:21.964312Z","shell.execute_reply.started":"2023-10-17T15:42:21.952566Z","shell.execute_reply":"2023-10-17T15:42:21.963377Z"},"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-17T15:42:21.969742Z","iopub.execute_input":"2023-10-17T15:42:21.970254Z","iopub.status.idle":"2023-10-17T15:42:21.977631Z","shell.execute_reply.started":"2023-10-17T15:42:21.970223Z","shell.execute_reply":"2023-10-17T15:42:21.976754Z"},"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-17T15:42:21.978736Z","iopub.execute_input":"2023-10-17T15:42:21.979482Z","iopub.status.idle":"2023-10-17T15:42:21.989265Z","shell.execute_reply.started":"2023-10-17T15:42:21.979453Z","shell.execute_reply":"2023-10-17T15:42:21.988284Z"},"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-17T15:42:21.990625Z","iopub.execute_input":"2023-10-17T15:42:21.991148Z","iopub.status.idle":"2023-10-17T15:42:21.999736Z","shell.execute_reply.started":"2023-10-17T15:42:21.991117Z","shell.execute_reply":"2023-10-17T15:42:21.998816Z"},"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-17T15:42:22.001060Z","iopub.execute_input":"2023-10-17T15:42:22.001664Z","iopub.status.idle":"2023-10-17T15:42:22.016917Z","shell.execute_reply.started":"2023-10-17T15:42:22.001633Z","shell.execute_reply":"2023-10-17T15:42:22.016081Z"},"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-17T15:42:22.018320Z","iopub.execute_input":"2023-10-17T15:42:22.018921Z","iopub.status.idle":"2023-10-17T15:42:22.123793Z","shell.execute_reply.started":"2023-10-17T15:42:22.018890Z","shell.execute_reply":"2023-10-17T15:42:22.122952Z"},"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-17T15:42:22.124855Z","iopub.execute_input":"2023-10-17T15:42:22.125144Z","iopub.status.idle":"2023-10-17T15:42:22.131667Z","shell.execute_reply.started":"2023-10-17T15:42:22.125116Z","shell.execute_reply":"2023-10-17T15:42:22.130644Z"},"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-17T15:42:22.132965Z","iopub.execute_input":"2023-10-17T15:42:22.133640Z","iopub.status.idle":"2023-10-17T15:42:22.493144Z","shell.execute_reply.started":"2023-10-17T15:42:22.133563Z","shell.execute_reply":"2023-10-17T15:42:22.492211Z"},"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-17T15:42:22.494505Z","iopub.execute_input":"2023-10-17T15:42:22.495183Z","iopub.status.idle":"2023-10-17T15:42:22.929561Z","shell.execute_reply.started":"2023-10-17T15:42:22.495149Z","shell.execute_reply":"2023-10-17T15:42:22.928653Z"},"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-17T15:42:22.930923Z","iopub.execute_input":"2023-10-17T15:42:22.931818Z","iopub.status.idle":"2023-10-17T15:42:22.965977Z","shell.execute_reply.started":"2023-10-17T15:42:22.931786Z","shell.execute_reply":"2023-10-17T15:42:22.965085Z"},"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-17T15:42:22.967611Z","iopub.execute_input":"2023-10-17T15:42:22.968131Z","iopub.status.idle":"2023-10-17T15:42:23.283929Z","shell.execute_reply.started":"2023-10-17T15:42:22.967976Z","shell.execute_reply":"2023-10-17T15:42:23.282760Z"},"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-17T15:42:23.285558Z","iopub.execute_input":"2023-10-17T15:42:23.286244Z","iopub.status.idle":"2023-10-17T15:42:23.294790Z","shell.execute_reply.started":"2023-10-17T15:42:23.286211Z","shell.execute_reply":"2023-10-17T15:42:23.293915Z"},"trusted":true},"execution_count":null,"outputs":[]}]}