A.I. Based Cavity Detection System
Here we are implementing the cavity detection system using deep learning techniques
Business problem and Introduction:-
In 21 st century 80–90% people are suffering from dental problems and early research shows that the dental problem is related to the cavity. Nowadays people are so much busy in their work hence they do not care about themselves this leads to health problems including dental problems.
Early diagnosis is very important for maintaining dental problems. Dentists use laser-technology for diagnosis of cavity this is very costly and these results are highly negative that dentists do not rely on results instead they relying on visual inspection. Artificial intelligence helps for identifying dental problems and also it predicts better solutions with the help of dentists to the patients.
Artificial intelligence helps for identifying dental problems and also it predicts better solutions with the help of dentists to the patients.. Artificial Intelligence has more power to save a large amount of data which is useful for individuals need. Artificial Intelligence fill the gap between doctors and laser-techniques
Cavity Types:-
Here We have to classify the the images as per cavities. There are total 6 types of cavities. based on this six type we have to classify or predict the probabilities of per classes
Data Collection :
Data will be collected using the following methods
a.Primary Data:Data regarding teeth and dental disease are collected from various dentists
b.Secondary Data: Data about Artificial intelligence will be collected from research journals and e-resources
The Collected Data can be stored in our own server with there location (path) in csv format. We collected total upto 300 images of cavities
- Note:- Here i implemented model only for 2 classes i.e, for class-I and class-II
Techniques Used
- Fast.ai (https://www.fast.ai)
- CNN (Resnet34)
Implementation:-
Fast.ai:-
Fastai library is pretty new, but it’s getting an extraordinary amount of traction. It’s making a lot of things a lot easier, but it’s also making new things possible. So really understanding the fastai software is something which is going to take you a long way.
So how does it compare? There’s only one major other piece of software like fastai that tries to make deep learning easy to use and that’s Keras. Keras is a really terrific piece of software, we actually used it for the previous courses until we switch to fastai. It runs on top of Tensorflow.
Importing Fast.ai :-
from fastai.vision import *
import numpy as np
import pandas as pd
Making folders for each class:-
folders = ['Class-I', 'Class-II']
files = ['Class-I', 'Class-II']
classes = ['Class-I','Class-II']
path = Path('data/Cavity')
Folder Structure must be as followes:-
Getting Image data from folders:-
Image Data generators in Fast.ai:-
Preprocessed Images:-
Model Architecture(resnet34):-
One of the problems ResNets solve is the famous known vanishing gradient. This is because when the network is too deep, the gradients from where the loss function is calculated easily shrink to zero after several applications of the chain rule. This result on the weights never updating its values and therefore, no learning is being performed. With ResNets, the gradients can flow directly through the skip connections backwards from later layers to initial filters.
Creating the CNN learner:-(resnet34 model)
learn = create_cnn(data, models.resnet34, metrics=[error_rate, accuracy])
Finding the appropriate learning rate
Fast.ai gives you the functionality for the finding the optimal learning rate. the code for this as
learn.lr_find()
learn.recorder.plot()
Initialization of the model:-
In whole process we are using transfer learning. we are applying the weights of the resnet34 model. so its easier to us for classifying the things
interp = ClassificationInterpretation.from_learner(learn)
Fitting the model:-
learn.fit_one_cycle(5)
here we can say that train loss is decreasing as well as our accuracy is improving per epochs. and also see the time for execution. Fast.ai is very fast as per name and as compared to tensorflow and keras. By using fast.ai we are getting better results than any other techniques. Thats why i am using the fast.ai implementation for blog
Train and validation loss:-
learn.recorder.plot_losses()
Printing Top Losses/Most confused images:-
interp.plot_top_losses(21, figsize=(15,11), heatmap=False)
Exporting the model:-
learn.export()
Loading the model:-
learn = load_learner(path)
Predicting the single point:-
defaults.device = torch.device(‘cpu’)
img = open_image('Test5.jpg')
img
pred_class,pred_idx,outputs = learn.predict(img)
pred_class
For Full tutorial code you will find on github here
References:-
Grace F. Olsen ; Susan S. Brilliant ; David Primeaux ; Kayvan Najaria “An image-processing enabled dental caries detection system” published in 2009 ICME International Conference on Complex Medical Engineering, INSPEC Accession Number: 10615830
Also See my other articles:-