{"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":"# Read images tiff\n\n\n# import tools","metadata":{}},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport seaborn as sns\nimport matplotlib.pyplot as plt\nimport os , cv2 , torch\nimport tifffile as tiff\nimport glob as gb\nfrom PIL import Image\nimport tensorflow as tf","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-01-30T20:36:49.885944Z","iopub.execute_input":"2023-01-30T20:36:49.886879Z","iopub.status.idle":"2023-01-30T20:37:00.187609Z","shell.execute_reply.started":"2023-01-30T20:36:49.886742Z","shell.execute_reply":"2023-01-30T20:37:00.185492Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Load DATA","metadata":{}},{"cell_type":"code","source":"DATA_PATH = \"../input/hubmap-organ-segmentation/\"\nsubmission = pd.read_csv('../input/hubmap-organ-segmentation/sample_submission.csv')\nimage_paths = sorted(gb.glob(os.path.join(DATA_PATH, 'train_images/*tiff')))\n\nprint(f\"Number of images : {len(image_paths)}\")\nprint(f\"First image : {image_paths[0]}\")","metadata":{"execution":{"iopub.status.busy":"2023-01-30T14:43:48.100186Z","iopub.execute_input":"2023-01-30T14:43:48.100817Z","iopub.status.idle":"2023-01-30T14:43:48.287124Z","shell.execute_reply.started":"2023-01-30T14:43:48.100781Z","shell.execute_reply":"2023-01-30T14:43:48.28588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Read images and get shapes","metadata":{}},{"cell_type":"code","source":"image_shapes = {}\n\nfor ind, image_path in enumerate(image_paths):\n    image = cv2.imread(image_path)\n    image_shapes[image.shape] = image_shapes.get(image.shape, 0) + 1\n\nimage_shapes","metadata":{"execution":{"iopub.status.busy":"2023-01-30T14:43:48.288348Z","iopub.execute_input":"2023-01-30T14:43:48.289144Z","iopub.status.idle":"2023-01-30T14:46:40.549701Z","shell.execute_reply.started":"2023-01-30T14:43:48.289108Z","shell.execute_reply":"2023-01-30T14:46:40.548472Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(f\"first image like image :{image[0]}\")","metadata":{"execution":{"iopub.status.busy":"2023-01-30T14:46:40.552626Z","iopub.execute_input":"2023-01-30T14:46:40.553374Z","iopub.status.idle":"2023-01-30T14:46:40.562216Z","shell.execute_reply.started":"2023-01-30T14:46:40.553326Z","shell.execute_reply":"2023-01-30T14:46:40.560903Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Visualize DATA","metadata":{}},{"cell_type":"code","source":"n_cols = 4\n\nfor ind, image_path in enumerate(image_paths):\n    image = cv2.imread(image_path)\n    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)\n    \n    if ind % n_cols == 0:\n        plt.figure(figsize=(16,5))\n        \n    plt.subplot(1, n_cols, ind % n_cols + 1)\n    plt.imshow(image)\n    plt.axis(\"off\")\n    if ind % n_cols == n_cols - 1:\n        plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-01-30T14:46:40.5634Z","iopub.execute_input":"2023-01-30T14:46:40.563743Z","iopub.status.idle":"2023-01-30T14:54:33.93069Z","shell.execute_reply.started":"2023-01-30T14:46:40.563714Z","shell.execute_reply":"2023-01-30T14:54:33.929321Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv(\"submission.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-01-30T14:54:33.932452Z","iopub.execute_input":"2023-01-30T14:54:33.933607Z","iopub.status.idle":"2023-01-30T14:54:34.232795Z","shell.execute_reply.started":"2023-01-30T14:54:33.933539Z","shell.execute_reply":"2023-01-30T14:54:34.230731Z"},"trusted":true},"execution_count":null,"outputs":[]}]}