Prasad Chaskar's other Models Reports

Major Concepts

 

Sign-Up/Login to access Several ML Models and also Deploy & Monetize your own ML solutions for free

Skin Disease Prediction

Models Status

Model Overview


Introduction


Skin  Disease  are  occurring  almost  on  all  groups  of  ages  among  people.  The  rate  of  skin  disease  has been  increased  due  to  lifestyle  and  changing  environments .They  are  usually caused  by  factors  like  different  organism’s  cells,  a  different  diet,  and  internal  and  external  factors, such  as  the  hierarchical  genetic  group  of  cells,  hormones,  and  immune  system  of  conditions.  These factors  may  act  together  or  in  a  sequence  of  skin  disease.  There  are  chronic  and  incurable  diseases, like  eczema  and  psoriasis,  and  malignant  diseases  like  malignant  melanoma.  Recent  researchers  have found  the  availability  of  cures  for  these  diseases  if  they  are  detected  in  theapplication  of skin  disease  detection  using CNN methods  was  felt  to  be  very necessary  to  help  all  people  who  want  to  know  about  skin  diseases  that  are  being  experienced  or  need information  about  skin  diseases.

The five types of skin diseases are :

1]Chickenpox (class 0)
2]Impetigo (class 1)
3] Infectious erythema (class 2)
4]Scabies (class 3)
5]Skin warts (class 4)


Dataset Link :https://www.kaggle.com/amaljeza/skin-diseases


Code:

Required Libraries :



import tensorflow as tf
from tensorflow.keras import models, layers
import matplotlib.pyplot as plt
from pprint import pprint
import cv2
import numpy as np​

Load Dataset :


import pathlib
from pathlib import Path
my_path = Path(r'/content/Skin disease/Train ')

skin_images_dict = {
'Chickenpox': list(my_path.glob('Chickenpox /*')),
'Impetigo': list(my_path.glob('Impetigo /*')),
'Infectious erythema': list(my_path.glob('Infectious erythema /*')),
'Scabies': list(my_path.glob('Scabies /*')),
'Skin warts': list(my_path.glob('Skin warts /*'))
}
skin_labels_dict = {
'Chickenpox': 0,
'Impetigo': 1,
'Infectious erythema': 2,
'Scabies': 3,
'Skin warts':4
}

Dependent and Independent Variable:


X = []
y = []
for tumor_name,images in skin_images_dict.items():
for image in images:
img = cv2.imread(str(image))
resize = cv2.resize(img,(200,200))
X.append(resize)
y.append(skin_labels_dict[tumor_name])

Perform some data preprocessing :


X = np.array(X)
y = np.array(y)

X_scaled = X/255

Model Creation :


from tensorflow.keras import  models,layers
model = models.Sequential([
layers.Conv2D(filters=32, kernel_size=(4, 4),
activation='relu', input_shape=(200, 200, 3)),
layers.MaxPooling2D(pool_size=(2, 2)),

layers.Conv2D(filters=64, kernel_size=(3, 3),
activation='relu'),
layers.MaxPooling2D(pool_size=(2, 2)),
layers.Conv2D(filters=124, kernel_size=(3, 3),
activation='relu'),
layers.Dropout(0.5),
layers.Flatten(),
layers.Dense(270,activation='relu'),
layers.Dense(5,activation='softmax')
]
)
model.compile(
optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)

Train Model :


model.fit(X_scaled,y,epochs=20)


Model Evaluation :
Load Test data :


test_path = Path(r'/content/Skin disease/Test ')
test_images_dict = {
'Chickenpox': list(test_path.glob('Chickenpox/*')),
'Impetigo': list(test_path.glob('Impetigo/*')),
'Infectious erythema': list(test_path.glob('Infectious erythema/*')),
'Scabies': list(test_path.glob('Scabies/*')),
'Skin warts': list(test_path.glob('Skin warts/*'))
}

Perform data processing operations on test data as we perform on train data.


X_test = []
y_test = []

for tumor_name,images in skin_images_dict.items():
for image in images:
img = cv2.imread(str(image))
resize = cv2.resize(img,(200,200))
X_test.append(resize)
y_test.append(skin_labels_dict[tumor_name])

X_test = np.array(X_test)
y_test = np.array(y_test)

X_test_scaled = X_test/255

Check Accuracy for test data :


model.evaluate(X_test_scaled,y_test)

Classification Report :
Class 0 : Chickenpox
Class 1 : Impetigo
Class 2 : Infectious erythema
Class 3 : Scabies
Class 4 : Skin warts


y_pred = list()
for i in model.predict(X_test_scaled):
y_pred.append(np.argmax(i))
y_pred = np.array(y_pred)

from sklearn.metrics import classification_report,confusion_matrix
print(classification_report(y_test,y_pred))


Confusion Matrix :


import seaborn as sns
import pandas as pd
class_names = [0,1,2,3,4]
fig,ax = plt.subplots()
tick_marks = np.arange(len(class_names))
plt.xticks(tick_marks,class_names)
plt.yticks(tick_marks,class_names)
cnf_matrix = confusion_matrix(y_test,y_pred)
sns.heatmap(pd.DataFrame(cnf_matrix), annot = True, cmap = 'YlGnBu',
fmt = 'g')
ax.xaxis.set_label_position('top')
plt.tight_layout()
plt.ylabel('Actual label')
plt.xlabel('Predicted label')
plt.show()


Thank You ):


0 comments