This content details the process of building and evaluating a deep learning model for classifying skin cancer as benign or malignant, using a ResNet50 architecture and transfer learning. It also outlines plans for a subsequent phase focused on identifying the affected area within an image.
Mind Map
Click to expand
Click to explore the full interactive mind map • Zoom, pan, and navigate
hi this is raju from smart air technologies
technologies
welcome back today we will see a concept
called detecting the skin cancer
using deep learning
here i am importing an image that is m4.jpg
m4.jpg
here you can see what is that this is
that image which i am feeding to my
model final model
then what happens once i feed that
i am displaying that image to show you
okay and i am feeding that image now
after reading i am going to get the
prediction done on my model this is my
model model resonance 50 here i am using
a resonance 50 i'm using that saved
model and i am loading the data okay and
i'm getting the result here
once i get the result
so it will give me the result in ra
format okay
class 1 will be 0 class 2 is 99 what
this mean is in our data set whenever i
open class 2 is malignant
class 1 is benign it means the date the
image is malignant but i should display
it so what i am doing is i am taking the
data i am reading it and i am taking the
maximum maximum value in that list and i
am taking its index now i will compare
it with this list once i compare it with
this list i will get if that that is the
second one it will be malignant if it is
first one it will be benign
type of cancer okay
now i'm getting malignant that that i'm
uh finally printing out as an entitled
it means if it's malignant it will be
malignant if it's benign it will say it
is benign we will try with benign one
one more time we'll take one another
input and we'll try okay so
so
here i pasted b1 b2
let us take a b1
okay under percent it says it belongs to
class one it means
finally it will
it will print us like this is belong
this belongs to banana and
okay it is printing the data this is the
first part of this video actually i need
to extend it to second part or third
part why because i will tell you the
second part will be detecting the area of
of
which is actually got affected here i
need to round it up or i need to
recognize that area to do that what are
the steps i need to do that i'll try to
explain you in the next part of video
because first we need to do
classification then we need to do the
recognition okay
in this case we are going we are
concentrating on classification of
benign and malignant cancer okay there
are skin cancer types so
try to follow uh the whole step here okay
okay
once if you see this video the next part
will be very easy for you to understand okay
before moving to concept i just
want to show you something
here we reach actually 300 subscribers
thank you for that we ever subscribed it
and here uh we are posting so many good
videos you can watch them because you
can see a face emotion deduction uh
building softwares
and there are so many good concepts like
uh pneumonia and cow detections malaria
disease detections and
and
brain tumor detection
on one of the best thing is image
augmentation here i i tried to explain
what is the
importance of image augmentation how it
helps to increase the accuracy of any
deep learning model
and also i try to explain uh properly
with some example what is the difference
between artificial intelligence data
science and machine learning you can
watch it once more uh if you didn't
watch it and also i told like what are
the best five ways to increase the
uh there are some good projects also
they may help you like detecting the and
written text from the medical prescription
prescription
and getting details of the medicine
and cricket data analysis this is one of the
the
one of the best analysis project you can
see within one month we got
2.7 k viewers like
so many people are watching it okay so
many people are liking this video
it will be very helpful for you
for an analysis perspective
perspective
and one of our best project like
so many students watching are like uh
handwritten text recognition using deep
learning part one here we are detecting
the handwritten part of any image we are
converting it into some other language
so there we are doing computer vision
plus uh machine translation so
so
you if you watch it you may get some
extra information extra knowledge also
yeah that was it uh
try to watch the videos try to visit to our
our
channel they may help you okay let us
now our first part of the code is
importing the data importing the
libraries here i'm importing os
operating system and glob operating
system is used to access the operating
system function uh operating system uh
element of the system that is files folders
folders mic
mic or
or
camera like that and glob is used to get
the in-depth information of any files or folders
folders
numpy is actually used to work with
arrays and matrices seaborn and
matplotlib are used to plot the graphs
pandas is a library which is used to
input any datasets external dataset
maybe csv excel sheet or dot txt okay
and also this is used to create new data sets
sets
we call uh we call it as a data frame
once we create data frame by creating
rows and columns we can convert that
into excel sheet or txt or
csv you can export that okay all those
then comes psychic learn using this
massacre learn is the machine learning
model based library here from that i am
taking a function called train test
split which is is which is used to
split the data into train test and validation
validation
that you will see in the uh
in the code or in the explanation next
how i am using that and in which way i
am splitting the data and then comes the
image data generator this is one of the
most important library uh try to follow
a follow-up in the video because you
will you will understand what is the
what is the key importance of this image
data generator why i am using it what is
the need for using it okay
and model model is the keras library
which is used to create deep learning
model from
layers or random layers will bundle up
and create a model you will see that
okay uh watch continuously you will see
i will explain
where i will use model and all
then comes layers convolution 2d max protruding
protruding
max pooling 2d flatten dance and dropout
these are all uh deep learning layers
are say neural networks are
like that you can
okay but about them i will tell you uh
below how we can stack them and build a
deep learning model in the end
now early stopping on callback
i will explain all these below okay if i
explain it now here i think it will uh
it will be somewhat hard to understand
once we go with the concept you will
understand it very clearly okay
this this was about the libraries anyway uh
uh
these libraries i will i'll explain
about these libraries in the video okay
so don't miss okay watch continuously
file uh first i am defining what is the
path of my data set
my data set contains
train folder and folder there are two
subfolders one is benign and another one
management these are two classes of the uh
uh
cancer cells now
after that i am going to get what are
the types of
classes i have i have two types one is
benign and malignant and after that
using glob as i mentioned above once if
i call globe.globe
i can mention the path whichever the
path i mention it will fetch the all
content of it file path is
train under train it will go first then
it will go to uh
uh
subfolders under train uh it has benign
and malignant it will go to those two
folders and after that if i use slash
and start or star it will fetch all the
content of all the subfolders like
complete path that you will get okay
here you can see
train b9
1298.jpg this is the
image by the complete image path in
benign like that you will get from both
banan and malignant it will give me the
complete path as a list i am taking it
as a list here you can see here if i am
doing it as list i will get the list of
all the paths okay this was my first
part next what i am doing is how to get
the labels here i have i think uh you
may know are
you may not know like uh whenever it
comes to any machine learning or deep
learning you we need to have two thing
one is input and another one is output
what is input input in our case is a
image what is output output should be
what that image is that is label we say
okay we should have two things for
example there in the file paths
train slash banan slash 1298.jpg
this is the image what is the label
where is that
we should have that list also
for this input we should have output
list we should create it if we don't
then now you will create it
then what i am doing is the bullish time
importing first okay then what i am
doing is i am splitting each each
element and among each element i am
taking the
second element here
you can see that like
zero one one nothing but the second element
element
benign or like that okay
when i extract only second element you
can see ben and bernie is there in the
end malignant will be there
okay for malignant image the data path
malignant will be there okay
maybe you can see here i think okay the
list is the list is very lengthy so we
are not getting there
here i am trying to create a data frame
as i mentioned i am taking those two
list i am making it as in a two columns
here file path that related
label okay that file path and that
related label malignant
this is benign okay this is malignant
benign malignant binary like that okay
for all the images now i have a proper
data set data frame here
now i want to analyze whether my data
set is balanced or unbalanced
it's almost we can say like it's bit
balanced okay there are 400
more images then it's fine okay not much
i'm just plotting the graph for uh
see that okay what my data said
then comes
how the data set is splitted and what is
the way of splitting the data set
and uh
how we actually split the data set what
is splitting the data set okay i think
above you said that uh function and call
i was calling from circuit learn
train underscore test underscore split
how it works and what are the inputs
that we are feeding what will what is
the output that we are going to get
okay about this i will explain with the
diagram uh that may help you to
understand very easily so
so
we'll leave some online drawing tools um
yeah i don't know that's right
i will give with an example okay that
may make you to understand the concept
this is a baby
say
you have under fruits with you
with thunder fruits what you do is 70
you will split separately
30 will spread separately
now what is the task that you are having
is you need to teach this baby about
these fruits
okay first you will take one fruit say
you are taking apple okay
okay
you are you are telling that boy i
happen like that
what are the features you will show to
him color
okay it's safe
it's taste
like that for every fruit you will show
these things we call these them as a
features input features
okay these are all input features
but that fruit he will show to him is
the actual input okay
okay
this is actually input and while you are
training you will tell him like okay
this is the apple this is a mango like
that that we call it as an output
okay this is the output now you are
training him so whatever the input you
are using for training we call that
input as a training input
okay and whatever the labels you are
telling during training we call it as a
now that's fine only for 70 fruits you
will do like that first time you will do
you will learn like 30 percent
accurately you will learn okay and you
will feel like oh you didn't learn very
well you will
teach with the 70 fruits again and you
will training
you may learn 60 percent better
and again you will do
you may learn seventy percent
we call these repetitions as iterations
or epochs
we say
is that fine
okay once he learned very well you feel
you felt like okay he learned very well
now he is uh able to predict any
any fruit whatever you will show now 30
fruits kept separately initially now you
will take one more fruit from here and
you will ask him
and he will say
you will predict you will say okay for
example you took mango okay you told
like this is the apple he predicted it wrong
wrong
okay here whatever the inputs you will
show now these 30 inputs they will be
and whatever you will predict no
this will car this we can't as a
predicted result
and you already know what that fruit you
are showing to him that is testing
output testing output is already known
to you now you will compare
uh is predicted result with your testing
data say you shown 34 stream out of 30
if predicted 20 correct
10 wrong okay then it is 20 by 30
percent of accuracy
like 60 percent accurately is predicting the
the
fruits that means 60 percent accuracy he
learned about the information okay
okay
here splitting the data is done 70 30.
the same thing happens in our case also
here you can see here of the whole data
i am splitting the data into 75 and 25
25 for uh testing 75 for training that
is okay random state is used to mix up
the data
here what happens normally above benign
will be there below malignant will be
there when i split 75 25 25 will go only
for malignant it should not happen like
that testing data should ha should not
have only one type of input so i will
mix up the columns like this
like this it should be actually banana
and malignant should be mixed up okay
the rose should be mixed up that's why i
then i'm trying to plot some images
okay i'm trying to plot some images from
the data here you can see okay i'm just
plotting that okay now
now
i'm calling a function called image data
generator which i told you i think i
will explain now
this image data generator what it will
do is whatever the image you will feed
it to here it will be converted into a
multi-dimensional array
of a fixed size okay
okay
we call this image data generator
augmentation library some we can do
augmentation using image data generator
what is mean by augmentation for that i
made video
this video you can see here
okay this image augmentation using a
python to increase the accuracy if you
watch this video you will understand
very better what about augmentation you
can watch it okay it will be very
yeah
uh so
once i'm calling this function and i'm
assigning to another uh lib function a
variable called train datagen now
whatever the data we have it should be
converted into rs for that what i am
doing is train data gen function to this
function okay
uh sub function is flow from directive
sub function is there i am calling that
i am pushing my data whatever the data
images i have all the things i am
pushing it to train data janna and train
underscore data then once i push the
data train underscore then will be array
of images training images now will be in
array format
with the size of hundred hundred okay
that size is thirty two uh that's
nothing but bundling up how many images your
your
okay for that for like that i am doing
it for training
and testing and also even for validation uh
uh
once i done that you can see
1977 are for training 660 are for
testing and 664 validation
now here i am doing transfer learning
transfer learning by using resonate 50
what is this transfer learning and how
we use it that is also i explained
already uh in this
itself image augmentation uh video
itself i try to explain that that's fine
here i'll uh i'll tell you the
for example
you have a two person one no karate very
well won't know
nothing okay no nothing about martial
art now if you are asked to teach
kung fu to both of them will learn
better okay
a person who know karate
it means a person who know already
something about martial art if you train
him the new data you will learn better
by using the old information
information
than the other person in the same thing
happens in the deep learning model if
you build a new fresh deep learning
model it will not
be that much good but if you take one of
the best deep learning model which is
already trained on some data
for long time
and you make some changes according to
our requirement and train it like that
we are doing press 950 is already
trained on image net data set of
thousand classes we are taking that we
are mentioning our requirement i am
saying okay my image is hundred under
cross three and
and uh
uh
my class of classes are two you can see
here here i am defining the tenses and
my classes are to learn and train using
these two
i'm defining that the model okay here
you can see there are some layers i'm
using dense layers okay about
particularly about these layers i will
make a video okay
what they will do mathematically i will
try to explain the mathematical what is
dense layer what is softness layer
and although okay
i will explain it uh later in some
videos i will let you know okay
for now you need to understand these are
all the layers i need to bundle up that
i will bundle up using the function
called model which i imported above now
i will call that and i will bundle up
all these like resnet 50 old trained
layers plus our new extra added appended
layers both together i will make a new
model i will name it as a model
and i am going to compile it with loss
loss
and matrix accuracy loss you can even
define it as a binary cross entropy
because i have two classes here okay and
matrix accuracy
and optimizer there are so many
optimizers you can play with if you want
or you can change the atom to add a
guard or rms proper like that but adam
shoots better that's why i'm i i am
going with adam now
uh then comes early stopping what is
this early stopping and why we need to
do it
here we will define if a while training
if validation accuracy of two epochs is
not increasing increasing after two
epochs let us stop that training
here what this mean is for example i am
training it for android packs
now after 50 epoch 5152 te epoch
accuracy was not increasing validation
accuracy was stopped actually
okay uh from there uh because this
android epochs it takes a lot of time
okay maybe uh eight hour like that it
will take but after 50 epoch there is no
improvement in validation occurs then
why you go for go for training eight
hours within four hours only you can
stop that work can be done using early
stalking here i remote early stopping
you can keep that early stopping okay
uh callback function you can call here i
removed because i wanted to train it for
android epoch and i trained it for
android epoch you can see uh
uh
so my uh
package training accuracy is 100
okay validation accuracy was 80 percent
uh this was the result after under epochs
epochs
and after training that i will save that model
model
now i am printing the
history we can say history that is
accuracy and losses accuracy you can see
uh training accuracy was 100
and validation accuracy was 85
now how you can improve this validation
accuracy that can be uh done by using
augmentation separately okay this you
can use this technique you can use this
video you watch it once okay
now you'll understand how we can
increase and what difference it makes
yeah now eighty-five percent another
percent this is not bad actually this is
this is good enough you can see i will
show you the results okay and loss is a
bit like
0.010 during training but
during validation a loss is 1.2
it's not that much bad okay when we
compare it this is not that much bad
okay this is also good only
now i am doing it for validate
validation or we can say cross
validation or validation we say like
remaining data will push and we will ask
the model it will predict and it will
say 85 percent it is predicting on test
data or validation data then
then
what i am trying to do is i am giving
test as a test data as a input as i
shown you how we will find out the
accuracy we will feed the test data test
input it will give us the output here i
am doing that
model dot predictors generate means for
the model i am giving the test input it
will give me the predicted output trade
now i am going to compare that okay
okay
now i am going to i am here comparing
that y test y test which i already know
testing output with the prediction
result why when i compare i will get
these values precision recall reference
score and support
i will make separate video for this
because this comes under a confusion
matrix okay analyzing the model using
confusion matrix all these having their
own equations
uh so
but for now you need to understand like
precision is almost equal to accuracy
almost like uh equations are almost same so
so
here you can see even accuracy for
accuracy also there is a question who i
already printed accuracy over so i'm not
printing that here again and again we
call this as a classification report
above i imported this library
classification report i am calling the
library and i am feeding the data i am
getting the classification report
these implies like how our model is
working what is the working state of our model
model
this is actually good information about
this i will make separate video how to
analyze and extract the information
using confusion matrix about a model okay
okay
if you want you can contact us okay i
will give you the equations and all
those stuffs
then what i will do is
i am taking some data from the
test and feeding it to model and i am
printing both what was the real and what
my model predicted you can see here true
was benign predictors banan was
malignant rigid magnet you can see here
there is no error at all here i try to
print 10
images for 10 also it is printing 100
okay there is not a single error in the prediction
prediction
okay uh
after that we need to do it on our own
images now how we can do
that is here we need to load that model
first of all okay
okay
after loading that model we should
import that image whatever the image i
need to uh
image i need to classify beyond.jpg i am
feeding it and here i am printing okay
once i fit that i will use i will use
opencv to read that image and i will fit
to my model okay here my model name is
loaded model imagenet actually
that i named
i named like that okay that's why i'm
using that name here you can see while i
was loading the name i given is imagenet
actually this is a restaurant model okay
to that model i'll give that imagex it's
nothing but the read whatever the image i
i
i read from the c to that i am pretty
feeding to my model it will give the
result and i am showing you that image
and also the result array
okay but from that area what i will do
is i will try to take max value where is
that maximum value 99 100 is in first
place so i will get the index of it okay
then what i what i will get index will
say 0 it means it belongs to benign so
it will give the result
that image plus title as a banana this
was the first part of this project and
my next project as i mentioned is i need
to create data set first of all for
recognition there what i will do is i
will take all these images i will create
segmented uh mask for all these images
that is our second part okay
okay
and once i have images and their mask i
can build a recognition model which can
detect a particular area where
this skin cancer is happening
so that will be our second part and
i will try to publish the second part as
soon as possible
and don't skip anything and if you don't
get anything uh in the video
you can contact us directly i will try
to help you with this
okay or if you want to
have any help for further
project or further
implementation maybe you will be having
some other different ideas instead of
bannon and malignant you will be having
uh six or seven kinds of cancer data set
with you if you want us to implement on
that you can contact us otherwise you
will only get yourself once you watch
this video completely
yeah this was all about uh this section
we will see in the next videos thank you
thank you for your time and pleasure
Click on any text or timestamp to jump to that moment in the video
Share:
Most transcripts ready in under 5 seconds
One-Click Copy125+ LanguagesSearch ContentJump to Timestamps
Paste YouTube URL
Enter any YouTube video link to get the full transcript
Transcript Extraction Form
Most transcripts ready in under 5 seconds
Get Our Chrome Extension
Get transcripts instantly without leaving YouTube. Install our Chrome extension for one-click access to any video's transcript directly on the watch page.