Improved lightweight network-based fundus retina image recognition method

By improving the lightweight network architecture, the deployment challenge of traditional pathological myopia diagnosis methods in resource-scarce areas has been solved, enabling rapid and accurate pathological myopia screening in primary healthcare institutions while reducing computational complexity and resource requirements.

CN121861393BActive Publication Date: 2026-05-15XIAN UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAN UNIV OF TECH
Filing Date
2026-03-18
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Traditional methods for diagnosing pathological myopia rely on expert experience, making diagnosis difficult in areas with scarce medical resources. Existing models have a large number of parameters and slow inference speed, making them difficult to deploy in primary healthcare institutions.

Method used

An improved lightweight network architecture is adopted, which replaces the SE module with the ECA module, optimizes the scaled and depth-separable convolutional structure, and combines inverse frequency weighting and efficient activation functions to optimize the MobileNetV3-Small network, reducing the number of parameters and improving inference speed.

Benefits of technology

It significantly reduces model storage requirements and computational complexity, enabling rapid processing of single fundus images, meeting clinical real-time requirements, and is suitable for resource-constrained mobile and edge devices, thus lowering the investment threshold for medical equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121861393B_ABST
    Figure CN121861393B_ABST
Patent Text Reader

Abstract

The application provides an improved light-weight network-based fundus retina image recognition method, and belongs to the technical field of image processing. The method comprises the following steps: obtaining pathological and non-pathological myopia fundus retina image datasets, pre-processing and dividing the datasets, using MobileNetV3-Small as the basis, replacing the SE module with an ECA module and optimizing the structure to obtain a light-weight model; during training, using the inverse frequency weighting method to process imbalance, saving the model with the optimal recall rate; finally, loading the model to infer the input image, outputting and saving the recognition result. The improved light-weight network-based fundus retina image recognition method solves the problems of the traditional pathological myopia processing method, such as dependence on expert experience, difficulty in diagnosis in areas with insufficient medical resources, and large model parameter quantity, slow inference speed and difficulty in deployment in primary medical institutions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a method for fundus retinal image recognition based on an improved lightweight network. Background Technology

[0002] With the widespread use of electronic products and changes in modern lifestyles, the global prevalence of myopia has exploded. Data from the World Health Organization (WHO) shows that the global myopia population has exceeded 2.6 billion, of which approximately 300 million are highly myopic. Pathological myopia (PM), caused by high myopia, has become one of the leading causes of irreversible vision loss. Pathological myopia not only manifests as increased refractive power but is also accompanied by pathological changes in the fundus structure, such as posterior staphyloma and retinal atrophy, which can lead to retinal detachment and even blindness in severe cases.

[0003] Traditionally, the diagnosis of pathological myopia relies on the clinical experience of ophthalmologists and high-precision imaging examinations, such as optical coherence tomography (OCT), fundus photography, and visual field testing. However, this diagnostic approach faces significant challenges in areas with limited medical resources. Furthermore, sophisticated imaging equipment like OCT is expensive and requires specialized technicians for operation and maintenance, making it difficult to implement in primary healthcare institutions. Traditional manual image interpretation is time-consuming and labor-intensive, struggling to meet the screening needs of large populations, especially in areas with high myopia prevalence, where the healthcare system is often overwhelmed.

[0004] In recent years, research on automatic identification of fundus diseases both domestically and internationally has gradually evolved from traditional machine learning to deep learning. Early international research employed support vector machines and random forests to extract handcrafted features for classification, but these methods had limited generalization capabilities. Subsequently, complex convolutional neural networks (CNNs) such as ResNet and Inception became mainstream, achieving significant progress in some fundus disease classification tasks. However, these models typically have high computational complexity, a large number of parameters, and high hardware requirements, making them difficult to deploy in resource-constrained primary healthcare institutions. Domestic research initially focused on multimodal data fusion, but in recent years has shifted to deep learning, achieving some success in clinical prediction. However, these models also suffer from problems such as large model parameter counts and slow inference speeds. Summary of the Invention

[0005] The purpose of this invention is to provide a fundus retinal image recognition method based on an improved lightweight network, which solves the problems of traditional pathological myopia treatment methods relying on expert experience, difficulties in diagnosis in areas with scarce medical resources, and the large number of parameters, slow inference speed, and difficulty in deployment in primary medical institutions of existing models.

[0006] To achieve the above objectives, this invention provides a method for fundus retinal image recognition based on an improved lightweight network.

