Alcohometer intelligent reading method and device, medium and electronic equipment
Through the improved YOLOV5 model and CA attention mechanism, combined with GhostNet to replace the backbone network, the problems of low reading efficiency and poor accuracy of alcohol meters are solved, and the efficient, accurate and automated reading of alcohol meters is achieved, which is suitable for continuous industrial scenarios. Chemical production.
Patent Information
- Application Number
- CN202411448410.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-11
AI Technical Summary
In the prior art, alcohol meters have low reading efficiency, poor accuracy and low automation, making it difficult to achieve timely and effective acquisition in situations where close monitoring of alcohol concentration is required.
The improved YOLOV5 model is adopted to take real-time images of the alcohol meter through the camera, preprocess and label, train the optimized YOLOV5 model, use CA attention mechanism and GhostNet to replace the backbone network, design the loss function to reduce the object detection error, and realize the Alcoholmeter real-time image recognition and alcohol content calculation.
It realizes efficient, accurate and automated reading of alcohol meters, and can achieve continuous production of automatic alcohol acquisition in industrial scenarios, reducing equipment complexity and cost, and is suitable for different types of alcohol meters.
Smart Images

Figure CN119418026A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of automated testing and measurement, and in particular relates to an alcohol meter intelligent reading method, device, medium and electronic equipment. Background Art
[0002] The alcohol meter is used to measure the alcohol content in liquor or alcohol solution. The traditional manual reading requires the alcohol meter to be placed vertically in the liquor. After it stabilizes, the reading on the top that is flush with the liquid surface is the alcohol content. However, on the one hand, this method may be affected by subjective factors, resulting in large reading errors and low efficiency; on the other hand, in today's occasions where alcohol concentration needs to be closely monitored, such as traffic safety checkpoints and industrial production, it cannot be obtained in a timely and effective manner, which leads to problems.
[0003] Although existing image processing technology and algorithms can be applied to real-time reading of instrument scales to help improve efficiency, since the alcohol meter is suspended in the liquid and the float moves up and down as the specific gravity of the liquid changes, the liquid easily adheres to the surface of the scale near the liquid surface, making it difficult to read the precise scale using existing intelligent reading methods. Depending on the state of liquid adhesion, the measurement accuracy may also be reduced. Alternatively, the equipment required for the intelligent reading solution is relatively complex and costly. Alternatively, the intelligent reading solution has strong limitations in applicability and can only be used for readings in specific fields and specific testing instruments. Summary of the invention
[0004] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present invention provides an intelligent reading method, device and medium for an alcohol meter to solve the technical problems of low reading efficiency, poor accuracy and low automation of alcohol meters in the prior art.
[0005] In order to achieve the above object, the main technical solutions adopted by the present invention include:
[0006] In a first aspect, an embodiment of the present invention provides an alcohol meter intelligent reading method, which is applied to an alcohol meter to detect the alcohol content of a solution, and includes:
[0007] S1, using a camera to obtain a real-time image of the alcohol meter and pre-processing it;
[0008] S2. Annotate the image, including target category and bounding box information, and establish a target detection dataset including the image and the label;
[0009] S3. Train YOLO using the target detection dataset V 5 model, and gradually adjust the weights through loss function back propagation and optimization algorithm to reduce the target detection error; the optimized YOLO V 5. The model outputs the detected target object category and the alcohol meter reading;
[0010] S4. Using the optimized YOLO V 5 The model performs real-time image recognition on the alcohol meter and calculates the alcohol content of the tested liquid.
[0011] Furthermore, the preprocessing in step S1 includes:
[0012] S11, performing scale normalization on the acquired image, scaling the input image or feature map to a uniform scale or range;
[0013] S12. Collect data from the alcohol meter and calibrate the readings of the alcohol meter.
[0014] Furthermore, the bounding box information in step S2 includes the center coordinates, width, height and alcohol meter reading; the label file adopts YOLO V 5 Format.
[0015] Furthermore, the loss function in step S3 is:
[0016] Loss = L loc +(QQ t ) 2
[0017] The iteration of the loss function is achieved through deep learning, where Q is the calibration target beyond the water surface; Q t is the model prediction result; L loc Border loss.
[0018] Furthermore, in step S3, the original YOLO V 5 The optimization of the model includes: adding GhostNet, replacing the backbone network or specific layers of the original YOLOv5 model according to the structure of GhostNet; according to the expected input size of GhostNet and the output requirements of YOLOv5, adjusting the input and output layers of the model to ensure that they match the structure of GhostNet.
[0019] Furthermore, in step S3, the original YOLO V 5 The optimization of the model includes: adding the CA attention mechanism, which can adjust the weights of the channels of the input feature map through learning.
[0020] Furthermore, in step S3, YOLO is trained V 5 model, specify the parameters required for training, including image size, batch size, number of training rounds, dataset configuration file path, and model configuration file path.
[0021] In a second aspect, an embodiment of the present invention further provides an alcohol meter intelligent reading device, comprising:
[0022] an alcohol meter, which is placed in the container and is used to detect the alcohol concentration of the solution;
[0023] A camera for capturing a real-time image of the alcohol meter;
[0024] The calculation module is connected to the camera for transmission, and is used to execute any of the above-mentioned alcohol meter intelligent reading methods and output the calculation results to the display module.
[0025] In a third aspect, an embodiment of the present invention further provides a computer-readable medium having computer-executable instructions stored thereon, wherein the executable instructions, when executed by a processor, implement any of the aforementioned alcohol meter intelligent reading methods.
[0026] In a fourth aspect, an embodiment of the present invention further provides an electronic device, characterized in that it includes a processor and a memory, wherein the memory stores computer media, and when the computer media is executed by the processor, it runs any of the aforementioned alcohol meter intelligent reading methods.
[0027] The technical solution of the present invention uses the improved YOLO V The 5 model outputs the alcohol meter reading in real time and can calculate the alcohol content synchronously. It is also applicable to alcohol meters with uneven scales, meeting the current industrial scenarios that require automatic acquisition of alcohol content for continuous production, and the supporting equipment only requires a camera, which is relatively simple overall. Among them, the design of the loss function is more in line with actual needs, and the accuracy of the alcohol meter reading is guaranteed through deep learning combined with the CA attention mechanism in iteration. In addition, by adding GhostNet to replace the backbone network or specific layers of the original YOLOv5 model, the model is also lightweight and can respond quickly to needs. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 The present invention is a flow chart of an alcohol meter intelligent reading method.
[0029] Figure 2 Flowchart of constructing the optimized YOLOV5 model for the present invention.
[0030] Figure 3 It is a structural diagram of the GhostNet model of the present invention.
[0031] Figure 4 This is a structural diagram of the CA attention mechanism model of the present invention.
[0032] Figure 5 The improved YOLO of the present invention V 5. Structural diagram of the model. DETAILED DESCRIPTION
[0033] 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 in conjunction with the accompanying drawings. Although certain embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be interpreted as being limited to the embodiments described herein. On the contrary, these embodiments are provided to provide a more thorough and complete understanding of the present invention. It should be understood that the drawings and embodiments of the present invention are only for exemplary purposes and are not intended to limit the scope of protection of the present invention.
[0034] The alcohol meter intelligent reading method in this embodiment includes the following steps:
[0035] Use the camera to obtain the real-time image of the alcohol meter and pre-process it;
[0036] The preprocessed alcohol meter image is input into the constructed optimized YOLOV5 model, and the target object category and alcohol meter reading are output;
[0037] The real-time alcohol content of the tested liquid is calculated by obtaining the alcohol meter reading.
[0038] Specifically, the step of "obtaining a real-time image of the alcohol meter using a camera and preprocessing" includes: using a camera to shoot, obtaining an image of the alcohol meter, and scale-normalizing the image. The main purpose of scale normalization in deep learning image recognition is to improve the robustness and generalization ability of the model and ensure that the model has a certain invariance to the target in the input image. The scale normalization operation in this embodiment includes scaling the input image or feature map to a uniform scale or range to facilitate data collection of the alcohol meter and calibrate the alcohol meter reading.
[0039] Specifically, refer to the attached Figure 2 In the step “inputting the preprocessed alcohol meter image into the constructed optimized YOLOV5 model and outputting the target object category and alcohol meter reading”, the steps of constructing the optimized YOLOV5 model include:
[0040] 1. Data preparation: collect image data containing the target object.
[0041] 2. Image annotation: annotate the image, including target category and bounding box information.
[0042] Prepare a target detection dataset containing images and labels. The annotation information of the image data is saved in the label file so that YOLOv5 can read it. The category, center coordinates, width and height information of each target and the alcohol meter reading are included as labels. In this technical solution, the annotation of the alcohol meter reading includes the alcohol meter scale reading Q0 corresponding to the current liquid level.
[0043] 3. Training images, gradually adjusting weights through custom loss function back propagation and optimization algorithms to reduce target detection errors. Specifically include:
[0044] The dataset is divided into training set, validation set and test set to carry out relevant training later.
[0045] Perform training and specify the parameters required for training, such as image size, batch size, number of training rounds, dataset configuration file path, model configuration file path, etc. The model adjusts the weights through backpropagation and optimization algorithms (usually SGD or Adam) to minimize the loss between the predicted box and the actual target.
[0046] Use the YOLOv5 model to identify the image and change the original loss function. If the alcohol meter reading in the image is Q0, the original loss function is:
[0047] Loss = λ1L cls +λ2L obj +λ3L loc
[0048] Among them, Lclc is the classification loss, Lobj is the confidence loss, and Lloc is the border loss
[0049] Since there is no classification problem, the confidence loss and classification loss are cancelled in this technical solution, and the loss and error of calibration Q are added on the original basis, so that the new loss function in this solution is obtained as follows:
[0050] Loss = L loc +(QQ t ) 2
[0051] Q means that when calibrating the data, the part beyond the water surface is used as the calibration target, and the part outside the water surface is added to the loss function. Qt is the model prediction result. The part beyond the liquid surface refers to the height beyond the liquid surface, which is greater than zero but less than or equal to the height from the maximum scale line of the alcohol meter to the liquid surface. The calibrated Q value is compared with the value obtained by the Qt model, and the loss function is added through iteration to obtain the appropriate prediction result.
[0052] During the training process, by adjusting the design of the loss function, the convergence speed of the model can be improved, allowing it to learn task-specific features and patterns more quickly; and by transforming the loss function, deep learning methods can be used in the iteration of the loss function to make the obtained Q value meet the accuracy requirements. The Q value is the reading we need. This method is efficient and convenient.
[0053] In addition, since online alcohol meter measurements require fast response, lightweight models can improve real-time performance and ensure timely and accurate results. In the application of online measurement of alcohol meters, lightweight models can reduce power consumption, extend device battery life, and adapt to low-power devices such as wireless sensors. In this technical solution, GhostNet is added to replace the backbone network or specific layers of YOLOv5 according to the structure of GhostNet. Adjust the input and output layers of the model according to the expected input size of GhostNet and the output requirements of YOLOv5. Make sure they match the structure of GhostNet. Among them, the Ghost module generates more feature maps by decomposing the standard convolution into a set of smaller basic convolutions and a set of cheap linear transformations, thereby reducing computational costs and the amount of parameters. GhostNet first generates a small number of basic feature maps through standard convolutions, and then uses a set of cheap linear operations) to generate more feature maps. The specific structure is shown in the attached figure. Figure 3 shown.
[0054] Specifically, the improved YOLOv5 model structure is as shown in the attached Figure 5 As shown:
[0055] The model architecture of YOLOv5 mainly consists of three parts: Backbone, Neck and Head. Backbone is responsible for feature extraction, usually using CSPDarknet as the backbone network, extracting multi-scale features through convolution and residual structures; Neck further fuses features of different scales through FPN and PAN structures to enhance the model's detection ability for small targets; Head is used to output the final detection results, including the bounding box and category of the target. The entire architecture is lightweight, efficient and real-time, and suitable for deployment on various hardware platforms. The main advantage of introducing the Ghost module in YOLOv5 is that it reduces the computational complexity and the number of model parameters, thereby improving the inference speed and efficiency of the model. The Ghost module generates fewer convolutional feature maps and generates "ghost" features using simple linear transformations, which can reduce redundant calculations while maintaining model accuracy. This lightweight design is very suitable for resource-constrained devices, such as mobile terminals or embedded systems, and can achieve faster inference speed and lower power consumption while still maintaining high detection performance.
[0056] While ensuring accuracy, the CA attention mechanism is also added in this embodiment. The CA attention mechanism can enhance the focus on important features by learning to adjust the weights of the channels of the input feature map. In the target detection task, this can help the model focus more on target-related features. Specifically, the specific structure of the CA attention mechanism is shown in the attached figure. Figure 4 As shown in the figure, the accuracy of the model is improved through the structure. The traditional channel attention mechanism only considers global information and ignores the spatial position information, which may lead to inconsistent responses to features at different positions. More detailed position information is captured by separating the spatial coordinate information channels (height and width), and then weighted processing is performed based on the channel information. This method enables the model to not only pay attention to important channel features, but also accurately locate the distribution of features in space, thereby improving the accuracy of feature expression and thus improving the overall accuracy of the model.
[0057] The feature expression ability of the model is improved by capturing the interactive information between channels and spatial positions. Unlike the traditional attention mechanism, the CA attention mechanism encodes global information into coordinate information in two directions (horizontal and vertical), so that the location information of the target can be captured more finely. The main advantage of introducing the CA attention mechanism is that it can more effectively improve the model's perception of the target without significantly increasing the computational complexity, especially in complex scenes or small target detection. By introducing the CA attention mechanism, the model can pay more attention to key areas and improve the accuracy and robustness of detection.
[0058] 4. Inference processing: the model output includes the detected target object category and the alcohol meter reading.
[0059] 5. Application: Test the optimized YOLOV5 model method on working conditions.
[0060] In summary, this technical solution improves and iterates the loss function of the original YOLOv5 model to specifically improve the accuracy of the alcohol meter readings; by replacing and adding GhostNet, the model is lightweight and the response speed of real-time monitoring is improved; and the CA attention mechanism is added to enhance the processing of target-related features. The optimized YOLOv5 model can effectively solve the problems of inaccurate alcohol meter readings, inability to respond in real time, and difficulty in industrial application in the prior art. Compared with other technologies in the field of obtaining instrument readings through image processing, this technical solution further specifically solves the technical problems of uneven scales of some alcohol meters that are difficult to read, or complex devices that need to be configured synchronously.
[0061] Yet another embodiment of the present invention provides an alcohol meter intelligent reading device, comprising: an alcohol meter, disposed in a container and used to detect the alcohol concentration of a solution;
[0062] A camera for capturing a real-time image of the alcohol meter;
[0063] The calculation module is connected to the camera for transmission, and is used to execute any of the above-mentioned alcohol meter intelligent reading methods and output the calculation results to the display module.
[0064] Another embodiment of the present invention provides a computer-readable storage medium, including a computer-readable storage medium storing a computer program and a processor. When the computer program is read and executed by the processor, the above-mentioned alcohol meter intelligent reading method is implemented.
[0065] The technical effect that can be achieved by this embodiment is basically the same as the technical effect that can be achieved by the aforementioned alcohol meter intelligent reading method, and will not be repeated here.
[0066] Yet another embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores a computer medium, and when the computer medium is executed by the processor, the intelligent reading method of an alcohol meter as described in any one of the above items is executed.
[0067] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.
[0068] Although the present invention is disclosed as above, the protection scope of the present invention is not limited thereto. Those skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention, and these changes and modifications will fall within the protection scope of the present invention.
[0069] Since the system / device described in the above embodiments of the present invention is a system / device used to implement the method of the above embodiments of the present invention, a person skilled in the art can understand the specific structure and deformation of the system / device based on the method described in the above embodiments of the present invention, and thus will not be described in detail here. All systems / devices used in the method of the above embodiments of the present invention belong to the scope of protection of the present invention.
[0070] Although the present invention is disclosed as above, the protection scope of the present invention is not limited thereto. Those skilled in the art may make various changes and modifications without departing from the spirit and scope of the present invention, and these changes and modifications will fall within the protection scope of the present invention.
Claims
1. An intelligent reading method for an alcohol meter, characterized in that: The method is applied to an alcohol meter to detect the alcohol content of a solution, and comprises: S1, using a camera to obtain a real-time image of the alcohol meter and pre-processing it; S2. Annotate the image, including target category and bounding box information, and establish a target detection dataset including the image and the label; S3. Train YOLO using the target detection dataset V 5 model, and gradually adjust the weights through loss function back propagation and optimization algorithm to reduce the target detection error; the optimized YOLO V 5. The model outputs the detected target object category and the alcohol meter reading; S4. Using the optimized YOLO V 5 The model performs real-time image recognition on the alcohol meter and calculates the alcohol content of the tested liquid.
2. An alcohol meter intelligent reading method as claimed in claim 1, characterized in that The preprocessing in step S1 includes: S11, performing scale normalization on the acquired image, scaling the input image or feature map to a uniform scale or range; S12. Collect data from the alcohol meter and calibrate the readings of the alcohol meter.
3. An intelligent reading method for an alcohol meter as claimed in claim 1, characterized in that The bounding box information in step S2 includes the center coordinates, width, height and alcohol meter reading; the label file uses YOLO V 5 Format.
4. An alcohol meter intelligent reading method as claimed in claim 1, characterized in that The loss function in step S3 is: The=L loc +(QQ t ) 2 The iteration of the loss function is achieved through deep learning, where Q is the calibration target beyond the water surface; Q t is the model prediction result; L loc Border loss.
5. An intelligent reading method for an alcohol meter as claimed in claim 1, characterized in that In step S3, the original YOLO V 5 The optimization of the model includes: adding GhostNet, replacing the backbone network or specific layers of the original YOLOv5 model according to the structure of GhostNet; according to the expected input size of GhostNet and the output requirements of YOLOv5, adjusting the input and output layers of the model to ensure that they match the structure of GhostNet.
6. An intelligent reading method for an alcohol meter as claimed in claim 4 or 5, characterized in that In step S3, the original YOLO V 5 The optimization of the model includes: adding the CA attention mechanism, which can adjust the weights of the channels of the input feature map through learning.
7. An alcohol meter intelligent reading method as claimed in claim 1, characterized in that In step S3, YOLO is trained V 5 model, specify the parameters required for training, including image size, batch size, number of training rounds, dataset configuration file path, and model configuration file path.
8. An intelligent reading device for an alcohol meter, characterized in that include: an alcohol meter, which is placed in the container and is used to detect the alcohol concentration of the solution; A camera for capturing a real-time image of the alcohol meter; The calculation module is connected to the camera for transmission, and is used to execute the alcohol meter intelligent reading method as described in any one of claims 1 to 7, and output the calculation result to the display module.
9. A computer-readable medium having computer-executable instructions stored thereon, characterized in that: When the executable instructions are executed by the processor, an intelligent reading method for an alcohol meter as described in any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that The invention comprises a processor and a memory, wherein the memory stores a computer medium, and when the computer medium is executed by the processor, the intelligent reading method of the alcohol meter as claimed in any one of claims 1 to 7 is executed.