{"cells":[{"metadata":{},"cell_type":"markdown","source":"Beginners guide to Image Segmentation with fast.ai"},{"metadata":{},"cell_type":"markdown","source":"work in progress"},{"metadata":{},"cell_type":"markdown","source":"## Preparation\nSetup environment"},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# the fast.ai library\nfrom fastai import *\nfrom fastai.vision import *\n\n# to inspect the directory\nimport os\nfrom pathlib import Path\n\n# for data manipulation\nimport pandas as pd\n\n# for numerical analysis\nimport numpy as np","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"INPUT = Path(\"../input/understanding_cloud_organization\")\nos.listdir(INPUT)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"TRAIN = INPUT/\"test_images\"\nTEST = INPUT/\"train_images\"\n\nprint(os.listdir(TRAIN)[:5])\nprint(os.listdir(TEST)[:5])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df = pd.read_csv(INPUT/\"train.csv\")\ntrain_df[[\"ImageId\", \"ClassId\"]] = train_df[\"Image_Label\"].str.split(\"_\", expand=True)\ntrain_df.drop(columns=\"Image_Label\", inplace=True)\ntrain_df = train_df[[\"ImageId\", \"ClassId\", \"EncodedPixels\"]]\ntrain_df = train_df.pivot(index=\"ImageId\", columns=\"ClassId\", values=\"EncodedPixels\")\ntrain_df.columns.name = \"\"\ntrain_df = train_df.reset_index(level=0)\ntrain_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"mask = open_mask_rle(train_df.iloc[101][\"Flower\"], shape=(1400, 2100))\nmask.show(figsize=(5,5), alpha=1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","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":1}