banner



How To Tell If Its Skin Cancer

Pedagogy Machines to Detect Skin Cancer

Leveraging artificial intelligence to allocate medical images such as images of moles, CT scans, MRI scans and etc. as a diagnosis tool.

  1. A visit to your family dr. to determine if further testing is required (~3 days to schedule an date)
  2. If further testing is required, a skin biopsy is typically performed (~iii weeks to schedule an appointment)
  3. If diagnosed with skin cancer, farther testing may be recommended to provide boosted details similar the phase of cancer (~additional ii weeks)

Understanding the dataset: MNIST HAM 10000

  • Actinic keratosis is considered to be a noncancerous (benign) type of skin cancer. However, if left untreated, it normally develops into squamous cell carcinoma (which is cancerous).
  • Dissimilar actinic keratosis, basal cell carcinoma is a cancerous blazon of skin lesion that develops in the basal cell layer located in the lower part of the epidermis. It is the about common type of peel cancer accounting for 80% of all cases.
  • Benign keratosis is a noncancerous and slow-growing blazon of skin cancer. They can be left untreated as they are typically harmless.
  • Dermatofibromas are besides noncancerous and usually harmless, thus no handling is required. It is commonly found pinkish in color and appears like a round bump.
  • Melanoma is a type of malignant peel cancer that originated from melanocytes, cells that are responsible for the pigment of your skin.
  • Melanocytic nevi are a benign type of melanocytic tumor. Patients with melanocytic nevi are considered to exist at a higher take chances of melanoma.
  • Vascular lesions are equanimous of a wide range of skin lesion including cherry angiomas, angiokeratomas, and pyogenic granulomas. They are similarly characterized as being red or purple in color and frequently appear equally a raised bump.

Basal cells are located in the lower part of the epidermis layer of the skin. Melanocytes are located beneath basal cells.

Only wait, what is Deep Learning?

  1. Input Layer: where the input information is fed into the model
  2. Hidden Layers: responsible for discovering the meaning of the information
  3. Output Layer: returns the predicted respond/label

Weights are denoted by the symbol w, and biases are denoted by the symbol b.

The cost role is also known as a loss function. Slope descent is used to find the minimum (which is labeled as the winner in the motion-picture show).

The Model: Leveraging Convolutional Neural Networks

  1. Convolutional layers
  2. Pooling layers
  3. Fully connected layers

An example of a convolutional layer doing its job. Dot multiplication is performed betwixt the matrix of the weight and the matrix of the input paradigm of the same shape equally the weight. The resulting product is produced and shown on the left-most matrix.

Max pooling function

The Nitty-Gritty (aka The Source Lawmaking)

          #-------------------------Kaggle API Setup---------------------          #Install kaggle library
!pip install kaggle
#Make a directory called .kaggle which makes it invisible
!mkdir .kaggle
import json
token = {"username":"ENTER YOUR USENAME","key":"ENTER YOUR Key"}
with open('/content/.kaggle/kaggle.json', 'w') as file:
json.dump(token, file)

!cp /content/.kaggle/kaggle.json ~/.kaggle/kaggle.json
!kaggle config set -n path -v{/content}
!chmod 600 /root/.kaggle/kaggle.json

          #---------------Downloading and unzipping the files--------------          #Data directory: where the files volition unzip to(destination folder)            
!mkdir information
!kaggle datasets download kmader/peel-cancer-mnist-ham10000 -p information
!apt install unzip !mkdir HAM10000_images_part_1
!mkdir HAM10000_images_part_2
!unzip /content/data/pare-cancer-mnist-ham10000.zip -d /content # Unzip the whole zipfile into /content/data
!unzip /content/data/HAM10000_images_part_1.null -d HAM10000_images_part_1
!unzip /content/data/HAM10000_images_part_2.zip -d HAM10000_images_part_2
#Ouputs me how many files I unzipped
!echo files in /content/data: `ls data | wc -l`
          #-------------------Make directories for the data-------------------          import os            
import errno
base_dir = 'base_dir' image_class = ['nv','mel','bkl','bcc','akiec','vasc','df'] #3 folders are made: base_dir, train_dir and val_dir try:
os.mkdir(base_dir)

except OSError equally exc:
if exc.errno != errno.EEXIST:
raise
pass

train_dir = bone.path.bring together(base_dir, 'train_dir')
attempt:
os.mkdir(train_dir)
except OSError as exc:
if exc.errno != errno.EEXIST:
heighten
pass
val_dir = os.path.join(base_dir, 'val_dir')
endeavor:
os.mkdir(val_dir)

except OSError as exc:
if exc.errno != errno.EEXIST:
heighten
laissez passer