[0007] Preferably, the specific steps of data preprocessing in S1 include: scaling all images proportionally to a longest side of 224 pixels, filling the area around the images with black to form a 224×224 square, and normalizing the images to the range of [-1,1]; performing random horizontal and vertical flipping data augmentation on the training set, while only resizing the validation set; generating a label list for the training set by traversing the image directory and based on the filename prefix, and generating a label list for the validation set by reading the image names and labels from the Excel file.

[0008] Preferably, the specific steps for replacing the SE module with the ECA module in S2 are as follows: remove the two fully connected layers of the SE module, and use a 1D convolutional kernel on the feature map after global average pooling to capture the interaction relationship between channels. The size of the convolutional kernel is determined by an adaptive formula based on the number of channels c.

[0009] ;

[0010] in, c It is the number of channels. r and b All of these are hyperparameters.

[0011] Preferably, the specific steps in S2 to optimize the expansion ratio in the MobileNetV3-Small network include: using the inverse residual module based on MobileNetV3 to compress the number of channels in the expansion layer to 25% of the input channels, and keeping the minimum number of channels in the expansion layer at 16; retaining the 5×5 large kernel design in the deep convolutional layer and adding a hard-swish activation function; and adopting a conditional residual mechanism to enable residual connections only when the input and output channels are equal and the stride is 1.

[0012] Preferably, the specific steps for optimizing the number of channels in the initial convolutional layer in S2 are as follows: the 3×3 convolution with 16 channels in the input layer of the original MobileNetV3-Small network is compressed into 8 channels, and the number of channels in the initial convolutional layer is optimized by using ConvBlock.

[0013] Preferably, the specific steps for optimizing the classifier structure in S2 include: introducing a progressive feature compression strategy, expanding the channels from 288 to 512 through 1×1 convolution to compensate for the loss of spatial context information caused by global average pooling; and inserting a Dropout layer into the classifier for regularization design to reduce the risk of model overfitting.

[0014] Preferably, the training hyperparameters and model training in S3 include: setting the training epochs to 20, using the Adam optimizer and setting the learning rate to 0.001; outputting the accuracy and loss value of training / validation in real time during training, as well as the recall, precision and F1-score for pathological myopia; generating a confusion matrix and visualizing the training curve after training is completed, and saving the best model as the best_recall_V3model.pth file.

[0015] Preferably, the expression for calculating the category weights using the inverse frequency weighting method in S3 is:

[0016] ;

[0017] in, For category The weight, N The total number of samples, M For category i The number of samples;

[0018] The weighted cross-entropy loss function is expressed as follows:

[0019] ;

[0020] in, Y The actual label value. This represents the probability value predicted by the model.

[0021] Preferably, the specific steps for recognition and prediction include: supporting image input in JPG / JPEG / PNG formats, and ensuring compatibility with both old and new weight file formats when loading the model; calculating the predicted category and confidence level after model inference, and saving the recognition results in two forms: first, adding red annotation text containing the Chinese category name and confidence level percentage to the upper left corner of the original image; second, generating a CSV file that records the file name, predicted category, confidence level, and processing status; setting an error handling mechanism to skip images that cannot be processed and recording the reasons for failure in the CSV file; and finally summarizing and outputting the successful and unsuccessful prediction results.

[0022] The fundus retinal image recognition method based on the improved lightweight network described in this invention is only intended to provide auxiliary reference at the image information level for physicians to carry out fundus disease diagnosis and treatment. It does not constitute a pathological diagnosis of the disease, nor can it be used as a direct basis for disease diagnosis, condition assessment, and treatment plan formulation.

[0023] Therefore, the present invention employs the above-described method for fundus retinal image recognition based on an improved lightweight network, and the technical effects are as follows:

[0024] 1. Significantly reduced parameter count: By improving the MobileNetV3-Small lightweight network architecture, replacing the original compression-excitation (SE) module with the efficient channel attention (ECA) module, and optimizing the scaled and depth-separable convolutional structure, the storage requirements and computational complexity of the model are significantly reduced, making it more suitable for deployment on resource-constrained mobile or edge devices.

[0025] 2. Significantly improved inference speed: While maintaining high accuracy, the inference speed has been effectively improved, providing a feasible solution for mobile deployment. This enables the model to quickly process a single fundus image on ordinary computing devices, meeting the real-time requirements of clinical practice.

[0026] 3. Maintaining high recall: The improved network model optimizes the number of parameters and inference speed while maintaining the same recall. The high recall of the model ensures the reliability of the screening results and reduces the risk of missed diagnoses.

[0027] 4. Applicable to primary healthcare scenarios: The proposed lightweight model and improvement strategy effectively solve the problem of high computing power requirements of traditional CNNs in medical scenarios, and reduce the investment threshold for medical equipment. Attached Figure Description

