<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mary Adewunmi on Medium]]></title>
        <description><![CDATA[Stories by Mary Adewunmi on Medium]]></description>
        <link>https://medium.com/@maryadewunmi?source=rss-783d698d7d73------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Tg9bIhVjk9O78ozJ9cwrLg.jpeg</url>
            <title>Stories by Mary Adewunmi on Medium</title>
            <link>https://medium.com/@maryadewunmi?source=rss-783d698d7d73------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:05:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maryadewunmi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Enhanced Melanoma Classifier Model with CNN-VGG16]]></title>
            <link>https://medium.com/codex/enhanced-melanoma-model-classifier-with-cnn-vgg16-c82e236fd3f0?source=rss-783d698d7d73------2</link>
            <guid isPermaLink="false">https://medium.com/p/c82e236fd3f0</guid>
            <category><![CDATA[biomedical-research]]></category>
            <category><![CDATA[medical-image-analysis]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[melanoma]]></category>
            <category><![CDATA[vgg16]]></category>
            <dc:creator><![CDATA[Mary Adewunmi]]></dc:creator>
            <pubDate>Mon, 16 Aug 2021 18:51:00 GMT</pubDate>
            <atom:updated>2021-08-28T14:59:06.866Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*hIv62MNI1o9pDJ2w" /><figcaption>Photo by <a href="https://unsplash.com/@nci?utm_source=medium&amp;utm_medium=referral">National Cancer Institute</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Having promised to increase the model accuracy from the last <a href="https://maryadewunmi.medium.com/build-a-melanoma-image-classification-model-with-convolutional-neural-network-cnn-d96a61b9e639">post</a>, I have researched further. In addition to increasing the image size of the image dataset through augmentation, preprocessing the images with VGG16 prior to training the model with CNN can give higher accuracy. While looking for ways of boosting the accuracy, I ran into Keras preprocessing function, which is specific to the VGG16 model keras.applications.vgg16.preprocess_input and does additional steps by subtracting the average RGB channel values from the original ImageNet training set.</p><p>In this project, we present a Melanoma classifier model based on the Deep Neural Network(DNN) originated by the Visual Geometry Group with 16 layers — VGG16 (Simonyan, K., &amp; Zisserman, A. (2014). First, we pre samples as byte plot pictures, in which each byte represents one grayscale pixel. Using the convolutional layers of VGG16 pre-trained on the ImageNet dataset, we extract the filter activation maps (also known as bottleneck features) by deducting the average RGB channel values of the original Image net and adjust the training set images.</p><p>Full code can be found <a href="https://github.com/MaryAdewunmi/Preprocess-Image-with-VGG16/blob/main/Melanoma_Classifier_Model_with_VGG16_CNN.ipynb">here</a>.</p><h3>🌱Objective of this Project</h3><p>It is to increase the accuracy of the Melanoma Classifier Model.</p><h3>🌱<strong>The framework used in this project</strong></h3><p>This just illustrated how we arrive at a faster model with high accuracy for training melanoma images.</p><ul><li>Collate the datasets from <a href="https://www.kaggle.com/c/siim-isic-melanoma-classification/data">here</a></li><li>Preprocess the images with VGG16 by extracting the features and labels</li><li>Set the parameters or fine-tuning the images and environment for the CNN model</li><li>Train the images with CNN</li><li>Evaluate the model with accuracy as the metrics</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*8jBzF2alHnoUDGs0PJljyw.png" /><figcaption><strong>The architecture of the VGG16 Preprocessed Model — Author</strong></figcaption></figure><h3>🌱<strong>Code</strong> <strong>Implementation</strong></h3><p>Import the necessary libraries especially Keras and Tensor flow using accuracy,precision and recall as the metrics.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0df4e79e2ba4caab3e28384d3595e2bd/href">https://medium.com/media/0df4e79e2ba4caab3e28384d3595e2bd/href</a></iframe><h3>🌱<strong>Load datasets</strong></h3><p>Load the datasets by using already splitter datasets, which was 2239 images to train and valid dataset batches and 118 to test batches dataset using an image data generator library.</p><p>We used TensorFlow-Keras, vgg16 image data generator, more on this can be found <a href="https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator">here</a></p><blockquote>📍Note that this is where the images are preprocessed with VGG16.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8075ba5cda59ea1ee46d00ce1cde853a/href">https://medium.com/media/8075ba5cda59ea1ee46d00ce1cde853a/href</a></iframe><p>👉<strong>Viewing the images, can you spot the difference in the input datasets?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*a3kjIn78r1lJ4FpfdRjtRA.png" /><figcaption><a href="https://www.kaggle.com/c/siim-isic-melanoma-classification/data">Original images</a></figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/776b15b1f1d51b2edbc0014e9c84e892/href">https://medium.com/media/776b15b1f1d51b2edbc0014e9c84e892/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*hYaaitnp6ONplPScphXymQ.png" /><figcaption>VGG16 Preprocessed lesion images — Author</figcaption></figure><h3>🌱<strong>Train the Images with CNN</strong></h3><p>Over the last decade, Convolutional Neural Networks have achieved breakthroughs in a range of pattern recognition domains, ranging from image processing to speech recognition. The most advantageous feature of CNNs is that they reduce the number of parameters in ANN. This accomplishment has inspired academics and developers to consider larger models to perform challenging tasks that were previously impossible to solve with traditional ANNs; The most significant assumption about issues solved by CNN is that they should not contain spatially dependent properties. To put it another way, in a face detection application, we don’t need to worry about where the faces are in the photos (S. Albawi et al.).</p><p>We used the Sequential model with convolutional 2D, kernel size (3,3), relu activation, padding with zeros, pool size, 2,2, learning rate, Adam optimizer with accuracy as metrics.</p><p>The layer’s activation function is called ‘Activation.’ Models using an activation function can account for nonlinear relationships. When forecasting diabetes in patients, for clarification, predicting a lesion image type out of 9 lesion types is a nonlinear model, we will use ReLU, or Rectified Linear Activation, as our activation function. Even though it is made up of two linear parts, it has been shown to operate effectively in neural networks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*tVoUHvlmB7zakJbuP9LrtA.png" /><figcaption><a href="https://ieeexplore.ieee.org/abstract/document/8308186">Source</a></figcaption></figure><p>Padding is equal to the ‘same’ by adding zeros to the images in other to boost the image quality after reducing the size of the images to fit into the CNN model requirement.</p><p>The optimizer and loss parameters are used to compile the model.<br>The learning rate is controlled by the optimizer. As an optimizer, we’ll use the ‘adam.’ Throughout the training, the adam optimizer adjusts the learning rate. The learning rate controls how quickly the model’s optimal weights are calculated. A slower learning rate of 0.0001, yes, it may take longer to compute the weights but it can result in more accurate weights.</p><p>In the domain of image processing, pooling is useful for lowering the resolution and complexity. The number of filters is unaffected by pooling. One of the most frequent forms of pooling strategies is max-pooling. It divides the image into sub-region rectangles and only returns the maximum value of each sub-inside. region’s One of the most common sizes used in max-pooling is 2×2. with stride 2. Moreover, pooling can be used with non-equal filters and strides to improve the efficiency(D. Stutz and L. Beyer(2014))</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b5007238ee40b836bc5c4af2373bf494/href">https://medium.com/media/b5007238ee40b836bc5c4af2373bf494/href</a></iframe><p>The model looks like this👇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*9a_Pzg9XYXrQr0tawIkQng.png" /><figcaption>Model Summary</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*egsk40xqrskU2ULGO1rzQw.png" /></figure><h3>🌱Compile the model</h3><p>Epochs and verbose The number of epochs determines how many times the model cycles over the data. The model will improve overtime as we run more epochs, up to a point. After that, the model will no longer improve with each epoch. Furthermore, the more epochs the model has, the longer it will take to run.</p><pre>history = model.fit(x=train_batches,<br>    steps_per_epoch=len(train_batches),<br>    validation_data=valid_batches,<br>    validation_steps=len(valid_batches),<br>    epochs=10,<br>    verbose=2<br>)</pre><h3>🌱 <strong>Performance Computation</strong></h3><p>Area under Curve(AUC) metric of 93% was achieved which indicated a very high accuracy melanoma classifier. The results also showed that there was no overfitting because the training and validation loss was declining, not increasing or with a weird-looking accuracy graph😂.</p><pre>result_batch = model.predict(test_batches)</pre><pre>labels_batch = label_names[np.argmax(result_batch, axis=-1)]<br>labels_batch</pre><p><strong>🎯Results👇</strong></p><p>Remember, we have 118 test images for testing our classifier model after splitting our datasets using the image data generator code.</p><p>Are you thinking what I am thinking🤔</p><blockquote>👌<strong>So, this model can actually be used for classifying other types of Skin cancer apart from Melanoma like Basal Cell Carcinoma, Dermatofibroma,Nevus, Squamous Cell Carcinoma and the rest.</strong></blockquote><pre>array([&#39;Basal Cell Carcinoma&#39;, &#39;Basal Cell Carcinoma&#39;, &#39;Nevus&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Melanoma&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Dermatofibroma&#39;, &#39;Nevus&#39;, Nevus&#39;,<br>       &#39;Nevus&#39;, &#39;Squamous Cell Carcinoma&#39;, &#39;Nevus&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Melanoma&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Melanoma&#39;, &#39;Pigmented Benign Keratosis&#39;, &#39;Melanoma&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Nevus&#39;, &#39;Squamous Cell Carcinoma&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Pigmented Benign Keratosis&#39;, &#39;Nevus&#39;,<br>       &#39;Melanoma&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Basal Cell Carcinoma&#39;, &#39;Nevus&#39;,<br>       &#39;Melanoma&#39;, &#39;Melanoma&#39;, &#39;Nevus&#39;, &#39;Vascular Lesion&#39;, &#39;Nevus&#39;,<br>       &#39;Nevus&#39;, &#39;Melanoma&#39;, &#39;Nevus&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Pigmented Benign Keratosis&#39;, &#39;Nevus&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;,<br>       &#39;Melanoma&#39;, &#39;Basal Cell Carcinoma&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Melanoma&#39;,<br>       &#39;Nevus&#39;, &#39;Melanoma&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Pigmented Benign Keratosis&#39;, &#39;Melanoma&#39;,<br>       &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Nevus&#39;, &#39;Pigmented Benign Keratosis&#39;, &#39;Squamous Cell Carcinoma&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Melanoma&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Nevus&#39;, &#39;Pigmented Benign Keratosis&#39;, &#39;Melanoma&#39;,<br>       &#39;Vascular Lesion&#39;, &#39;Melanoma&#39;, &#39;Melanoma&#39;, &#39;Melanoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Nevus&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Melanoma&#39;, &#39;Nevus&#39;, &#39;Melanoma&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Melanoma&#39;, &#39;Nevus&#39;, &#39;Basal Cell Carcinoma&#39;, &#39;Vascular Lesion&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Basal Cell Carcinoma&#39;, &#39;Melanoma&#39;, &#39;Nevus&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Nevus&#39;, &#39;Squamous Cell Carcinoma&#39;, &#39;Pigmented Benign Keratosis&#39;,<br>       &#39;Nevus&#39;, &#39;Nevus&#39;, &#39;Melanoma&#39;, &#39;Basal Cell Carcinoma&#39;,<br>       &#39;Pigmented Benign Keratosis&#39;, &#39;Nevus&#39;], dtype=&#39;&lt;U26&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*pBJcPtwTLld_7i6ku2D0rg.png" /></figure><p>The classifier also achieved a precision of 1, recall of 0.5 and an F1-score of 0.67.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/536/1*NskXEn_W1LZdfb21L7iYAw.png" /></figure><h3>🌱<strong>Save Classifier Model and Result Prediction</strong></h3><p>We saved the melanoma model using this simple code below for future reuse and transfer learning purposes.</p><pre>saved_model = model.save(&quot;melanoma_model&quot;)</pre><p><strong>🎯Results prediction</strong></p><p>Remember the data sets has been split into Melanoma and other classes of lesion images under the test directory. So, you can pick the images one after the other to classify whether it is Melanoma or not Melanoma. If it is Melanoma, then urgent action needs to be taken place and if otherwise, further investigation can be carried out.</p><pre>from keras.preprocessing import image<br>img = image.load_img(&#39;../input/skin-cancer9-classesisic/Skin cancer ISIC The International Skin Imaging Collaboration/Test/dermatofibroma/ISIC_0001114.jpg&#39;,target_size=(224,224))<br>img = np.asarray(img)<br>plt.imshow(img)<br>img = np.expand_dims(img, axis=0)</pre><pre>from keras.models import load_model<br>saved_model = load_model(&quot;melanoma_model&quot;)<br>output = saved_model.predict(img)<br>if output[0][0] &gt; output[0][1]:<br>    print(&quot;melanoma&quot;)<br>else:<br>    print(&#39;not melanoma&#39;)</pre><p>Melanoma Classifier for images ISIC_0000002(Melanoma),ISIC_0000004.jpg(Melanoma) and ISIC_0001114.jpg(Not Melanoma)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*xA4o9NEJh-z3c07YDnPeQg.png" /><figcaption>ISIC_0000002.jpg</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*TBhHEMqUI_aS-mYem41ALQ.png" /><figcaption>ISIC_0000004.jpg</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*65AcW9IB-Y-QpUbKdA59RA.png" /><figcaption>ISIC_0001114.jpg</figcaption></figure><h3>🌱Conclusion</h3><p>This Melanoma Classifier achieved a performance accuracy of 93%, precision of 1 and recall of 0.5% with Melanoma images, through preprocessing images with VGG16. This indicated that training images need to be adjusted before they can be trained on deep learning models especially when aiming at higher performance accuracy.</p><p>Full code can be found on my <a href="https://github.com/MaryAdewunmi/Preprocess-Image-with-VGG16/blob/main/Melanoma_Classifier_Model_with_VGG16_CNN.ipynb">here</a></p><p>For researchers, kindly reference and cite the work using this link <a href="https://www.scienceopen.com/document/read?id=bbdc162f-242b-41d4-a07a-6df03110f0bd">https://www.scienceopen.com/document/read?id=bbdc162f-242b-41d4-a07a-6df03110f0bd</a></p><p>🌱<strong>References</strong></p><p>📌Rotemberg, V., Kurtansky, N., Betz-Stablein, B., Caffery, L., Chousakos, E., Codella, N., Combalia, M., Dusza, S., Guitera, P., &amp; Gutman, D. (2021). A patient-centric dataset of images and metadata for identifying melanomas using clinical context. <em>Scientific Data</em>, <em>8</em>(1), 1–8.</p><p>📌Simonyan, K., &amp; Zisserman, A. (2014). Very deep convolutional networks for large-scale image recognition. <em>arXiv preprint arXiv:1409.1556</em>.</p><p>📌<a href="https://www.kaggle.com/c/siim-isic-melanoma-classification/data">https://www.kaggle.com/c/siim-isic-melanoma-classification/data</a></p><p>📌S. Albawi, T. A. Mohammed and S. Al-Zawi, “Understanding of a convolutional neural network,” <em>2017 International Conference on Engineering and Technology (ICET)</em>, 2017, pp. 1–6, doi: 10.1109/ICEngTechnol.2017.8308186.</p><p>📌D. Stutz and L. Beyer, “Understanding Convolutional Neural Networks,” 2014.</p><p>📌<a href="https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator">https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing/image/ImageDataGenerator</a></p><p>Congrats! You are now well on your way to building a Melanoma cancer classifier with VGG16-CNN👏👏</p><p>For referencing and citations, the scientific poster on this work can be found <a href="https://www.scienceopen.com/document/read?id=bbdc162f-242b-41d4-a07a-6df03110f0bd">here</a></p><p>The Github repository for this tutorial can be found <a href="https://github.com/MaryAdewunmi/Preprocess-Image-with-VGG16/blob/main/Melanoma_Classifier_Model_with_VGG16_CNN.ipynb">here</a>.</p><p>Thanks for reading!</p><p>Happy coding😘</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c82e236fd3f0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/enhanced-melanoma-model-classifier-with-cnn-vgg16-c82e236fd3f0">Enhanced Melanoma Classifier Model with CNN-VGG16</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Melanoma Image Classification model with Convolutional Neural Network(CNN)]]></title>
            <link>https://maryadewunmi.medium.com/build-a-melanoma-image-classification-model-with-convolutional-neural-network-cnn-d96a61b9e639?source=rss-783d698d7d73------2</link>
            <guid isPermaLink="false">https://medium.com/p/d96a61b9e639</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[medical-image-analysis]]></category>
            <category><![CDATA[convolutional-neural-net]]></category>
            <category><![CDATA[melanoma]]></category>
            <dc:creator><![CDATA[Mary Adewunmi]]></dc:creator>
            <pubDate>Thu, 10 Jun 2021 13:09:36 GMT</pubDate>
            <atom:updated>2021-06-12T09:09:27.011Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IBcY1D_QlSisyPUIVoNPuA.jpeg" /><figcaption><a href="https://unsplash.com/photos/XknuBmnjbKg?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditShareLink">Source</a></figcaption></figure><p>Melanoma is otherwise called malignant melanoma. It is a type of skin cancer that develops from the pigment-producing cells known as melanocytes. Melanomas typically occur in the skin but may rarely occur in the mouth, intestines or eye (uveal melanoma) — <a href="https://en.wikipedia.org/wiki/Melanoma">Wikipedia</a><br>Symptoms might include a new, unusual growth or a change in an existing mole. Melanomas can occur anywhere on the body.<br>Treatment may involve surgery, radiation, medication or in some cases, chemotherapy.</p><p><strong>📌 Task at hand<br></strong>This Notebook is written to identify melanoma in lesion images in the target data. The problem is to predict the probability (floating point) that the lesion in the image is malignant (the target).</p><p>The datasets can be found <a href="https://www.kaggle.com/c/siim-isic-melanoma-classification">here</a>.</p><p>The complete notebook can be found <a href="https://github.com/MaryAdewunmi/Kaggle-BIPOC/blob/main/isic-melanoma-image-classification-with-cnn.ipynb">here</a>.</p><p><strong>📌 Importing the necessary libraries</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8669fa1d3d41663a631af861206ec80/href">https://medium.com/media/b8669fa1d3d41663a631af861206ec80/href</a></iframe><p><strong>📌 The datasets</strong></p><p>The datasets were publicly made available by Kaggle and can be found <a href="https://www.kaggle.com/c/siim-isic-melanoma-classification">here</a>. It is provided by the International Skin Imaging Collaboration (ISIC), funded by the International Society for Digital Imaging of the Skin, which is an international initiative to improve melanoma diagnosis (ISDIS). The ISIC Archive houses the world’s largest collection of high-resolution dermoscopic photographs of skin lesions. Contributors to the images include:</p><p>1. Dermatology Service, Melanoma Unit, Hospital Clínic de Barcelona, IDIBAPS, Universitat de Barcelona, Barcelona, Spain<br>2. Memorial Sloan Kettering Cancer Center New York, NY<br>3. Department of Dermatology, Medical University of Vienna. Vienna, Austria<br>4. Melanoma Institute Australia. Sydney, Australia<br>5. The University of Queensland, Brisbane, Australia<br>6. Department of Dermatology, University of Athens Medical School</p><p>It has 9 classes of Skin diseases which are pigmented benign keratosis, melanoma, vascular lesion, actinic keratosis, squamous cell carcinoma, basal cell carcinoma, seborrheic keratosis, dermatofibroma and nevus.</p><p><strong>📌 Splitting datasets into train and validation data using Keras image data generator</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9bf571f7e37cf7060426db5eb9e27822/href">https://medium.com/media/9bf571f7e37cf7060426db5eb9e27822/href</a></iframe><p><strong>📌Visualizing the classes of skin lesion images in the dataset</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/49e49c74ab0466e4d686241069a5afc6/href">https://medium.com/media/49e49c74ab0466e4d686241069a5afc6/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VlOUhIx4ZAcq3SRrM8qsMQ.png" /></figure><p>The figure above showed 5 classes of lesion images but there are 9 classes, knowing fully well that we pick the images from train datasets and there are bound to be a repetition of image classes since our data was split randomly not sorted.</p><p><strong>📌 Prefetching and Autotuning of Images as part of Image preprocessing</strong></p><p>Prefetching of images is used to prepare the environment for training and ensuring images are taken from the disk without having I/O blocked while autotuning of images in batches is to prevent the large dataset from becoming a bottleneck while training the model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dced2174cb88a18db2b1bdc7c63d667/href">https://medium.com/media/4dced2174cb88a18db2b1bdc7c63d667/href</a></iframe><p><strong>📌Normalization</strong></p><blockquote><a href="https://radiopaedia.org/"><strong>Image normalization</strong></a> is a process, often used in the preparation of data sets for artificial intelligence (AI), in which multiple <strong>images</strong> are put into a common statistical distribution in terms of size and pixel values; however, a single <strong>image</strong> can also be <strong>normalized</strong> within itself.</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c751bdb50e6405164c2e0b1c4d12f5bb/href">https://medium.com/media/c751bdb50e6405164c2e0b1c4d12f5bb/href</a></iframe><p>This is a very important part of preprocessing images because there are some images with large pixel intensity values and it may be impossible to extract features from such images with the current model. Another challenge with images having multiple colours is that it is computationally intensive to work with.</p><p><strong>📌 Training the Model with CNN</strong></p><p>There are three types of layers in CNN which are convolutional, pooling and fully connected layer with additional layers of dropout for reducing overfitting of models and finally the activation layer for adding non -linearity to the model. More on CNN can be found <a href="https://www.upgrad.com/blog/basic-cnn-architecture/">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*wsFpCOxFrb18d_1ii8RgeA.png" /></figure><p><a href="https://medium.com/techiepedia/binary-image-classifier-cnn-using-tensorflow-a3f5d6746697">Source</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88cb18b0c0f05cb62902a2b19f27f98d/href">https://medium.com/media/88cb18b0c0f05cb62902a2b19f27f98d/href</a></iframe><p><strong>📌 Visualizing the model’s parameters</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/86b24eecbff814e95e0f6decb299b6cd/href">https://medium.com/media/86b24eecbff814e95e0f6decb299b6cd/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*05TYJRtmXIDOu65g5Jb04Q.png" /></figure><p>The accuracy of the model changes since the training images was randomly picked, the accuracy will resonate with the image type picked for training.</p><p><strong>📌 Model accuracy</strong></p><p>Visualizing the model performance below shows there is overfitting of the model because the training loss is constantly decreasing but the validation loss is not. This shows that the model has memorized the training data patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*7ZEs6zN2JuZrO7ta-c10ag.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4c9a79180010a02452f783e1af3352e/href">https://medium.com/media/a4c9a79180010a02452f783e1af3352e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*lKQvx0kOQbNNZM9Sza7zRg.png" /></figure><p><strong>📌Ways of boosting the performance include one or more combination of the following:</strong></p><p>👉Reduce the layers of the neural network</p><p>👉 Add dropout and tune its rate✔</p><p>👉 Apply L2 normalization and tune the lambda value✔</p><p>👉 Freeze the number of neurons in each network layer so as to reduce the parameters</p><p>👉 Add more training data which is not always economical because of storage cost, a workaround is to augment the images</p><p><strong>📌Augmentation</strong></p><p>We augment the images considering the small dataset we used in a bid to manage space and lower the cost of training the images.</p><p>More from Augmentation can be found <a href="https://neptune.ai/blog/data-augmentation-in-python">here</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/305b19b700f0d62b33a7802d95161963/href">https://medium.com/media/305b19b700f0d62b33a7802d95161963/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*wIiTRLrHykKLiapQ4bnQ7g.png" /></figure><p>To re-train the model with the augmented images</p><p>👉Reduce the layers of the neural network✔</p><p>👉 Add more training data which is not always economical because of storage cost, a workaround is to augment the images✔</p><p><strong>📌 View the model’s performance with augmented images</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*7O52spx1ypNLxNgCycc_uA.png" /><figcaption>Accuracy/Loss</figcaption></figure><p>The model performance looks good and it ranges between 60 -65% depending on the size of the images randomly picked from the training data and can still be worked upon with an efficient net model. I will do that in my future post.</p><p><strong>📌 Conclusion</strong></p><p>Training medical images can be an uphill task if the image size is small and can cause overfitting problem but can be fixed by augmenting the available images. Also, the accuracy can further be improved with preprocessing operations like applying a filter to the image, tuning the parameters, using other network topology like EffNet.</p><p>The complete notebook can be found<a href="https://github.com/MaryAdewunmi/Kaggle-BIPOC/blob/main/isic-melanoma-image-classification-with-cnn.ipynb"> here</a>.</p><p><strong>📌References</strong></p><p>✔Data curated from <a href="https://www.kaggle.com/c/siim-isic-melanoma-classification">https://www.kaggle.com/c/siim-isic-melanoma-classification</a></p><p>✔<a href="https://en.wikipedia.org/wiki/Melanoma">https://en.wikipedia.org/wiki/Melanoma</a></p><p>✔<a href="https://neptune.ai/blog/data-augmentation-in-python">https://neptune.ai/blog/data-augmentation-in-python</a></p><p>✔Source: <a href="https://medium.com/techiepedia/binary-image-classifier-cnn-using-tensorflow-a3f5d6746697">https://medium.com/techiepedia/binary-image-classifier-cnn-using-tensorflow-a3f5d6746697</a></p><p>✔<a href="https://www.upgrad.com/blog/basic-cnn-architecture/">https://www.upgrad.com/blog/basic-cnn-architecture/</a></p><p>If you found this tutorial useful, kindly appreciate it with a clap👏. Constructive criticism is welcome👍</p><p>More <a href="https://about.me/maryadewunmi">information</a> about me.</p><p>Happy coding😉.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d96a61b9e639" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analysing large images with Dask library]]></title>
            <link>https://maryadewunmi.medium.com/analysing-images-with-dask-a45e76def4cf?source=rss-783d698d7d73------2</link>
            <guid isPermaLink="false">https://medium.com/p/a45e76def4cf</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[medical-image-analysis]]></category>
            <category><![CDATA[dask]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[image]]></category>
            <dc:creator><![CDATA[Mary Adewunmi]]></dc:creator>
            <pubDate>Mon, 31 May 2021 07:27:00 GMT</pubDate>
            <atom:updated>2021-06-10T19:32:13.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eMx95xhu55j_HqeU3ev7Vg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@nci?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">National Cancer Institute</a> on <a href="https://unsplash.com/s/photos/medical-images?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This is a short tutorial on how to load images with the dask machine learning library.</p><p>I decided to write a tutorial on this when I saw, there was no straightforward tutorial on how I can load a large image dataset without my kernel crashing or an error of low memory to accommodate the proposed dataset.</p><p><strong>📌 Why did I choose to use Dask?</strong></p><p>Dask enables the natural scaling of Pandas, Scikit-Learn, and Numpy workflows with little rewriting when dealing with large datasets with a single computer. It works effectively with these tools, copying the majority of its API and internal data structures. Furthermore, Dask collaborates with these libraries to guarantee that they progress in a consistent manner, reducing friction when moving from a local laptop to a multi-core workstation, and finally to a distributed cluster.</p><p>The full code can be found <a href="https://github.com/MaryAdewunmi/Kaggle-BIPOC/blob/main/isic-images-analysis-with-dask%20(1).ipynb">here</a>.</p><p><strong>📌Setting up the environment</strong></p><ol><li><strong>Installing the necessary Libraries</strong></li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7f53423e06de5c71285305a1aa597c8/href">https://medium.com/media/d7f53423e06de5c71285305a1aa597c8/href</a></iframe><p><strong>2. Create a temporary directory for temporary files in other to prevent large images from occupying space on the system memory.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4e8dc21cda8e51475dc5681c7f335c0/href">https://medium.com/media/a4e8dc21cda8e51475dc5681c7f335c0/href</a></iframe><p><strong>3. Importing our datasets</strong></p><pre><strong>About the datasets, it can be downloaded from </strong><a href="https://www.kaggle.com/c/siim-isic-melanoma-classification/data">https://www.kaggle.com/c/siim-isic-melanoma-classification/data</a></pre><pre>The datasets was publicly made available by Kaggle but provided by the International Skin Imaging Collaboration (ISIC), funded by the International Society for Digital Imaging of the Skin, is an international initiative to improve melanoma diagnosis (ISDIS). The ISIC Archive houses the world&#39;s largest collection of high-resolution dermoscopic photographs of skin lesions. Contributors to the images include:</pre><pre>​1. Dermatology Service, Melanoma Unit, Hospital Clínic de Barcelona, IDIBAPS, Universitat de Barcelona, Barcelona, Spain</pre><pre>2. Memorial Sloan Kettering Cancer Center New York, NY</pre><pre>3. Department of Dermatology, Medical University of Vienna. Vienna, Austria</pre><pre>4. Melanoma Institute Australia. Sydney, Australia</pre><pre>5. The University of Queensland, Brisbane, Australia</pre><pre>6. Department of Dermatology, University of Athens Medical School</pre><pre>It has 9 classes of Skin diseases which are pigmented benign keratosis, melanoma,vascular lesion,actinic keratosis,squamous cell carcinoma,basal cell carcinoma,seborrheic keratosis,dermatofibroma and nevus.<br></pre><p>This codes actually divides the datasets into chunk and save it in a temporary directory that we created earlier</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa0a285f834cba6a0bd75eafabe284ff/href">https://medium.com/media/aa0a285f834cba6a0bd75eafabe284ff/href</a></iframe><p>One can also preprocess images uploaded with dask, by changing it to gray as illustrated below, for distinct pixel information, augment images for more dataset, segment images and filter the images using dask temporary storage.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/478b0a54463b987670362ae19cc4be3b/href">https://medium.com/media/478b0a54463b987670362ae19cc4be3b/href</a></iframe><p>Another beautiful thing about dask is you can decide to visualize computation graph of images, how it is being preprocessed, the array, chunk size and data type of your image with few lines of code and it will be very useful for debugging in case there is an error on the graph.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/454b523e245b063e64e3ce94261d3cd9/href">https://medium.com/media/454b523e245b063e64e3ce94261d3cd9/href</a></iframe><p><strong>📌Conclusion</strong></p><p>Dask is a powerful tool in the hand of Machine learning analyst especially when large image datasets are involved. It is cheap to use compare to Cloud notebooks and one can also use them with Cloud servers notebooks like Jupyter notebook, Saturn notebook and the likes.</p><p><strong>📌 References</strong></p><p>👉Photo by <a href="https://unsplash.com/@nci?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">National Cancer Institute</a> on <a href="https://unsplash.com/s/photos/medical-images?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></p><p>👉 Datasets can be found <a href="https://www.kaggle.com/c/siim-isic-melanoma-classification">here</a></p><p>👉Dask <a href="http://docs.dask.org/">documentation</a></p><p>Any feedback or constructive criticism is welcome.</p><p>You can find me <a href="https://about.me/maryadewunmi">here</a>.</p><p>Happy coding😉!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a45e76def4cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>