Deep Learning

Understanding and using deep learning networks

糖尿病视网膜病变检测

Post by Dr.Barath Narayanan.,代顿大学研究所(udri)与共同作者:博士Russell C. Hardie,代顿大学(UD),Manawduge Supun De Silva, UD, andNathaniel K. Kueterman, UD.

Introduction

Diabetic Retinopathy (DR) is one of the leading cause for blindness, affecting over 93 million people across the world. DR is an eye disease associated with diabetes. Detection and grading DR at an early stage would help in preventing permanent vision loss. Automated detection and grading during the retinal screening process would help in providing a valuable second opinion. In this blog, we implement a simple transfer-learning based approach using a deep Convolutional Neural Network (CNN) todetect DR.
如果您使用研究代码的任何部分,请引用以下文章:The Kaggle blindness detection challenge dataset (Aptos 2019 DataSet.)包含单独的培训和测试案例。在此博客中,我们仅利用培训数据集进行学习和估算性能。这些图像被印度Aravind眼科医院捕获。培训数据集包含专业临床医生标记为不同类别(正常,轻度DR,适度博士,严重DR和ProMiferative Dr)的图像。Note that, in this blog, we solely focus on detecting DR, you could find more details about our grading architecture in ourpaper.

Grouping Data by Category

We extract the labels from excel sheet and segregate the images into 2-folders as 'no' or 'yes' as we're solely focused on detecting DR in this blog.The helper code for splitting the data into categories is at the end of this post.

Load the Database

Let's begin by loading the database usingimageDatastore. It's a computationally efficient function to load the images along with its labels for analysis.
% Two-class Datapathby_class_datapath ='火车数据集两个类';% Image DatastoreIMDS = imageageAtastore(两个_class_datapath,...'uppordubfolders',true,...'labelsource','foldernames');% Determine the split uptotal_split = countAcneLabel(IMDS)

可视化图像

Let's visualize the images and see how images differ for each class. It would also help us determine the type of classification technique that could be applied for distinguishing the two classes. Based on the images, we could identify preprocessing techniques that would assist our classification process. We could also determine the type of CNN architecture that could be utilized for the study based on the similarities within the class and differences across classes. In this article, we implement transfer learning using inception-v3 architecture. You canreadour paper to see the performance of different preprocessing operations and other established architectures.
%图像数量num_images = length(imds.labels);% Visualize random 20 imagesperm=randperm(num_images,20); figure; for idx=1:20 subplot(4,5,idx); imshow(imread(imds.Files{perm(idx)})); title(sprintf('%s',imds.Labels(perm(idx)))) end

训练, Testing and Validation

让我们将DataSet拆分为培训,验证和测试。首先,我们将数据集分成80%(培训和验证)和20%(测试)的组。确保分割每个类的相等数量。
%拆分培训和测试数据集train_percent = 0.80;[IMDStrain,IMDSTEST] = SpliteachLabel(IMDS,Train_percent,'Oranduize');% Split the Training and Validationvalid_percent=0.1; [imdsValid,imdsTrain]=splitEachLabel(imdsTrain,valid_percent,'randomize');
这让我们面临以下数量:
Yes No
训练Set: 1337 1300
Validation Set: 144 149
Test Set: 361 371

Deep Learning Approach

Let’s adopt a transfer learning approach to classify retinal images. In this article, I’m utilizing Inception-v3 for classification, you could utilize other transfer learning approaches as mentioned in thepaperor any other architecture that you think might be suited for this application. My MathWorks blogs on transfer learning using other established networks can be found here:AlexNet.,reset.

训练

We will utilize validation patience of 3 as the stopping criteria. For starters, we use 'MaxEpochs' as 2 for our training, but we can tweak it further based on our training progress. Ideally, we want the validation performance to be high when training process is stopped. We choose a mini-batch size of 32 based on our hardware memory constraints, you could pick a bigger mini-batch size but make sure to change the other parameters accordingly.
将图像转换为299 x 299以适应架构Augimdstrain = AugmentedimagedAtastore([299 299],IMDstrain);augimdsvalid = augmentedimagedataStore([299 299],IMDSValid);%设置培训选项选项= TrainingOptions('adam','maxepochs',2,'minibatchsize',32,...'plots','培训 - 进展','verbose',0,'executionenvironment','parally',...'validationdata',augimdsvalid,'验证频道',50,'validationpatience',3);nettransfer = trainnetwork(Augimdstrain,Incepnet,选项);

Testing and Performance Evaluation

% Reshape the test images match with the networkaugimdsTest = augmentedImageDatastore([299 299],imdsTest);%预测测试标签[predicted_labels,posterior] = classify(netTransfer,augimdsTest);% Actual Labelsactual_labels = imdsTest.Labels;% Confusion Matrixfigure plotconfusion(actual_labels,predicted_labels) title('Confusion Matrix: Inception v3');
%ROC曲线test_labels=double(nominal(imdsTest.Labels)); [fp_rate,tp_rate,T,AUC] = perfcurve(test_labels,posterior(:,2),2); figure; plot(fp_rate,tp_rate,'b-');hold on; grid on; xlabel('False Positive Rate'); ylabel('Detection Rate');

类激活映射结果

我们使用代码可视化这些网络的类激活映射(CAM)结果://www.tatmou.com/help/deeplearning/examples/investige-network-predictions-using-class-activation-mapping.html.. This would help in providing insights behind the algorithm's decision to the doctors.
以下是各种情况的结果:

Conclusions

In this blog, we have presented a simple deep learning-based classification approach for CAD of DR in retinal images. The classification algorithm using Inception-v3 without any preprocessing performed relatively well with an overall accuracy of 98.0% and an AUC of 0.9947 (results may vary because of the random split). In thepaper,我们研究了各种建立的CNN架构在不同预处理条件下为同一组培训和测试案例的表现。结合各种架构的结果在AUC和整体准确性方面都提供了促进的性能。对这些算法的综合研究,无论是在计算(内存和时间)和性能方面,允许主题专家做出明智的选择。此外,我们介绍了我们的新建筑方法paper用于博士的检测和分级。

About the Author

博士Barath Narayanan.毕业于MS和PH.D.2013年和2017年代顿大学(UD)的电气工程学位。他目前拥有作为研究科学家的联合任命UDRI's Software Systems Groupand as an Adjunct Faculty for theECE departmentat UD. His research interests include deep learning, machine learning, computer vision, and pattern recognition.

辅助代码

Code for grouping data by DR category (yes or no)

After downloading the ZIP files from the website and extracting them to a folder called "train_images". Make sure to download the excel sheet (train.csv - convert it to .xlsx for this code) containing the true labels by expert clinicians. We extract the labels from excel sheet and segregate the images into 2-folders as 'no' or 'yes' as we solely focus on detecting DR in this blog.
% Training Data pathdatapath ='train_images \';% Two-class Data pathby_class_datapath ='火车数据集两个类\';% Class Namesclass_names = {'no','是'};mkdir(Sprintf('%s%s',pers_class_datapath,class_names {1}))mkdir(sprintf(sprintf('%s%s',post_class_datapath,class_names {2}))%用标签读取Excel表[num_data,text_data] = xlsread('train.xlsx');%确定标签train_labels=num_data(:,1);% Merge all labels marked into Mild, Medium, Severe and Proliferative DR%进入单个类别'是'train_labels(train_labels~=0)=2;% Rest of the dataset belongs to 'No' categorytrain_labels(train_labels==0)=1;% 文件名filename = text_data(2:结束,1);% Now, write these images 2-folders 'Yes' or 'No' for us to develop a deep% learning architecture utilizing Deep learning toolbox%确定文件将它们放在单独的文件夹中对于idx = 1:长度(文件名)% You could uncomment if you would like to see live progress% fprintf('Processing %d among %d files:%s \n',idx,length(filename),filename{idx})[/%]% Read the imagecurrent_filename=strrep(filename{idx}, char(39), ''); img=imread(sprintf('%s%s.png',datapath,current_filename));%在相应文件夹中写下图像imwrite(img,sprintf('%s%s%s%s.png',two_class_datapath,class_names{train_labels(idx)},'\',current_filename)); clear img; end
|
  • 打印
  • send email

Comments

To leave a comment, please clickhereto sign in to your MathWorks Account or create a new one.