[0028] Figure 1 This is an experimental flowchart of the fundus retinal image recognition method based on the improved lightweight network of the present invention;

[0029] Figure 2 These are partial fundus retinal images from the dataset in this embodiment of the invention;

[0030] Figure 3 This is a schematic diagram of the improved MobileNetV3_small network architecture in an embodiment of the present invention;

[0031] Figure 4 This is a line graph showing the training accuracy in an embodiment of the present invention;

[0032] Figure 5 This is a verification accuracy chart in an embodiment of the present invention;

[0033] Figure 6 This is a bar chart of parameter quantities in an embodiment of the present invention;

[0034] Figure 7 This is a bar chart of FLOPs in an embodiment of the present invention;

[0035] Figure 8 This is a schematic diagram of the training set accuracy curve in an embodiment of the present invention;

[0036] Figure 9 This is a schematic diagram of the validation set accuracy curve in an embodiment of the present invention;

[0037] Figure 10 This is a schematic diagram of the recall rate curve in an embodiment of the present invention. Detailed Implementation

[0038] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.

[0039] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.

[0040] Example 1

[0041] like Figure 1 As shown, this invention proposes a fundus retinal image recognition method based on an improved lightweight network. The MobileNetV3-Small lightweight network architecture is improved by replacing the original squeeze-and-excitation (SE) module with an efficient channel attention (ECA) module, and optimizing the scaling and depth-separable convolutional structure. While maintaining high accuracy, the number of parameters is significantly reduced, and the inference speed is improved by 171.6% (6.44ms / frame), enabling rapid identification of pathological myopia. Specifically, the method includes the following steps:

[0042] S1. Data Acquisition and Preprocessing: Acquire a dataset containing fundus and retinal images of pathological myopia and non-pathological myopia. Preprocess the dataset, including image resizing, normalization, and data augmentation. Data augmentation is only applied during the training phase. Divide the dataset into training, validation, and test sets.

[0043] S2. Improved lightweight network model architecture: Using MobileNetV3-Small network as the base model, the original compressed-excitation SE module in MobileNetV3-Small network is replaced with an efficient channel attention ECA module. The expansion ratio, initial number of convolutional layer channels and classifier structure in MobileNetV3-Small network are optimized to obtain the improved lightweight network model.

[0044] S3. Training the improved lightweight network model: The class weights are calculated using the inverse frequency weighting method to handle the data imbalance problem. The improved lightweight network model is initialized, the training hyperparameters are set, and the model is trained using the cross-entropy loss function with class weights. The model with the best recall is saved.

[0045] S4. Recognition and Prediction: Load the optimal lightweight network model that has been trained, perform preprocessing and model inference operations on the input fundus retinal image, and output the recognition result.

[0046] like Figure 2 As shown, this embodiment uses the publicly available iChallenge-PM dataset, which contains 800 fundus retinal images. Among them, there are 385 fundus retinal images of pathological myopia and 415 fundus retinal images of non-pathological myopia. This part of the images covers fundus retinal images of high myopia and normal vision.

[0047] A prominent feature of fundus images in highly myopic eyes is the leopard-spot fundus. The mechanism is as follows: High myopia causes elongation of the eye axis, causing retinal vessels to immediately thin and straighten after leaving the optic disc. Simultaneously, changes occur in the choroidal capillaries, leading to nutritional deficiencies in the retinal pigment epithelium, resulting in a reduction or disappearance of superficial pigment. Consequently, the exposed red choroidal vessels intermingle with the brown pigment between the vascular network, forming a leopard-spot fundus. A significant feature of pathological myopia fundus images is the presence of patchy retinal atrophy and macular atrophy. Macular atrophy is a well-defined, round choroidal-retinal atrophy lesion, appearing grayish-white or white, surrounded by a degenerated fibrovascular membrane, and it tends to enlarge over time. It is important to distinguish macular atrophy from patchy retinal atrophy, although patients often have both lesions simultaneously. Normally, macular atrophy is centered on the fovea, not the geometric center of the atrophic area. As long as the atrophy involves the fovea, it can be identified as macular atrophy, and its shape is circular. In contrast, patchy retinal atrophy is not centered on the fovea and has irregular edges.

[0048] The 800 fundus retinal images were divided into groups according to a 7:2:1 ratio, as follows:

[0049] Training set: Contains 560 images, including 298 images of the fundus and 262 images of the fundus and retina of non-pathological myopia.

[0050] Validation set: Contains 160 images, including 87 images of the fundus and retina of pathological myopia and 73 images of the fundus and retina of non-pathological myopia.

