Fog day insulator defect detection method and device, electronic equipment and storage medium
By training a target YOLO model using a training set under foggy conditions, the domain offset problem in insulator defect detection under foggy conditions was solved, achieving efficient and accurate insulator defect detection and improving the safety of the power system.
Patent Information
- Application Number
- CN202411399149.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2044-10-09
AI Technical Summary
Under foggy conditions, existing technologies struggle to effectively identify insulator defects, primarily due to the domain shift between sunny and foggy weather, which degrades the performance of detection models. Furthermore, traditional defogging algorithms are computationally expensive, and data collection and labeling are costly.
By acquiring a training set, including defective marked insulator image data under sunny conditions and defect-free marked insulator image data under foggy conditions, and using a pre-trained YOLO model and a domain classifier, a target YOLO model is trained, reducing the dependence on a large amount of marked data and achieving efficient detection of insulator defects in foggy weather.
It significantly improves the detection accuracy and efficiency of insulator defects under foggy conditions, reduces data collection and labeling costs, and enhances the operational safety and reliability of the power system.
Smart Images

Figure CN119067963B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of power system inspection, and in particular to a fog weather insulator defect detection method and device, an electronic device and a storage medium. BACKGROUND
[0002] Insulators are key components in high-voltage power transmission systems, and their defects are one of the important factors leading to power system accidents. Therefore, it is very important to detect defects in insulators.
[0003] Under sunny weather conditions, existing technologies can effectively identify and locate insulator defects due to the availability of a large amount of labeled data and various sophisticated techniques. However, under severe weather conditions such as heavy fog, insulator defect detection still faces significant challenges. This is mainly due to the severe performance degradation of detection models trained from sunny day image data in a foggy environment. The reason for this is the significant domain shift problem between sunny and foggy days, i.e., the image feature distribution obtained under different weather conditions differs significantly.
[0004] Traditional methods to deal with the impact of foggy weather mainly improve the visual clarity of images through image processing techniques, such as dehazing algorithms. While this improves image quality to some extent, it often comes with high computational costs, and these methods cannot fundamentally solve the fundamental changes in image feature distribution caused by weather changes. In addition, although training models directly on image data collected under foggy conditions can improve performance to some extent, this method is limited by the high cost of data collection and labeling. SUMMARY
[0005] The present application provides a fog weather insulator defect detection method, device, electronic device and storage medium to solve the problem of high computational cost caused by dehazing algorithms, reduce the dependence on a large amount of labeled data in the model training process, and achieve efficient and accurate detection of insulator defects.
[0006] According to an aspect of the present application, a fog weather insulator defect detection method is provided, which comprises:
[0007] obtaining a training set, the training set comprising a source domain and a target domain, the source domain being a set of defective labeled insulator image data under sunny conditions, and the target domain being a set of non-defective labeled insulator image data under a preset concentration of foggy weather conditions;
[0008] train a pre-training model based on the training set to obtain a target YOLO model; the pre-training model is composed of a pre-training YOLO model and a domain classifier; the target YOLO model is a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value, and the domain classifier is used for predicting a domain classification result of image feature information; the image feature information is feature information from global to local extracted from the training set insulator image data based on the pre-training YOLO model, and the domain classification result is used for describing a probability value of the image feature information belonging to a source domain or a target domain;
[0009] obtain target insulator image data corresponding to a preset concentration of fog, perform defect detection on the target insulator image data based on the target YOLO model, and obtain an insulator defect detection result.
[0010] According to another aspect of the present application, there is provided an insulator defect detection device in foggy weather, which comprises:
[0011] a training set acquisition module configured to acquire a training set, the training set comprising a source domain and a target domain, the source domain being a set of insulator image data with defect labels under sunny conditions, and the target domain being a set of insulator image data without defect labels under foggy weather conditions with a preset concentration;
[0012] a training module configured to train a pre-training model based on the training set to obtain a target YOLO model; the pre-training model is composed of a pre-training YOLO model and a domain classifier; the target YOLO model is a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value, and the domain classifier is used for predicting a domain classification result of image feature information; the image feature information is feature information from global to local extracted from the training set insulator image data based on the pre-training YOLO model, and the domain classification result is used for describing a probability value of the image feature information belonging to a source domain or a target domain;
[0013] a prediction module configured to obtain target insulator image data corresponding to a preset concentration of fog, perform defect detection on the target insulator image data based on the target YOLO model, and obtain an insulator defect detection result.
[0014] According to another aspect of the present application, there is provided an electronic device, which comprises:
[0015] at least one processor; and
[0016] a memory in communication connection with the at least one processor; wherein,
[0017] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the insulator defect detection method in any of the embodiments of the application.
[0018] According to another aspect of the application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to implement the insulator defect detection method in any of the embodiments of the application when executed by the processor.
[0019] The technical solution of the embodiment of the application acquires a training set, the training set including a source domain and a target domain, the source domain being a set of insulator image data marked with defects under sunny conditions, and the target domain being a set of insulator image data without defect marking under a preset concentration of foggy conditions; the data in the target domain in the training set is data without defect marking, greatly reducing the dependence on a large amount of marked data, and significantly reducing the cost and workload of data collection and marking in actual application. Further, the pre-training model is trained based on the training set to obtain a target YOLO model; because the pre-training model is composed of a pre-training YOLO model and a domain classifier, the target YOLO model is a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value, and the domain classifier is used for predicting a domain classification result of image feature information; the image feature information is feature information from global to local extracted from the insulator image data in the training set based on the pre-training YOLO model, and the domain classification result is used for describing a probability value of the image feature information belonging to the source domain or the target domain; the addition of the domain classifier in the training process effectively aligns the feature distribution between the source domain (sunny image) and the target domain (foggy image), and significantly reduces the domain shift problem caused by weather changes; thereby, the target insulator image data corresponding to the preset concentration of fog is acquired, the target insulator image data is subjected to defect detection based on the target YOLO model, an insulator defect detection result is obtained, the detection precision and efficiency of insulator defects under foggy conditions are improved, and the operation safety and reliability of the power system are improved.
[0020] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the application, nor to limit the scope of the application. Other features of the application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to make the technical solutions in the embodiments of the present application clearer, the accompanying drawings needed in the embodiments will be briefly introduced. Obviously, the accompanying drawings in the following description only show some embodiments of the present application, and all other embodiments obtained by those of ordinary skill in the art without any creative effort based on the accompanying drawings should fall into the protection scope of the present application.
[0022] Figure 1 is a flow chart of a fog weather insulator defect detection method according to an embodiment of the present application;
[0023] Figure 2 is a flow chart of another fog weather insulator defect detection method according to an embodiment of the present application;
[0024] Figure 3 is a flow chart of another fog weather insulator defect detection method according to an embodiment of the present application;
[0025] Figure 4 is a flow chart of a fog weather insulator defect detection method according to an embodiment of the present application;
[0026] Figure 5 is a structural schematic diagram of a fog weather insulator defect detection device according to an embodiment of the present application;
[0027] Figure 6 is a structural schematic diagram of an electronic device for implementing the fog weather insulator defect detection method according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the technical solutions in the embodiments of the present application clearer, the accompanying drawings needed in the embodiments will be briefly introduced. Obviously, the accompanying drawings in the following description only show some embodiments of the present application, and all other embodiments obtained by those of ordinary skill in the art without any creative effort based on the accompanying drawings should fall into the protection scope of the present application.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and in the above description of the drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to only those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0030] Embodiment one
[0031] Figure 1 A flowchart of a fog weather insulator defect detection method provided for an embodiment of the present application, the embodiment can be applicable to the case of predicting insulator defects under fog weather conditions, the method can be executed by a fog weather insulator defect detection device, the fog weather insulator defect detection device can be realized in the form of hardware and / or software, and the fog weather insulator defect detection device can be configured in any electronic device with network communication function.
[0032] As Figure 1 shown, the fog weather insulator defect detection method of the present application includes the following processes:
[0033] S110, acquiring a training set, the training set including a source domain and a target domain, the source domain being a set of insulator image data with defect labels under sunny conditions, and the target domain being a set of insulator image data without defect labels under fog weather conditions of a preset density.
[0034] Specifically, the insulator image data of the source domain and the target domain can be collected by a drone or a fixed monitoring device. After collection, the insulator image data of the source domain is labeled with defects as data for model training. The insulator image data of the target domain does not need to be labeled, reducing the workload of labeling data.
[0035] The defect label includes information such as normalized bounding box center coordinates, width and height.
[0036] Optionally, the training set is acquired, including: acquiring first insulator image data, performing defect marking and first domain label marking on the first insulator image data to obtain marked first insulator image data, and grouping the marked first insulator image data to form a source domain; the first insulator image data is insulator image data under sunny conditions, and the first domain label is 0; acquiring second insulator image data, performing second domain label marking on the second insulator image data to obtain marked second insulator image data, and grouping the marked second insulator image data to form a source domain; the second insulator image data is insulator image data under a preset density of foggy conditions, and the second domain label is 1.
[0037] In S120, the pre-training model is trained based on the training set to obtain a target YOLO model; the pre-training model is composed of a pre-training YOLO model and a domain classifier, and the target YOLO model is a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value; the domain classifier is used for predicting a domain classification result of image feature information; the image feature information is feature information from global to local extracted from insulator image data in the training set based on the pre-training YOLO model, and the domain classification result is used for describing a probability value of the image feature information belonging to a source domain or a target domain.
[0038] The target loss can be understood as the sum of a loss corresponding to the pre-training YOLO model and a loss corresponding to the domain classifier. The preset loss value can be understood as a maximum loss value of a detection result of the pre-training model reaching a preset accuracy.
[0039] Specifically, the pre-training YOLO model in the pre-training model extracts feature information from insulator image data in the training set to obtain image feature information, the domain classifier in the pre-training model predicts a domain classification result of the image feature information, and further, a loss value of the domain classifier is obtained according to the domain classification result. Meanwhile, the pre-training YOLO model in the pre-training model also performs defect marking on insulator image data in the source domain in the training set to obtain a defect marking result, and a defect loss value is obtained based on the defect marking result and the defect marking of the insulator image data in the source domain itself. Further, a target loss of the pre-training model is obtained based on the loss value of the domain classifier and the defect loss value. If the target loss is greater than the preset loss value, it indicates that the accuracy of the pre-training model at this time is unqualified, the model parameters corresponding to the target loss need to be updated to the pre-training YOLO model in the pre-training model, and the pre-training model is continuously trained until the target loss is less than or equal to the preset loss value, which indicates that the accuracy of the pre-training model at this time is qualified, and the pre-training YOLO model corresponding to the target loss of the pre-training model being less than or equal to the preset loss value is taken as the target YOLO model.
[0040] S130, acquire target insulator image data corresponding to preset concentration of fog, perform defect detection on the target insulator image data based on a target YOLO model, and obtain an insulator defect detection result.
[0041] Specifically, the target YOLO model is a model for different preset concentrations of fog, the target insulator image data is acquired, the preset concentration of fog corresponding to the target insulator image data is determined, and then the target insulator image data is input into the corresponding target YOLO model for defect detection to obtain an accurate insulator defect detection result.
[0042] The technical scheme of the embodiment of the application acquires a training set, the training set includes a source domain and a target domain, the source domain is a set of insulator image data with defect labels under sunny conditions, and the target domain is a set of insulator image data without defect labels under preset concentration of fog; the data of the target domain in the training set is data without defect labels, which greatly reduces the dependence on a large amount of labeled data, and can significantly reduce the cost and workload of data collection and labeling in actual application. Further, the pre-training model is trained based on the training set to obtain a target YOLO model; because the pre-training model is composed of a pre-training YOLO model and a domain classifier; the target YOLO model is a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value, and the domain classifier is used for predicting a domain classification result of image feature information; the image feature information is feature information from global to local extracted from the insulator image data in the training set based on the pre-training YOLO model, and the domain classification result is used for describing a probability value of the image feature information belonging to the source domain or the target domain; the addition of the domain classifier in the training process effectively aligns the feature distribution between the source domain (sunny image) and the target domain (foggy image), and significantly reduces the domain shift problem caused by weather changes; thereby acquiring target insulator image data corresponding to preset concentration of fog, performing defect detection on the target insulator image data based on the target YOLO model, and obtaining an insulator defect detection result, which improves the detection accuracy and efficiency of insulator defects under foggy conditions and improves the operation safety and reliability of the power system.
[0043] Embodiment two
[0044] Figure 2 The flowchart of another fog insulator defect detection method provided by the embodiment of the application, the technical scheme of the embodiment is further optimized on the basis of the process of S120 in the foregoing embodiment, and the embodiment can be combined with each optional scheme in one or more of the foregoing embodiments.
[0045] As Figure 2 shown, the fog insulator defect detection method of the application includes the following processes:
[0046] S210, a training set is obtained, the training set comprising a source domain and a target domain, the source domain being a set of defect-labeled insulator image data under sunny conditions, and the target domain being a set of non-defect-labeled insulator image data under a preset density of foggy conditions.
[0047] Specifically, first insulator image data is obtained, the first insulator image data is subjected to defect labeling and first domain label labeling to obtain labeled first insulator image data, and a set of the labeled first insulator image data is used to form the source domain; the first insulator image data is insulator image data under sunny conditions, and the first domain label is 0; second insulator image data is obtained, the second insulator image data is subjected to second domain label labeling to obtain labeled second insulator image data, and a set of the labeled second insulator image data is used to form the source domain; the second insulator image data is insulator image data under a preset density of foggy conditions, and the second domain label is 1.
[0048] In this embodiment, the domain classifier comprises at least one image-level domain classifier and at least one instance-level domain classifier. The image-level domain classifier is used to process feature distribution differences of insulator image data at a global image level, and these features reflect extensive information of the overall image scene rather than detailed information of specific objects.
[0049] The instance-level domain classifier is used to process feature distribution differences of insulator image data at a local image level. Instance-level features are formed through layer-by-layer extraction and feature combination at a deeper level of the network, and these features are more specific and are usually related to specific object categories and tasks. The goal of the instance-level domain classifier is to make the feature distribution of insulator instances under different weather conditions more similar, especially in terms of shape, size, and edge definition.
[0050] The image-level domain classifier is composed of a gradient reversal layer, a convolution layer, a batch normalization layer, and an activation function, and the instance-level domain classifier is composed of a gradient reversal layer, a fully connected layer, an activation function, and a Dropout layer.
[0051] In this embodiment, the pre-trained YOLO model comprises a feature extractor, and the feature extractor comprises at least one global feature extraction layer (Backbone) and at least one local feature extraction layer (Neck). The local feature extraction layer is located behind all the global feature extraction layers and is used to further extract features output from the global feature extraction layers; the pre-trained YOLO model is also used to predict and label defect features in insulator image data.
[0052] The number of global feature extraction layers is greater than or equal to the number of image-level domain classifiers, and the number of local feature extraction layers is greater than or equal to the number of instance-level domain classifiers.
[0053] Correspondingly, before the pre-training model is trained based on the training set to obtain the target YOLO model, the method comprises: selecting a first preset number of global feature extraction layers from the at least one global feature extraction layer as target global feature extraction layers, and selecting a second preset number of local feature extraction layers from the at least one local feature extraction layer as target local feature extraction layers; one target global feature extraction layer corresponds to one image-level domain classifier, and one target local feature extraction layer corresponds to one instance-level domain classifier. That is, if the feature data output by m global feature extraction layers is used, the number of image-level domain classifiers corresponding thereto is also m; if the feature data output by n local feature extraction layers is used, the number of instance-level domain classifiers corresponding thereto is also n.
[0054] S220, feature extraction is performed on the insulator image data of the source domain based on each target global feature extraction layer in the pre-trained YOLO model, to obtain first image feature information corresponding to the output of each target global feature extraction layer; the first image feature information is marked with a first domain label.
[0055] The first image feature information can be understood as the feature distribution of the insulator image data of the source domain at the global image level.
[0056] S230, feature extraction analysis is performed on the first image feature information based on the image-level domain classifier corresponding to each target global feature extraction layer, to obtain a first domain classification result output by the image-level domain classifier corresponding to each target local feature extraction layer; the first domain classification result is used to describe the probability value of the first image feature information belonging to the source domain or the target domain.
[0057] S240, feature extraction is performed on the insulator image data of the target domain based on each target local feature extraction layer in the pre-trained YOLO model, to obtain second image feature information corresponding to the output of each target local feature extraction layer; the second image feature information is marked with a second domain label.
[0058] The second image feature information can be understood as the feature distribution of the insulator image data of the target domain at the local image level.
[0059] S250, feature extraction analysis is performed on the second image feature information based on the instance-level domain classifier corresponding to each target local feature extraction layer, to obtain a second domain classification result output by the instance-level domain classifier corresponding to each target local feature extraction layer; the second domain classification result is used to describe the probability value of the second image feature information belonging to the source domain or the target domain.
[0060] S260. Based on the classification result of the first domain and the label of the first domain, determine the first loss value of the image-level domain classifier. Based on the classification result of the second domain and the label of the second domain, determine the second loss value of the instance-level domain classifier. Use the sum of the first loss value and the second loss value as the classification loss value of the domain classifier.
[0061] Specifically, there is a first correspondence between the first domain classification result and the first domain label and the first loss value of the image-level domain classifier; and a second correspondence between the second domain classification result and the second domain label and the second loss value of the instance-level domain classifier. Therefore, the first loss value of the image-level domain classifier is retrieved from the first correspondence based on the first domain classification result and the first domain label; and the second loss value of the instance-level domain classifier is retrieved from the second correspondence based on the second domain classification result and the second domain label. Further, a first weight for the first loss value and a second weight for the second loss value are determined. Based on the first loss value, the second loss value, the first weight of the first loss value, and the second weight of the second loss value, the classification loss value of the domain classifier is obtained.
[0062] As an optional embodiment, determining the first loss value of the image-level domain classifier based on the first domain classification result and the first domain label includes: expressing the first loss value L of the image-level domain classifier using the following formula. img :
[0063]
[0064] Among them, D i This represents the domain label of the i-th insulator image data in the training set. The domain label includes the first domain label and the second domain label. This represents the predicted probability value of the m-th image-level classifier at position (x, y) in the i-th insulator image data in the training set, which is the classification result of the first domain.
[0065] Accordingly, the second loss value of the instance-level domain classifier is determined based on the second domain classification result and the second domain label, including: expressing the first loss value L of the instance-level domain classifier using the following formula. ins :
[0066]
[0067] Among them, D i p represents the domain label of the i-th insulator image data in the training set. The domain label includes the first domain label and the second domain label. i,n This represents the predicted probability value of the i-th insulator image data in the training set in the n-th instance-level domain classifier, i.e., the classification result of the second domain.
[0068] The technical solution in this embodiment uses a loss calculation formula to determine the loss value, thus achieving a more accurate calculation of the loss value.
[0069] S270, input the insulator image data of the source domain in the training set into the pre-trained YOLO model to obtain a defect prediction result, and determine a detection loss value of the pre-trained YOLO model based on the defect prediction result and the insulator image data of the source domain; the defect prediction result is a prediction label result of the pre-trained YOLO model in the insulator image data of the source domain.
[0070] Specifically, the pre-trained YOLO model will mark the defects of the insulator image data of the source domain to obtain the defect prediction result, which includes information such as the normalized center coordinates, width and height of the bounding box. The detection loss of the pre-trained YOLO model mainly includes three parts: bounding box loss, confidence loss and classification loss.
[0071] Bounding box loss: this part of the loss calculates the deviation between the predicted bounding box and the actual labeled bounding box. The pre-trained YOLO model usually uses IOU (intersection over union) or more complex variants such as GIOU, CIOU to evaluate the alignment degree of the predicted box and the true box.
[0072] Confidence loss: evaluate the confidence degree of whether the pre-trained YOLO model predicts the bounding box to contain a defect object, and compare it with the actual situation. If the prediction box correctly contains the defect object, the loss value is smaller; on the contrary, if the prediction box incorrectly marks as containing a defect object or fails to identify the real object, the loss value increases.
[0073] Classification loss: if the prediction box correctly identifies the object, this part of the loss calculates the error between the predicted class and the actual class. This is usually achieved through cross-entropy loss, which evaluates the difference between the model's predicted probability for each class and the actual label.
[0074] Further, the bounding box loss, confidence loss and classification loss are added and summed according to the weight proportion as the detection loss value of the pre-trained YOLO model.
[0075] S280, based on the classification loss value and the detection loss value, determine the target loss of the pre-trained model, when the target loss is greater than the preset loss value, update the pre-trained YOLO model corresponding to the target loss in the pre-trained model to the pre-trained YOLO model, continue to train the pre-trained model based on the training set, until the target loss is greater than the preset loss value, the pre-trained YOLO model corresponding to the target loss of the pre-trained model when the target loss is less than or equal to the preset loss value is taken as the target YOLO model.
[0076] Specifically, the classification loss value and the detection loss value can be weighted and summed in proportion to the weight to obtain a target loss of the pre-training model. When the target loss is greater than a preset loss value, a pre-training YOLO model corresponding to the target loss is updated to a pre-training model in the pre-training YOLO model, and the pre-training model is continuously trained based on the training set until the target loss is greater than the preset loss value. When the target loss of the pre-training model is less than or equal to the preset loss value, the pre-training YOLO model corresponding thereto is taken as a target YOLO model.
[0077] In S290, target insulator image data corresponding to a preset concentration of fog is obtained, and the target insulator image data is subjected to defect detection based on a target YOLO model to obtain an insulator defect detection result.
[0078] The embodiment technical scheme obtains a training set, performs feature extraction on insulator image data of a source domain based on each target global feature extraction layer in a pre-trained YOLO model, obtains first image feature information corresponding to the output of each target global feature extraction layer, performs feature extraction analysis on the first image feature information based on an image-level domain classifier corresponding to each target global feature extraction layer, and obtains a first domain classification result output by the image-level domain classifier corresponding to each target local feature extraction layer; the first domain classification result is used to describe a probability value of the first image feature information belonging to the source domain or the target domain, performs feature extraction on insulator image data of the target domain based on each target local feature extraction layer in the pre-trained YOLO model, obtains second image feature information corresponding to the output of each target local feature extraction layer, performs feature extraction analysis on the second image feature information based on an instance-level domain classifier corresponding to each target local feature extraction layer, and obtains a second domain classification result output by the instance-level domain classifier corresponding to each target local feature extraction layer; the second domain classification result is used to describe a probability value of the second image feature information belonging to the source domain or the target domain, effectively aligns the feature distribution between the source domain (a sunny day image) and the target domain (a foggy day image), significantly reduces the domain shift problem caused by weather changes, and further, determines a first loss value of the image-level domain classifier based on the first domain classification result and a first domain label, determines a second loss value of the instance-level domain classifier based on the second domain classification result and a second domain label, and takes the sum of the first loss value and the second loss value as a classification loss value of the domain classifier. Insulator image data of the source domain in the training set is input into the pre-trained YOLO model, a defect prediction result is obtained, and a detection loss value of the pre-trained YOLO model is determined based on the defect prediction result and the insulator image data of the source domain. The target loss of the pre-trained model is determined based on the classification loss value and the detection loss value. When the target loss is greater than a preset loss value, the pre-trained YOLO model corresponding to the target loss is updated to a pre-trained YOLO model in the pre-trained model, and the pre-trained model is continuously trained based on the training set until the target loss of the pre-trained model is less than or equal to the preset loss value. The pre-trained YOLO model corresponding to the target loss is taken as a target YOLO model. The addition of the two losses improves the accuracy of the target YOLO model, so that subsequent target insulator image data corresponding to a preset concentration of fog is obtained, defect detection is performed on the target insulator image data based on the target YOLO model, and an accurate insulator defect detection result can be obtained, the detection accuracy and efficiency of insulator defects under foggy weather conditions are improved, and the operation safety and reliability of the power system are improved.
[0079] Embodiment three
[0080] Figure 3The flowchart of another fog insulator defect detection method provided by the embodiment of the present application, the technical scheme of the embodiment is further optimized on the basis of the above-mentioned embodiment, and the embodiment can be combined with each optional scheme in one or more of the above-mentioned embodiments. The same steps as in the foregoing embodiments will not be described in detail.
[0081] As shown in the figure, the fog insulator defect detection method of the present application comprises the following processes: Figure 3
[0082] S3101, obtain a training set, the training set comprising a source domain and a target domain, the source domain being a set of insulator image data with defect labels under sunny conditions, and the target domain being a set of insulator image data without defect labels under a preset concentration of foggy conditions.
[0083] S3102, based on each target global feature extraction layer in the pre-trained YOLO model, perform feature extraction on the insulator image data of the source domain, and obtain first image feature information corresponding to the output of each target global feature extraction layer; the first image feature information is marked with a first domain label.
[0084] S3103, based on the image-level domain classifier corresponding to each target global feature extraction layer, perform feature extraction analysis on the first image feature information, and obtain a first domain classification result output by the image-level domain classifier corresponding to each target local feature extraction layer; the first domain classification result is used to describe the probability value of the first image feature information belonging to the source domain or the target domain.
[0085] S3104, based on each target local feature extraction layer in the pre-trained YOLO model, perform feature extraction on the insulator image data of the target domain, and obtain second image feature information corresponding to the output of each target local feature extraction layer; the second image feature information is marked with a second domain label.
[0086] S3105, based on the instance-level domain classifier corresponding to each target local feature extraction layer, perform feature extraction analysis on the second image feature information, and obtain a second domain classification result output by the instance-level domain classifier corresponding to each target local feature extraction layer; the second domain classification result is used to describe the probability value of the second image feature information belonging to the source domain or the target domain.
[0087] S3106, based on the first domain classification result and the first domain label, determine a first loss value of the image-level domain classifier, based on the second domain classification result and the second domain label, determine a second loss value of the instance-level domain classifier, and take the sum of the first loss value and the second loss value as a classification loss value of the domain classifier.
[0088] S3107, input the insulator image data of the source domain in the training set into the pre-trained YOLO model, obtain a defect prediction result, and determine a detection loss value of the pre-trained YOLO model based on the defect prediction result and the insulator image data of the source domain; the defect prediction result is a prediction label result of the pre-trained YOLO model in the insulator image data of the source domain.
[0089] S3108, determine the total number of features in the first image feature information processed by each image-level domain classifier, and determine a consistency loss based on the total number of features, the first domain classification result and the second domain classification result; the consistency loss is used to describe the prediction difference of the image-level domain classifier and the instance-level domain classifier for the same feature in the same insulator image data.
[0090] Specifically, the consistency loss is determined based on the total number of features, the first domain classification result and the second domain classification result, including: the consistency loss L is expressed by the following formula cst :
[0091]
[0092] Where, |I m | represents the total number of features in the first image feature information processed by the mth image-level domain classifier, represents the prediction probability value of the mth image-level domain classifier at position (x, y) in the ith insulator image data in the training set, i.e., the first domain classification result, p i,n represents the prediction probability value of the nth instance-level domain classifier in the ith insulator image data in the training set, i.e., the second domain classification result.
[0093] S3109, determine the target loss of the pre-trained model based on the classification loss value, the consistency loss and the detection loss value, when the target loss is greater than a preset loss value, update the pre-trained YOLO model corresponding to the target loss in the pre-trained model to the pre-trained YOLO model in the pre-trained model, continue to train the pre-trained model based on the training set, and when the target loss is greater than the preset loss value, the pre-trained YOLO model corresponding to the target loss of the pre-trained model when the target loss of the pre-trained model is less than or equal to the preset loss value is taken as the target YOLO model.
[0094] Specifically, the target loss of the pre-trained model is determined based on the classification loss value, the consistency loss and the detection loss value, which can be represented as:
[0095] L total =L det +λ1(L img +L ins )+λ2L cst ;
[0096] Wherein, λ1 and λ2 represent the weights of the classification loss value and the consistency loss value respectively.
[0097] As shown in Figure 4 When the target loss is greater than the preset loss value, the pre-trained YOLO model corresponding to the target loss is updated in the pre-trained model, that is, the model parameters are updated by back propagation, and the pre-trained model with updated network parameters is continuously trained based on the training set. When the target loss is greater than the preset loss value, the pre-trained YOLO model corresponding to the target loss of the pre-trained model is less than or equal to the preset loss value, and the target YOLO model is obtained.
[0098] S3110, obtain target insulator image data corresponding to a preset concentration of fog, and perform defect detection on the target insulator image data based on the target YOLO model to obtain an insulator defect detection result.
[0099] The embodiment technical scheme obtains a training set, performs feature extraction on insulator image data of a source domain based on each target global feature extraction layer in a pre-trained YOLO model, obtains first image feature information corresponding to the output of each target global feature extraction layer, performs feature extraction analysis on the first image feature information based on an image-level domain classifier corresponding to each target global feature extraction layer, and obtains a first domain classification result output by the image-level domain classifier corresponding to each target local feature extraction layer; performs feature extraction on insulator image data of a target domain based on each target local feature extraction layer in the pre-trained YOLO model, obtains second image feature information corresponding to the output of each target local feature extraction layer, performs feature extraction analysis on the second image feature information based on an instance-level domain classifier corresponding to each target local feature extraction layer, and obtains a second domain classification result output by the instance-level domain classifier corresponding to each target local feature extraction layer; further, a first loss value of the image-level domain classifier is determined based on the first domain classification result and a first domain label, a second loss value of the instance-level domain classifier is determined based on the second domain classification result and a second domain label, and a sum of the first loss value and the second loss value is taken as a classification loss value of the domain classifier. Insulator image data of the source domain in the training set is input into the pre-trained YOLO model, a defect prediction result is obtained, and a detection loss value of the pre-trained YOLO model is determined based on the defect prediction result and the insulator image data of the source domain. A total number of features in the first image feature information processed by each image-level domain classifier is determined, and a consistency loss is determined based on the total number of features, the first domain classification result and the second domain classification result; the consistency loss is used to describe the prediction difference of the same feature in the same insulator image data by the image-level domain classifier and the instance-level domain classifier. A target loss of the pre-trained model is determined based on the classification loss value, the consistency loss and the detection loss value, when the target loss is greater than a preset loss value, a pre-trained YOLO model corresponding to the target loss is updated to a pre-trained YOLO model in the pre-trained model, the pre-trained model is continuously trained based on the training set, and when the target loss is greater than the preset loss value, a pre-trained YOLO model corresponding to a case where the target loss of the pre-trained model is less than or equal to the preset loss value is taken as a target YOLO model. The addition of the three losses realizes the improvement of the accuracy of the target YOLO model, so that subsequent target insulator image data corresponding to a preset concentration of fog is obtained, defect detection is performed on the target insulator image data based on the target YOLO model, and an accurate insulator defect detection result can be obtained, the detection accuracy and efficiency of the insulator defect under the foggy weather condition are improved, and the operation safety and reliability of the power system are improved.
[0100] Embodiment four
[0101] Figure 5A structure diagram of a fog weather insulator defect detection device provided according to an embodiment of the present application, the embodiment can be applicable to the case of predicting insulator defects under fog weather conditions, the fog weather insulator defect detection device can be realized in the form of hardware and / or software, and the fog weather insulator defect detection device can be configured in any electronic device with network communication function.
[0102] As shown in Figure 5 , the fog weather insulator defect detection device of the present application comprises:
[0103] The training set acquisition module 410 is configured to acquire a training set, the training set comprising a source domain and a target domain, the source domain being a set of insulator image data with defect labels under sunny conditions, and the target domain being a set of insulator image data without defect labels under fog weather conditions of a preset density.
[0104] The training module 420 is configured to train a pre-training model based on the training set to obtain a target YOLO model; the pre-training model being composed of a pre-training YOLO model and a domain classifier; the target YOLO model being a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value, and the domain classifier being configured to predict a domain classification result of image feature information; the image feature information being feature information from global to local extracted from insulator image data in the training set based on the pre-training YOLO model, and the domain classification result being used to describe a probability value of the image feature information belonging to the source domain or the target domain.
[0105] The prediction module 430 is configured to acquire target insulator image data corresponding to fog of a preset density, and perform defect detection on the target insulator image data based on the target YOLO model to obtain an insulator defect detection result.
[0106] On the basis of the above embodiment, optionally, the training set acquisition module is configured to: acquire first insulator image data, mark defects and a first domain label on the first insulator image data to obtain marked first insulator image data, and group the marked first insulator image data to form the source domain; the first insulator image data being insulator image data under sunny conditions, and the first domain label being 0; acquire second insulator image data, mark a second domain label on the second insulator image data to obtain marked second insulator image data, and group the marked second insulator image data to form the source domain; the second insulator image data being insulator image data under fog weather conditions of a preset density, and the second domain label being 1.
[0107] On the basis of the above-mentioned embodiment, optionally, the domain classifier comprises at least one image-level domain classifier and at least one instance-level domain classifier, the image-level domain classifier is used to process feature distribution differences of insulator image data on a global image level, and the instance-level domain classifier is used to process feature distribution differences of insulator image data on a local image level, the image-level domain classifier is composed of a gradient reversal layer, a convolution layer, a batch normalization layer and an activation function, and the instance-level domain classifier is composed of a gradient reversal layer, a fully connected layer, an activation function and a Dropout layer.
[0108] The pre-trained YOLO model comprises a feature extractor, the feature extractor comprises at least one global feature extraction layer and at least one local feature extraction layer, the local feature extraction layer is located behind all the global feature extraction layers and is used to further extract features output from the global feature extraction layer, and the pre-trained YOLO model is also used to predict and mark defect features in insulator image data.
[0109] The number of the global feature extraction layers is greater than or equal to the number of the image-level domain classifiers, and the number of the local feature extraction layers is greater than or equal to the number of the instance-level domain classifiers.
[0110] On the basis of the above-mentioned embodiment, optionally, the training module comprises a selection unit, the selection unit is used to: select a first preset number of global feature extraction layers from the at least one global feature extraction layer as target global feature extraction layers, and select a second preset number of local feature extraction layers from the at least one local feature extraction layer as target local feature extraction layers; one target global feature extraction layer corresponds to one image-level domain classifier, and one target local feature extraction layer corresponds to one instance-level domain classifier.
[0111] On the basis of the above-mentioned embodiment, optionally, the training module comprises a first training unit, the first training unit is used to:
[0112] Based on each target global feature extraction layer in the pre-trained YOLO model, feature extraction is performed on insulator image data of the source domain, and first image feature information corresponding to output of each target global feature extraction layer is obtained; the first image feature information is marked with a first domain label;
[0113] Based on the image-level domain classifier corresponding to each target global feature extraction layer, feature extraction analysis is performed on the first image feature information, and a first domain classification result output by the image-level domain classifier corresponding to each target local feature extraction layer is obtained; the first domain classification result is used to describe a probability value of the first image feature information belonging to the source domain or the target domain;
[0114] The insulator image data of the target domain is feature-extracted based on each target local feature extraction layer in the pre-trained YOLO model, and second image feature information corresponding to the output of each target local feature extraction layer is obtained; the second image feature information is marked with a second domain label;
[0115] The second image feature information is feature-extracted and analyzed based on the instance-level domain classifier corresponding to each target local feature extraction layer, and a second domain classification result output by the instance-level domain classifier corresponding to each target local feature extraction layer is obtained; the second domain classification result is used to describe a probability value of the second image feature information belonging to the source domain or the target domain;
[0116] A first loss value of the image-level domain classifier is determined based on the first domain classification result and the first domain label, a second loss value of the instance-level domain classifier is determined based on the second domain classification result and the second domain label, and a sum of the first loss value and the second loss value is taken as a classification loss value of the domain classifier;
[0117] The insulator image data of the source domain in the training set is input into the pre-trained YOLO model, a defect prediction result is obtained, and a detection loss value of the pre-trained YOLO model is determined based on the defect prediction result and the insulator image data of the source domain; the defect prediction result is a prediction marking result of the pre-trained YOLO model in the insulator image data of the source domain;
[0118] A target loss of the pre-trained model is determined based on the classification loss value and the detection loss value; when the target loss is greater than a preset loss value, a pre-trained YOLO model corresponding to the target loss is updated to a pre-trained YOLO model in the pre-trained model, the pre-trained model is continuously trained based on the training set, and when the target loss is greater than the preset loss value, a pre-trained YOLO model corresponding to a case where the target loss of the pre-trained model is less than or equal to the preset loss value is taken as the target YOLO model.
[0119] On the basis of the above-mentioned embodiments, the first loss value L of the image-level domain classifier can be represented by the following formula: img :
[0120]
[0121] wherein D i represents a domain label of the i-th insulator image data in the training set, the domain label includes a first domain label and a second domain label, represents a prediction probability value of the m-th image-level domain classifier at the position (x, y) in the i-th insulator image data in the training set, that is, a first domain classification result.
[0122] Correspondingly, the first loss value L of the instance-level domain classifier is expressed by the following formula ins :
[0123]
[0124] wherein D i represents the domain label of the i-th insulator image data in the training set, the domain label includes the first domain label and the second domain label, p i,n represents the prediction probability value of the i-th insulator image data in the training set in the n-th instance-level domain classifier, that is, the second domain classification result.
[0125] On the basis of the above-mentioned embodiments, optionally, the training module comprises a second training unit, and the second training unit is configured to:
[0126] determine the total number of features in the first image feature information processed by each of the image-level domain classifiers;
[0127] based on the total number of features, the first domain classification result and the second domain classification result, determine a consistency loss; the consistency loss is used to describe the prediction difference of the image-level domain classifier and the instance-level domain classifier for the same feature in the same insulator image data;
[0128] based on the classification loss value, the consistency loss and the detection loss value, determine a target loss of the pre-training model, when the target loss is greater than a preset loss value, update the pre-training YOLO model corresponding to the target loss in the pre-training model to a pre-training YOLO model in the pre-training model, continue to train the pre-training model based on the training set, until the target loss is greater than the preset loss value, the pre-training YOLO model corresponding to the target loss of the pre-training model when the target loss is less than or equal to the preset loss value is used as the target YOLO model.
[0129] The fog insulator defect detection device provided in the embodiments of the present application can execute the fog insulator defect detection method provided in any of the embodiments of the present application, and has the corresponding functional modules and beneficial effects of the execution method.
[0130] Embodiment five
[0131] According to the embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0132] Figure 6A structural diagram of an electronic device that can be used to implement the foggy insulator defect detection method of embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices such as personal digital processors, cellular telephones, smart phones, wearable devices (e.g., headsets, glasses, watches, etc.), and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present application described and / or claimed in this document.
[0133] As shown in Figure 6 The electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., connected in communication with the at least one processor 11, where the memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer programs stored in the read-only memory (ROM) 12 or loaded into the random access memory (RAM) 13 from the storage unit 18. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0134] Various components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc., an output unit 17, such as various types of displays, a speaker, etc., a storage unit 18, such as a magnetic disk, an optical disk, etc., and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0135] The processor 11 can be various general and / or special purpose processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the foggy insulator defect detection method.
[0136] In some embodiments, the foggy day insulator defect detection method can be implemented as a computer program tangibly embodied in a computer readable storage medium, e.g., storage unit 18. In some embodiments, parts or all of the computer program can be loaded and / or installed onto electronic device 10 via, e.g., ROM 12 and / or communication unit 19. When the computer program is loaded onto RAM 13 and executed by processor 11, one or more steps of the foggy day insulator defect detection method described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to perform the foggy day insulator defect detection method by other means, e.g., with the aid of firmware.
[0137] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a complex programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0138] Computer programs used to implement the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the computer program, when executed by the processor, implements the functions / acts specified in the flowcharts and / or block diagrams. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as part of a standalone software package, partially on a machine and partially on a remote machine or entirely on a remote machine or server.
[0139] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0140] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0141] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0142] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0143] It should be understood that the various forms of flow shown above can be reordered, added to, or have steps deleted. For example, the steps described in the present application can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, which are not limited herein.
[0144] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for detecting defects of a fog insulator, characterized by, The method comprises: obtaining a training set, the training set comprising a source domain and a target domain, the source domain being a set of defective marked insulator image data under sunny conditions, and the target domain being a set of non-defective marked insulator image data under a preset concentration of foggy conditions; training a pre-training model based on the training set to obtain a target YOLO model; the pre-training model is composed of a pre-training YOLO model and a domain classifier; the target YOLO model is a pre-training YOLO model corresponding to a target loss of the pre-training model being less than or equal to a preset loss value, and the domain classifier is used for predicting a domain classification result of image feature information; the image feature information is feature information from global to local extracted from insulator image data in the training set based on the pre-training YOLO model, and the domain classification result is used for describing a probability value of the image feature information belonging to the source domain or the target domain; obtaining target insulator image data corresponding to a preset concentration of fog, and performing defect detection on the target insulator image data based on the target YOLO model to obtain an insulator defect detection result; wherein the domain classifier comprises at least one image-level domain classifier and at least one instance-level domain classifier, the image-level domain classifier is used for processing feature distribution differences of insulator image data at a global image level, and the instance-level domain classifier is used for processing feature distribution differences of insulator image data at a local image level; the image-level domain classifier is composed of a gradient reversal layer, a convolution layer, a batch normalization layer and an activation function, and the instance-level domain classifier is composed of a gradient reversal layer, a fully connected layer, an activation function and a Dropout layer; the pre-training YOLO model comprises a feature extractor, the feature extractor comprises at least one global feature extraction layer and at least one local feature extraction layer, the local feature extraction layer is located behind all global feature extraction layers and is used for further feature extraction on features output from the global feature extraction layer; and the pre-training YOLO model is also used for predicting defect features in insulator image data; the number of global feature extraction layers is greater than or equal to the number of image-level domain classifiers, and the number of local feature extraction layers is greater than or equal to the number of instance-level domain classifiers; wherein, before training the pre-training model based on the training set to obtain the target YOLO model, the method comprises: selecting a first preset number of global feature extraction layers from the at least one global feature extraction layer as target global feature extraction layers, and selecting a second preset number of local feature extraction layers from the at least one local feature extraction layer as target local feature extraction layers; one target global feature extraction layer corresponds to one image-level domain classifier, and one target local feature extraction layer corresponds to one instance-level domain classifier.
2. The method of claim 1, wherein, obtaining a training set, comprising: obtain the first insulator image data, mark defects and first domain label of the first insulator image data to obtain the first insulator image data after marking, and group the first insulator image data after marking to form the source domain; the first insulator image data is insulator image data under sunny conditions, and the first domain label is 0; obtain the second insulator image data, mark the second domain label of the second insulator image data to obtain the second insulator image data after marking, and group the second insulator image data after marking to form the source domain; the second insulator image data is insulator image data under a preset density of foggy conditions, and the second domain label is 1.
3. The method of claim 1, wherein, training the pre-training model based on the training set to obtain a target YOLO model, comprising: based on each of the target global feature extraction layers in the pre-training YOLO model, extracting features of the insulator image data of the source domain to obtain first image feature information corresponding to the output of each target global feature extraction layer; the first image feature information is marked with a first domain label; based on the image-level domain classifier corresponding to each of the target global feature extraction layers, performing feature extraction analysis on the first image feature information to obtain a first domain classification result output by the image-level domain classifier corresponding to each target local feature extraction layer; the first domain classification result is used to describe the probability value of the first image feature information belonging to the source domain or the target domain; based on each target local feature extraction layer in the pre-training YOLO model, extracting features of the insulator image data of the target domain to obtain second image feature information corresponding to the output of each target local feature extraction layer; the second image feature information is marked with a second domain label; based on the instance-level domain classifier corresponding to each of the target local feature extraction layers, performing feature extraction analysis on the second image feature information to obtain a second domain classification result output by the instance-level domain classifier corresponding to each target local feature extraction layer; the second domain classification result is used to describe the probability value of the second image feature information belonging to the source domain or the target domain; based on the first domain classification result and the first domain label, determining a first loss value of the image-level domain classifier, based on the second domain classification result and the second domain label, determining a second loss value of the instance-level domain classifier, and taking the sum of the first loss value and the second loss value as a classification loss value of the domain classifier; input the insulator image data of the source domain in the training set into the pre-training YOLO model to obtain a defect prediction result, and determine a detection loss value of the pre-training YOLO model based on the defect prediction result and the insulator image data of the source domain; the defect prediction result is a predicted marking result of the pre-training YOLO model in the insulator image data of the source domain; determine a target loss of the pre-training model based on the classification loss value and the detection loss value, when the target loss is greater than a preset loss value, update a pre-training YOLO model corresponding to the target loss in the pre-training model, continue to train the pre-training model based on the training set, and when the target loss is greater than the preset loss value, use a pre-training YOLO model corresponding to a case where the target loss of the pre-training model is less than or equal to the preset loss value as the target YOLO model.
4. The method of claim 3, wherein, determine a first loss value of the image-level domain classifier based on the first domain classification result and the first domain label, including: The first loss value of the image-level domain classifier is expressed by the following formula : ; wherein, represents a domain label of the i-th insulator image data in the training set, the domain label including a first domain label and a second domain label, represents a predicted probability value of the m-th image-level domain classifier at a position of the i-th insulator image data in the training set , i.e. a first domain classification result. correspondingly, determine a second loss value of the instance-level domain classifier based on the second domain classification result and the second domain label, including: The first loss value of the instance-level domain classifier is expressed by the following formula : ; wherein, represents the domain label of the i-th insulator image data in the training set, and the domain label includes a first domain label and a second domain label, represents a predicted probability value of the i-th insulator image data in the training set at the n-th instance-level domain classifier, i.e., a second domain classification result.
5. The method according to claim 3 or 4, characterized in that, train a pre-training model based on the training set to obtain a target YOLO model, including: determine a total number of features in the first image feature information processed by each image-level domain classifier; determine a consistency loss based on the total number of features, the first domain classification result and the second domain classification result; the consistency loss is used to describe the prediction difference of the same feature in the same insulator image data by the image-level domain classifier and the instance-level domain classifier; determine a target loss of the pre-training model based on the classification loss value and the detection loss value, when the target loss is greater than a preset loss value, update a pre-training YOLO model corresponding to the target loss in the pre-training model, continue to train the pre-training model based on the training set, and when the target loss is greater than the preset loss value, use a pre-training YOLO model corresponding to a case where the target loss of the pre-training model is less than or equal to the preset loss value as the target YOLO model.
6. A device for detecting defects of a fog insulator, characterized by comprising: The device comprises: a training set acquisition module configured to acquire a training set, the training set comprising a source domain and a target domain, the source domain being a set of insulator image data with defect labels under sunny conditions, and the target domain being a set of insulator image data without defect labels under a preset density of foggy conditions; a training module configured to train a pre-training model based on the training set to obtain a target YOLO model; the pre-training model is composed of a pre-training YOLO model and a domain classifier; the target YOLO model is a pre-training YOLO model corresponding to a case where a target loss of the pre-training model is less than or equal to a preset loss value; the domain classifier is used to predict a domain classification result of image feature information; the image feature information is feature information from global to local extracted from insulator image data in the training set based on the pre-training YOLO model; and the domain classification result is used to describe a probability value of the image feature information belonging to the source domain or the target domain; a prediction module configured to acquire target insulator image data corresponding to a preset density of fog, perform defect detection on the target insulator image data based on the target YOLO model, and obtain an insulator defect detection result. The domain classifier comprises at least one image-level domain classifier and at least one instance-level domain classifier, the image-level domain classifier is used for processing feature distribution differences of insulator image data on a global image level, and the instance-level domain classifier is used for processing feature distribution differences of insulator image data on a local image level; the image-level domain classifier comprises a gradient reversal layer, a convolution layer, a batch normalization layer and an activation function; and the instance-level domain classifier comprises a gradient reversal layer, a full connection layer, an activation function and a Dropout layer. The pre-trained YOLO model comprises a feature extractor, the feature extractor comprises at least one global feature extraction layer and at least one local feature extraction layer, the local feature extraction layer is located behind all global feature extraction layers and is used for further feature extraction on features output from the global feature extraction layer; and the pre-trained YOLO model is also used for predicting and marking defect features in insulator image data. The number of the global feature extraction layers is greater than or equal to the number of the image-level domain classifiers, and the number of the local feature extraction layers is greater than or equal to the number of the instance-level domain classifiers. The training module comprises a selection unit, the selection unit is used for selecting a first preset number of global feature extraction layers from the at least one global feature extraction layer as target global feature extraction layers and selecting a second preset number of local feature extraction layers from the at least one local feature extraction layer as target local feature extraction layers; one target global feature extraction layer corresponds to one image-level domain classifier, and one target local feature extraction layer corresponds to one instance-level domain classifier.
7. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected with the at least one processor in communication; wherein the memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the insulator defect detection method in any one of claims 1-5.
8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions, and the computer instructions are used to enable the processor to execute the insulator defect detection method in any one of claims 1-5 when executed.
Citation Information
Patent Citations
Injection molding product surface image defect identification method based on transfer learning
CN110111297A
Image detection model training method and device and image detection method
CN115331097A