{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Table of Contents\n1. Introduction\n2. Models\n    * [U-Net3](https://arxiv.org/ftp/arxiv/papers/2004/2004.08790.pdf)\n    * [U-2-Net](https://arxiv.org/pdf/2005.09007v1.pdf)    \n    * [U-Net++](https://arxiv.org/abs/1807.10165)\n    * [U-Net](https://link.springer.com/chapter/10.1007%2F978-3-319-24574-4_28)\n    * [ResUNet](https://arxiv.org/abs/1904.00592)\n    \n3. Results \n","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"## Introduction\n**Melanoma**\n* an uncommon skin cancer ([ACS, 2020](https://www.cancer.org/cancer/melanoma-skin-cancer/about/what-is-melanoma.html))\n    * skin cancer is most prevalent cancer ([SCF,2020](https://www.skincancer.org/skin-cancer-information/skin-cancer-facts/))\n* responsible for 75% of skin cancer deaths ([Peterson, 2016](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4998683/))\n* 100,000 new melanoma cases will be diagnosed in 2020 ([ACS, 2020](https://www.cancer.org/content/dam/cancer-org/research/cancer-facts-and-statistics/annual-cancer-facts-and-figures/2020/cancer-facts-and-figures-2020.pdf)). \n* 7,000 people will die from melanoma in 2020 ([Trager, 2020](https://practicaldermatology.com/articles/2020-apr/update-biomarkers-for-guiding-treatment-in-early-stage-melanoma#:~:text=Although%20it%20accounts%20for%20only,the%20end%20of%20this%20year.&text=The%20American%20Joint%20Committee%20on,stage%20I%20through%20IV%20disease.)).\n* If caught early, most melanomas can be cured with minor surgery ([ACS, 2020](https://www.cancer.org/cancer/melanoma-skin-cancer/treating/surgery.html#:~:text=When%20melanoma%20is%20diagnosed%20by,numb%20it%20before%20the%20excision.)).\n* Currently, dermatologists evaluate every one of a patient's moles to identify outlier lesions or “ugly ducklings” that are most likely to be melanoma ([SCF, 2020](https://www.skincancer.org/skin-cancer-information/melanoma/melanoma-warning-signs-and-images/)).\n* Early and accurate detection, aided by artificial intelligence utilizing \"contextual\" info within each patient, can make treatment more effective and positively impact millions of people ([Nature, 2020](https://www.nature.com/articles/d41586-020-00847-2)).\n\n**This Competition Notebook**\n* melanoma is identified in [images of skin lesions from the ISIC Archive](https://www.kaggle.com/c/siim-isic-melanoma-classification/data),the largest publicly available collection of quality-controlled dermoscopic images of skin lesions.\n* The most widely successfull lesion detection classification algorithms (e.g. [U-Net3](https://arxiv.org/ftp/arxiv/papers/2004/2004.08790.pdf), [U-2-Net](https://arxiv.org/pdf/2005.09007v1.pdf), [U-Net++](https://arxiv.org/abs/1807.10165), [U-Net](https://link.springer.com/chapter/10.1007%2F978-3-319-24574-4_28), [ResUNet](https://arxiv.org/abs/1904.00592)) are utilized to automatically detect and label melanoma in the images.","execution_count":null},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nimport sys\nimport cv2 as cv\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nimport PIL\nfrom PIL import Image\nimport pydicom\nimport tensorflow as tf\n\n\n#for dirname, _, filenames in os.walk('/kaggle/input'):\n #   for filename in filenames:\n  #      print(os.path.join(dirname, filename))\n\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session\nos.chdir('/kaggle/input/')\ndpath='/kaggle/input/siim-isic-melanoma-classification/'","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_csv=pd.read_csv('./siim-isic-melanoma-classification/train.csv')\ntrain_csv","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# read tfrec\ntfrd=os.path.join(dpath,'./tfrecords/')\ntfr=tf.data.TFRecordDataset(tfrd)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"type(tfrd+('./test06-687.tfrec'))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# Create a dictionary describing the features.\nimage_feature_description = {\n    'height': tf.io.FixedLenFeature([], tf.int64),\n    'width': tf.io.FixedLenFeature([], tf.int64),\n    'depth': tf.io.FixedLenFeature([], tf.int64),\n    'label': tf.io.FixedLenFeature([], tf.int64),\n    'image_raw': tf.io.FixedLenFeature([], tf.string),\n}","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"def _parse_image_function(example_proto):\n  # Parse the input tf.Example proto using the dictionary above.\n  return tf.io.parse_single_example(example_proto, image_feature_description)\n\nparsed_image_dataset = tfr.map(_parse_image_function)\nparsed_image_dataset","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# dcm to jpg and info\ndcm_path='/kaggle/input/siim-isic-melanoma-classification/train/'\noutpath='/kaggle/working/dcm_jpg/'\nimages_path=os.listdir(dcm_path)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# read dcm\ndcdir=os.path.join(dpath,'train/')\ndc1=pydicom.dcmread(dcdir+'ISIC_0074311.dcm')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"dc1","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"# Create list of first 20 jpg\ntjd='/kaggle/input/siim-isic-melanoma-classification/jpeg/train/'\nims=[]\nlimit=20\nprocessed=0\nfor i in os.listdir(tjd):\n    impath=os.path.join(tjd,i)\n    if os.path.isfile(impath):\n        j=Image.open(impath)\n        ims.append(j)\n    processed += 1\n    if processed > limit:\n        break\nims","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"collapsed":true},"cell_type":"code","source":"# Plot first 20 jpg\nfig=plt.figure(figsize=(15,10))\ncolumns=5;rows=4\nfor i in range(1,columns*rows+1):\n    img=ims[i]\n    fig.add_subplot(rows,columns,i)\n    plt.imshow(img)\nplt.show","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":4}