[0051] Test set: Contains 80 images.

[0052] The training set image directory is traversed, and labels are assigned based on the prefix of the image filename. Specifically, if the filename prefix is ​​"N" or "H", it is labeled as 0; if the filename prefix is ​​"P", it is labeled as 1.

[0053] A label list is generated based on this rule, and the image paths and corresponding labels are written to the train.txt file in a specific format: "image path label". The validation set is prepared by reading a pre-stored Excel file containing validation set image names and labels, concatenating the complete paths of the image names, and writing the results to the valid.txt file in a similar format to the training set.

[0054] A PyTorch dataset class named LoadData is defined for loading and processing image data. This class reads image paths and labels from a text file at a specified path and applies different preprocessing steps depending on the training or validation mode. The training mode includes data augmentation operations such as random horizontal, vertical, and flipping, while the validation mode only performs simple resizing. All images are scaled proportionally to a longest side of 224 pixels and padded with black to form a 224×224 square, finally normalized to the range [-1, 1]. The class also implements the getitem method to return the processed image tensor, integer labels, and image paths, and the len method to obtain the dataset size. The entire class encapsulates the standard data loading process from file reading to preprocessing.

[0055] This invention employs a hybrid design strategy to improve the MobileNetV3-Small network. On one hand, it utilizes resource-constrained Neural Architecture Search (NAS) technology to automatically optimize the global network structure, enabling the network to automatically adapt to fundus image features. On the other hand, it combines manually designed lightweight "bottleneck" residual blocks to optimize feature extraction for subtle pathological changes such as retinal atrophy and macular degeneration associated with pathological myopia, thereby enhancing the network's ability to capture subtle pathological features.

[0056] The original network used the traditional ReLU activation function, while this invention introduces the computationally efficient h-swish activation function. The h-swish activation function reduces inference latency by 30% while maintaining nonlinear expressive power. This characteristic enables the improved network to achieve sub-second rapid diagnosis of a single fundus image on ordinary computing devices, meeting clinical real-time requirements and providing strong support for rapid screening of pathological myopia.

[0057] The SE module in the original MobileNetV3-Small network uses a fully connected layer, which suffers from redundant computation. This invention improves upon this by employing a lightweight SE module at the network's end. This module, through dynamic channel weight adjustment, enables the network to focus on the regions in the fundus image most relevant to pathological myopia, such as the peripapillary atrophy arc and other key areas, while suppressing irrelevant background interference, effectively improving the accuracy of identifying key pathological features. This improvement avoids redundant computation in fully connected layers, thus improving computational efficiency.

[0058] To reduce computational complexity, this invention reduces the number of convolutional channels in the final stage of the network and removes redundant layers. The simplified network significantly reduces computational complexity with almost no impact on accuracy. The improved model has a small number of parameters, only 1 / 20 of the standard ResNet50, yet it maintains comparable classification performance on the iChallenge-PM dataset, greatly reducing the model's dependence on computational resources and improving its practicality and deployability.

[0059] MobileNetV3-Small employs a composite scaling factor (width factor α) to balance model capacity and computational cost. For the relatively small medical image dataset used in this study, the width factor α is set to 0.75. This adjustment effectively prevents overfitting on small datasets while ensuring sufficient feature extraction, enabling the model to better learn pathological myopia features in fundus images.

[0060] As an extension of the SE attention mechanism, the core purpose of the ECA mechanism is to enhance the accuracy of convolutional neural networks in judging the importance of each channel. Unlike the SE module, which uses complex fully connected layers to calculate channel attention, the ECA mechanism adopts a simpler and more efficient method, avoiding many drawbacks of fully connected layers and realizing effective interaction and fusion of information between channels.

[0061] The SE module uses two fully connected layers to capture the dependencies between channels, but the ECA mechanism argues that this cross-channel interaction introduces too many parameters and makes the learning process unnecessary and complex. The ECA mechanism simplifies this process by abandoning fully connected layers and adopting a more lightweight approach to achieve inter-channel interaction. The ECA mechanism directly applies 1×1 convolutional kernels to the feature map after global average pooling. This approach not only avoids dimensionality reduction and ensures the integrity of feature information but also effectively captures the interaction relationships between channels, achieving good results with very few parameters and significantly reducing model complexity and computational cost.

[0062] The ECA mechanism uses 1D convolution to fuse information between channels. 1D convolution models the interaction between channels through a variable kernel size.

[0063] To ensure sufficient channel interaction regardless of the number of channels, the kernel size is adjusted according to the number of channels. c Adaptive adjustment. Specifically, the size of the convolution kernel is adaptively adjusted using a specific formula.

