CN-116485926-B - Water meter water mist image generation method
Abstract
The invention discloses a method for generating a water mist image of a water meter, which comprises an image generation stage of an countermeasure network, specifically a water mist image generator and a discriminator trained by using a countermeasure idea, a image generation stage of comparison learning constraint, specifically a query encoder and a key encoder which are designed to encode image blocks from the water mist image of the water meter and a clean water meter image respectively to obtain feature vectors corresponding to each image block, wherein the feature vectors obtained by the image blocks at the same position in the two images are regarded as positive sample pairs, the feature vectors obtained by the image blocks at different positions in the two images are pressed into a negative sample queue, all negative sample feature vectors in the negative sample queue are regarded as negative sample pairs, one positive sample is respectively lost with all the negative sample pairs to calculate infoNCE, infoNCE loss of all the positive samples is obtained, and the water mist image generator is reversely updated to obtain the final water mist image generator. The invention effectively reduces training parameters and improves training efficiency.
Inventors
- GAO XUE
- Liang Zhengcong
Assignees
- 华南理工大学
Dates
- Publication Date
- 20260512
- Application Date
- 20230328
Claims (8)
- 1. A method for generating a water mist image of a water meter, comprising: the image generation stage of the countermeasure network comprises the following steps: inputting the clean water meter image into a water mist image generator, and outputting the water mist image of the water meter; Inputting the water meter water mist image into a discriminator, outputting a characteristic diagram, calculating the loss with a true label to generate countermeasures loss, and reversely updating a water mist image generator; Inputting the clean water meter image and the water meter mist image into a discriminator, respectively calculating losses with the true tag and the false tag, generating countermeasures, and reversely updating the discriminator; the image generation stage of contrast learning constraint comprises the following steps: Designing a query encoder and a key encoder, which are used for encoding image blocks from a water mist image of the water meter and a clean water meter image respectively to obtain a feature vector corresponding to each image block; the feature vector obtained by the image block at the same position in the two images is regarded as a positive sample pair; pressing feature vectors obtained by image blocks at different positions in two images into a negative sample queue, and regarding all negative sample feature vectors in the negative sample queue as negative sample pairs; Calculating infoNCE losses of one positive sample and all negative samples respectively to obtain infoNCE losses of all positive samples, and reversely updating the water mist image generator to obtain a final water mist image generator; repeating the phase of generating images by comparing and learning constraints by utilizing the output of a plurality of intermediate layers of the query encoder and the key encoder, calculating to obtain the integral infoNCE loss, and integrating and reversely updating the water mist image generator; The query encoder and the key encoder output a plurality of intermediate layers, randomly select a plurality of neurons at the same position as intermediate sample characteristics, repeat the phase of generating images by comparing learning constraints, calculate a plurality of infoNCE losses, integrate and reversely update the water mist image generator, and specifically comprise the following steps: Taking neurons of corresponding image blocks in the intermediate layer output feature graphs of the query encoder and the key encoder as sample features, inputting the sample features into corresponding MLP layers for calculation to respectively obtain feature vectors; Selecting the outputs of a plurality of intermediate layers, selecting neurons at the same position, repeating the phase of generating an image by comparing learning constraints, and finally calculating the loss of the whole infoNCE; every middle layer is selected, a new negative sample queue is required to be set, and the sample characteristics of the middle layer and all corresponding negative sample characteristics are dynamically updated.
- 2. The method of claim 1, wherein the body structure of the mist image generator is a resNet network.
- 3. The method according to claim 1, wherein the discriminator is embodied as patchGAN.
- 4. A method according to any one of claims 1-3, wherein the query encoder is a cropped water mist image generator and an MLP layer, sharing parameters with the water mist image generator.
- 5. A method according to any one of claims 1-3, wherein the key encoder is a query encoder searching for a vector similar to the query feature vector from the encoded key feature vectors, and the network structure of the key encoder is the same as that of the query encoder, but the key encoder does not share parameters with the query encoder, and the method adopts a momentum update mode.
- 6. The method of claim 1, wherein the negative sample update procedure is as follows: The negative sample queue stores the negative sample feature vector calculated each time, and takes all the sample features as the negative samples for the training; the size of the negative sample queue is 65536, if the negative sample queue is not full at the moment, the sample feature vector obtained by the current training calculation is pressed in continuously; If the negative sample queue is full, the oldest set of sample features at the head of the queue is pressed to the dequeue according to the first-in first-out characteristics of the queue, and the latest obtained sample features are pressed to the queue.
- 7. The method of claim 1, wherein four intermediate layers are selected to assist in network learning.
- 8. The method of claim 4, wherein the cropping the water mist image generator is specifically a cropping of a portion of the convolutional layer and the active layer of the water mist image generator.
Description
Water meter water mist image generation method Technical Field The invention relates to the field of image processing, in particular to a method for generating a water mist image of a water meter. Background Along with the advancement of smart cities, remote meter reading systems and technologies are receiving more and more attention. On the one hand, the remote meter reading system can greatly reduce the investment of manpower and material resources of an energy operation unit and a management department in the collection of different types of energy data such as water, electricity, gas, heat and the like, and simultaneously promote the effective utilization of the data in the follow-up large data intelligent analysis and data mining. The intelligent camera meter obtains meter reading images by using an image acquisition terminal (such as a smart phone, acquisition hardware equipment and the like), and automatically identifies by using a high-performance identification model, thereby being a novel remote meter reading mode. The intelligent shooting meter has the characteristics of (1) low cost, (2) immediate assembly without disassembly of the existing meter and pipeline, (3) good expandability, convenience in accessing meters of different types and specifications, objective and accurate acquired image data, and the like. Has wide application prospect. The current intelligent camera shooting table can obtain higher recognition accuracy by adopting a high-performance recognition method and model, such as an artificial intelligent algorithm. However, the water meter has specificity, and the water meter itself is more likely to be polluted by water mist, and at present, certain errors can occur in the identification of the water meter by computer vision. In order to solve the problem, the most common method is to remove the water mist in the water meter image to clean the water meter image, and then send the water meter image into a subsequent detection and identification system for detection and identification. However, in practical application, the number of data in the data set for training the water mist removing network of the water meter is very small, so that the network cannot be trained very effectively, and the trained network cannot remove the water mist of the water meter effectively, so that an expansion method of the water mist data set of the water meter or a method for enhancing the training data of the network is needed to solve the current data set problem. Disclosure of Invention In order to overcome the defects and shortcomings of the prior art, the invention aims to provide a method for generating a water mist image of a water meter. The invention combines the countermeasure idea and the contrast learning idea, improves the model performance by utilizing the idea of the momentum encoder, ensures the capability of the model for generating the water mist image of the water meter, greatly reduces the training parameters of the model and shortens the training time of the model. Meanwhile, the method can play a role in data expansion or data enhancement for training of the water mist removing network of the water meter, and the effectiveness and reliability of training of the water mist removing network are improved. The aim of the invention is achieved by the following technical scheme: A method for generating a water mist image of a water meter, comprising: the image generation stage of the countermeasure network comprises the following steps: inputting the clean water meter image into a water mist image generator, and outputting the water mist image of the water meter; Inputting the water meter water mist image into a discriminator, outputting a characteristic diagram, calculating the loss with a true label to generate countermeasures loss, and reversely updating a water mist image generator; Inputting the clean water meter image and the water meter mist image into a discriminator, respectively calculating losses with the true tag and the false tag, generating countermeasures, and reversely updating the discriminator; the image generation stage of contrast learning constraint comprises the following steps: Designing a query encoder and a key encoder, which are used for encoding image blocks from a water mist image of the water meter and a clean water meter image respectively to obtain a feature vector corresponding to each image block; the feature vector obtained by the image block at the same position in the two images is regarded as a positive sample pair; pressing feature vectors obtained by image blocks at different positions in two images into a negative sample queue, and regarding all negative sample feature vectors in the negative sample queue as negative sample pairs; And calculating infoNCE losses of one positive sample and all negative samples respectively to obtain infoNCE losses of all positive samples, and updating the water mist image generator reversely to obtain a final wate