{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.6.0"}},"nbformat":4,"nbformat_minor":0,"cells":[{"metadata":{"_cell_guid":"1f3b1292-0f0e-426b-7120-4423202bb4c0","_active":false,"collapsed":false},"source":"import numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom skimage.io import imread, imshow\nimport cv2\n\nfrom subprocess import check_output\nprint(check_output([\"ls\", \"../input/train\"]).decode(\"utf8\"))","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"d35e2316-6628-e721-b912-ca3846fcd405","_active":false,"collapsed":false},"source":"from glob import glob\nbasepath = '../input/train/'\n\nall_cervix_images = []\n\nfor path in sorted(glob(basepath + \"*\")):\n    cervix_type = path.split(\"/\")[-1]\n    cervix_images = sorted(glob(basepath + cervix_type + \"/*\"))\n    all_cervix_images = all_cervix_images + cervix_images   \n\ndf = pd.DataFrame({'imagepath': all_cervix_images})\ndf['filetype'] = df.apply(lambda row: row.imagepath.split(\".\")[-1], axis=1)\ndf['type'] = df.apply(lambda row: row.imagepath.split(\"/\")[-2], axis=1)\ndf.head()","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"fbe54406-e1ed-7f01-4d0a-20229c6d6ac4","_active":false,"collapsed":false},"source":"df.shape","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"f7bfc804-968c-1b4c-6fad-1cb2510dc99c","_active":false,"collapsed":false},"source":"from scipy.misc import imread","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"05d6f616-3e9f-77d3-5020-596b2ec891b1","_active":false,"collapsed":false},"source":"img_paths = df.imagepath\nimgs = [imread(img_path) for img_path in img_paths[:200]]","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"656a13a6-c147-1d6f-1f88-af26a4eba84c","_active":false,"collapsed":false},"source":"len(imgs), imgs[0].shape","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"1f3b1292-0f0e-426b-7120-4423202bb4c0","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"d35e2316-6628-e721-b912-ca3846fcd405","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"05d6f616-3e9f-77d3-5020-596b2ec891b1","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"f7bfc804-968c-1b4c-6fad-1cb2510dc99c","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"656a13a6-c147-1d6f-1f88-af26a4eba84c","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"7bf8e8be-4dd3-f44d-3ec9-1ecd6aa9fc3f","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"8118a9b8-ee0d-6961-a5cf-48aec2dffecc","_active":false,"collapsed":false},"source":"target_labels = df.type.apply(lambda x: int(x.split('_')[-1]))","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"1c6339d9-ea4f-6fb0-c4a1-a28151597e4d","_active":false,"collapsed":false},"source":"from collections import Counter\nCounter(target_labels)","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"39d1ed2f-a71a-fbdb-a5f9-c1e7927d17f2","_active":false,"collapsed":false},"source":"imgs[0].shape","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"8e597045-18f0-0819-333b-0f8d691963d0","_active":false,"collapsed":false},"source":"import os\nimport psutil\nprocess = psutil.Process(os.getpid())\nprint(process.memory_info().rss / 1000000000)","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"0b743428-520b-d5ef-23b6-640c25a9c799","_active":false,"collapsed":false},"source":"print(process.memory_percent())","execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"},{"metadata":{"_cell_guid":"363a5ebb-f93a-0c1a-dc26-1e9f9431c544","_active":false,"collapsed":false},"source":null,"execution_count":null,"cell_type":"code","outputs":[],"execution_state":"idle"}]}