[0064] ;

[0065] in,c It is the number of channels. r and b All are hyperparameters. The kernel size is automatically adjusted based on the number of channels to ensure that the kernel size is neither too large nor too small, thereby ensuring that ECA can capture appropriate cross-channel information.

[0066] In summary, the ECA mechanism achieves efficient computation of channel attention while reducing model complexity by avoiding fully connected layers and utilizing adaptive 1D convolutions. By adaptively adjusting the size of the convolution kernel, ECA can effectively capture cross-channel dependencies while reducing redundant computations.

[0067] like Figure 3 As shown, the improved Bottleneck structure is based on the inverse residual module of MobileNetV3, introducing a dynamic expansion ratio and channel compression strategy. The dynamic expansion ratio is adjusted, whereas the original MobileNetV3 expansion layer uses a fixed expansion factor, resulting in redundant computation. Table 1 shows the improved MobileNetV3-Small network structure, where Input represents the size of the input feature map of the current layer; Operator is the operation or module used in the current layer; exp_size is only valid in the LiteBottleneck module and represents the number of channel expansions; #out is the number of output channels of the current layer; SE represents whether an attention mechanism is used; NL represents which activation function is used; and s represents the stride.

[0068] Table 1. Improved MobileNetV3-Small network structure

[0069]

[0070] The improved module dynamically expands the channel count using a formula, compressing the number of channels in the expanded layer to 25% of the input channels. For example, with 48 input channels, the expanded layer only requires 12 channels instead of the traditional 288 channels (6×48). Depthwise separable convolution optimization retains the original 5×5 large kernel design in the deep convolutional layers to enhance the local receptive field, but adds a hard-swish activation function to improve nonlinear expressiveness. Lightweight residual connections employ a conditional residual mechanism, enabling residual connections only when the input and output channels are equal and the stride is 1. Compared to the original model's forced residual strategy, this avoids the extra computation caused by invalid branches. Given the high resolution of fundus images and the excessive computational cost of traditional models, the improved module meets the real-time requirements of mobile devices. Pathological myopia lesions often manifest as local hemorrhages or macular degeneration; depthwise separable convolution and compact expansion strategies effectively capture subtle lesion features, and dynamic channel compression avoids the reduced parallel computing efficiency caused by insufficient channels on low-end devices.

[0071] The original MobileNetV3-Small input layer uses a 16-channel convolution, which is computationally redundant given the high resolution of fundus images. The initial convolutional layer channel count is compressed from 16 to 8, further reducing the number of parameters. Experiments show that shallow networks have high channel redundancy; reducing this redundancy has little impact on accuracy but significantly improves computational efficiency.

[0072] The original MobileNetV3_Small classifier uses Global Average Pooling (GAP) and a single fully connected layer (FC), which can easily lead to feature compression overload on small ophthalmic sample data. Now, a progressive feature compression strategy is introduced. GAP directly reduces the dimensionality of 7×7×576 features to 1×1×576, losing spatial context information. The progressive feature compression strategy is introduced to enhance the features by expanding the channels from 288 to 512 through 1×1 convolution, which compensates for the information loss caused by GAP and improves feature discriminativeness. Regularization design and the insertion of Dropout layers reduce overfitting.

[0073] The improved version significantly enhances computational efficiency while maintaining model performance through a lightweight attention mechanism, dynamic channel adjustment, and structural optimization, making it more suitable for deployment on mobile or edge devices. These improvements align with the design trend of lightweight networks, making them particularly suitable for scenarios with limited computing resources.

[0074] Class weights are calculated using an inverse frequency-weighted method to handle data imbalance and initialize a lightweight network model. Training lasts for 20 epochs, using the Adam optimizer with a learning rate of 0.001 and a cross-entropy loss function with class weights. Each epoch outputs the training / validation accuracy, loss value, and recall, precision, and F1-score specifically for pathological myopia. The system automatically saves the model with the best recall and performs a final evaluation after training, outputting complete metrics including recall, precision, and inference speed for the best epoch. The entire process also includes error sample saving, confusion matrix generation, and training curve visualization, providing comprehensive monitoring of model performance changes. The final best model is saved as the file best_recall_V3model.pth and evaluated on the test set.

[0075] Inverse frequency-weighted method for calculating class weights:

[0076] ;

[0077] in, For category The weight, N The total number of samples, M For category i The number of samples.

[0078] The weighted cross-entropy loss function addresses the class imbalance problem by introducing weights to weight the loss for each class. The weight for each class is set as follows: w The weighted cross-entropy loss function can then be defined as:

[0079] ;

