{"cells":[{"metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","execution":{"iopub.execute_input":"2021-02-01T20:21:11.714732Z","iopub.status.busy":"2021-02-01T20:21:11.713915Z","iopub.status.idle":"2021-02-01T20:21:19.033531Z","shell.execute_reply":"2021-02-01T20:21:19.034126Z"},"papermill":{"duration":7.33083,"end_time":"2021-02-01T20:21:19.034349","exception":false,"start_time":"2021-02-01T20:21:11.703519","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"import os\nimport glob\nimport shutil\nimport json\nimport keras\nimport itertools\nimport numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport tensorflow as tf\nfrom PIL import Image\nimport matplotlib.pyplot as plt\nfrom collections import Counter\n\nwork_dir = '../input/cassava-leaf-disease-classification/'\nos.listdir(work_dir) \ntrain_path = '/kaggle/input/cassava-leaf-disease-classification/train_images'","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-01T20:21:19.050961Z","iopub.status.busy":"2021-02-01T20:21:19.050064Z","iopub.status.idle":"2021-02-01T20:21:31.482127Z","shell.execute_reply":"2021-02-01T20:21:31.480859Z"},"papermill":{"duration":12.442669,"end_time":"2021-02-01T20:21:31.482265","exception":false,"start_time":"2021-02-01T20:21:19.039596","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"import keras\n\nfinal_model2 = keras.models.load_model('../input/efficentnetresnet50-weights/resnet50.h5')","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-01T20:21:31.503938Z","iopub.status.busy":"2021-02-01T20:21:31.503245Z","iopub.status.idle":"2021-02-01T20:21:35.082153Z","shell.execute_reply":"2021-02-01T20:21:35.081606Z"},"papermill":{"duration":3.592875,"end_time":"2021-02-01T20:21:35.082273","exception":false,"start_time":"2021-02-01T20:21:31.489398","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"TEST_DIR = '../input/cassava-leaf-disease-classification/test_images/'\ntest_images = os.listdir(TEST_DIR)\npredictions = []\nIMG_SIZE = 512\nIMG_SIZE1 = 512\n\nsize1= (IMG_SIZE,IMG_SIZE1)\nfor image in test_images:\n    img1 = Image.open(TEST_DIR + image)\n    img1 = img1.resize(size1)\n    img1 = np.expand_dims(img1, axis=0)\n    prediction2 = final_model2.predict(img1)\n    print(prediction2)\n\n    predictions.extend(prediction2.argmax(axis = 1))","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-01T20:21:35.099794Z","iopub.status.busy":"2021-02-01T20:21:35.099092Z","iopub.status.idle":"2021-02-01T20:21:35.105811Z","shell.execute_reply":"2021-02-01T20:21:35.106334Z"},"papermill":{"duration":0.018314,"end_time":"2021-02-01T20:21:35.106459","exception":false,"start_time":"2021-02-01T20:21:35.088145","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"predictions","execution_count":null,"outputs":[]},{"metadata":{"execution":{"iopub.execute_input":"2021-02-01T20:21:35.121438Z","iopub.status.busy":"2021-02-01T20:21:35.120750Z","iopub.status.idle":"2021-02-01T20:21:35.387794Z","shell.execute_reply":"2021-02-01T20:21:35.386448Z"},"papermill":{"duration":0.275943,"end_time":"2021-02-01T20:21:35.387939","exception":false,"start_time":"2021-02-01T20:21:35.111996","status":"completed"},"tags":[],"trusted":true},"cell_type":"code","source":"sub = pd.DataFrame({'image_id': test_images, 'label': predictions})\ndisplay(sub)\nsub.to_csv('submission.csv', index = False)","execution_count":null,"outputs":[]}],"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":4,"nbformat_minor":4}