Python develops and builds an eye disease recognition system based on a lightweight convolutional neural network model

Common eye diseases include but are not limited to the following:

  1. Cataracts: Cataracts are when the lens of the eye becomes blurry or opaque, causing vision loss. It is usually age-related, but can also be caused by other factors such as genetics, trauma, diabetes, etc.

  2. Glaucoma: Glaucoma is a group of eye diseases that cause damage to the optic nerve, often caused by increased intraocular pressure. If left untreated, glaucoma can cause permanent vision loss.

  3. Retinal diseases: The retina is the light-sensitive layer in the eye that transmits visual signals to the brain. Retinal diseases, including retinal detachment and macular degeneration, can lead to loss of central vision or visual field defects.

  4. Diabetic retinopathy: People with diabetes may develop diabetic retinopathy, which is damage to the retina caused by high blood sugar. If left untreated, diabetic retinopathy can cause serious vision problems.

  5. Dry Eye Syndrome: Dry eye syndrome is a lack of adequate tears or poor quality tears on the surface of the eye, resulting in dry eyes, pain, fatigue and blurred vision.

  6. Strabismus: Strabismus is an abnormal position or orientation of the eyes that prevents both eyes from focusing on the same object at the same time. This can cause blurred vision, eye strain, and depth perception issues.

Traditional eye diseases are mostly diagnosed and analyzed based on professional doctors and special medical equipment, and the diagnostic and photographed images of the eyeballs themselves can be used to build recognition models. The core idea of ​​this article is to consider convolutional neural network models. To build an auxiliary model dedicated to eye disease diagnosis and identification, first look at the renderings:

An artificially constructed data set is used here to simulate real medical scenarios, including six common types of eye diseases, as follows:

["cataract", "diabetic_retinopathy", "glaucoma", "high", "normal", "pathological"]

Next, let’s briefly look at the data of various eye diseases in order, as follows:

【cataract】

[Diabetic retinopathy]

【glaucoma】

[High myopia]

【Normal eyeball】

[Pathological myopia]

Visualizing the feature distribution of the original dataset looks like this:

There are already many related practices in my previous articles, so I will not describe the entire processing process in detail here. For ease of use, after iterative development in subsequent versions, here I built a lightweight convolution Neural network model development and training framework, the overall project structure is as follows:

The project file details are as follows:

file name File description
data Original data set directory
results Results directory
createDataset Data set processing module
dataset.h5 data set
dataset.json Dataset file
guiAPP Visualization system module
inference Offline reasoning module
labels.json tag category list
trainCNN Model development module
main.py General entry module

In the past, some partners reported that problems such as code or module mismatch and incompatibility are prone to occur in different environments. We have specially dealt with them here, and finally formed:

createDataset
trainCNN
inference
guiAPP

For the four basic components, I have provided a complete method for use. You only need to write simple business code to realize the complete modeling process. main.py is the file you need to write, as shown below:

import os
import createDataset
import trainCNN


#参数配置
dataDir="data/"
saveDir="results/"


#构建数据集
createDataset.randomSplit(dataDir=dataDir)
createDataset.buildH5Dataset()


#训练模型
if not os.path.exists(saveDir + "model.h5"):
    trainCNN.trainModel(saveDir=saveDir)


#启动系统
import guiAPP

It only takes less than 10 lines of code to build your own image recognition system. Here dataDir is your own data set directory, and saveDir is the directory you specify for storing model result files. You don’t need to create it yourself, the program will automatically Create a complete results file that looks like this:

Not only will the model files, weights and other data be stored, but the loss and accuracy of the training process will also be automatically visualized, as shown below:

【Accuracy Curve】

【Loss Value Curve】

Of course, you can also draw the confusion matrix yourself, as shown below:

Guess you like

Origin blog.csdn.net/Together_CZ/article/details/133145915