Water meter reading detection and identification method, equipment, system and storage medium
By combining a lightweight target detection algorithm with a heavy parameterized recognition model, the robustness problem of traditional water meter reading recognition methods in complex environments is solved, efficient and accurate recognition of water meter readings is achieved, and the intelligent level of water management is improved.
Patent Information
- Application Number
- CN202410309059.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-18
- Publication Date
- 2025-09-19
AI Technical Summary
In the existing technology, traditional water meter reading recognition methods have poor robustness and are difficult to adapt to complex environments. In addition, deep learning methods do not consider the inconsistent frequency of numbers in image samples and the different recognition difficulties, resulting in insufficient recognition efficiency and accuracy.
A lightweight target detection algorithm model and a re-parameterized recognition model are adopted to obtain the coordinates of the water meter reading frame through the lightweight target detection algorithm model. The model is combined with the re-parameterized recognition model for preprocessing and recognition. The Focal-C-CTC and RepVGG-A0 models are used for training and optimization to achieve fast inference and efficient recognition.
It improves the efficiency and accuracy of water meter reading detection and identification, adapts to complex environments, provides a better user experience, and improves the data processing efficiency and water use efficiency of water management.
Smart Images

Figure CN120673427A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of intelligent water meter reading image recognition, and in particular to a water meter reading detection and recognition method, device, system and storage medium. Background Art
[0002] For many years, the water supply industry has faced numerous management pain points, with manual meter reading being one of them. On the one hand, rising labor costs have led to increasing operational cost pressures. Manual meter reading also suffers from long settlement cycles and the risk of errors. Furthermore, leakage rates among my country's water supply companies remain high. In recent years, smart water meters have become increasingly widespread. They can remotely transmit meter readings, replacing manual readings and improving operational efficiency. They also help water supply companies address leakage in their pipeline networks. However, many users still rely on traditional water meters, such as old mechanical wheel meters. With the advancement of digital technology, these traditional meters can now be equipped with camera covers and image-based recognition technology. Traditional water meter reading image recognition uses morphological processing such as opening and closing operations and binarization to separate the characters in the meter readings. Template matching or machine learning classification is then used to achieve image-based character recognition. However, these methods suffer from poor robustness and limited adaptability to complex environments. Deep learning methods, which feed large numbers of samples into the network for learning, overcome these issues. However, existing deep learning methods do not consider issues such as inconsistent frequencies of different numbers in image samples, different recognition difficulties, and fast reasoning of models in practical applications. Summary of the Invention
[0003] Therefore, in order to overcome at least some of the defects and shortcomings in the prior art, the embodiments of the present invention provide a water meter reading detection and identification method, device, system and storage medium, which can solve the problems of inconsistent frequency of occurrence and different recognition difficulties of different numbers in image samples. At the same time, it realizes the rapid reasoning of the model in practical applications, further improves the efficiency and accuracy of the water meter reading detection and identification method, and brings a better user experience for massive water users.
[0004] In the first aspect, an embodiment of the present invention provides a water meter reading detection and recognition method, including: S1: obtaining the coordinates of the water meter reading frame based on the water meter image and the lightweight target detection algorithm model; the skeleton network of the lightweight target detection algorithm model is a lightweight model; S2: preprocessing the water meter reading frame according to the coordinates to obtain a water meter reading area image; S3: obtaining a probability matrix based on the water meter reading area image and the re-parameterized recognition model; S4: decoding the probability matrix to obtain the water meter reading.
[0005] In one embodiment of the present invention, it also includes a first determination step for determining the lightweight target detection algorithm model, and the first determination step includes: S11: sending the water meter detection image training set to the pre-training detection model to obtain the detection result; S12: processing the detection result based on the box regression loss function, the target loss function and the classification loss function to obtain the first total loss function; S13: optimizing the pre-training detection model to obtain the post-training detection model; using the post-training detection model as the pre-training detection model for the next training, repeating the above steps S11-S13 until the first total loss function reaches the first preset target, executing S14: stopping optimization, and determining multiple first target optimization models based on the multiple first total loss functions obtained by repeating the above steps S11-S13, the multiple first target optimization models are selected from the multiple post-training detection models obtained when repeating the above steps S11-S13; determining the lightweight target detection algorithm model based on the multiple first target optimization models.
[0006] In one embodiment of the present invention, step S14 specifically includes: obtaining multiple first evaluation indicators based on the detection results of the multiple first target optimization models; judging the multiple first evaluation indicators, and taking the first target optimization model corresponding to the first evaluation indicator with the highest value of the multiple first evaluation indicators as the lightweight target detection algorithm model.
[0007] In one embodiment of the present invention, the reparameterized recognition model is a model trained based on the loss function Focal-C-CTC.
[0008] In one embodiment of the present invention, the reparameterized recognition model is a model obtained based on the RepVGG-A0 model, and the RepVGG-A0 model training architecture is composed of multiple three-branch architectures stacked together, and the three-branch architectures are a branch with a convolution kernel size of 3, a branch with a convolution kernel size of 1, and an identity mapping branch.
[0009] In one embodiment of the present invention, it also includes a second determination step for determining the re-parameterized recognition model, and the second determination step includes: S31: sending the water meter reading recognition area image training set to the pre-training recognition model to obtain a recognition result; S32: processing the recognition result based on the loss function Focal-C-CTC to obtain a second total loss function; S33: optimizing the pre-training recognition model to obtain a post-training recognition model; using the post-training recognition model as the pre-training recognition model for the next training, repeating the above steps S31-S33 until the second total loss function reaches a second preset target, and executing S34: stopping optimization, and determining multiple second target optimization models based on the multiple second total loss functions obtained by repeating the above steps S31-S33, the multiple second target optimization models are selected from the multiple post-training recognition models obtained when repeating the above steps S31-S33; determining the re-parameterized recognition model based on the multiple second target optimization models.
[0010] In one embodiment of the present invention, step S34 specifically includes: obtaining multiple second evaluation indicators based on the recognition results of the multiple second objective optimization models; judging the multiple second evaluation indicators, and taking the second objective optimization model corresponding to the second evaluation indicator with the highest value of the multiple second evaluation indicators as the final model; re-parameterizing the final model to reduce the number of parameters, and fusing the three-branch structure of the final model into a single-branch structure to obtain the re-parameterized recognition model.
[0011] In one embodiment of the present invention, step S1 specifically includes: transforming the lightweight target detection algorithm model to obtain a detection IR model; sending the water meter image into the detection IR model to obtain the coordinates of the water meter reading box; step S3 specifically includes: transforming the re-parameterized recognition model to obtain a recognition IR model; sending the water meter reading area image into the recognition IR model, and inferring the water meter reading area image through the recognition IR model to obtain a probability matrix.
[0012] In a second aspect, an embodiment of the present invention provides a water meter reading detection and identification device, comprising: a memory provided with a water meter reading detection and identification program; a processor connected to the memory, the processor being used to run the water meter reading detection and identification program to execute a water meter reading detection and identification method as described in any one of the foregoing items.
[0013] In the third aspect, an embodiment of the present invention provides a water meter reading detection and identification system, comprising: a water meter reading detection and identification device, a file server and a water meter image acquisition and transmission device, wherein the file server is connected to the water meter image acquisition and transmission device and the water meter reading detection and identification device, respectively; the water meter image acquisition and transmission device is used to acquire water meter images and send the water meter images to the file server; the file server is used to obtain the water meter images transmitted by the water meter image transmission device and send them to the water meter reading detection and identification device, receive the water meter readings sent back by the water meter reading detection and identification device and store them; the water meter reading detection and identification device is used to execute the water meter reading detection and identification method as described in any one of the foregoing items, and send the water meter readings back to the file server.
[0014] In a fourth aspect, an embodiment of the present invention provides a water meter reading detection and identification system, comprising: a water meter reading detection and identification device and a file server, wherein the water meter reading detection and identification device is used to collect water meter images and execute the water meter reading detection and identification method as described in any one of the foregoing items, and send the water meter reading to the file server; the file server is used to obtain and store the water meter reading transmitted by the water meter reading detection and identification device.
[0015] In a fifth aspect, an embodiment of the present invention provides a storage medium storing a water meter reading detection and identification program, wherein the water meter reading detection and identification program is used to execute the water meter reading detection and identification method as described in any one of the above items.
[0016] From the above, it can be seen that the above one or more technical solutions of the present invention can have the following advantages and beneficial effects: the embodiment of the present invention detects and identifies water meter images by using a lightweight target detection algorithm model and a re-parameterized recognition model, which can solve the problem of inconsistent frequency of occurrence and different recognition difficulties of different numbers in image samples. At the same time, it realizes the rapid reasoning of the model in practical applications, further improves the efficiency and accuracy of the water meter reading detection and recognition method, and brings a better user experience for massive water users. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] For ease of explanation, the present invention is described in detail with reference to the following specific implementations and accompanying drawings.
[0018] Figure 1 A schematic flow chart of a water meter reading detection and identification method provided by an embodiment of the present invention.
[0019] Figure 2 for Figure 1 Schematic diagram of the flow chart of the first determination step in .
[0020] Figure 3 for Figure 1 Schematic diagram of the flow chart of the second determination step in .
[0021] Figure 4 A schematic diagram of a re-parameterized model of a water meter reading detection and recognition method provided by an embodiment of the present invention.
[0022] Figure 5 for Figure 4 Schematic diagram of the reparameterized model unit is shown.
[0023] Figure 6 A schematic diagram of an LSTM with an attention mechanism added to a water meter reading detection and recognition method provided by an embodiment of the present invention.
[0024] Figure 7 A schematic structural diagram of a water meter reading detection and identification device provided by an embodiment of the present invention.
[0025] Figure 8 A schematic structural diagram of a water meter reading detection and identification system provided by an embodiment of the present invention.
[0026] Figure 9 A schematic structural diagram of another water meter reading detection and identification system provided by an embodiment of the present invention.
[0027] Figure 10 A schematic structural diagram of a storage medium provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0028] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0029] In order to enable those skilled in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative efforts should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] It should also be noted that the division of multiple embodiments in the present invention is only for the convenience of description and should not constitute a special limitation. The features in various embodiments can be combined and referenced to each other without contradiction.
[0032] [First embodiment]
[0033] like Figure 1 As shown, an embodiment of the present invention provides a method for detecting and identifying water meter readings, and the specific steps include, for example:
[0034] S1: Based on the water meter image and the lightweight object detection algorithm model, the coordinates of the water meter reading frame are obtained; the skeleton network of the lightweight object detection algorithm model is a lightweight model;
[0035] S2: Preprocess the water meter reading frame according to the coordinates to obtain the water meter reading area image;
[0036] S3: Based on the water meter reading area image and the re-parameterized recognition model, a probability matrix is obtained;
[0037] S4: Decode the probability matrix to obtain the water meter reading.
[0038] Specifically, in one implementation of this embodiment, step S1, for example, specifically includes: sending the water meter image into a lightweight target detection algorithm model to obtain the coordinates of the water meter reading frame. Among them, the lightweight target detection algorithm model is, for example, yolo-fastest v2. The skeleton network of the lightweight target detection algorithm model is, for example, the lightweight model shufflenetv2. The lightweight model shufflenet v2 uses group convolution and channel shuffle to improve ResNet, limiting the convolution operation to each group, and analyzing and selecting appropriate parameters such as the number of input and output channels and the number of groups. The computational complexity of this model will be significantly reduced. Secondly, step S2, for example, specifically includes: performing an affine transformation on the water meter reading frame according to the coordinates, and after correction, obtaining an image of the water meter reading area, and scaling the image of the water meter reading area to an appropriate size. Among them, the correction method is, for example, based on an open source computer vision and machine learning software library, such as the opencv library. Optionally, the correction method is completed, for example, with the help of the warpPerspective function in the opencv library, and finally the water meter reading area image is scaled to an appropriate size, for example, to 160×32. Again, step S3, for example, specifically includes: sending the corrected and scaled water meter reading area image to the reparameterized recognition model. The reparameterized recognition model is, for example, a model trained based on the loss function Focal-C-CTC (Focal-Center-Connectionist Temporal Classification), such as the model RC-AT-LSTM (Reparameterization Convolutional Neural Network-Attention-Long Short Term Memory). Then, step S4, for example, specifically includes: decoding the probability matrix through CTC (Connectionist Temporal Classification) to obtain the water meter reading.
[0039] The embodiments of the present invention detect and identify water meter images using a lightweight target detection algorithm model and a re-parameterized recognition model, thereby resolving the issues of inconsistent frequencies of different digits in image samples and varying degrees of recognition difficulty. Furthermore, the embodiments of the present invention achieve rapid model reasoning in practical applications. The embodiments of the present invention further improve the efficiency and accuracy of water meter reading detection and recognition methods, providing a better user experience for large water users. Furthermore, the application of lightweight target detection algorithm models will provide more efficient and accurate data processing methods for water management, helping to improve management levels, optimize resource allocation, and increase water use efficiency, thereby driving the water industry towards intelligence and informatization.
[0040] Furthermore, in another implementation of this embodiment, step S1 specifically includes, for example: transforming the lightweight target detection algorithm model to obtain a detection IR model; sending the water meter image into the detection IR model to obtain the coordinates of the water meter reading box. Step S3 specifically includes, for example: transforming the re-parameterized recognition model to obtain a recognition IR model; sending the water meter reading area image into the recognition IR model, and inferring the water meter reading area image through the recognition IR model to obtain a probability matrix, for example, implementing fast reasoning under the openvino framework. This embodiment further transforms the lightweight target detection algorithm model and the re-parameterized recognition model into an IR model, and then implements fast reasoning under the openvino framework. This method can obtain results more quickly, thereby improving the efficiency of the lightweight target detection algorithm model and the re-parameterized recognition model.
[0041] like Figure 2 As shown, the water meter reading detection and recognition method of this embodiment further includes, for example, a first determination step of determining a lightweight target detection algorithm model. The first determination step specifically includes, for example:
[0042] S11: Send the water meter detection image training set to the pre-training detection model to obtain the detection results;
[0043] S12: Processing the detection results based on the box regression loss function, the target loss function, and the classification loss function to obtain a first total loss function;
[0044] S13: Optimize the pre-training detection model to obtain a post-training detection model;
[0045] The post-training detection model is used as the pre-training detection model for the next training, and the above steps S11-S13 are repeated until the first total loss function reaches the first preset target.
[0046] S14: Stop optimization, and determine multiple first target optimization models based on the multiple first total loss functions obtained by repeating the aforementioned steps S11-S13, where the multiple first target optimization models are selected from the multiple post-training detection models obtained by repeating the aforementioned steps S11-S13; determine a lightweight target detection algorithm model based on the multiple first target optimization models.
[0047] Optionally, step S14 specifically includes, for example, obtaining multiple first evaluation indicators based on the detection results of multiple first target optimization models, judging the multiple first evaluation indicators, and selecting the first target optimization model corresponding to the first evaluation indicator with the highest value among the multiple first evaluation indicators as the lightweight target detection algorithm model.
[0048] Specifically, before proceeding to step S11, the images in the water meter detection image training set, including water meters, are scaled to an appropriate size, for example, to 416×416, using the OpenCV library. After the water meter detection image training set is fed into the pre-trained detection model, data augmentation strategies are applied to the images in the water meter detection image training set, such as random cropping, random scaling, and random brightness and contrast changes, such as small-angle rotation and small-amplitude translation. Simultaneously, the pre-trained detection model is initialized using parameters pre-trained with the Cocoa dataset, and detection results are obtained.
[0049] Secondly, the detection results are processed using the box regression loss function, the target loss function, and the classification loss function. For example, the box regression loss (CIOU) is used to measure the difference between the detection prediction box and the detection real box. The smaller the difference, the more accurate the detection result of the pre-training detection model. The target (Obj) loss is used to measure the ability of the pre-training detection model to determine whether there is an object in the image. The classification (Cls) loss is used to measure the accuracy of the pre-training detection model for different classification detections. Among them, the box regression loss satisfies the following formula for example:
[0050] IOU=(min(x p2 , x l2 )-max(x p1 , x l1 ))*(min(y p2 ,y l2 )-max(y p1 ,y l1 )),
[0051]
[0052]
[0053]
[0054]
[0055] Loss CIoU =1-CIOU.
[0056] Among them, (x l1 ,y l1 )、(x l2 ,y l2 ) are the coordinates of the upper left corner and lower right corner of the detection real box; (x p1 ,y p1 )、(x p2 ,y p2) are the coordinates of the upper left corner and lower right corner of the detection prediction box; c is the diagonal length of the minimum enclosing rectangle of the two boxes; ρ is the distance between the center points of the two boxes; α is the influence factor of v.
[0057] The target loss is, for example, BCEWithLogitsLoss, which is a binary cross entropy loss function; the classification loss is, for example, Focal BCEWithLogitsLoss. For example, the following formula is satisfied:
[0058]
[0059] α is used to balance positive and negative samples, and γ is used to make the model pay more attention to difficult samples. For example, α = 0.5 and γ = 2.
[0060] Therefore, the total loss function satisfies the following formula:
[0061] Loss=w1·Loss CIOU +w2·Loss Obj +w3·Focal Loss Cls ,
[0062] Among them, w1, w2, w3 are the weights of the box regression loss function, the target loss function and the classification loss function, respectively, where, for example, w1=1, w2=1, w3=1.
[0063] This embodiment uses the box regression loss function, the target loss function and the classification loss function to judge and measure the detection results, which can determine the accuracy of the pre-training detection model, so as to better measure whether the pre-training detection model needs to be optimized. For example, the initial pre-training detection model is recorded as A0, and the water meter detection image training set is sent to A0 to obtain the detection result, wherein the water meter detection image training set, for example, contains multiple water meter detection images whose detection true frames and detection true frame coordinates are known; the detection result, for example, includes the detection prediction frame and detection prediction frame coordinates corresponding to each water meter detection image. The detection result is processed using the box regression loss function, the target loss function and the classification loss function to obtain the initial first total loss function, for example, recorded as loss0, and the initial first total loss function loss0 is evaluated to determine whether A0 needs to be optimized. When the result of the judgment is that optimization is required, A0 is optimized to obtain A1. A1 is used as the pre-training detection model for the next round of training, that is, repeating the previous training steps. Assuming i is the round, that is, i is, for example, the round number. When the optimization reaches the i-th round, the post-training detection model is A i , the training detection model obtained by the next round of optimization is A i+1 For example, when the jth round is reached, the post-training detection model obtained in the jth round is A j , the first total loss function loss of the jth roundj Convergence begins. If the optimization ends at the end of the nth round, the post-training detection model obtained at the nth round is A n , the first total loss function obtained in the nth round is loss n , that is, loss j -loss n The first total loss function between reaches convergence, that is, loss j -loss n The first total loss function value balance between is within a certain range, with little fluctuation. At this time, it is considered that the first total loss function has reached the first preset target, that is, it is considered that the optimization can be stopped. At this time, A j -A n The trained detection model between the two is used as the first target optimization model. Multiple first target optimization models are processed to obtain multiple first evaluation indicators, such as the accuracy of the detection prediction box and classification. The multiple first evaluation indicators are judged and the first target optimization model corresponding to the first evaluation indicator with the highest value among the multiple first evaluation indicators is selected as the lightweight target detection algorithm model. This step method enables rapid model inference in practical applications, further improving the efficiency and accuracy of water meter reading detection and recognition methods, and providing users with a better user experience.
[0064] Optionally, during the model optimization training process, for example, an SGD (Stochastic Gradient Descent) optimizer can be used for optimization. The parameters can be set as shown in the following table:
[0065]
[0066] The first evaluation index is, for example, Recall, Precision, and F1 Score, which satisfy the following formula:
[0067]
[0068]
[0069]
[0070] The meanings of TP, FP, and FN are as follows:
[0071] Predicted results / actual results True False Positive TP FP Negative TN FN
[0072] Among them, the real result in the table is, for example, the detection real frame, and the predicted result is, for example, the detection predicted frame. TP, for example, means that the detection real frame has framed the water meter image, and the detection predicted frame has also framed the water meter image; FP, for example, means that the detection real frame has not framed the water meter image, but the detection predicted frame has framed the water meter image; TN, for example, means that the detection real frame has framed the water meter image, but the detection predicted frame has not framed the water meter image; FN, for example, means that the detection real frame has not framed the water meter image, and the detection predicted frame has not framed the water meter image. The experiment takes the trained detection model corresponding to the highest F1 (i.e., the first evaluation indicator) score among multiple first evaluation indicators (also called test sets) as the final model, that is, the lightweight target detection algorithm model.
[0073] like Figure 3 As shown, the water meter reading detection and recognition method further includes, for example, a second determination step of determining the re-parameterized recognition model. The second determination step specifically includes, for example:
[0074] S31: sending the water meter reading recognition area image training set to the pre-training recognition model to obtain the recognition result;
[0075] S32: Processing the recognition result based on the loss function Focal-C-CTC to obtain a second total loss function;
[0076] S33: Optimizing the pre-training recognition model to obtain a post-training recognition model;
[0077] The trained recognition model is used as the pre-trained recognition model for the next training, and the above steps S31-S33 are repeated until the second total loss function reaches the second preset target.
[0078] S34: Stop optimization, and determine multiple second target optimization models based on the multiple second total loss functions obtained by repeating the aforementioned steps S31-S33, where the multiple second target optimization models are selected from the multiple trained recognition models obtained by repeating the aforementioned steps S31-S33; determine the reparameterized recognition model based on the multiple second target optimization models.
[0079] Optionally, step S34 specifically includes, for example, obtaining multiple second evaluation indicators based on the recognition results of multiple second target optimization models. The multiple second evaluation indicators are judged, and the second target optimization model corresponding to the second evaluation indicator with the highest value of the multiple second evaluation indicators is taken as the final model. The final model is reparameterized to reduce the number of parameters, and the three-branch structure of the final model is fused into a single-branch structure to obtain a reparameterized recognition model, specifically, the multiple convolution kernels and BN layers on the multiple branches in the reparameterized unit are fused and equivalently converted into a single convolution kernel on a single branch, thereby greatly reducing the number of parameters, thereby improving the working efficiency of the reparameterized recognition model.
[0080] Specifically, before performing step S31, data enhancement strategies are first applied to the images in the water meter reading recognition area image training set, such as random cropping, random scaling, random brightness and contrast changes, such as small angle rotation, small amplitude translation, etc. The water meter reading recognition area image training set is fed into the pre-training recognition model to obtain recognition results. Secondly, the recognition results are processed based on the loss function Focal-C-CTC to obtain a second total loss function, for example, satisfying the following formula:
[0081]
[0082] Among them, α is used to balance positive and negative samples; γ can make the model pay more attention to difficult samples. λ is used to weight the two loss functions; x i is the high-dimensional feature of the sample; is the center point of each high-dimensional feature, where, for example, α = 0.5, γ = 2, and λ = 1.
[0083] This embodiment uses the loss function Focal-C-CTC to judge and measure the recognition results, which can determine the accuracy of the results of the pre-training recognition model, so as to better measure whether the pre-training recognition model needs to be optimized. For example, the initial pre-training recognition model is recorded as B0, and the water meter reading recognition area recognition image training set is sent to B0 to obtain the initial recognition result, wherein the water meter reading recognition area recognition image training set, for example, contains multiple water meter reading recognition area recognition images whose recognition true frames and recognition true frame coordinates are known; the recognition result, for example, includes the recognition prediction frame and recognition prediction frame coordinates corresponding to each water meter reading recognition area recognition image. The recognition result is processed using the loss function Focal-C-CTC to obtain the initial second total loss function, for example, recorded as loss focal-c-ctc0 , for the initial second total loss function loss focal-c-ctc0 Evaluate and judge whether B0 needs to be optimized. When the result of the judgment is that optimization is needed, optimize B0 to obtain B1. Use B1 as the pre-training recognition model for the next round of training, that is, repeat the previous training steps. Assume that i is the round, that is, i is the round number. When the optimization reaches the i-th round, the post-training recognition model is B i , the trained recognition model obtained in the next round of optimization is B i+1 For example, when the jth round is reached, the trained recognition model obtained in the jth round is B j , the second total loss function loss of the jth round focal-c-ctcj Convergence begins. If the optimization ends at the end of the nth round, the trained recognition model obtained at the nth round is B n , the second total loss function obtained in the nth round is loss focal-c-ctcn , that is, loss focal-c-ctcj-loss focal-c-ctcn The second total loss function between reaches convergence, that is, loss focal-c-ctcj -loss focal-c-ctcn The numerical balance of the second total loss function between is within a certain range and the fluctuation is very small. At this time, it is considered that the second total loss function has reached the second preset target, that is, it is considered that the optimization can be stopped. At this time, B j -B n The trained recognition model between them is used as the second target optimization model, and multiple second target optimization models are processed to obtain multiple second evaluation indicators. The second evaluation indicator is, for example, the converted reading accuracy. The multiple second evaluation indicators are judged, and the second target optimization model corresponding to the second evaluation indicator with the highest value among the multiple second evaluation indicators is taken as the final model. The three-branch structure of the final model is fused into a single-branch structure to obtain the re-parameterized recognition model.
[0084] Optionally, during the model optimization training process, the Adam optimizer can be used for optimization. The parameters can be set as shown in the following table:
[0085]
[0086] This embodiment takes into account that there may be some "intermediate states" of water meter reading recognition area images during the operation of the water meter. For example, when the water meter reading exceeds the previous integer value but has not yet reached the next integer value, the intermediate state is set as a new label. The correspondence between characters and labels in the model is shown in the following table:
[0087]
[0088]
[0089] The way to convert the label into water meter reading characters is as follows:
[0090]
[0091] The reading on the water meter is, for example, a five-digit number, the last character represents the last digit of the five-digit number, and the non-last characters represent the first four digits of the five-digit number. Here, C represents a converted single character; L represents an unconverted single label.
[0092] The formula for converting water meter reading characters into water meter readings is as follows:
[0093]
[0094] Where N represents the converted water meter reading; C i Represents the i-th character from the end.
[0095] The evaluation indicators are AR, LPR, and LCR, and the formula is as follows:
[0096]
[0097]
[0098]
[0099] Among them, n c represents the number of characters predicted correctly; n represents the total number of characters; AR represents the accuracy of a single character; L p Represents the unconverted water meter reading to identify the predicted accurate quantity; L c represents the accurate number of water meter readings identified and predicted after conversion; L represents the total number of water meter readings; LPR represents the accuracy rate of readings before conversion; LCR represents the accuracy rate of readings after conversion, which is the second evaluation indicator.
[0100] Further, if Figure 4 and Figure 5 As shown, the re-parameterized recognition model is, for example, an RC-AT-LSTM model, and the RC-AT-LSTM model includes, for example, a RepVGG-A0 model and an Attention-LSTM model. During the model optimization training process, for example, in the aforementioned steps S31-S33, the RepVGG-A0 model is, for example, a three-branch structure. For example, the RepVGG-A0 model training architecture is, for example, composed of a plurality of three-branch architectures stacked together, and the three-branch architectures are respectively a branch with a convolution kernel size of 3, a branch with a convolution kernel size of 1, and an identity mapping branch. After the training is completed, for example, in step S34, that is, when testing or putting it into use, the model is re-parameterized, for example, through mathematical equivalent transformation, the three-branch structure is merged into a single-branch structure. This mode decouples the architectural consistency of training and testing, and obtains higher model accuracy based on fewer model parameters. This method improves the inference speed while maintaining the accuracy. Among them, as Figure 5 As shown in , A is the model unit in the training phase, and B is the model unit in the inference phase. Figure 6As shown, the Attention-LSTM model is an LSTM model with an added attention mechanism. This setting increases the Attention-LSTM model's focus on key areas of the water meter image, thereby improving the accuracy of the Attention-LSTM model. The Attention-LSTM model uses the LSTM and fully connected layers to obtain a probability matrix, which is then decoded to obtain the water meter reading. Optionally, the aforementioned recognition IR model is obtained, for example, through conversion of the final model. The aforementioned first and second determination steps can be obtained, for example, through training before commissioning or during commissioning, without limitation.
[0101] The embodiment of the present invention detects and identifies water meter images by using a lightweight target detection algorithm model and a re-parameterized recognition model, which can solve the problems of inconsistent frequency of occurrence and different recognition difficulties of different numbers in image samples. It improves the accuracy of water meter reading detection and recognition in complex environments through measures such as data enhancement, and improves the speed of the lightweight target detection algorithm model and the re-parameterized recognition model through model lightweight measures, thereby realizing rapid reasoning of the model in practical applications, further improving the efficiency and accuracy of the water meter reading detection and recognition method, and bringing a better user experience for massive water users.
[0102] [Second embodiment]
[0103] like Figure 7 As shown, an embodiment of the present invention provides a water meter reading detection and identification device 100. Specifically, the water meter reading detection and identification device 100 includes, for example, a memory 110 and a processor 120.
[0104] Specifically, if Figure 7 As shown, the memory 110 is provided with, for example, a water meter reading detection and recognition program 111. The water meter reading detection and recognition program 111 can, for example, call the lightweight target detection algorithm model and the re-parameterized recognition model of the first embodiment. The processor 120 is connected to the memory 110 and is configured to, for example, execute the water meter reading detection and recognition program 111 to execute the water meter reading detection and recognition method of the first embodiment.
[0105] [Third embodiment]
[0106] like Figure 8 and Figure 9 As shown, an embodiment of the present invention provides a water meter reading detection and identification system 10. Specifically, as Figure 8 As shown, in one implementation of this embodiment, the water meter reading detection and identification system 10 includes, for example, a water meter reading detection and identification device 100 , a file server 200 , and a water meter image acquisition and transmission device 300 .
[0107] Specifically, the file server 200 is connected to the water meter image acquisition and transmission device 300 and the water meter reading detection and recognition device 100. The water meter image acquisition and transmission device 300 is used, for example, to capture water meter images and transmit them to the file server 200, while also deploying a water meter reading detection and recognition algorithm. The file server 200 is used, for example, to obtain the water meter images transmitted by the water meter image transmission device and transmit them to the water meter reading detection and recognition device 100, and to receive and store the water meter readings returned by the water meter reading detection and recognition device 100. The water meter reading detection and recognition device 100 is used, for example, to execute the water meter reading detection and recognition method described in the first embodiment and to transmit the water meter readings back to the file server 200.
[0108] Further, if Figure 9 As shown, in another implementation of this embodiment, the water meter reading detection and identification system 10 includes, for example, a water meter reading detection and identification device 100 and a file server 200 .
[0109] Specifically, the water meter reading detection and recognition device 100 is used, for example, to capture a water meter image and execute the water meter reading detection and recognition method of the first embodiment, and to send the water meter reading to the file server 200. The file server 200 is used, for example, to obtain and store the water meter reading transmitted by the water meter reading detection and recognition device 100.
[0110] [Fourth embodiment]
[0111] like Figure 10 As shown, an embodiment of the present invention provides a storage medium 300. Specifically, the storage medium 300 is, for example, a computer-readable storage medium. The storage medium 300 stores a water meter reading detection and identification program 111, which is used to execute the water meter reading detection and identification method of the first embodiment.
[0112] The above description shows and describes the basic principles and main features of the embodiments of the present invention and the advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which shall fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A water meter reading detection and identification method, characterized in that: include: S1: Based on the water meter image and the lightweight target detection algorithm model, the coordinates of the water meter reading frame are obtained; the skeleton network of the lightweight target detection algorithm model is a lightweight model; S2: pre-processing the water meter reading frame according to the coordinates to obtain a water meter reading area image; S3: Obtaining a probability matrix based on the water meter reading area image and the re-parameterized recognition model; S4: Decode the probability matrix to obtain the water meter reading.
2. The water meter reading detection and identification method according to claim 1, characterized in that: The method further includes a first determination step of determining the lightweight target detection algorithm model, wherein the first determination step includes: S11: Send the water meter detection image training set to the pre-training detection model to obtain the detection results; S12: Processing the detection result based on the box regression loss function, the target loss function, and the classification loss function to obtain a first total loss function; S13: Optimizing the pre-training detection model to obtain a post-training detection model; The post-training detection model is used as the pre-training detection model for the next training, and the above steps S11-S13 are repeated until the first total loss function reaches the first preset target. S14: Stop optimization, and determine multiple first target optimization models based on the multiple first total loss functions obtained by repeating the aforementioned steps S11-S13, wherein the multiple first target optimization models are selected from the multiple post-training detection models obtained by repeating the aforementioned steps S11-S13; determine the lightweight target detection algorithm model based on the multiple first target optimization models.
3. The water meter reading detection and identification method according to claim 2, characterized in that: Step S14 specifically includes: obtaining multiple first evaluation indicators based on the detection results of the multiple first target optimization models; judging the multiple first evaluation indicators, and taking the first target optimization model corresponding to the first evaluation indicator with the highest value among the multiple first evaluation indicators as the lightweight target detection algorithm model.
4. The water meter reading detection and identification method according to claim 1, characterized in that: The reparameterized recognition model is a model obtained by training based on the loss function Focal-C-CTC.
5. The water meter reading detection and identification method according to claim 4, characterized in that: The reparameterized recognition model is a model obtained based on the RepVGG-A0 model. The RepVGG-A0 model training architecture is composed of multiple three-branch architectures stacked together, and the three-branch architectures are a branch with a convolution kernel size of 3, a branch with a convolution kernel size of 1, and an identity mapping branch.
6. The water meter reading detection and identification method according to claim 5, characterized in that: The method further includes a second step of determining the re-parameterized recognition model, wherein the second step comprises: S31: sending the water meter reading recognition area image training set to the pre-training recognition model to obtain the recognition result; S32: Processing the recognition result based on the loss function Focal-C-CTC to obtain a second total loss function; S33: Optimizing the pre-training recognition model to obtain a post-training recognition model; The post-training recognition model is used as the pre-training recognition model for the next training, and the above steps S31-S33 are repeated until the second total loss function reaches the second preset target. S34: Stop optimization, and determine multiple second objective optimization models based on the multiple second total loss functions obtained by repeating the aforementioned steps S31-S33, wherein the multiple second objective optimization models are selected from the multiple trained recognition models obtained by repeating the aforementioned steps S31-S33; determine the reparameterized recognition model based on the multiple second objective optimization models.
7. The water meter reading detection and identification method according to claim 6, characterized in that: Step S34 specifically includes: obtaining multiple second evaluation indicators based on the recognition results of the multiple second target optimization models; judging the multiple second evaluation indicators, and taking the second target optimization model corresponding to the second evaluation indicator with the highest value of the multiple second evaluation indicators as the final model; re-parameterizing the final model to reduce the number of parameters, and fusing the three-branch structure of the final model into a single-branch structure to obtain the re-parameterized recognition model.
8. The water meter reading detection and identification method according to claim 1, characterized in that: Step S1 specifically includes: transforming the lightweight target detection algorithm model to obtain a detection IR model; sending the water meter image into the detection IR model to obtain the coordinates of the water meter reading box; step S3 specifically includes: transforming the re-parameterized recognition model to obtain a recognition IR model; sending the water meter reading area image into the recognition IR model, and inferring the water meter reading area image through the recognition IR model to obtain a probability matrix.
9. A water meter reading detection and identification device, characterized in that: include: A memory, provided with a water meter reading detection and identification program; A processor is connected to the memory, and the processor is used to run the water meter reading detection and identification program to execute the water meter reading detection and identification method according to any one of claims 1 to 8.
10. A water meter reading detection and identification system, characterized in that: include: A water meter reading detection and identification device, a file server and a water meter image acquisition and transmission device, wherein the file server is connected to the water meter image acquisition and transmission device and the water meter reading detection and identification device respectively; The water meter image acquisition and transmission device is used to acquire water meter images and send the water meter images to the file server; The file server is used to obtain the water meter image transmitted by the water meter image transmission device and send it to the water meter reading detection and identification device, receive the water meter reading sent back by the water meter reading detection and identification device and store it; the water meter reading detection and identification device is used to execute the water meter reading detection and identification method as described in any one of claims 1 to 8, and send the water meter reading back to the file server.
11. A water meter reading detection and identification system, characterized in that: include: A water meter reading detection and identification device and a file server, wherein the water meter reading detection and identification device is used to collect water meter images and execute the water meter reading detection and identification method as described in any one of claims 1 to 8, and send the water meter reading to the file server; the file server is used to obtain and store the water meter reading transmitted by the water meter reading detection and identification device.
12. A storage medium, characterized in that: A water meter reading detection and identification program is stored, and the water meter reading detection and identification program is used to execute the water meter reading detection and identification method according to any one of claims 1 to 8.