[0080] in, Y The first in the real label i The class's label value, usually Y ∈{0,1}, The model predicts the first i The probability value of the class. ∈[0,1].

[0081] The prediction process loads the best_recall_V3model.pth model saved during training, supporting compatibility with both old and new weight file formats. For each image in the input directory, the program executes the following steps sequentially: image reading, normalization preprocessing, model inference, calculation of predicted class and confidence score. Prediction results are saved in two forms: an output image with red annotation text added to the upper left corner of the original image; and a CSV file recording detailed prediction results. Special attention has been paid to Chinese font display issues; if the system lacks the "simhei.ttf" font, it will automatically revert to the default font. The entire process has a robust error handling mechanism, skipping images that cannot be processed and recording the reasons for failure in the CSV file. Finally, all successful and unsuccessful prediction results are summarized and output.

[0082] This system of metrics for evaluating the performance of deep learning models in tasks such as disease screening covers key indicators such as recall, precision, F1-score, number of parameters, number of floating-point operations, and inference speed, providing a scientific basis for comprehensively and accurately evaluating model performance.

[0083] Recall measures a model's ability to avoid missed diagnoses and is crucial in disease screening. It is defined as the proportion of correctly identified positive samples out of all true positive samples. In binary classification problems, a true positive (TP) represents the number of samples correctly predicted as positive, and a false negative (FN) represents the number of samples incorrectly predicted as negative. The formula for recall can be expressed as:

[0084] ;

[0085] By calculating the recall rate, we can intuitively understand the model's performance in identifying real positive samples. The higher the recall rate, the stronger the model's ability to identify positive samples and the lower the possibility of missed diagnoses.

[0086] Precision primarily measures a model's ability to avoid misdiagnosis; that is, the proportion of samples where the model predicts a positive result that are actually positive. In disease diagnosis, precision reflects the probability that the model misclassifies a healthy person as a patient. A false positive (FP) is the number of samples that the model incorrectly predicts as positive. The formula for calculating precision is:

[0087] ;

[0088] A higher accuracy rate indicates that the model is more accurate in predicting positive samples and has a lower chance of misdiagnosis.

[0089] The F1-score is the harmonic mean of recall and precision, used to comprehensively evaluate the balance between these two metrics. In scenarios with imbalanced positive and negative samples, such as rare disease diagnosis, using recall or precision alone may not fully reflect the model's performance. The F1-score, by taking both metrics into account, provides a more objective evaluation. Its calculation formula is:

[0090] ;

[0091] The F1-score ranges from 0 to 1. The closer the value is to 1, the better the balance between recall and precision, and the better the performance.

[0092] The number of parameters represents the total number of trainable parameters in a model, mainly including weights and biases. The calculation method for the number of parameters differs for different types of network layers. For example, the number of parameters in a fully connected layer is the product of the input and output dimensions; the number of parameters in a convolutional layer is the product of the kernel size, the number of input channels, and the number of output channels. The number of parameters is an important indicator of model complexity. Models with a large number of parameters typically require more memory bandwidth to store and transfer parameters, which may slow down the model's inference speed and increase computational resource consumption.

[0093] FLOPs are a key metric for measuring the computational complexity of a model, representing the number of floating-point operations required for one forward inference operation. For example, the FLOPs of a 3×3 convolutional layer are calculated as: output feature map size × kernel area × number of input channels × number of output channels. Higher FLOPs mean greater computational load, longer computation time, and higher energy consumption during inference. Therefore, it is crucial to control FLOPs appropriately when designing and evaluating models to improve inference efficiency and energy utilization.

[0094] Inference speed refers to the actual time a model takes to process a single sample on specific hardware, typically measured in frames per second (FPS) or milliseconds per sample. FPS represents the number of samples a model can process per second, while milliseconds per sample represents the time required to process one sample. Inference speed is a crucial indicator of a model's performance in real-world applications, directly impacting its effectiveness in real-time scenarios. In scenarios with high real-time requirements, such as disease screening, it is essential to ensure that the model has a fast inference speed to meet practical needs.

