Battery detection method, system and device and storage medium
By improving the YOLOv8 network to build a battery detection model, the battery quantity and model are automatically identified, which solves the problems of inaccuracy and inefficiency of traditional counting methods, and achieves accurate counting and efficient production of battery packaging boxes.
Patent Information
- Application Number
- CN202410635071.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-22
- Publication Date
- 2024-09-03
AI Technical Summary
The traditional counting method of battery packaging boxes relies on weight measurement. There are size and weight differences that lead to inaccurate counting. It also requires manual operation, which is inefficient and prone to human error.
The improved YOLOv8 network is used to build a battery detection model. By preprocessing and training battery packaging images, a final detection model is generated, which automatically identifies the battery quantity and model and reduces manual intervention.
It achieves accurate detection of battery quantity, reduces errors caused by differences in process purity, improves production line efficiency, and reduces human resource requirements.
Smart Images

Figure CN118587478A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of battery detection, and in particular to a battery detection method, system, device and storage medium. Background Art
[0002] After the production of batteries is completed, they need to be counted before packaging. In the current battery box counting process, the traditional weighing method is mainly relied on to determine the number of batteries in the box. However, this method has some defects and shortcomings. The traditional counting method is limited by the process because it relies on the measurement of battery weight. Batteries may have slight size and weight differences during the manufacturing process, resulting in inaccurate counting results. Moreover, due to the involvement of manual operations in the packaging process, there may be human errors and errors in the counting process. In addition, the traditional counting method requires each package box to be placed on a weighing device for weighing, which requires additional time and human resources, resulting in low packaging efficiency. Summary of the invention
[0003] In view of this, an object of the present invention is to overcome the deficiencies in the prior art and to provide a battery detection method, system, device and storage medium.
[0004] The present invention provides the following technical solutions:
[0005] In a first aspect, the present application provides a battery detection method, comprising:
[0006] Obtaining battery packaging pictures, and preprocessing the battery packaging pictures to obtain a battery picture training set;
[0007] Building a battery detection model based on an improved YOLOv8 network, and training the battery detection model using the battery image training set to obtain a final detection model;
[0008] Acquire a battery picture to be tested based on the battery picture training set;
[0009] Preprocessing the image of the battery to be tested to obtain a preprocessed image;
[0010] The preprocessed image is input into the final detection model to obtain a detection result; the detection result includes the battery model and battery quantity corresponding to the battery image to be tested.
[0011] In one implementation, the battery detection model is constructed based on the improved YOLOv8 network, including:
[0012] Using the YOLOv8 network as a baseline network, and using the SPD network to replace the stride convolution and pooling layers of the YOLOv8 network, to obtain the improved YOLOv8 network;
[0013] The large target output layer of the improved YOLOv8 network is replaced with multiple medium target output layers to obtain the battery detection model.
[0014] In one implementation, the battery detection model is trained using the battery image training set to obtain a final detection model, including:
[0015] Step 1: input the battery image training set into the battery detection model to train the battery detection model;
[0016] Step 2: Obtain the output of the battery detection model, and determine whether the output of the battery detection model is a preset output;
[0017] Step 3: If the output of the battery detection model is not the preset output, adjust the parameters of the battery detection model to obtain an adjusted model, and replace the adjusted model with the battery detection model;
[0018] Repeat step 1, step 2 and step 3 until the output of the battery detection model is the preset output, and then use the battery detection model with the preset output as the final detection model.
[0019] In one implementation, the step of obtaining the image of the battery to be tested based on the battery image training set includes:
[0020] Obtaining the target angle and target brightness when shooting the battery image training set, and adjusting the shooting angle of the camera to the target angle;
[0021] Acquire a current environment picture in real time at the target angle through the camera, and determine the current environment brightness according to the current environment picture;
[0022] The fill light brightness of the external light source is determined according to the current ambient brightness and the target brightness, the current ambient brightness is adjusted to the target brightness by the external light source, and the camera is controlled to obtain the image of the battery to be tested at the target angle and the target brightness.
[0023] In one implementation, the preprocessing of the image of the battery to be tested to obtain the preprocessed image includes:
[0024] Using a sliding window cropping algorithm, cropping each of the battery images to be tested into initial images of the same size;
[0025] After filtering each of the initial images, image enhancement is performed to obtain an intermediate image;
[0026] Each of the intermediate images is adjusted to the same size and the same angle to obtain the pre-processed image.
[0027] In one implementation, the step of inputting the preprocessed image into the final detection model to obtain a detection result includes:
[0028] Using the target detection algorithm of the final detection model to process each of the battery images to be tested, to obtain the total number of batteries corresponding to each of the battery images to be tested;
[0029] Using the feature extraction layer of the final detection model, feature extraction is performed on each of the battery images to obtain feature information of each of the battery images to be tested;
[0030] Performing forward propagation processing on the feature information corresponding to each of the battery images to be tested, to obtain a battery model prediction result for each of the battery images to be tested;
[0031] Normalizing each battery model prediction result to obtain a probability distribution of the battery model of each battery image to be tested;
[0032] The number of batteries corresponding to each battery model in each battery picture to be tested is calculated according to the total number of batteries in each battery picture to be tested and the probability distribution.
[0033] In one embodiment, the target detection algorithm of the final detection model is used to process each of the images of the batteries to be tested to obtain the total number of batteries corresponding to each of the images of the batteries to be tested, including:
[0034] Generate a candidate frame for each of the battery images to be tested, and classify each of the candidate frames using a target detection algorithm to obtain a classification result; the classification result includes the position of the battery in each of the candidate frames;
[0035] The overlapping candidate boxes in the classification results are removed by using a non-maximum suppression algorithm, the remaining classification results are used as final results, and the total number of batteries is obtained according to the final results.
[0036] In a second aspect, the present application provides a battery detection system, comprising:
[0037] A preprocessing module, used to obtain battery packaging pictures, preprocess the battery packaging pictures, and obtain a battery picture training set;
[0038] A training module, used for building a battery detection model based on an improved YOLOv8 network, and training the battery detection model using the battery image training set to obtain a final detection model;
[0039] An acquisition module is used to acquire a picture of a battery to be tested, and preprocess the picture of the battery to be tested to obtain a preprocessed picture;
[0040] The detection module is used to input the pre-processed image into the final detection model to obtain a detection result; the detection result includes the battery model and battery quantity corresponding to the battery image to be tested.
[0041] In a third aspect, the present application provides an electronic device, comprising a memory and at least one processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the battery detection method as described in the first aspect.
[0042] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed, the battery detection method as described in the first aspect is implemented.
[0043] The embodiments of the present invention have the following beneficial effects:
[0044] The battery detection method provided by the present invention can identify the number of batteries through a battery detection model, thereby realizing accurate detection and counting of batteries and reducing errors caused by process purity differences. Moreover, after automatically acquiring images of batteries to be tested, the number of batteries can be obtained through the battery detection model, thereby improving the efficiency of the production line and reducing the demand for human resources.
[0045] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0047] Figure 1 A schematic diagram of a battery detection method flow chart is shown;
[0048] Figure 2 A schematic diagram of the battery detection model training method flow is shown;
[0049] Figure 3 A schematic diagram of a method for obtaining a picture of a battery to be tested is shown;
[0050] Figure 4 A schematic diagram of a method for obtaining the number of batteries is shown;
[0051] Figure 5 A schematic diagram of the framework structure of a battery detection system is shown.
[0052] Description of main component symbols:
[0053] 500, battery detection system; 501, preprocessing module; 502, training module; 503, acquisition module; 504, detection module. DETAILED DESCRIPTION
[0054] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0055] The terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of the template are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0057] Example 1
[0058] See also Figure 1 , Figure 1 A schematic flow chart of a battery detection method provided in this embodiment, which can be applied to various battery production and packaging scenarios to improve the accuracy and efficiency of battery quantity detection, includes:
[0059] S101. Obtain battery packaging pictures, and preprocess the battery packaging pictures to obtain a battery picture training set.
[0060] Specifically, the battery pictures can be historical pictures taken when the batteries were packaged. The unclear or incomplete pictures in the historical pictures are removed, and the remaining pictures are annotated and labeled. The annotation information includes the battery model and battery quantity contained in each picture to obtain a battery picture training set. Since the number of batteries is usually identified after being placed in the packaging box, the battery packaging picture can be obtained when the batteries have been placed in the packaging box for packaging but the packaging box has not been sealed. At this time, the number of batteries is easier to identify because they are placed in a more regular pattern. Users can also choose the appropriate time to obtain battery pictures according to the actual production scenario.
[0061] If the battery image to be tested is tested together with the battery packaging box when testing the battery quantity and model, then the battery image training set must also include the image data of the battery packaging box, preferably the packaging images on the same production line, to ensure the consistency of the training set and the image to be tested, and reduce the error during training.
[0062] S102, building a battery detection model based on an improved YOLOv8 network, and training the battery detection model using the battery image training set to obtain a final detection model.
[0063] Specifically, the YOLOv8 network is selected as the baseline network, and referring to the idea of SPD, the shallow feature map (low resolution but weak semantic information) and the deep feature map (high resolution but rich semantic information) are aggregated, that is, the strided convolution and pooling layers of the YOLOv8 network are replaced by the SPD network to obtain an improved YOLOv8 network, so as to enhance the expression ability of the model's multi-scale features and increase the model's small target detection ability.
[0064] Then, the large target output layer of the improved YOLOv8 network is replaced with multiple medium target output layers, and the number of medium target outputs in the model is increased to adapt to the characteristics of large number, dense and medium targets of detection targets. Finally, the hyperparameters of the model, such as learning rate, batch size, network structure and number of layers, are set to optimize the performance and generalization ability of the model, and the battery detection model is obtained.
[0065] See also Figure 2 , step S102 includes:
[0066] S1021, step 1, inputting the battery image training set into the battery detection model to train the battery detection model.
[0067] Specifically, after the detection model is constructed, the model needs to be trained so that it has the function of battery detection. First, a single battery image in the battery image training set is input into the battery detection model.
[0068] S1022, step 2, obtaining the output of the battery detection model, and determining whether the output of the battery detection model is a preset output.
[0069] Specifically, after a single battery image is input into the battery detection model, the battery detection model will output a corresponding detection result, and the preset output of the model is the number and model of batteries contained in the battery image. Usually, the first output result is different from the preset output, so subsequent processing is required.
[0070] S1023, step three, if the output of the battery detection model is not the preset output, adjusting the parameters of the battery detection model to obtain an adjusted model, and replacing the adjusted model with the battery detection model.
[0071] Specifically, if the output of the battery detection model is not the preset output, the parameters of the battery detection model are adjusted so that the output result gradually approaches the preset output. The back propagation algorithm or optimization algorithm can be used to adjust the parameters of the model, and then the loss function is used to verify whether the accuracy of the detection model meets the requirements. If it does not meet the requirements, the adjusted model is replaced with the battery detection model, and the next round of training is repeated.
[0072] S1024. Repeat step 1, step 2, and step 3 until the output of the battery detection model is the preset output, and then use the battery detection model whose output is the preset output as the final detection model.
[0073] When the loss function value reaches the preset value, the model training can be determined to be complete. For example, in the conventional model training process, to make the output of the detection model and the preset output have a similarity of 100%, not only the training time is long, but the cost is also too high. Therefore, usually when the similarity between the two reaches about 99%, or the loss function reaches the preset value, the model training can be determined to be complete, and the model at this time is used as the final detection model.
[0074] S103: acquiring a battery image to be tested based on the battery image training set, and preprocessing the battery image to be tested to obtain a preprocessed image.
[0075] In order to improve the recognition effect of the battery image to be tested, a high-resolution camera device can be used to capture images of the battery packaging box. The camera device is equipped with autofocus and autoexposure functions to adapt to different scenes and lighting conditions.
[0076] In addition, the cost of high-resolution camera equipment may be high, so the detection accuracy can also be improved by controlling the shooting angle and brightness of the camera. Alternatively, a high-resolution camera device can be used at the same time, and the shooting angle of the camera device can be adjusted.
[0077] See also Figure 3 , step S103 includes:
[0078] S1031. Obtain a target angle and a target brightness when shooting the battery image training set, and adjust the shooting angle of the camera to the target angle.
[0079] Specifically, since the camera device of the battery image is usually fixed, its shooting angle is usually also fixed. When obtaining the battery image to be tested, it is necessary to ensure that the battery image to be tested can be normally recognized by the final detection model. The shooting angle of the battery image to be tested can be adjusted to make it the same as the shooting angle of the battery image training set, thereby greatly improving the recognition accuracy of the model.
[0080] S1032. Obtain a current environment picture in real time at the target angle through the camera, and determine the current environment brightness according to the current environment picture.
[0081] In addition to the shooting angle, the brightness of the image will also have a great impact on the detection results when the detection model performs image detection. Too high or too low brightness will affect the accuracy of the detection results. Therefore, the camera can be used to obtain the current environment image in real time, and the current environment brightness can be determined based on the current environment image.
[0082] S1033. Determine the fill light brightness of an external light source according to the current ambient brightness and the target brightness, adjust the current ambient brightness to the target brightness through the external light source, and control the camera to obtain the image of the battery to be tested at the target angle and the target brightness.
[0083] Specifically, the brightness of the battery picture taken to be tested can be identified every three minutes to determine the current ambient brightness. The target brightness can be the brightness of the picture with higher recognition accuracy in the battery picture training set. For example: when the detection model has a high detection accuracy at the brightness of A, B and C, the target brightness can be determined to be A, B and C. If the current ambient brightness is D, determine which target brightness D is closer to, so as to determine the minimum fill light brightness of the external light source, thereby ensuring that the shooting angle and brightness of the battery picture taken to be tested can be recognized by the detection model, and the detection result is more accurate.
[0084] In one embodiment, the preprocessing of the image of the battery to be tested to obtain a preprocessed image includes:
[0085] First, a sliding window cropping algorithm is used to crop each of the battery images to be tested into initial images of the same size to expand the number of images.
[0086] Then, each of the initial images is filtered, such as median filtering and Gaussian filtering, to remove noise and interference in the image, and then the brightness, contrast and color balance of the image are adjusted to perform image enhancement processing to obtain an intermediate image.
[0087] Each of the intermediate images is adjusted to the same size and angle to ensure consistent processing of the input data by the subsequent neural network model, thereby obtaining the preprocessed image.
[0088] The same method can also be used when preprocessing battery packaging images.
[0089] S104, inputting the pre-processed image into the final detection model to obtain a detection result; the detection result includes the battery model and battery quantity corresponding to the battery image to be tested.
[0090] An anchor-box-based object detection algorithm can be used to determine the total number of batteries.
[0091] Specifically, determine the target area for collecting images of the battery to be tested, and when the battery packaging box enters the target area, obtain the image of the battery to be tested, where the image of the battery to be tested can be multiple images taken in a short period of time. For example: when packaging box A enters the target area, if packaging box A is on the production line at this time, packaging box A may be in a moving state. At this time, multiple images of packaging box A can be taken, and the detection results of multiple images can be combined. Prevent missed detection and false detection caused by unstable cameras or unreliable external conditions such as lighting.
[0092] See also Figure 4 , step S104 includes:
[0093] S1041. Process each of the images of the batteries to be tested using the target detection algorithm of the final detection model to obtain the total number of batteries corresponding to each of the images of the batteries to be tested.
[0094] Specifically, a candidate frame is generated for each of the battery images to be tested, wherein the candidate frame may be a plurality of candidate frames generated on a single image where a battery may exist.
[0095] Then, a target detection algorithm is used to classify and regress each candidate frame to obtain a classification result; the classification result includes the position of the battery in each candidate frame, so as to determine whether there is a battery in each candidate frame and the precise position and boundary frame of the battery.
[0096] Using a non-maximum suppression algorithm, the overlapping candidate boxes in the classification results are removed, the remaining classification results are used as the final results, and the total number of batteries is obtained according to the final results. The final result may be the box with the highest confidence, and the number of batteries included in the box with the highest confidence is used as the total number of batteries.
[0097] S1042: Using the feature extraction layer of the final detection model, extract features from each of the images of the battery to be tested to obtain feature information of each of the images of the battery to be tested.
[0098] The feature information may include edge, texture, shape, etc.
[0099] S1043: Perform forward propagation processing on the feature information corresponding to each of the battery images to be tested, to obtain a battery model prediction result for each of the battery images to be tested.
[0100] S1044: Normalize each battery model prediction result to obtain a probability distribution of the battery model of each battery image to be tested.
[0101] Among them, the softmax function can be used to normalize the battery model prediction results.
[0102] S1045. Calculate the number of batteries corresponding to each battery model in each of the battery pictures to be tested according to the total number of batteries in each of the battery pictures to be tested and the probability distribution.
[0103] Specifically, if a battery package includes multiple types of batteries, the number of batteries corresponding to each battery type can be calculated through the probability distribution of each battery type and the total number of batteries, and the detection result is more intelligent.
[0104] This embodiment uses a neural network model to identify the number and model of batteries, avoiding errors caused by small differences in battery size and weight, thereby improving the accuracy of counting. It is no longer necessary to place each package on a weighing device for weighing, reducing additional time and labor costs.
[0105] After obtaining the number of batteries corresponding to each battery model in each battery packaging box, the battery counting results can be output and displayed on the user interface or related devices to provide users with real-time battery counting information. The battery model and battery quantity can also be bound to the test data of the battery cell in the background data set and stored in the database for subsequent data backtracking and error checking.
[0106] Example 2
[0107] See also Figure 5, the present application also provides a battery detection system, comprising:
[0108] A preprocessing module 501 is used to obtain battery packaging pictures, preprocess the battery packaging pictures, and obtain a battery picture training set;
[0109] A training module 502 is used to build a battery detection model based on the improved YOLOv8 network, and train the battery detection model using the battery image training set to obtain a final detection model;
[0110] An acquisition module 503 is used to acquire a picture of a battery to be tested, and preprocess the picture of the battery to be tested to obtain a preprocessed picture;
[0111] The detection module 504 is used to input the pre-processed image into the final detection model to obtain a detection result; the detection result includes the battery model and battery quantity corresponding to the battery image to be tested.
[0112] It can be understood that the implementation of the battery detection method described in the above embodiment 1 is also applicable to this embodiment, so it will not be described again here.
[0113] Example 3
[0114] The embodiment of the present application also provides a computer device, for example, the computer device can be, but is not limited to, a desktop computer, a notebook, etc., and its existence form is not limited, mainly depending on whether it needs to support the interface display function of the browser web page, etc. Exemplarily, the computer device includes a memory and at least one processor, the memory stores a computer program, and the processor is used to execute the computer program to implement the battery detection method described in the above embodiment 1.
[0115] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. At least one of the general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0116] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0117] Furthermore, the memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data (such as iteration data, version data, etc.) created according to the use of the computer device, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0118] Example 4
[0119] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to execute the battery detection method described in the above-mentioned embodiment 1.
[0120] It can be understood that the implementation of the battery detection method described in the above embodiment 1 is also applicable to this embodiment, so it will not be described again here.
[0121] The computer-readable storage medium may be either a non-volatile storage medium or a volatile storage medium. For example, the computer-readable storage medium may include, but is not limited to, various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0122] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0123] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0124] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0125] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
[0126] In all examples shown and described herein, any specific values should be interpreted as merely exemplary and not as limiting, and thus other examples of the exemplary embodiments may have different values.
[0127] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0128] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.
Claims
1. A battery detection method, characterized in that: include: Obtaining battery packaging pictures, and preprocessing the battery packaging pictures to obtain a battery picture training set; Building a battery detection model based on an improved YOLOv8 network, and training the battery detection model using the battery image training set to obtain a final detection model; Acquire a battery image to be tested based on the battery image training set, and preprocess the battery image to be tested to obtain a preprocessed image; The preprocessed image is input into the final detection model to obtain a detection result; the detection result includes the battery model and battery quantity corresponding to the battery image to be tested.
2. The battery detection method according to claim 1, characterized in that: The battery detection model is constructed based on the improved YOLOv8 network, including: Using the YOLOv8 network as a baseline network, and using the SPD network to replace the stride convolution and pooling layers of the YOLOv8 network, to obtain the improved YOLOv8 network; The large target output layer of the improved YOLOv8 network is replaced with multiple medium target output layers to obtain the battery detection model.
3. The battery detection method according to claim 1, characterized in that: The method of training the battery detection model using the battery image training set to obtain a final detection model includes: Step 1: input the battery image training set into the battery detection model to train the battery detection model; Step 2: Obtain the output of the battery detection model, and determine whether the output of the battery detection model is a preset output; Step 3: If the output of the battery detection model is not the preset output, adjust the parameters of the battery detection model to obtain an adjusted model, and replace the adjusted model with the battery detection model; Repeat step 1, step 2 and step 3 until the output of the battery detection model is the preset output, and then use the battery detection model with the preset output as the final detection model.
4. The battery detection method according to claim 1, characterized in that: The obtaining the battery image to be tested based on the battery image training set includes: Obtaining the target angle and target brightness when shooting the battery image training set, and adjusting the shooting angle of the camera to the target angle; Acquire a current environment picture in real time at the target angle through the camera, and determine the current environment brightness according to the current environment picture; The fill light brightness of the external light source is determined according to the current ambient brightness and the target brightness, the current ambient brightness is adjusted to the target brightness by the external light source, and the camera is controlled to obtain the image of the battery to be tested at the target angle and the target brightness.
5. The battery detection method according to claim 4, characterized in that: The preprocessing of the image of the battery to be tested to obtain a preprocessed image includes: Using a sliding window cropping algorithm, cropping each of the battery images to be tested into initial images of the same size; After filtering each of the initial images, image enhancement is performed to obtain an intermediate image; Each of the intermediate images is adjusted to the same size and the same angle to obtain the pre-processed image.
6. The battery detection method according to claim 1, characterized in that: The step of inputting the preprocessed image into the final detection model to obtain a detection result includes: Using the target detection algorithm of the final detection model to process each of the battery images to be tested, to obtain the total number of batteries corresponding to each of the battery images to be tested; Using the feature extraction layer of the final detection model, feature extraction is performed on each of the battery images to obtain feature information of each of the battery images to be tested; Performing forward propagation processing on the feature information corresponding to each of the battery images to be tested, to obtain a battery model prediction result for each of the battery images to be tested; Normalizing each battery model prediction result to obtain a probability distribution of the battery model of each battery image to be tested; The number of batteries corresponding to each battery model in each battery picture to be tested is calculated according to the total number of batteries in each battery picture to be tested and the probability distribution.
7. The battery detection method according to claim 6, characterized in that: The target detection algorithm of the final detection model is used to process each of the battery images to obtain the total number of batteries corresponding to each of the battery images to be tested, including: Generate a candidate frame for each of the battery images to be tested, and classify each of the candidate frames using a target detection algorithm to obtain a classification result; the classification result includes the position of the battery in each of the candidate frames; The overlapping candidate boxes in the classification results are removed by using a non-maximum suppression algorithm, the remaining classification results are used as final results, and the total number of batteries is obtained according to the final results.
8. A battery detection system, characterized in that: include: A preprocessing module, used to obtain battery packaging pictures, preprocess the battery packaging pictures, and obtain a battery picture training set; A training module, used for building a battery detection model based on an improved YOLOv8 network, and training the battery detection model using the battery image training set to obtain a final detection model; An acquisition module, used for acquiring a battery image to be tested based on the battery image training set, and preprocessing the battery image to be tested to obtain a preprocessed image; The detection module is used to input the pre-processed image into the final detection model to obtain a detection result; the detection result includes the battery model and battery quantity corresponding to the battery image to be tested.
9. An electronic device, characterized in that: The method comprises a memory and at least one processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the battery detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the battery detection method according to any one of claims 1 to 7 is implemented.
