Diopter detection model training method and system
By using the train-and-verify method and utilizing multi-threading and cross-entropy loss function to optimize the refractive power detection model, the problem of low training efficiency was solved, real-time monitoring and efficient model export were achieved, and the detection effect was improved.
Patent Information
- Application Number
- CN202511243393.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-02
- Publication Date
- 2025-10-03
AI Technical Summary
The existing technology has low training efficiency for refractive power detection models, and cannot monitor parameters in real time. The training process cannot be stopped at any time, resulting in poor detection results.
A training-while-verification method is adopted to train and verify the refractive power detection model through two threads. The model status is monitored in real time, and the model at the required time point is exported when the verification result fails. A 95:5 training set and verification set ratio and a 90:10 computing power distribution are used to optimize the model using the cross-entropy loss function.
Improved the efficiency of refractive index detection model training, enabling real-time training stop and export of the required model, thus improving detection results.
Smart Images

Figure CN120747671A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of optical detection technology, and in particular to a diopter detection model training method and system. Background Art
[0002] Refractive testing is a medical examination used to assess the refractive state of the eye. Its primary purpose is to identify individual vision problems, such as myopia, hyperopia, or astigmatism, and to provide the necessary parameters for choosing glasses or contact lenses. The eye's refractive system (including the cornea and lens) focuses incoming light onto the retina, forming a clear image. If there are defects in the refractive system, light cannot be accurately focused, resulting in blurred vision. Using neural network models to perform refractive testing is one of the current research areas.
[0003] Patent document CN118982819A discloses a lens diopter detection method, system, intelligent terminal, and storage medium. The method constructs a diopter detection model based on image data set information and a preset model algorithm; obtains the image data information of the lens to be detected; and inputs the image data information into the diopter detection model to predict the actual diopter information of the lens. This technology, which improves detection efficiency by performing diopter detection through detection models, is a development direction in this field. However, traditional model training methods require post-training verification. This approach has the disadvantages of low training efficiency, the inability to monitor parameters in real time, and the inability to stop the training process at any time, resulting in poor detection performance of the resulting detection model. Summary of the Invention
[0004] In view of the defects in the prior art, the purpose of the present invention is to provide a diopter detection model training method and system.
[0005] A refractive index detection model training method provided by the present invention includes: Step S1: Acquire multiple batches of lens image samples, each batch including multiple lens images acquired continuously in chronological order, and divide the lens image samples into a training set and a validation set; Step S2: Allocate computing power to the processing modules, with some computing power used for training and some for verification; Step S3: The order of the images in the training set and the validation set are shuffled respectively, and the diopter detection model is trained and validated simultaneously by two threads in the processing module, and the output of the model is the diopter change trend of the lens image samples; Step S4: monitor the training status of the model in real time and derive the diopter detection model at the required time point during the training process.
[0006] Furthermore, in step S1, the ratio of the training set to the validation set is 95:5; In step S2, 90% of the computing power is used for training, and 10% of the computing power is used for verification.
[0007] Furthermore, the step S3 includes: training the diopter detection model through the first thread to obtain a first training result, verifying the first training result through the second thread, and repeating the cycle.
[0008] Furthermore, step S3 includes: each batch of lens image samples corresponds to a loss function, and during the training process, if the value of the loss function and the average intersection-over-union ratio decreases, then the lens image samples are increased, otherwise the lens image samples are reduced until the value of the loss function stabilizes; Among them, the loss function includes cross entropy loss:
[0009] in, is the prediction result of the model, x is the batch, w is the weight, x n is the nth image in batch x.
[0010] Furthermore, in step S3, during the training process, a time signature is established for each while loop; In step S4, if the verification result of the refractive power detection model is qualified at the first time, but is unqualified at the second time, the refractive power detection model corresponding to the time stamp at the first time is derived.
[0011] A refractive index detection model training system provided by the present invention includes: Module M1: Acquire multiple batches of lens image samples, each batch includes multiple lens images collected continuously in chronological order, and divide the lens image samples into a training set and a validation set; Module M2: allocates computing power to the processing modules, with some computing power used for training and some for verification; Module M3: The order of the images in the training set and the validation set are shuffled respectively, and the diopter detection model is trained and validated simultaneously through two threads in the processing module. The output of the model is the diopter change trend of the lens image samples; Module M4: monitors the training status of the model in real time and exports the refractive power detection model at the required time points during the training process.
[0012] Furthermore, in the module M1, the ratio of the training set to the validation set is 95:5; In the module M2, 90% of the computing power is used for training, and 10% of the computing power is used for verification.
[0013] Furthermore, the module M3 includes: training the diopter detection model through a first thread to obtain a first training result, verifying the first training result through a second thread, and repeating the cycle.
[0014] Furthermore, the module M3 includes: each batch of lens image samples corresponds to a loss function, and during the training process, if the value of the loss function decreases, the lens image samples are increased, otherwise the lens image samples are reduced until the value of the loss function stabilizes; Among them, the loss function includes cross entropy loss:
[0015] in, is the prediction result of the model, x is the batch, w is the weight, x n is the nth image in batch x.
[0016] Furthermore, in the module M3, during the training process, a time signature is established for each while loop; In the module M4, if the verification result of the refractive power detection model is qualified at the first time, but is unqualified at the second time, the refractive power detection model corresponding to the time stamp at the first time is derived.
[0017] Compared with the prior art, the present invention has the following beneficial effects: During the training process of the refractive power detection model, the present invention can verify the model in real time, thereby improving the efficiency of the refractive power detection model training. The training process can be stopped at any time and the model of the required training time period can be exported, thereby improving the detection effect of the final model. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Other features, objects and advantages of the present invention will become more apparent upon reading the detailed description of non-limiting embodiments with reference to the following drawings: Figure 1 It is the workflow diagram of the present invention. DETAILED DESCRIPTION
[0019] The present invention will be described in detail below with reference to specific embodiments. The following examples will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those skilled in the art, several changes and improvements can be made without departing from the scope of the present invention. These all fall within the scope of protection of the present invention.
[0020] like Figure 1 As shown, the present invention provides a diopter detection model training method, comprising: Step S1: Acquire multiple batches of lens image samples, each batch comprising multiple lens images acquired sequentially in chronological order, and divide the lens image samples into a training set and a validation set. In this embodiment, the ratio of the training set to the validation set is set to 95:5, wherein the lens image samples can be obtained from an existing database.
[0021] Step S2: Allocate computing power to the processing modules, with some allocated for training and some for verification. Processing modules can be CPUs, GPUs, FPGAs, or ASICs, and there can be multiple of them. A typical allocation of computing power is 90% for model training and 10% for model verification. The allocation of computing power can be tailored to actual conditions. For example, if sufficient computing power is available, the proportion of computing power required for training can be appropriately reduced while the proportion required for verification can be increased.
[0022] Step S3: The order of the images in the training set and the validation set are shuffled respectively, and the refractive power detection model is trained and validated simultaneously through two threads in the processing module. The output of the model is the refractive power change trend of the lens image samples.
[0023] The first thread trains the refractive power detection model to obtain the first training result, and the second thread verifies the first training result, and so on. During the training process, each batch of lens image samples corresponds to a loss function. If the loss function and the average intersection-over-union ratio are decreasing, the lens image samples are increased, and vice versa, the lens image samples are reduced until the value of the loss function stabilizes. The loss function includes cross entropy loss:
[0024] in, is the prediction result of the model, x is the batch, w is the weight, x n is the nth image in batch x. During training, a time stamp is established in each while loop so that the model in the current loop corresponds to the current time. For example, in a while loop, the current time is obtained as the time stamp through the time function. After each loop, the model parameters and verification metrics with the time stamp are automatically saved.
[0025] Step S4: Monitor the model training status in real time and export the diopter detection model for the desired time point during the training process. Specifically, monitor the verification results of the second thread in real time. If the verification result of the model for the previous time signature is qualified, but the verification result of the model for the current time signature is unqualified, the training process can be stopped immediately and the model for the previous time signature can be exported to avoid unnecessary waste of resources and time.
[0026] In other embodiments, the method further includes step S5: continuously acquiring multiple lens images of the subject to be measured in chronological order, performing diopter detection using the derived model, and obtaining a diopter change trend of the subject to be measured. Specifically, the method includes: Step S51: Continuously capture multiple images of the subject to be tested in chronological order, segment the lens region of the images to be tested, and input them into a diopter change trend detection model. The images can be captured using a wearable device such as glasses with a camera worn by the subject to be tested. The capture method includes: S551. The light source of the wearable module is used to excite light so that the light enters the wearer's eyeball, and the light is diffusely reflected and refracted by the retina and lens to obtain a first reflected light.
[0027] S512. Collect first video information including the first reflected light through the optical axis of the camera module of the wearable module.
[0028] S513. Use OpenCV tools to segment the first video information into multiple lens regions according to time; wherein the first video information includes first reflected light rays diffusely reflected and refracted by the retina and the lens.
[0029] Step S52: dilate the lens region to isolate the image of the expanded lens region. This means adding pixel values at the edge of the lens region to expand the overall pixel value, thereby achieving an image dilation effect.
[0030] Step S53: first filter the isolated image to remove noise, and then obtain the curvature of the grayscale change of the lens area based on the filtered image.
[0031] One approach is to perform a fast Fourier transform to obtain a spectrum graph. The fast Fourier transform includes:
[0032] in, is the representation of the image in the frequency domain, is the representation of the image in the spatial domain, u 、 v is the frequency coordinate in the frequency domain, i The spectrum also includes the curvature of the grayscale change in the lens area.
[0033] Another approach is to construct a rectangular area based on the isolated image by taking the maximum and minimum grayscale values, isolate the image corresponding to the rectangular area to obtain a second image, take all grayscale values in the second image, fit the grayscale values using the least squares method to obtain a straight line, and calculate the curvature of the straight line.
[0034] Step S54: Obtain the change trend of the diopter according to the curvature and time sequence of the grayscale change of the lens area.
[0035] In the present invention, when light passes through the lens and enters the fundus, if the refractive power changes, the focus of the light moves forward, and the more the focus moves, the greater the refractive power; when the light is diffusely reflected at the fundus and returns through the lens again, the greater the refractive power, the wider the line.
[0036] Assuming an ideal state, infrared light enters from the eye axis, passes through the lens to the fundus, is refracted in the lens after diffuse reflection, and then passes through the optical axis of the infrared camera. There is no energy loss in all light paths, and the camera can also fully receive it. The eyeball is assumed to be a standard sphere, then the emitted lines should decrease evenly from the middle to both sides. In any area of the line, the energy values of all pixel points are taken out, arranged from large to small, and then the values are fitted into a straight line using the least squares method. Then the slopes of any area should be equal.
[0037] It is understandable that the retina occupies approximately 70% of the fundus area. As long as light passes through the lens in any area within that 70% range, effective diffuse reflection will occur. The total energy value of the reflected line is lower, but the slope is the same as the ideal state. In other words, the refractive index is not correlated with the brightness of the reflected light. Because the lens is constantly in motion relative to the wearable module, there is no guarantee that the light can always pass through the lens to obtain valid parameters, so the measurement is not coherent. Therefore, it is only necessary to calculate the slope change of the energy of the reflected light in a fixed area to obtain the corresponding refractive index change.
[0038] The present invention also provides a refractive index detection model training system. The refractive index detection model training system can be implemented by executing the process steps of the refractive index detection model training method. That is, those skilled in the art can understand the refractive index detection model training method as a preferred embodiment of the refractive index detection model training system. The system includes: Module M1: Acquire multiple batches of lens image samples, each batch includes multiple lens images collected continuously in chronological order, and divide the lens image samples into a training set and a validation set.
[0039] Module M2: Allocates computing power to the processing module, with part of the computing power used for training and part for verification.
[0040] Module M3: The order of the images in the training set and the validation set are disrupted respectively, and the refractive power detection model is trained and validated simultaneously through two threads in the processing module.
[0041] Module M4: monitors the training status of the model in real time and exports the refractive power detection model at the required time points during the training process.
[0042] Those skilled in the art will appreciate that, in addition to implementing the system and its various devices, modules, and units provided by the present invention in purely computer-readable program code, it is entirely possible to implement the same functions of the system and its various devices, modules, and units provided by the present invention in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; the devices, modules, and units for implementing various functions can also be considered as both software modules implementing the method and structures within the hardware component.
[0043] The above describes specific embodiments of the present invention. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art may make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. The embodiments of this application and the features in the embodiments may be combined with each other in any manner unless there is a conflict.
Claims
1. A refractive power detection model training method, characterized in that: include: Step S1: Acquire multiple batches of lens image samples, each batch including multiple lens images acquired continuously in chronological order, and divide the lens image samples into a training set and a validation set; Step S2: Allocate computing power to the processing modules, with some computing power used for training and some for verification; Step S3: The order of the images in the training set and the validation set are disrupted respectively, and the diopter detection model is trained and validated simultaneously by two threads in the processing module, and the output of the model is the diopter change trend of the lens image samples; Step S4: monitor the training status of the model in real time and derive the diopter detection model at the required time point during the training process.
2. The refractive index detection model training method according to claim 1, wherein: In step S1, the ratio of the training set to the validation set is 95:5; In step S2, 90% of the computing power is used for training, and 10% of the computing power is used for verification.
3. The refractive index detection model training method according to claim 1, wherein: The step S3 includes: training the diopter detection model through the first thread to obtain a first training result, verifying the first training result through the second thread, and repeating the cycle.
4. The refractive index detection model training method according to claim 1, wherein: The step S3 includes: each batch of lens image samples corresponds to a loss function, and during the training process, if the value of the loss function and the average intersection-over-union ratio decreases, then the lens image samples are increased, otherwise the lens image samples are reduced until the value of the loss function stabilizes; Among them, the loss function includes cross entropy loss: in, is the prediction result of the model, x is the batch, w is the weight, x n is the nth image in batch x.
5. The refractive index detection model training method according to claim 1, wherein: In step S3, during the training process, a time signature is established for each while loop; In step S4, if the verification result of the refractive power detection model is qualified at the first time, but is unqualified at the second time, the refractive power detection model corresponding to the time stamp at the first time is derived.
6. A diopter detection model training system, characterized in that: include: Module M1: Acquire multiple batches of lens image samples, each batch includes multiple lens images collected continuously in chronological order, and divide the lens image samples into a training set and a validation set; Module M2: allocates computing power to the processing modules, with some computing power used for training and some for verification; Module M3: The order of the images in the training set and the validation set are shuffled respectively, and the diopter detection model is trained and validated simultaneously through two threads in the processing module. The output of the model is the diopter change trend of the lens image samples; Module M4: monitors the training status of the model in real time and exports the refractive power detection model at the required time points during the training process.
7. The diopter detection model training system according to claim 6, characterized in that: In the module M1, the ratio of the training set to the validation set is 95:5; In the module M2, 90% of the computing power is used for training, and 10% of the computing power is used for verification.
8. The diopter detection model training system according to claim 7, characterized in that: The module M3 includes: training the diopter detection model through a first thread to obtain a first training result, verifying the first training result through a second thread, and repeating the cycle.
9. The diopter detection model training system according to claim 6, characterized in that: The module M3 includes: each batch of lens image samples corresponds to a loss function, and during the training process, if the value of the loss function decreases, the lens image samples are increased, otherwise the lens image samples are reduced until the value of the loss function stabilizes; Among them, the loss function includes cross entropy loss: in, is the prediction result of the model, x is the batch, w is the weight, x n is the nth image in batch x.
10. The diopter detection model training system according to claim 6, characterized in that: In the module M3, during the training process, a time signature is established for each while loop; In the module M4, if the verification result of the refractive power detection model is qualified at the first time, but is unqualified at the second time, the refractive power detection model corresponding to the time stamp at the first time is derived.
Citation Information
Patent Citations
Lens diopter detection method and system, intelligent terminal and storage medium
CN118982819A
Method for training detection model for diopter detection and related product
CN115082459A
Diopter calculation method and device
CN116570231A
Program generation device and program generation method
CN117099057A
Theoretical drive domain control of ophthalmic prediction method based on machine learning
CN117280425A