Lithium battery defect detection method, device and equipment based on vision and text knowledge distillation and computer readable storage medium
By training a lightweight student model through visual and textual knowledge distillation, the high cost and slow inference of existing lithium battery defect detection methods are solved, achieving efficient and accurate lithium battery defect detection that is suitable for industrial deployment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- WUHAN ZHITONG VISION TECHNOLOGY CO LTD
- Filing Date
- 2026-01-09
- Publication Date
- 2026-04-21
AI Technical Summary
Existing deep learning-based lithium battery defect detection methods rely on labeled data, which is costly, difficult to handle new defects, and the zero-shot method has slow inference speed and high resource consumption, making it impossible to deploy directly on the production line.
A method based on visual and textual knowledge distillation is adopted. A lightweight student model is trained by receiving a set of pseudo-labels. The model parameters are adjusted using the total loss function until the preset loss value is reached. By combining feature imitation loss and relation imitation loss, the model's ability to detect new defect types is improved.
It achieves efficient and accurate lithium battery defect detection. The lightweight student model outperforms the zero-shot method on the production line, approaches the accuracy of supervised models, and maintains fast inference speed.
Smart Images

Figure CN121904508A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of lithium battery defect detection technology, and in particular to a lithium battery defect detection method, apparatus, equipment, and computer-readable storage medium based on visual and text knowledge distillation. Background Technology
[0002] Existing supervised methods based on deep learning rely on labeled data. For example, lithium batteries have many types of defects with blurred boundaries, requiring a large amount of manual labeling, which is extremely costly and limits the scale of the model. They are also difficult to handle new defects. For example, supervised models can only identify defects that appear in the training set and have no ability to identify new types of defects. Therefore, the visual language model CLIP is often used. Although it has zero-shot capability, its inference speed is slow and its resource consumption is large, so it cannot be directly deployed on the production line. Summary of the Invention
[0003] The purpose of this application is to provide a lithium battery defect detection method, apparatus, device, and computer-readable storage medium based on visual and textual knowledge distillation, which can improve the efficiency and accuracy of lithium battery defect detection.
[0004] This application discloses a lithium battery defect detection method based on visual and textual knowledge distillation. The steps of the lithium battery defect detection method based on visual and textual knowledge distillation include:
[0005] S1: Receive a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt;
[0006] S2: Construct a lightweight student model, train the lightweight student model using the pseudo-label set, and obtain the probability distribution of the student model output;
[0007] S3: Substitute the similarity distribution output by the teacher model and the probability distribution output by the student model of the corresponding pseudo-label set into the total loss function. The total loss function includes the sum of the classification loss of the first weight and the relationship imitation loss of the second weight to obtain the total loss value.
[0008] S4: Adjust the parameters of the lightweight student model according to the gradient direction of the total loss value;
[0009] S5: Repeat steps S3 and S4 above until the total loss value is less than or equal to the preset loss value, and obtain the target lightweight student model.
[0010] Optionally, in step S3: substituting the corresponding pseudo-label set and the student model output label set into the total loss function, the total loss function including the sum of the classification loss with the first weight and the feature imitation loss with the second weight to obtain the total loss value:
[0011] The total loss function also includes a third-weighted feature imitation loss.
[0012] Optionally, the classification loss is the standard cross-entropy loss, and the relation imitation loss is the KL divergence loss.
[0013] Optionally, the feature imitation loss is the mean squared error or the cosine similarity loss.
[0014] Optionally, step S1: receiving a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt, includes the following steps before the step:
[0015] S11: Receive a text prompt set, wherein the text prompt set includes multiple prompt texts;
[0016] S12: Receive an unlabeled image set, which includes multiple images;
[0017] S13: Input the unlabeled image set and the text prompt set into the teacher model, calculate the cosine similarity score between the visual features of each image in the unlabeled image set and the prompt text in the text prompt set, select the prompt text with the highest cosine similarity score to form a pseudo label, and obtain the initial pseudo label set;
[0018] S14: The initial pseudo-label set is filtered to obtain the pseudo-label set.
[0019] Optionally, step S14: filtering the initial pseudo-tag set to obtain the pseudo-tag set includes:
[0020] S141: Calculate the difference between the most favorable similarity and the second most favorable similarity for each pseudo-label in the initial pseudo-label set;
[0021] S142: Filter out pseudo-labels whose difference between the most favorable similarity and the second most favorable similarity is greater than a first preset value to obtain the first process pseudo-label set.
[0022] Optionally, after step S142: filtering pseudo-labels whose difference between the most favorable similarity and the second most favorable similarity is greater than a first preset value to obtain the first process pseudo-label set, the method further includes:
[0023] S15: Calculate the entropy value of the pseudo-labels in the pseudo-label set of the first process;
[0024] S16: Filter out pseudo-labels whose entropy value is greater than the second preset value to obtain the pseudo-label set.
[0025] This application also discloses a lithium battery defect detection device based on visual and textual knowledge distillation, the lithium battery defect detection device based on visual and textual knowledge distillation includes:
[0026] Main body of the device;
[0027] A product conveyor belt, connected to the main body of the device, is used to transport the products to be tested;
[0028] A camera, connected to the main body of the device, is used to photograph the products to be inspected on the product conveyor belt.
[0029] The defect identification module, connected to the camera, is used to receive images captured by the camera and execute the target lightweight student model obtained by the lithium battery defect detection method based on visual and text knowledge distillation.
[0030] This application also discloses an electronic device, the electronic device comprising:
[0031] At least one processor; and,
[0032] A memory communicatively connected to the at least one processor; wherein,
[0033] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform a lithium battery defect detection method based on visual and textual knowledge distillation.
[0034] This application also discloses a computer-readable storage medium storing a computer program that, when executed by a processor, implements a lithium battery defect detection method based on visual and textual knowledge distillation.
[0035] This application receives a set of pseudo-labels, each containing an image and a corresponding text prompt. The images in the pseudo-label set are then input into a lightweight student model to obtain the probability distribution of the student model's output. The similarity distribution between the student model's output and the teacher model's output is then substituted into the total loss function to obtain the total loss value. Based on the gradient direction of the total loss value, the parameters of the lightweight student model are adjusted until the total loss value is less than or equal to a preset loss value. This allows the lightweight student model to perform the complex tasks of the teacher model, enabling it to effectively detect new defect types or variants not present in the training set. The overall accuracy is significantly higher than direct zero-shot methods and approaches or reaches the level of supervised models requiring extensive annotation, while maintaining a relatively fast inference speed suitable for industrial deployment. Attached Figure Description
[0036] The accompanying drawings, which form part of the specification, are used to provide a further understanding of the embodiments of this application and illustrate the implementation methods of this application, together with the textual description, to explain the principles of this application. Obviously, the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any creative effort. In the drawings:
[0037] Figure 1 This is a schematic diagram of a lithium battery defect detection method based on visual and textual knowledge distillation, according to an embodiment of this application.
[0038] Figure 2 This is a schematic diagram of a method for generating a pseudo-tag set according to an embodiment of this application;
[0039] Figure 3 This is a schematic diagram of a lithium battery defect detection device based on visual and textual knowledge distillation, according to an embodiment of this application.
[0040] Figure 4 This is a schematic diagram of an electronic device according to an embodiment of this application.
[0041] Among them, 10, electronic equipment; 11, memory; 12, processor; 13, display; 14, network interface; 15, main body of the device; 16, product conveyor belt; 17, camera; 18, defect identification module; 19, product to be inspected; 20, lithium battery defect detection device based on visual and text knowledge distillation. Detailed Implementation
[0042] It should be understood that the terminology, specific structural and functional details used herein are merely for describing particular embodiments and are representative. However, this application may be implemented in many alternative forms and should not be construed as being limited to the embodiments set forth herein.
[0043] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating relative importance or implying the number of technical features indicated. Therefore, unless otherwise stated, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature; "multiple" means two or more. The term "comprising" and any variations thereof mean non-exclusive inclusion, where one or more other features, integers, steps, operations, units, components, and / or combinations thereof may be present or added.
[0044] In addition, terms such as “center,” “horizontal,” “up,” “down,” “left,” “right,” “vertical,” “horizontal,” “top,” “bottom,” “inner,” and “outer” that indicate orientation or positional relationship are based on the orientation or relative positional relationship shown in the accompanying drawings. They are only for the purpose of simplifying the description of this application and do not indicate that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application.
[0045] Furthermore, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium, or internal connections between two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0046] The present application will now be described in detail with reference to the accompanying drawings and optional embodiments.
[0047] Figure 1 This is a schematic diagram of a lithium battery defect detection method based on visual and textual knowledge distillation, according to an embodiment of this application. Figure 1 As shown, this application discloses a lithium battery defect detection method based on visual and textual knowledge distillation. The steps of the lithium battery defect detection method based on visual and textual knowledge distillation include:
[0048] S1: Receive a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt;
[0049] For example, the pseudo-label = (I1, t1), where I1 is an image and t1 is a text prompt, such as "scratches on the surface of lithium battery electrode", "stripe defects caused by uneven coating", and "black spots of metal foreign matter".
[0050] S2: Construct a lightweight student model, train the lightweight student model using the pseudo-label set, and obtain the probability distribution of the student model output;
[0051] It is understood that training the lightweight student model using the pseudo-label set refers to inputting images from the pseudo-label set into the lightweight student model, and the lightweight student model outputting the corresponding probability distribution.
[0052] The lightweight student models mentioned include small CNNs (convolutional neural networks) such as MobileNet and EfficientNet-Lite. These lightweight student models possess second-level inference capabilities, but lack native CLIP semantic understanding. The initial probability distribution output by the lightweight student model was merely a guess.
[0053] S3: Substitute the similarity distribution output by the teacher model and the probability distribution output by the student model of the corresponding pseudo-label set into the total loss function. The total loss function includes the sum of the classification loss of the first weight and the relationship imitation loss of the second weight to obtain the total loss value.
[0054] For example, the same image from the pseudo-label set is fed into the teacher model and the lightweight student model respectively to obtain the probability distribution of the student model output and the similarity distribution of the teacher model output.
[0055] For example, the teacher model includes zero-shot visual-language models (such as CLIP), SigLIP, EVA-CLIP, ALIGN, etc.
[0056] The total loss function is: The classification loss is The relationship imitation loss is The =α +γ α and γ are adjustable loss weight coefficients. For example, the classification loss is the standard cross-entropy loss, and the relation mimicry loss is the KL divergence loss.
[0057] S4: Adjust the parameters of the lightweight student model according to the gradient direction of the total loss value;
[0058] For example, adjusting the parameters of the lightweight student model according to the descent gradient direction of the total loss value includes adjusting the fully connected parameters of the output layer in the lightweight student model.
[0059] S5: Repeat steps S3 and S4 above until the total loss value is less than or equal to the preset loss value, and obtain the target lightweight student model.
[0060] Then, after obtaining the target lightweight student model, it can be directly used on the production line. In step S5: repeat steps S3 and S4 until the total loss value is less than or equal to the preset loss value. After obtaining the target lightweight student model, the following steps are also included:
[0061] S6: Obtain photos of the product to be inspected;
[0062] S7: Input the product photo to be detected into the target lightweight student model to obtain the detection probability distribution, and take the highest probability value as the product label for output.
[0063] For example, if image 1 is input into the target lightweight student model, the probability distribution is obtained as follows: "Scratches on the surface of lithium battery electrode" → 0.9, "Stripe defects caused by uneven coating" → 0.6, "Black spots of metal foreign matter" → 0.45. At this time, the output product label with the highest probability is selected as (image 1, "Scratches on the surface of lithium battery electrode").
[0064] This application receives a set of pseudo-labels, each containing an image and a corresponding text prompt. The images in the pseudo-label set are then input into a lightweight student model to obtain the probability distribution of the student model's output. The similarity distribution between the student model's output and the teacher model's output is then substituted into the total loss function to obtain the total loss value. Based on the gradient direction of the total loss value, the parameters of the lightweight student model are adjusted until the total loss value is less than or equal to a preset loss value. This allows the lightweight student model to perform the complex tasks of the teacher model, enabling it to effectively detect new defect types or variants not present in the training set. The overall accuracy is significantly higher than direct zero-shot methods and approaches or reaches the level of supervised models requiring extensive annotation, while maintaining a relatively fast inference speed suitable for industrial deployment.
[0065] Meanwhile, to ensure reliability and stability, new detection samples and their true labels can be collected at preset intervals to form a new label set. This new label set is then used to test the target lightweight student model and evaluate its detection accuracy. If a significant decline in model performance is observed, new sample data can be used to retrain and optimize the target lightweight student model using steps S2-S5 to adapt to potential subtle differences between different batches of lithium battery products.
[0066] Furthermore, in step S3: substituting the corresponding pseudo-label set and the student model output label set into the total loss function, the total loss function includes the sum of the classification loss of the first weight and the feature imitation loss of the second weight to obtain the total loss value:
[0067] The total loss function also includes a third-weighted feature imitation loss.
[0068] The feature imitation loss is either mean squared error or cosine similarity loss.
[0069] The feature imitation loss is Correspondingly, Where α, β, and γ are adjustable loss weight coefficients. This further improves the accuracy of the target lightweight student model.
[0070] Feature imitation loss aims to make the visual feature maps of the intermediate layers of the target student model as close in distribution as possible to the feature maps of the corresponding layers of the teacher model. This enables the student model to learn the powerful feature representation capabilities of the teacher model.
[0071] The relation imitation loss ensures that the category similarity distribution (i.e., the probability vector after softmax) output by the target student model is consistent with the text-image similarity distribution output by the teacher model, which allows the target student model to inherit the teacher model's ability to understand category relationships.
[0072] Correspondingly, adjusting the parameters of the lightweight student model based on the descent gradient direction of the total loss value also includes adjusting the convolution kernel parameters of the intermediate layers.
[0073] Figure 2 This is a schematic diagram of a method for generating a pseudo-tag set according to an embodiment of this application, as shown below. Figure 2 As shown, step S1: receiving a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt, precedes the following steps:
[0074] S11: Receive a text prompt set, wherein the text prompt set includes multiple prompt texts;
[0075] For example, the set of received text prompts includes "scratches on the surface of lithium battery electrodes", "stripe defects caused by uneven coating", and "black spots of metallic foreign matter".
[0076] S12: Receive an unlabeled image set, which includes multiple images;
[0077] S13: Input the unlabeled image set and the text prompt set into the teacher model, calculate the cosine similarity score between the visual features of each image in the unlabeled image set and the prompt text in the text prompt set, select the prompt text with the highest cosine similarity score to form a pseudo label, and obtain the initial pseudo label set;
[0078] S14: The initial pseudo-label set is filtered to obtain the pseudo-label set.
[0079] In step S13: the unlabeled image set and the text prompt set are substituted into the teacher model, and the cosine similarity score between the visual features of each image in the unlabeled image set and the prompt text in the text prompt set is calculated sequentially. The prompt text with the highest cosine similarity score is selected to form a pseudo-label, resulting in an initial pseudo-label set including:
[0080] S1311: Input the unlabeled image set and the text prompt set into the teacher model;
[0081] S1312: Calculate the cosine similarity score between the visual features of each image in the unlabeled image set and each of the prompt texts in the text prompt set in turn;
[0082] S1313: Select the prompt text with the highest cosine similarity score to form pseudo-labels, and obtain the initial pseudo-label set.
[0083] This allows us to obtain the initial set of pseudo-labels output by the teacher model.
[0084] Of course, another option is:
[0085] S1321: Input the unlabeled image set and the text prompt set into the teacher model;
[0086] S1322: Calculate the cosine similarity score between the visual features of each image in the unlabeled image set and the prompt text in the text prompt set in turn;
[0087] S1323: When the visual features of each image in the unlabeled image set have a cosine similarity score with the prompt text in the text prompt set that is greater than or equal to a preset similarity score;
[0088] S1324: Select prompt texts and images with cosine similarity scores greater than or equal to preset similarity scores to form pseudo-labels, thus obtaining an initial pseudo-label set.
[0089] This allows for faster training.
[0090] Furthermore, step S14: filtering the initial pseudo-tag set to obtain the pseudo-tag set includes:
[0091] S141: Calculate the difference between the most favorable similarity and the second most favorable similarity for each pseudo-label in the initial pseudo-label set;
[0092] S142: Filter out pseudo-labels whose difference between the most favorable similarity and the second most favorable similarity is greater than a first preset value to obtain the first process pseudo-label set.
[0093] S142: After the step of filtering pseudo-labels whose difference between the most favorable similarity and the second most favorable similarity is greater than a first preset value to obtain the first process pseudo-label set, the method further includes:
[0094] S15: Calculate the entropy value of the pseudo-labels in the pseudo-label set of the first process;
[0095] S16: Filter out pseudo-labels whose entropy value is greater than the second preset value to obtain the pseudo-label set.
[0096] By using a joint metric of the difference between the most favorable and the second most favorable similarity (Margin) and entropy, highly reliable pseudo-labels are automatically selected, which greatly improves the quality of distilled data and ensures the training effect of student models.
[0097] Figure 3 This is a schematic diagram of a lithium battery defect detection device based on visual and textual knowledge distillation, according to an embodiment of this application. Figure 3 As shown, this application also discloses a lithium battery defect detection device 20 based on visual and textual knowledge distillation. The lithium battery defect detection device 20 based on visual and textual knowledge distillation includes: a device body 15; a product conveyor belt 16 connected to the device body 15 for transporting the product 19 to be inspected; a camera 17 connected to the device body 15 for capturing images of the product 19 to be inspected on the product conveyor belt 16; and a defect recognition module 18 connected to the camera 17 for receiving images captured by the camera 17 and executing the target lightweight student model obtained by the lithium battery defect detection method based on visual and textual knowledge distillation as described in any one of claims 1-7.
[0098] By receiving a set of pseudo-labels, each containing an image and a corresponding text prompt, and then inputting the images from the pseudo-label set into a constructed lightweight student model, the probability distribution of the student model's output is obtained. The similarity distribution between the student model's output and the teacher model's output is then substituted into the total loss function to obtain the total loss value. Based on the gradient direction of the total loss value, the parameters of the lightweight student model are adjusted until the total loss value is less than or equal to a preset loss value. This allows the lightweight student model to perform the complex tasks of the teacher model, enabling it to effectively detect new defect types or variants not present in the training set. Its overall accuracy is significantly higher than direct zero-shot methods and approaches or reaches the level of supervised models requiring extensive annotation, while maintaining a relatively fast inference speed suitable for industrial deployment.
[0099] This allows the lithium battery defect detection device 20, based on visual and textual knowledge distillation, to accurately determine the type of product defect without requiring complex transportation, thus maintaining a fast reasoning speed and improving generation efficiency.
[0100] Figure 4 This is a schematic diagram of an electronic device according to an embodiment of this application, as shown below. Figure 4As shown, this application also discloses an electronic device 10, which includes: at least one processor 12; and a memory 11 communicatively connected to the at least one processor 12; wherein the memory 11 stores instructions executable by the at least one processor 12, which are executed by the at least one processor 12 to enable the at least one processor 12 to perform the above-described lithium battery defect detection method based on visual and text knowledge distillation.
[0101] Specifically, the electronic device 10 includes, but is not limited to, a memory 11, a processor 12, a display 13, and a network interface 14. The electronic device 10 connects to a network via the network interface 14 to acquire raw test data. The network can be an intranet, the Internet, GSM, WCDMA, 4G, 5G, Bluetooth, Wi-Fi, or other wireless or wired networks.
[0102] The memory 11 includes at least one type of readable medium, including flash memory, hard disk, multimedia card, card-type memory 11 (e.g., SD or DX memory 11), random access memory 11 (RAM), static random access memory 11 (SRAM), read-only memory 11 (ROM), electrically erasable programmable read-only memory 11 (EEPROM), programmable read-only memory 11 (PROM), magnetic memory 11, disk, optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of the electronic device 10, such as the hard disk or memory of the electronic device 10. In other embodiments, the memory 11 can also be an external storage device of the electronic device 10, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. of the electronic device 10. Of course, the memory 11 can also include both internal storage units and external storage devices of the electronic device 10. In this embodiment, the memory 11 is typically used to store the operating system and various application software installed on the electronic device 10, such as the program code of a lithium battery defect detection method based on visual and text knowledge distillation. In addition, the memory 11 can also be used to temporarily store various types of data that have been output or will be output.
[0103] In some embodiments, processor 12 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor 12, or other data processing chip. This processor 12 is typically used to control the overall operation of the electronic device 10, such as performing data interaction or communication-related control and processing. In this embodiment, processor 12 is used to run program code stored in memory 11 or process data, such as running program code for a lithium battery defect detection method based on visual and textual knowledge distillation.
[0104] The display 13 may be referred to as a display screen or display unit. In some embodiments, the display 13 may be an LED display 13, a liquid crystal display 13, a touch-sensitive liquid crystal display 13, and an organic light-emitting diode (OLED) touch screen, etc. The display 13 is used to display information processed in the electronic device 10 and to display a visual working interface, such as displaying the results of data statistics.
[0105] The network interface 14 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface), which is typically used to establish a communication connection between the electronic device 10 and other electronic devices 10.
[0106] Figure 4 Only an electronic device 10 with memory 11, processor 12, display 13, and network interface 14, as well as a lithium battery defect detection method based on visual and text knowledge distillation, is shown. However, it should be understood that it is not required to implement all the components shown, and more or fewer components may be implemented instead.
[0107] Optionally, the electronic device 10 may further include a user interface, which may include a display 13, an input unit such as a keyboard, and optionally a standard wired interface or a wireless interface. Optionally, in some embodiments, the display 13 may be an LED display 13, a liquid crystal display 13, a touch-sensitive liquid crystal display 13, or an organic light-emitting diode (OLED) touchscreen, etc. The display 13 may also be appropriately referred to as a screen or display unit, used to display information processed in the electronic device 10 and to display a visual user interface.
[0108] The electronic device 10 may also include radio frequency (RF) circuits, sensors, and audio circuits, etc., which will not be described in detail here.
[0109] In the above embodiments, when the processor 12 executes the lithium battery defect detection method based on visual and textual knowledge distillation stored in the memory 11, it can perform the following steps:
[0110] S1: Receive a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt;
[0111] S2: Construct a lightweight student model, train the lightweight student model using the pseudo-label set, and obtain the probability distribution of the student model output;
[0112] S3: Substitute the similarity distribution output by the teacher model and the probability distribution output by the student model of the corresponding pseudo-label set into the total loss function. The total loss function includes the sum of the classification loss of the first weight and the relationship imitation loss of the second weight to obtain the total loss value.
[0113] S4: Adjust the parameters of the lightweight student model according to the gradient direction of the total loss value;
[0114] S5: Repeat steps S3 and S4 until the total loss value is less than or equal to the preset loss value, thus obtaining the target lightweight student model. Furthermore, this embodiment of the invention also proposes a computer-readable medium, which can be non-volatile or volatile. This computer-readable medium can be any one or any combination of several of the following: hard disk, multimedia card, SD card, flash memory card, SMC, read-only memory 11 (ROM), erasable programmable read-only memory 1111 (EPROM), portable compact disk read-only memory 11 (CD-ROM), USB memory 11, etc. The computer-readable medium includes a data storage area and a program storage area. The data storage area stores data created based on the use of blockchain nodes, and the program storage area stores a lithium battery defect detection method based on visual and textual knowledge distillation. When the lithium battery defect detection method based on visual and textual knowledge distillation is executed by the processor 12, it performs the following operations:
[0115] S1: Receive a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt;
[0116] S2: Construct a lightweight student model, train the lightweight student model using the pseudo-label set, and obtain the probability distribution of the student model output;
[0117] S3: Substitute the similarity distribution output by the teacher model and the probability distribution output by the student model of the corresponding pseudo-label set into the total loss function. The total loss function includes the sum of the classification loss of the first weight and the relationship imitation loss of the second weight to obtain the total loss value.
[0118] S4: Adjust the parameters of the lightweight student model according to the gradient direction of the total loss value;
[0119] S5: Repeat steps S3 and S4 above until the total loss value is less than or equal to the preset loss value, and obtain the target lightweight student model.
[0120] It should be noted that, through the above description of the embodiments, those skilled in the art can clearly understand that the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, electronic device, or network device, etc.) to execute the methods of the various embodiments of the present invention.
[0121] It should be noted that the limitations on each step involved in this solution are not considered as limiting the order of steps, provided that they do not affect the implementation of the specific solution. The steps listed first can be executed first, later, or even simultaneously. As long as this solution can be implemented, it should be considered to fall within the scope of protection of this application.
[0122] It should be noted that the inventive concept of this application can form many embodiments, but due to the limited space of the application documents, they cannot all be listed. Therefore, without conflict, the embodiments described above or the technical features can be arbitrarily combined to form new embodiments. After the embodiments or technical features are combined, the original technical effect will be enhanced.
[0123] The above description, in conjunction with specific optional embodiments, provides a further detailed explanation of this application and should not be construed as limiting the specific implementation of this application to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of this application, and all such modifications or substitutions should be considered within the scope of protection of this application.
Claims
1. A lithium battery defect detection method based on visual and textual knowledge distillation, characterized in that, The steps of the lithium battery defect detection method based on visual and textual knowledge distillation include: S1: Receive a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt; S2: Construct a lightweight student model, train the lightweight student model using the pseudo-label set, and obtain the probability distribution of the student model output; S3: Substitute the similarity distribution output by the teacher model and the probability distribution output by the student model of the corresponding pseudo-label set into the total loss function. The total loss function includes the sum of the classification loss of the first weight and the relationship imitation loss of the second weight to obtain the total loss value. S4: Adjust the parameters of the lightweight student model according to the gradient direction of the total loss value; S5: Repeat steps S3 and S4 until the total loss value is less than or equal to the preset loss value, and obtain the target lightweight student model.
2. The lithium battery defect detection method based on visual and textual knowledge distillation according to claim 1, characterized in that, In step S3: Substituting the corresponding pseudo-label set and the student model output label set into the total loss function, the total loss function includes the sum of the classification loss with the first weight and the feature imitation loss with the second weight, to obtain the total loss value: The total loss function also includes a third-weighted feature imitation loss.
3. The lithium battery defect detection method based on visual and textual knowledge distillation according to claim 1, characterized in that, The classification loss is the standard cross-entropy loss, and the relation imitation loss is the KL divergence loss.
4. The lithium battery defect detection method based on visual and textual knowledge distillation according to claim 2, characterized in that, The feature imitation loss is either mean squared error or cosine similarity loss.
5. The lithium battery defect detection method based on visual and textual knowledge distillation according to claim 1, characterized in that, Before step S1: receiving a set of pseudo-tags, wherein the set of pseudo-tags includes multiple pseudo-tags, and each pseudo-tag includes an image and a corresponding text prompt, the following steps are included: S11: Receive a text prompt set, wherein the text prompt set includes multiple prompt texts; S12: Receive an unlabeled image set, which includes multiple images; S13: Input the unlabeled image set and the text prompt set into the teacher model, calculate the cosine similarity score between the visual features of each image in the unlabeled image set and the prompt text in the text prompt set, select the prompt text with the highest cosine similarity score to form a pseudo label, and obtain the initial pseudo label set; S14: The initial pseudo-label set is filtered to obtain the pseudo-label set.
6. The lithium battery defect detection method based on visual and textual knowledge distillation according to claim 5, characterized in that, S14: The step of filtering the initial pseudo-tag set to obtain the pseudo-tag set includes: S141: Calculate the difference between the most favorable similarity and the second most favorable similarity for each pseudo-label in the initial pseudo-label set; S142: Filter out pseudo-labels whose difference between the most favorable similarity and the second most favorable similarity is greater than a first preset value to obtain the first process pseudo-label set.
7. The lithium battery defect detection method based on visual and textual knowledge distillation according to claim 6, characterized in that, S142: After the step of filtering pseudo-labels whose difference between the most favorable similarity and the second most favorable similarity is greater than a first preset value to obtain the first process pseudo-label set, the method further includes: S15: Calculate the entropy value of the pseudo-labels in the pseudo-label set of the first process; S16: Filter out pseudo-labels whose entropy value is greater than the second preset value to obtain the pseudo-label set.
8. A lithium battery defect detection device based on visual and textual knowledge distillation, characterized in that, The lithium battery defect detection device based on visual and textual knowledge distillation includes: Main body of the device; A product conveyor belt, connected to the main body of the device, is used to transport the products to be tested; A camera, connected to the main body of the device, is used to photograph the products to be inspected on the product conveyor belt. The defect identification module, connected to the camera, is used to receive images captured by the camera and execute the target lightweight student model obtained by the lithium battery defect detection method based on visual and textual knowledge distillation as described in any one of claims 1-7.
9. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the lithium battery defect detection method based on visual and textual knowledge distillation as described in any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the lithium battery defect detection method based on visual and textual knowledge distillation as described in any one of claims 1 to 7.