[0095] like Figure 4 As shown in the training curves, the ShuffleNetV2 and MobileNetV3-Small networks significantly outperformed the ResNet network with a larger number of parameters in the later stages of training. This indicates that the lightweight model improves feature learning efficiency through efficient architectural design strategies such as depthwise separable convolutions and channel shuffling, converging to higher accuracy in just 20 training epochs. Validation set performance analysis. Figure 5 The study indicates that MobileNetV3_Small achieved a recall of 98.85% and a validation accuracy of 96.9% in round 8. Its peak recall was 2.3% and 1.1% higher than SqueezeNet's 96.55% and ShuffleNetV2's 97.70%, respectively, demonstrating its clinical value in improving the diagnostic sensitivity of pathological myopia and reducing missed diagnoses. (Network parameter bar chart) Figure 6 The results show that MobileNetV3_Small requires only 1.52M parameters, which is 6.46% of ResNet. Although SqueezeNet has fewer parameters, its validation accuracy drops significantly. The low accuracy of SqueezeNet indicates that excessive compression can impair the model's ability to represent subtle lesions in the fundus. In contrast, MobileNetV3-Small retains key features by introducing an attention mechanism (SE module) and a dynamic activation function (h-swish), demonstrating that MobileNetV3_Small achieves a better balance between parameter compression and performance. Figure 7 The MobileNetV3_Small FLOPs of 67.7M are 1.64% of the ResNet FLOPs. Combined with its high recall rate, this verifies the applicability of the lightweight design for the deployment of edge medical devices.

[0096] Experimental data fully demonstrates that MobileNetV3_Small outperforms the comparison models in all three dimensions: accuracy, recall, and computational efficiency. Its lightweight design effectively solves the problem of high computational power requirements of traditional CNNs in medical scenarios. Further improvements will be made to the MobileNetV3_Small network to reduce the number of parameters while maintaining high recall, thereby lowering the investment threshold for medical equipment.

[0097] This embodiment uses ablation experiments to systematically evaluate the improved modules of the MobileNetV3_Small network. Specifically, this includes improvements to the attention mechanism, scaling adjustments, halving the number of channels, classifier optimization, and multi-module integration experiments based on the original network. Recall, number of parameters, number of floating-point operations (FLOPs), inference speed, precision, and F1 score are used as core evaluation metrics. Higher recall indicates a lower false negative rate; lower parameter count, fewer FLOPs, and lower inference speed indicate a model that better meets lightweight standards; higher precision indicates a lower false positive rate; and the F1 score is the harmonic mean of recall and precision.

[0098] Experimental results show that when the ECA module is used to replace the SE module or the number of initial layer channels is halved, the network maintains the following performance: Figure 10 While achieving a recall rate of 98.85%, the study significantly reduced the number of parameters and floating-point operations while improving inference speed. Although the precision and F1 score decreased slightly as shown in Table 2, Figure 8 The displayed training set accuracy continues to rise, and Figure 9 The validation set accuracy remained consistently above 90%, indicating that the ECA module effectively maintained the sensitivity of lesion features through both the channel attention mechanism and the halving of the initial layer channel count. Further optimization of the classifier, while maintaining the same recall, not only improved computational efficiency, but also, as shown in Table 2, improved precision and F1 score. Figure 8 The training set accuracy curve shows a steeper upward trend, indicating that the classifier structure adjustment enhances diagnostic reliability through feature space optimization. Notably, when only the Bottleneck structure is extended, although the model maintains the original precision and F1 score, the significant reduction in computational complexity, as shown in Table 2, verifies the improvement in computational efficiency achieved by the expansion ratio optimization. The final fully improved scheme further reduces computational load while maintaining zero recall by replacing the SE module with the ECA module, optimizing the computational path through structural expansion, adjusting the classifier to balance feature representation, and halving the number of channels in the initial layer, thus meeting the real-time screening requirements for mobile devices. These findings provide key algorithmic support for the lightweight improvement of pathological myopia diagnostic equipment. Improved computational efficiency ensures the feasibility of deployment in low-computing-power environments, while stable high recall and... Figure 9 The displayed validation accuracy ensures the clinical reliability of the screening results.

[0099] Table 2 Comparison of Key Indicators in Ablation Experiments Using MobileNetV3-Small Lightweight Improved Version

[0100]

[0101] Therefore, this invention adopts the aforementioned fundus retinal image recognition method based on an improved lightweight network, using MobileNetV3-Small as the base model. By replacing the original SE module with the ECA attention mechanism and compressing the channel dimension, the number of parameters is reduced to 175.7K (a 31.2% reduction compared to the original model) while maintaining the same recall rate, and the inference speed is improved by 171.6%. To verify the effectiveness of this method, quantitative comparative experiments on parameter size, computational complexity, and inference speed were designed, as well as ablation experiments involving gradually adding an ECA module to replace the SE module, adjusting the expansion ratio, halving the number of channels in the initial layer, and adjusting the classifier structure. The experiments show that the optimized model achieves a balance between accuracy and efficiency on the iChallenge-PM dataset, providing a feasible path for rapid screening in primary healthcare scenarios.

[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for fundus retinal image recognition based on an improved lightweight network, characterized in that, Includes the following steps: S1. Data Acquisition and Preprocessing: Acquire a dataset containing fundus and retinal images of pathological myopia and non-pathological myopia. Preprocess the dataset, including image resizing, normalization, and data augmentation. Data augmentation is only applied during the training phase. Divide the dataset into training, validation, and test sets. S2. Improved lightweight network model architecture: Using MobileNetV3-Small network as the base model, the original compressed-excitation SE module in MobileNetV3-Small network is replaced with an efficient channel attention ECA module. The expansion ratio, initial number of convolutional layer channels and classifier structure in MobileNetV3-Small network are optimized to obtain the improved lightweight network model. S3. Training the improved lightweight network model: The class weights are calculated using the inverse frequency weighting method to handle the data imbalance problem. The improved lightweight network model is initialized, the training hyperparameters are set, and the model is trained using the cross-entropy loss function with class weights. The model with the best recall is saved. S4. Image Recognition and Prediction: Load the optimal lightweight network model that has been trained, perform preprocessing and model inference operations on the input fundus retinal image, and output the image recognition result. The specific steps for optimizing the expansion ratio in the MobileNetV3-Small network in S2 include: using the inverse residual module based on MobileNetV3 to compress the number of channels in the expansion layer to 25% of the input channels, and keeping the minimum number of channels in the expansion layer at 16; retaining the 5×5 large kernel design in the deep convolutional layer and adding a hard-swish activation function; and adopting a conditional residual mechanism, enabling residual connections only when the input and output channels are equal and the stride is 1. The specific steps for optimizing the classifier structure in S2 include: introducing a progressive feature compression strategy, expanding the channels from 288 to 512 through 1×1 convolution to compensate for the loss of spatial context information caused by global average pooling; and inserting a Dropout layer into the classifier for regularization design to reduce the risk of model overfitting.

2. The method for fundus retinal image recognition based on an improved lightweight network according to claim 1, characterized in that, The specific steps of data preprocessing in S1 include: scaling all images proportionally to a longest side of 224 pixels, filling the area around the images with black to form a 224×224 square, and normalizing the images to the range of [-1,1]; performing random horizontal and vertical flipping data augmentation on the training set, while only resizing the validation set; generating a label list for the training set by traversing the image directory and based on the filename prefix, and generating a label list for the validation set by reading the image names and labels from the Excel file.

3. The method for fundus retinal image recognition based on an improved lightweight network according to claim 1, characterized in that, The specific steps for replacing the SE module with the ECA module in S2 are as follows: remove the two fully connected layers of the SE module, and use a 1D convolutional kernel on the feature map after global average pooling to capture the interaction between channels. The size of the convolutional kernel is determined by an adaptive formula based on the number of channels c. ; in, c It is the number of channels. r and b All of these are hyperparameters.

4. The fundus retinal image recognition method based on an improved lightweight network according to claim 1, characterized in that, The specific steps for optimizing the number of channels in the initial convolutional layer in S2 are as follows: the 3×3 convolution with 16 channels in the input layer of the original MobileNetV3-Small network is compressed to 8 channels, and the number of channels in the initial convolutional layer is optimized by using ConvBlock.

5. The method for fundus retinal image recognition based on an improved lightweight network according to claim 1, characterized in that, In S3, setting training hyperparameters and model training includes: setting the training epochs to 20, using the Adam optimizer and setting the learning rate to 0.001; during training, outputting the accuracy and loss value of training / validation in real time, as well as the recall, precision and F1-score for pathological myopia; after training, generating a confusion matrix and visualizing the training curves, and saving the best model as the best_recall_V3model.pth file.

6. The method for fundus retinal image recognition based on an improved lightweight network according to claim 1, characterized in that, The expression for calculating class weights using the inverse frequency weighting method in S3 is as follows: ; in, For category The weight, N The total number of samples, M For category i The number of samples; The weighted cross-entropy loss function is expressed as follows: ; in, Y The actual label value. This represents the probability value predicted by the model.

7. The method for fundus retinal image recognition based on an improved lightweight network according to claim 1, characterized in that, The specific steps for recognition and prediction include: supporting image input in JPG / JPEG / PNG formats, and ensuring compatibility with both old and new weight file formats when loading the model; calculating the predicted category and confidence level after model inference, and saving the recognition results in two forms: first, adding red annotation text containing the Chinese category name and confidence level percentage to the upper left corner of the original image; second, generating a CSV file that records the file name, predicted category, confidence level, and processing status; setting up an error handling mechanism to skip images that cannot be processed and recording the reasons for failure in the CSV file; and finally summarizing and outputting the successful and unsuccessful prediction results.