{"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":"import numpy as np\nimport pandas as pd\nimport glob #, ipyplot\nimport matplotlib.pyplot as plt\nfrom PIL import Image, ImageDraw, ImageFilter\n\np = '/kaggle/input/hubmap-hacking-the-human-vasculature/'\ntrain = pd.read_csv(p+'tile_meta.csv')\ntrain['path'] = train['id'].map(lambda x: p + 'train/' + str(x) + '.tif')\nwsi = pd.read_csv(p+'wsi_meta.csv')\nmask = pd.read_json(p+'polygons.jsonl', lines=True)\n\ntest = pd.DataFrame(glob.glob(p+'test/**.tif'), columns=['path'])\ntest['id'] = test['path'].map(lambda x: x.split('/')[-1].split('.')[0])\n\nsub = pd.read_csv(p+'sample_submission.csv')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-05-28T05:01:37.705022Z","iopub.execute_input":"2023-05-28T05:01:37.706218Z","iopub.status.idle":"2023-05-28T05:01:41.209731Z","shell.execute_reply.started":"2023-05-28T05:01:37.706178Z","shell.execute_reply":"2023-05-28T05:01:41.208694Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(wsi[wsi.source_wsi == 2])\npaths = train[train['source_wsi']==2].reset_index(drop=True)\n\nx, y = (paths.i.max() + 512, paths.j.max() + 512)\nx_, y_ = paths.i.min(), paths.j.min()\nimg = Image.new(mode=\"RGB\", size=(x - x_,y - y_)) #'TIFF'\nfor i in range(len(paths)):\n    img.paste(Image.open(paths.path[i]), (paths.i[i] - x_, paths.j[i] - y_))\n    #break\nimg = img.resize((x // 2, y // 2))\nplt.imshow(img)","metadata":{"execution":{"iopub.status.busy":"2023-05-28T05:07:54.289923Z","iopub.execute_input":"2023-05-28T05:07:54.290577Z","iopub.status.idle":"2023-05-28T05:08:37.560949Z","shell.execute_reply.started":"2023-05-28T05:07:54.290524Z","shell.execute_reply":"2023-05-28T05:08:37.559732Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2023-05-28T05:09:27.311311Z","iopub.execute_input":"2023-05-28T05:09:27.311725Z","iopub.status.idle":"2023-05-28T05:09:27.332999Z","shell.execute_reply.started":"2023-05-28T05:09:27.311684Z","shell.execute_reply":"2023-05-28T05:09:27.331702Z"},"trusted":true},"execution_count":null,"outputs":[]}]}