#make sub directories for the labels
for x in image_class:
os.mkdir(train_dir+'/'+ten)
for x in image_class:
os.mkdir(val_dir+'/'+ten)
          #-----------------splitting data/transfering data-------------------          #import libraries            
import pandas as pd
import shutil
df = pd.read_csv('/content/information/HAM10000_metadata.csv') # Set y as the labels
y = df['dx']
#split data
from sklearn.model_selection import train_test_split
df_train, df_val = train_test_split(df, test_size=0.i, random_state=101, stratify=y)
# Transfer the images into folders, Set the image id equally the alphabetize
image_index = df.set_index('image_id', inplace=True)
# Go a list of images in each of the two folders
folder_1 = os.listdir('HAM10000_images_part_1')
folder_2 = os.listdir('HAM10000_images_part_2')
# Get a list of train and val images
train_list = list(df_train['image_id'])
val_list = list(df_val['image_id'])
# Transfer the grooming images
for image in train_list:
fname = image + '.jpg' if fname in folder_1:
#the source path
src = bone.path.bring together('HAM10000_images_part_1', fname)

#the destination path
dst = os.path.join(train_dir+'/'+df['dx'][image], fname)
impress(dst)

shutil.copyfile(src, dst)

if fname in folder_2:
#the source path
src = bone.path.join('HAM10000_images_part_2', fname)
#the destination path
dst = os.path.join(train_dir, fname)

shutil.copyfile(src, dst)

# Transfer the validation images
for paradigm in val_list:
fname = paradigm + '.jpg' if fname in folder_1:
#the source path
src = bone.path.join('HAM10000_images_part_1', fname)
#the destination path
dst = os.path.join(val_dir+'/'+df['dx'][epitome], fname)

shutil.copyfile(src, dst)

if fname in folder_2:
#the source path
src = os.path.join('HAM10000_images_part_2', fname)

# destination path to image
dst = bone.path.join(val_dir, fname)
# copy the image from the source to the destination
shutil.copyfile(src, dst)
y_valid.suspend(df['dx'][image])
# Check how many grooming images are in train_dir
print(len(os.listdir('base_dir/train_dir')))
print(len(os.listdir('base_dir/val_dir')))
# Check how many validation images are in val_dir
print(len(os.listdir('information/HAM10000_images_part_1')))
print(len(os.listdir('data/HAM10000_images_part_2')))
          #--------------image generator---------------
from keras.preprocessing.image import ImageDataGenerator
import keras
print(df.caput())
image_class = ['nv','mel','bkl','bcc','akiec','vasc','df']
train_path = 'base_dir/train_dir/'
valid_path = 'base_dir/val_dir/'
print(os.listdir('base_dir/train_dir'))
print(len(os.listdir('base_dir/val_dir')))
image_shape = 224 train_datagen = ImageDataGenerator(rescale=ane./255)
val_datagen = ImageDataGenerator(rescale=1./255)
#declares information generator for train and val batches
train_batches = train_datagen.flow_from_directory(train_path,
target_size = (image_shape,image_shape),
classes = image_class,
batch_size = 64
)
valid_batches = val_datagen.flow_from_directory(valid_path,
target_size = (image_shape,image_shape),
classes = image_class,
batch_size = 64 )
          #-------------------------------model------------------------------
from keras.models import Sequential
from keras.layers import Dense, Activation
from keras.layers import Conv2D, MaxPool2D, Dropout, Flatten
from keras.callbacks import ReduceLROnPlateau
from keras.models import Model
mobile = keras.applications.mobilenet.MobileNet()
ten = mobile.layers[-6].output
# Add a dropout and dumbo layer for predictions
x = Dropout(0.25)(x)
predictions = Dumbo(7, activation='softmax')(x)
print(mobile.input)
internet = Model(inputs=mobile.input, outputs=predictions)
mobile.summary()
for layer in net.layers[:-23]:
layer.trainable = False
net.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
learning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', patience=3, verbose=i, gene=0.5, min_lr=0.00001) history = net.fit_generator(train_batches, epochs=10)

Key Takeaways

  • Deep learning is inspired past the neural connectivity of the encephalon in that every node in each layer is continued to the side by side layer
  • Convolutional neural networks have 3 chief types of hidden layers: convolutional layer, pooling layer, and fully connected layer
  • A filter (for CNNs) is used to extract features from the data

Don't forget to:

  • Clap this commodity if yous enjoyed information technology
  • Connect with me on LinkedIn

Source: https://medium.com/analytics-vidhya/teaching-machines-to-detect-skin-cancer-bd165566f0fe

Posted by: taorminapricandere.blogspot.com

0 Response to "How To Tell If Its Skin Cancer"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel