Described in this article is a simple deep convolutional network (CNN), with a state-of-the-art EfficientNet backbone and an attention attention mechanism, to classify the severity of diabetic retinopathy in retinal images. The model can be trained using the publicly available diabetic retinopathy dataset on Kaggle.
Configuration
Imports
​Manage training data
Specify paths for the training files
Helper function to run Linux commands within Python
Unzip the training data
Create and process training dataframe
Histogram summary of the training dataframe
Train-validation split
Balance the training data
Train and validation data generators
Open and process images
Data generators
Visualize the data generator outputs
Visualize train data generator
Visualize validation data generator
Attention mechanism
Diabetic retinopathy classifier
Model summary
Model: "model" __________________________________________________________________________________________________ Layer (type) Output Shape Param # Connected to ================================================================================================== input_2 (InputLayer) [(None, 512, 512, 3) 0 __________________________________________________________________________________________________ efficientnetb0 (Functional) (None, 16, 16, 1280) 4049571 input_2[0][0] __________________________________________________________________________________________________ retina_model_bn_inp (BatchNorma (None, 16, 16, 1280) 5120 efficientnetb0[0][0] __________________________________________________________________________________________________ retina_model_attn_dropout_in (D (None, 16, 16, 1280) 0 retina_model_bn_inp[0][0] __________________________________________________________________________________________________ retina_model_attn_conv2D_64 (Co (None, 16, 16, 64) 81984 retina_model_attn_dropout_in[0][0 __________________________________________________________________________________________________ retina_model_attn_conv2D_16 (Co (None, 16, 16, 16) 1040 retina_model_attn_conv2D_64[0][0] __________________________________________________________________________________________________ retina_model_attn_conv2D_8 (Con (None, 16, 16, 8) 136 retina_model_attn_conv2D_16[0][0] __________________________________________________________________________________________________ retina_model_attn_conv2D_1 (Con (None, 16, 16, 1) 9 retina_model_attn_conv2D_8[0][0] __________________________________________________________________________________________________ retina_model_attn_final (Conv2D (None, 16, 16, 1280) 1280 retina_model_attn_conv2D_1[0][0] __________________________________________________________________________________________________ retina_model_attn_out (Multiply (None, 16, 16, 1280) 0 retina_model_attn_final[0][0] retina_model_attn_dropout_in[0][0 __________________________________________________________________________________________________ retina_model_gap_feat (GlobalAv (None, 1280) 0 retina_model_attn_final[0][0] __________________________________________________________________________________________________ retina_model_gap_mask (GlobalAv (None, 1280) 0 retina_model_attn_out[0][0] __________________________________________________________________________________________________ retina_model_reshape_feat (Resh (None, 1, 1280) 0 retina_model_gap_feat[0][0] __________________________________________________________________________________________________ retina_model_reshape_mask (Resh (None, 1, 1280) 0 retina_model_gap_mask[0][0] __________________________________________________________________________________________________ retina_model_gap_rescale (Lambd (None, 1, 1280) 0 retina_model_reshape_feat[0][0] retina_model_reshape_mask[0][0] __________________________________________________________________________________________________ retina_model_gap_dropout (Dropo (None, 1, 1280) 0 retina_model_gap_rescale[0][0] __________________________________________________________________________________________________ retina_model_fc_dense_128 (Dens (None, 1, 128) 163968 retina_model_gap_dropout[0][0] __________________________________________________________________________________________________ retina_model_fc_dropout (Dropou (None, 1, 128) 0 retina_model_fc_dense_128[0][0] __________________________________________________________________________________________________ retina_model_output (Dense) (None, 1, 5) 645 retina_model_fc_dropout[0][0] ================================================================================================== Total params: 4,303,753 Trainable params: 250,342 Non-trainable params: 4,053,411 __________________________________________________________________________________________________ None
Train model
Visualize attention mechanism
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
OverviewMoad Computer is an actionable insights firm. We provide enterprises with end-to-end artificial intelligence solutions. Actionable Insights blog is a quick overview of things we are most excited about. Archives
November 2022
Categories |