{"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":"markdown","source":"# 12장 병든 잎사귀 식별 경진대회 환경 세팅된 노트북 양식","metadata":{"papermill":{"duration":0.019813,"end_time":"2021-07-28T23:49:39.978001","exception":false,"start_time":"2021-07-28T23:49:39.958188","status":"completed"},"tags":[]}},{"cell_type":"code","source":"\nimport pandas as pd\ndata = \"/kaggle/input/plant-pathology-2020-fgvc7/\"\ntrain = pd.read_csv(data + \"train.csv\")\ntest = pd.read_csv(data + \"test.csv\")\nsub = pd.read_csv(data + \"sample_submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:22.252426Z","iopub.execute_input":"2022-07-29T08:06:22.252866Z","iopub.status.idle":"2022-07-29T08:06:22.279787Z","shell.execute_reply.started":"2022-07-29T08:06:22.252826Z","shell.execute_reply":"2022-07-29T08:06:22.279099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.shape, test.shape","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:24.750730Z","iopub.execute_input":"2022-07-29T08:06:24.751310Z","iopub.status.idle":"2022-07-29T08:06:24.758365Z","shell.execute_reply.started":"2022-07-29T08:06:24.751260Z","shell.execute_reply":"2022-07-29T08:06:24.757715Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train.tail()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:29.079810Z","iopub.execute_input":"2022-07-29T08:06:29.080461Z","iopub.status.idle":"2022-07-29T08:06:29.091175Z","shell.execute_reply.started":"2022-07-29T08:06:29.080416Z","shell.execute_reply":"2022-07-29T08:06:29.090290Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test.tail()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:31.852612Z","iopub.execute_input":"2022-07-29T08:06:31.853484Z","iopub.status.idle":"2022-07-29T08:06:31.864091Z","shell.execute_reply.started":"2022-07-29T08:06:31.853441Z","shell.execute_reply":"2022-07-29T08:06:31.863175Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.head()","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:34.502779Z","iopub.execute_input":"2022-07-29T08:06:34.503122Z","iopub.status.idle":"2022-07-29T08:06:34.519929Z","shell.execute_reply.started":"2022-07-29T08:06:34.503091Z","shell.execute_reply":"2022-07-29T08:06:34.519147Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"health =train.loc[train[\"healthy\"]==1]\nm_D = train.loc[train[\"multiple_diseases\"]==1]\nrust = train.loc[train[\"rust\"]==1]\nscab = train.loc[train[\"scab\"]==1]","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:39.135839Z","iopub.execute_input":"2022-07-29T08:06:39.136300Z","iopub.status.idle":"2022-07-29T08:06:39.143955Z","shell.execute_reply.started":"2022-07-29T08:06:39.136268Z","shell.execute_reply":"2022-07-29T08:06:39.143107Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib as mpl\n\nmpl.rc(\"font\", size =10)\nplt.figure(figsize=(7,7))\n\nlabel = [\"health\",\"m-D\", \"rust\", \"scab\"]\nplt.pie([len(health), len(m_D), len(rust), len(scab)],\n       labels=label,\n       autopct=\"%.1f%%\");","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:45.284648Z","iopub.execute_input":"2022-07-29T08:06:45.285081Z","iopub.status.idle":"2022-07-29T08:06:45.395441Z","shell.execute_reply.started":"2022-07-29T08:06:45.285032Z","shell.execute_reply":"2022-07-29T08:06:45.394617Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.gridspec as gridspec\nimport cv2\n\ndef show_image(img_ids, rows=2, cols=3):\n    assert len(img_ids) <= rows*cols\n    \n    plt.figure(figsize=(15,8))\n    grid = gridspec.GridSpec(rows, cols)\n    \n    for idx, img_id in enumerate(img_ids):\n        img_path = f'{data}/images/{img_id}.jpg'\n        image = cv2.imread(img_path)\n        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n        ax = plt.subplot(grid[idx])\n        ax.imshow(image)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:50.802221Z","iopub.execute_input":"2022-07-29T08:06:50.802669Z","iopub.status.idle":"2022-07-29T08:06:50.810633Z","shell.execute_reply.started":"2022-07-29T08:06:50.802638Z","shell.execute_reply":"2022-07-29T08:06:50.809698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"num_of_imgs = 6\nlast_heal_img_i = health['image_id'][-num_of_imgs:]#last_healthy_img_ids=last_healimg_i\nlast_multiple_diseases_img_ids = m_D['image_id'][-num_of_imgs:]\nlast_rust_img_ids = rust['image_id'][-num_of_imgs:]\nlast_scab_img_ids = scab['image_id'][-num_of_imgs:]","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:06:56.665561Z","iopub.execute_input":"2022-07-29T08:06:56.665981Z","iopub.status.idle":"2022-07-29T08:06:56.672905Z","shell.execute_reply.started":"2022-07-29T08:06:56.665953Z","shell.execute_reply":"2022-07-29T08:06:56.672284Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_image(last_heal_img_i)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:07:00.430804Z","iopub.execute_input":"2022-07-29T08:07:00.431216Z","iopub.status.idle":"2022-07-29T08:07:04.272996Z","shell.execute_reply.started":"2022-07-29T08:07:00.431187Z","shell.execute_reply":"2022-07-29T08:07:04.272185Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_image(last_multiple_diseases_img_ids)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:08:47.201579Z","iopub.execute_input":"2022-07-29T08:08:47.202126Z","iopub.status.idle":"2022-07-29T08:08:51.015734Z","shell.execute_reply.started":"2022-07-29T08:08:47.202092Z","shell.execute_reply":"2022-07-29T08:08:51.013248Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_image(last_rust_img_ids)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:09:06.446208Z","iopub.execute_input":"2022-07-29T08:09:06.446502Z","iopub.status.idle":"2022-07-29T08:09:10.164786Z","shell.execute_reply.started":"2022-07-29T08:09:06.446473Z","shell.execute_reply":"2022-07-29T08:09:10.161542Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"show_image(last_scab_img_ids)","metadata":{"execution":{"iopub.status.busy":"2022-07-29T08:09:30.942565Z","iopub.execute_input":"2022-07-29T08:09:30.943004Z","iopub.status.idle":"2022-07-29T08:09:34.670937Z","shell.execute_reply.started":"2022-07-29T08:09:30.942973Z","shell.execute_reply":"2022-07-29T08:09:34.670266Z"},"trusted":true},"execution_count":null,"outputs":[]}]}