Training of reflection erasing network and reflection erasing method, device and equipment thereof
Through the training and application of the reflective erasure network, the problem of unclear surface detection of highly reflective workpieces is solved, and the accurate erasure of reflective areas and the accuracy of defect detection are improved.
Patent Information
- Application Number
- CN202311154540.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-07
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2043-09-07
AI Technical Summary
In industrial manufacturing, the surface of workpieces made of highly reflective materials is seriously reflective, resulting in unclear defect detection results and affecting detection accuracy and success rate.
The reflective erasure network is used to establish the mapping relationship between the original reflective image and the non-reflective image of the reflective workpiece through the combined network structure of the generator and the discriminator. The trained network is used to generate the non-reflective image, thereby realizing the reflection area Erase accurately.
It improves the accuracy of defect detection on the surface of highly reflective workpieces, reduces false detections and missed detections, and enhances the detection success rate.
Smart Images

Figure CN117333382B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of deep learning technology, and in particular to a reflection erasing network training and a reflection erasing method, device and equipment thereof. Background Art
[0002] In industrial manufacturing, high-gloss materials are often used to process workpieces with a certain degree of flatness and clear surface texture. Most of these workpieces usually have a relatively smooth surface, and a light source is usually required to fill in the workpiece with light when performing surface inspection. However, some workpieces have not only smooth surfaces, but also highly reflective properties, which makes the surface of the acquired image reflective, resulting in unclear defective surfaces of the workpiece, and it is impossible to obtain the details of the reflective parts of the workpiece in the image. This will affect the extraction of defect features of the object being tested, resulting in false detection and missed detection in the defect detection results, reducing the success rate of surface defect detection of such workpieces, and causing great difficulties in defect detection of workpieces.
[0003] Therefore, further solutions are still needed to remove the reflections from such workpieces in order to accurately detect surface defects. Summary of the invention
[0004] Multiple aspects of the present application provide a reflective erasing network training and a reflective erasing method, device and equipment thereof, which are used to solve the problem of low success rate of defect detection of workpieces with reflective characteristics.
[0005] The embodiment of the present application provides a training method for a reflective erasure network, comprising: obtaining original reflective images of a plurality of reflective workpieces under a plurality of different imaging effects, and original non-reflective images of the plurality of reflective workpieces; establishing a mapping relationship between the original reflective image and the original non-reflective image of each of the plurality of reflective workpieces to obtain a reflective erasure network training set; based on the reflective erasure network training set, training a reflective erasure network, wherein the reflective erasure network comprises a first generator, a second generator, a first discriminator, and a second discriminator, wherein the first generator is connected to the first discriminator, and the second generator is connected to the second discriminator, wherein the original reflective image of each of the plurality of reflective workpieces is used as an input of the first generator, and the original non-reflective image of each of the plurality of reflective workpieces is used as an input of the second generator; wherein the network of the first generator The network module of the first discriminator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate a non-reflective image of the input reflective workpiece based on the original reflective image of the input reflective workpiece, and the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece; the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece.
[0006] The embodiment of the present application also provides a reflection erasing method, comprising: obtaining a target workpiece image to be reflection-erased; inputting the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is trained based on multiple reflection images and corresponding reflection area annotations; based on the reflection erasing network and the reflection detection result of the target workpiece image, performing a reflection erasing operation on the target workpiece image to obtain the target workpiece image after reflection erasure, wherein the reflection erasing network is trained based on a training method for a reflection erasing network.
[0007] The embodiment of the present application also provides a training device for a reflective erasure network, comprising: an image acquisition module, used to acquire original reflective images of multiple reflective workpieces under multiple different imaging effects, and original non-reflective images of the multiple reflective workpieces; a relationship establishment module, used to establish a mapping relationship between the original reflective image and the original non-reflective image of each reflective workpiece in the multiple reflective workpieces, so as to obtain a reflective erasure network training set; a network training module, used to train a reflective erasure network based on the reflective erasure network training set, the reflective erasure network comprising a first generator, a second generator, a first discriminator and a second discriminator, the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, the original reflective image of each reflective workpiece in the multiple reflective workpieces is used as an input of the first generator, and the original non-reflective image of each reflective workpiece in the multiple reflective workpieces is used as an output of the second generator. input; wherein, the network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate a non-reflective image of the input reflective workpiece based on the original reflective image of the input reflective workpiece, and the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece; the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece.
[0008] The embodiment of the present application also provides a reflection erasing device, comprising: an image acquisition module, used to acquire a target workpiece image to be reflection-erased; a reflection detection module, used to input the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is obtained by training based on multiple reflection images and corresponding reflection area annotations; a reflection erasing module, used to perform a reflection erasing operation on the target workpiece image based on the reflection erasing network and the reflection detection result of the target workpiece image to obtain the target workpiece image after reflection erasure, wherein the reflection erasing network is obtained by training based on a training method for a reflection erasing network.
[0009] An embodiment of the present application also provides an electronic device, comprising: a memory and a processor; the memory is used to store a computer program; the processor is coupled to the memory and is used to execute the computer program to implement a training method such as a reflective erasure network or steps in a reflective erasure method.
[0010] An embodiment of the present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor implements a training method for a reflective erasure network or steps in a reflective erasure method.
[0011] The training method of the reflection erasure network provided in the embodiment of the present application can obtain original reflection images of multiple reflective workpieces under multiple different imaging effects, and original non-reflection images of multiple reflective workpieces; then establish a mapping relationship between the original reflection image and the original non-reflection image of each reflective workpiece in the multiple reflective workpieces to obtain a reflection erasure network training set; finally, based on the reflection erasure network training set for which the mapping relationship between the original reflection image and the original non-reflection image of each reflective workpiece is established, a reflection erasure network is obtained by training, and the reflection erasure network includes a first generator, a second generator, and a third generator. A discriminator and a second discriminator, a first generator is connected to the first discriminator, the second generator is connected to the second discriminator, an original reflective image of each of a plurality of reflective workpieces is used as input to the first generator, and an original non-reflective image of each of a plurality of reflective workpieces is used as input to the second generator; wherein the network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier. Since the first generator is used to generate a non-reflective image of the input reflective workpiece based on the original reflective image of the input reflective workpiece, the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece, and the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece, it is obvious that the result of the first discriminator can be used to optimize the network parameters of the first generator, and the result of the second discriminator can be used to optimize the network parameters of the second generator, and the output result of the first generator is used as the input of the first discriminator, and the output result of the second generator is used as the input of the second discriminator, so that the first discriminator and the first generator can improve each other, and the second discriminator and the second generator can improve each other. The reflective erasure network trained in this way can accurately erase the reflective area, and defect detection on the workpiece image with the reflective area erased can improve the accuracy of defect detection.
[0012] The reflective erasing method provided in the embodiment of the present application can obtain the target workpiece image to be reflectively erased, and input the target workpiece image into the reflective detection network to output the reflective detection result in the target workpiece image. The reflective detection network is obtained by training based on multiple reflective images and corresponding reflective area annotations. Finally, based on the reflective erasing network and the reflective detection result of the target workpiece image, the reflective erasing operation is performed on the target workpiece image to obtain the target workpiece image after the reflective erasure. The reflective erasing network is obtained by training based on the training method of the reflective erasing network. Since the reflective detection network and the reflective erasing network can be combined to detect the reflective area of the workpiece image with reflection and erase the reflective area, on this basis, the surface image of the workpiece with high reflective material is subjected to defect detection, which can greatly improve the accuracy of defect detection on the workpiece surface. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0014] Figure 1 A flowchart of a method for training a reflective erasing network provided for an exemplary embodiment of the present application;
[0015] Figure 2 A schematic diagram of the structure of a reflective erasing network provided in an embodiment of the present application;
[0016] Figure 3 A schematic diagram of the structure of a first generator and a second generator provided in an embodiment of the present application;
[0017] Figure 4 A schematic diagram of the structure of the first discriminator and the second discriminator provided in an embodiment of the present application;
[0018] Figure 5 A schematic diagram of a process of a reflective erasing method provided in an embodiment of the present application;
[0019] Figure 6 A schematic diagram of the structure of a reflective detection network provided in an embodiment of the present application;
[0020] Figure 7 A schematic diagram of the effect of applying a reflective erasing method provided by an exemplary embodiment of the present application to an actual scene;
[0021] Figure 8 A schematic diagram of a training device for a reflective erasing network provided for an exemplary embodiment of the present application;
[0022] Fig. 9A schematic diagram of a reflective erasing device provided for an exemplary embodiment of the present application;
[0023] Fig.10 A schematic structural diagram of an electronic device provided for an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0025] In order to solve the problem of low success rate of defect detection of workpieces with reflective characteristics, a training method of a reflective erasure network and a reflective erasure method thereof are provided in some embodiments of the present application. The reflective area can be detected in combination with the reflective detection network, and the reflective erasure network for accurately erasing the reflective area can be trained, and finally, defect detection can be performed on the workpiece image with the reflective area erased, so as to improve the accuracy of its defect detection.
[0026] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0027] Figure 1 A flow chart of a method for training a reflective erasure network provided by an exemplary embodiment of the present application. Figure 1 As shown, the method includes:
[0028] Step 110 , obtaining original reflective images of a plurality of reflective workpieces under a plurality of different imaging effects, and original non-reflective images of a plurality of reflective workpieces.
[0029] The number of original reflective images of each of the multiple reflective workpieces under multiple different imaging effects may be multiple, and each original reflective image may correspond to an original non-reflective image of the reflective workpiece. The original reflective images of each reflective workpiece may be placed in a set named source domain, and the original non-reflective images of each reflective workpiece may be placed in a set named target domain.
[0030] Step 120 , establishing a mapping relationship between an original reflective image and an original non-reflective image of each reflective workpiece among the plurality of reflective workpieces, so as to obtain a reflection erasing network training set.
[0031] It can be understood that the reflection erasure network training set may include multiple groups of reflection erasure data, and each group of reflection erasure data may include a combination of an original reflection image of a reflective workpiece and an original non-reflection image of the reflective workpiece.
[0032] Step 130, based on the reflective erasure network training set, train a reflective erasure network, the reflective erasure network includes a first generator, a second generator, a first discriminator and a second discriminator, the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, the original reflective image of each reflective workpiece among the multiple reflective workpieces is used as an input of the first generator, and the original non-reflective image of each reflective workpiece among the multiple reflective workpieces is used as an input of the second generator.
[0033] Among them, the network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate an input reflective workpiece non-reflective image based on the input reflective workpiece original reflective image, and the first discriminator is used to determine the similarity between the input reflective workpiece non-reflective image generated by the first generator module and the original non-reflective image of the input reflective workpiece; the second generator is used to generate an input reflective image of the reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the input reflective image of the reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece.
[0034] Figure 2 The structure diagram of the reflective erasing network provided in the embodiment of the present application includes a first generator G s→t and the second generator G t→s And the first discriminator D t and the second discriminator D s Among them, the first generator G s→t Used to generate a non-reflective image of the reflective workpiece based on the input original reflective image X of the reflective workpiece The first discriminator D t For determining the first generator module G s→t Generates a non-reflective image of a reflective workpiece The similarity between the original non-reflective image Y of the reflective workpiece; the second generator G t→s Used to generate a reflective image of the reflective workpiece based on the original non-reflective image Y of the reflective workpiece The second discriminator D s For determining the second generator module G t→s Generated reflective image of reflective workpiece The similarity between the original reflective image X of the reflective workpiece.
[0035] Figure 3 A schematic diagram of the structure of the first generator and the second generator provided in the embodiment of the present application. s→ and the second generator G t→s The structure is as Figure 3 As shown in Figure 2. Both generators are composed of three parts: encoder, auxiliary classifier and decoder. The encoder is used to downsample the input image and perform feature encoding operation through the image feature extraction module to obtain the encoded feature map ( Figure 3 shown in is the data of the first channel on the encoding feature map, is the data of the nth channel on the encoding feature map), the auxiliary classifier is used to generate a high semantic vector based on the encoding feature map to obtain the attention feature map ( Figure 3 shown in is the data of the first channel on the attention feature map, is the data of the nth channel on the attention feature map), the decoder is used to decode the attention feature map to obtain the image to be output, and upsample the image to be output to obtain the output image, wherein the decoder is composed of a fully connected layer and an adaptive image feature extraction network. Among them, the size of the output image is consistent with the size of the input image, the size of the image to be output is consistent with the size of the image after the input image is downsampled, and the size of the image to be output is smaller than the size of the output image and the input image, which is used to reduce the amount of calculation of the generator network on the input image. Among them, the auxiliary classifier module is used to determine the importance measure of each channel in the encoded feature map, and the available weights w1~w n To represent, where w1 is the weight of the first channel in the encoding feature map, w n is the weight of the nth channel in the encoded feature map. Figure 3 The attention feature map shown It is obtained based on the weight of each channel in the encoding feature map and the weighted data of each channel in the encoding feature map.
[0036] Among them, the auxiliary classifier is used to generate a channel importance measure that focuses on more important regions and ignores minor regions. Specifically, the auxiliary classifier uses global pooling and max-pooling to learn the weight w of the kth channel data of the feature map in the source domain k , weight w k It determines the importance of the feature data of the channel and implements the attention mechanism under the feature map.
[0037] Figure 4 Schematic diagram of the structure of the first discriminator and the second discriminator provided in the embodiment of the present application. Both discriminators are composed of an encoder and an auxiliary classifier. The encoder is used to perform downsampling operations on the input image (the original non-reflective image of the target workpiece image and the non-reflective image of the target workpiece image, the non-reflective image is generated by the first generator) and perform feature encoding operations through the image feature extraction network to obtain a coded feature map ( Figure 4 shown in is the data of the first channel on the encoding feature map, is the data of the nth channel on the encoding feature map), the auxiliary classifier is used to generate a high semantic vector based on the encoding feature map to obtain the attention feature map ( Figure 4 shown in is the data of the first channel on the attention feature map, is the data of the nth channel on the attention feature map), and finally the attention feature map is regressed and fitted by the regression module logit to obtain the similarity between the input images (i.e., the original non-reflective image of the target artifact image and the non-reflective image of the target artifact image).
[0038] In some exemplary embodiments, based on the reflection erasure network training set, the reflection erasure network is trained, including:
[0039] An original reflective image and an original non-reflective image of a target workpiece are randomly selected from a reflective removal dataset, where the target workpiece is any one of multiple reflective workpieces;
[0040] Taking the original reflective image of the target workpiece as an input of a first generator, so as to generate a non-reflective image of the target workpiece based on the original reflective image of the target workpiece by the first generator, and taking the original non-reflective image of the target workpiece as an input of a second generator, so as to generate a reflective image of the target workpiece based on the original non-reflective image of the target workpiece by the second generator;
[0041] Using the original reflected image of the target workpiece and the reflected image of the target workpiece as inputs of a first discriminator to determine a first similarity between the original reflected image of the target workpiece and the reflected image of the target workpiece by the first discriminator, and using the original non-reflection image of the target workpiece and the non-reflection image of the target workpiece as inputs of a second discriminator to determine a second similarity between the original non-reflection image of the target workpiece and the non-reflection image of the target workpiece by the second discriminator;
[0042] Optimizing network parameters of the network modules of the first generator and the second generator based on the first similarity and the second similarity;
[0043] According to the preset training rounds, the steps of randomly selecting an original reflective image and an original non-reflective image of a target workpiece from the reflection removal dataset to optimizing the network parameters of the network modules of the first generator and the second generator are repeated to train a reflection erasure network.
[0044] Among them, the generator (the first generator or the second generator) will learn its corresponding transformation function by minimizing the loss, and the loss of the first generator or the second generator is calculated by measuring the difference between the data generated by the generator (the first generator or the second generator) and the target data. Taking the first generator as an example, the data generated by the first generator is a non-reflection image of the target workpiece, and the target data of the first generator is the original non-reflection image of the target workpiece, then the difference between the non-reflection image of the target workpiece and the original non-reflection image of the target workpiece can be used as the loss of the first generator. Taking the second generator as an example, the data generated by the second generator is a reflective image of the target workpiece, and the target data of the first generator is the original reflective image of the target workpiece, then the difference between the reflective image of the target workpiece and the original reflective image of the target workpiece can be used as the loss of the second generator. The greater the difference between the data generated by the generator (the first generator or the second generator) and the target data, the higher the penalty the generator will receive. The loss of the discriminator (the first discriminator or the second discriminator) is also used to train the discriminator, so that the first discriminator can be good at distinguishing between real data (i.e., the original non-reflective image of the target workpiece) and synthetic data (i.e., the non-reflective image of the target workpiece generated by the first generator), and the second discriminator can be good at distinguishing between real data (i.e., the original reflective image of the target workpiece) and synthetic data (i.e., the reflective image of the target workpiece generated by the second generator). Obviously, the generation result of the first generator can be used as the input of the first discriminator for training the first discriminator, and the result of the first discriminator is used to optimize the first generator; the generation result of the second generator is used as the input of the second discriminator for training the second discriminator, and the result of the second discriminator is used to optimize the second generator. That is, the first generator and the first discriminator can improve each other, and the second generator and the second discriminator can also improve each other.
[0045] The training method of the reflective erasure network provided in the embodiment of the present application can obtain original reflective images of multiple reflective workpieces under multiple different imaging effects, and original non-reflective images of multiple reflective workpieces; then establish a mapping relationship between the original reflective image and the original non-reflective image of each reflective workpiece in the multiple reflective workpieces to obtain a reflective erasure network training set; finally, based on the reflective erasure network training set with the established mapping relationship between the original reflective image and the original non-reflective image of each reflective workpiece, train to obtain a reflective erasure network, the reflective erasure network comprising a first generator, a second generator, a first discriminator and a second discriminator, the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, the original reflective image of each reflective workpiece in the multiple reflective workpieces is used as an input of the first generator, and the original non-reflective image of each reflective workpiece in the multiple reflective workpieces is used as an input of the second generator; wherein the network module of the first generator, the network module of the second generator, the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder, an auxiliary classifier and a decoder. Since the first generator is used to generate a non-reflective image of the input reflective workpiece based on the original reflective image of the input reflective workpiece, the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece, and the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece, it is obvious that the result of the first discriminator can be used to optimize the network parameters of the first generator, and the result of the second discriminator can be used to optimize the network parameters of the second generator, and the output result of the first generator is used as the input of the first discriminator, and the output result of the second generator is used as the input of the second discriminator, so that the first discriminator and the first generator can improve each other, and the second discriminator and the second generator can improve each other. The reflective erasure network trained in this way can accurately erase the reflective area, and defect detection on the workpiece image with the reflective area erased can improve the accuracy of defect detection.
[0046] Figure 6 The following is a flow chart of a reflective erasing method provided by an exemplary embodiment of the present application. Figure 6 As shown, the method includes:
[0047] Step 510, obtaining an image of a target workpiece to be erased.
[0048] Step 520 , input the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is trained based on a plurality of reflection images and corresponding reflection area annotations.
[0049] In some exemplary embodiments, the process of constructing a reflective detection network includes:
[0050] Acquire a plurality of reflective images, where the plurality of reflective images are images of a plurality of reflective workpieces under a plurality of different imaging effects;
[0051] Performing pixel-level mask annotation on the multiple reflective images to obtain pixel-level mask annotations of the multiple reflective images;
[0052] A reflective detection network is trained based on multiple reflective images, pixel-level mask annotations of multiple reflective images, and a preset loss function. The preset loss function is constructed based on the cross entropy loss, the Dice loss, a set similarity function of the two sub-networks, and coefficients corresponding to the Dice losses of the two sub-networks.
[0053] In some exemplary embodiments, in order to reduce the complexity of the reflective detection network and improve the efficiency of reflective detection, the reflective detection network is constructed based on the target detection network MobileNetV3-Small. The reflective detection network includes the first 10 layers of the network structure of MobileNetV3-Small, and the reflective detection network achieves upsampling through linear interpolation; moreover, in order to improve the training effect, the reflective detection network guides the training process of the reflective detection network by adding auxiliary segmentation heads and corresponding losses during training, thereby guiding the reflective detection network to learn more useful feature representations. The operation of adding the auxiliary segmentation head is only performed during the training process of the reflective detection network, and therefore does not affect the detection speed of the reflective detection network.
[0054] Specifically, Figure 6 A schematic diagram of the training and prediction process of the reflective detection network provided in the embodiment of the present application, in Figure 6In the figure, the reflective detection network consists of a semantic network, a segmentation head, an auxiliary segmentation head and a loss function, wherein the semantic network is the backbone network of the reflective detection network. The backbone network retains the first ten layers of the MobileNetV3-Small network structure. The feature map size output by the last convolutional layer of the network is downsampled 16 times compared to the original input image, that is, 16 / 1 of the original input image. The ASPP in the figure is a dilated spatial convolutional pooling pyramid, which is used to realize free multi-scale feature extraction of the input image downsampled 16 times to obtain the feature representation of the input image. The segmentation head is used to segment the reflective area according to the feature representation of the input image. The segmentation head is effective in both the training and prediction stages. The auxiliary segmentation head is used to segment the reflective area according to the shallow features, and assist the training of the reflective detection network, so that the shallow features pay more attention to the reflective information, improve the training efficiency of the model, and shorten the training time. It is only used in the training stage, and the auxiliary segmentation head is removed by pruning in the inference stage. The training process of the reflective detection network may include:
[0055] S11, design a lightweight reflective detection network Ref_Det.
[0056] The backbone network of the reflective detection network Ref_Det is built based on the target detection network MobileNetV3-Small, and the backbone network of the reflective detection network Ref_Det only retains the first 10 layers of the target detection network MobileNetV3-Small. Obviously, compared with the input size of the original image, the size of the feature map output by the last convolutional layer of the reflective detection network is downsampled by 16 times, that is, the size of the feature map output by the last convolutional layer of the reflective detection network is 16 / 1 of the original image size. Moreover, unlike the conventional segmentation network, this reflective detection network does not add upsampling operations, but only achieves upsampling through linear interpolation, in order to further improve the detection speed of the reflective detection network.
[0057] S12, constructing a training data set Ref_Data for the reflection detection network Ref_Det.
[0058] As an example, the training data set Ref_Data may contain 5,000 reflective images of 16 reflective workpieces under different imaging effects, and the reflective area of each reflective image is annotated with a pixel-level mask.
[0059] S13, the calculation formula of the loss function of the reflective detection network Ref_Det is Loss = λ s L ce +λ ad L dice .
[0060] Among them, Lce represents the cross entropy loss, L dice represents the Dice loss of the two sub-networks, λ s ,λ ad , are the coefficients corresponding to the cross entropy loss and Dice loss respectively.
[0061] S14, the optimizer of the model uses the Adam optimization algorithm, momentum: 0.937, the initial learning rate is 0.01, the training data scale is 5,000 images, and the training stops after 90 rounds.
[0062] Step 530 , based on the reflection erasing network and the reflection detection result of the target workpiece image, a reflection erasing operation is performed on the target workpiece image to obtain a target workpiece image after reflection erasing.
[0063] Among them, the reflective erasure network is based on Figure 1 to Figure 5 The method is obtained by training using any of the reflection erasing network training methods.
[0064] In some exemplary embodiments, based on the reflection erasing network and the reflection detection result of the target workpiece image, performing a reflection erasing operation on the target workpiece image to obtain the target workpiece image after reflection erasing includes:
[0065] Based on the reflection detection result in the target workpiece image, determine an area in the target workpiece image where the pixel value is less than a preset pixel value;
[0066] Grayscale filling is performed on areas where the pixel value is less than a preset pixel value, so as to obtain multiple reflective areas in the target workpiece image;
[0067] Determine the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of multiple reflective areas of the target workpiece image;
[0068] Based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective areas of the target workpiece image, the multiple reflective areas of the target workpiece image are aggregated to obtain the reflective area of the target workpiece image;
[0069] The reflective area of the target workpiece image is subjected to a reflective erasing operation through a reflective erasing network to obtain the target workpiece image after the reflective erasing.
[0070] The area with a pixel value less than a preset pixel value is a non-reflective area in the target workpiece image, and the preset pixel value can be set based on experience to distinguish between a reflective area and a non-reflective area. Specifically, grayscale filling is performed on the area with a pixel value less than the preset pixel value, and a grayscale filling of 128 can be performed on the area with a pixel value less than the preset pixel value.
[0071] In some exemplary embodiments, based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective regions of the target workpiece image, the multiple reflective regions of the target workpiece image are aggregated to obtain the reflective regions of the target workpiece image, including:
[0072] Using the density peak clustering algorithm, based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective areas of the target workpiece image, the multiple reflective areas of the target workpiece image are clustered to obtain multiple clusters;
[0073] Determine the connected domains of the reflective areas included in each cluster among the multiple clusters, and perform preset processing on the connected domains of the reflective areas included in each cluster among the multiple clusters to obtain the connected domains after the preset processing, wherein the preset processing at least includes: merging the connected domains in the multiple clusters whose intersection-to-union ratio is greater than or equal to a preset threshold;
[0074] Based on the preset processed connected domain, the reflective area of the target workpiece image is determined.
[0075] Specifically, the process of polymerizing the reflective area may include:
[0076] (1) The multiple reflective areas are clustered using the density peak clustering algorithm. The clustering features include the center point coordinates (x, y), width w, height h and corresponding rotation angle θ of the circumscribed rectangle of each reflective area, and M clusters are obtained.
[0077] (2) Find the connected region Ref_Region of each cluster containing the reflective area;
[0078] (3) If the intersection-and-union ratio between two connected domains is greater than or equal to a preset threshold, the two connected domains are merged, and if the intersection-and-union ratio between two connected domains is less than or equal to the preset threshold, the two connected domains are retained.
[0079] Figure 7 A schematic diagram of the effect of applying a reflective erasing method provided in an exemplary embodiment of the present application in an actual scene. Figure 7 The first image in is the original reflected image of the target workpiece. Figure 7 The second image in the figure is the original non-reflective image of the target workpiece. Figure 7 The third figure in is a non-reflection image of the target workpiece, which is generated by the reflection erasure network based on the original reflection image of the target workpiece.
[0080] The reflective erasing method provided in the embodiment of the present application can obtain the target workpiece image to be reflectively erased, and input the target workpiece image into the reflective detection network to output the reflective detection result in the target workpiece image. The reflective detection network is obtained by training based on multiple reflective images and corresponding reflective area annotations. Finally, based on the reflective erasing network and the reflective detection result of the target workpiece image, the reflective erasing operation is performed on the target workpiece image to obtain the target workpiece image after the reflective erasure. The reflective erasing network is obtained by training based on the training method of the reflective erasing network. Since the reflective detection network and the reflective erasing network can be combined to detect the reflective area of the workpiece image with reflection and erase the reflective area, on this basis, the surface image of the workpiece with high reflective material is subjected to defect detection, which can greatly improve the accuracy of defect detection on the workpiece surface.
[0081] In addition, the method provided in this embodiment can be applied to any application scenario of defect detection on the surface of a workpiece with reflective light.
[0082] It should be noted that the execution subject of each step of the method provided in the above embodiment can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 110 to 130 can be device A; for another example, the execution subject of steps 110 to 120 can be device A, and the execution subject of step 130 can be device B; and so on.
[0083] It should also be noted that the training method of the reflective erasure network and the ideas of network training and reflective erasure in the reflective erasure method provided in the embodiments of the present application are not only limited to the scenario of defect detection. When defect detection is replaced by other target detection, such as more general and universal object (vehicles, people, cats, etc.) detection scenarios, the network training and network construction methods in the above-mentioned inventive conception are also applicable to such scenarios.
[0084] In addition, in some of the processes described in the above embodiments and the accompanying drawings, multiple operations that appear in a specific order are included, but it should be clearly understood that these operations may not be executed in the order in which they appear in this article or executed in parallel, and the sequence numbers of the operations, such as 110, 120, 510, 520, etc., are only used to distinguish between different operations, and the sequence numbers themselves do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions of "first", "second", etc. in this article are used to distinguish different messages, devices, modules, etc., do not represent the order of precedence, and do not limit "first" and "second" to different categories.
[0085] Figure 8The structure diagram of a reflective erasing network training device 800 provided by an exemplary embodiment of the present application is shown in FIG. Figure 8 As shown, the device 800 includes: an image acquisition module 810, a relationship establishment module 820 and a network training module 830, wherein:
[0086] An image acquisition module 810 is used to acquire original reflective images of a plurality of reflective workpieces under a plurality of different imaging effects, and original non-reflective images of the plurality of reflective workpieces;
[0087] A relationship building module 820 is used to establish a mapping relationship between an original reflective image and an original non-reflective image of each reflective workpiece among a plurality of reflective workpieces, so as to obtain a reflective erasure network training set;
[0088] A network training module 830 is used to train a reflective erasure network based on the reflective erasure network training set, wherein the reflective erasure network includes a first generator, a second generator, a first discriminator, and a second discriminator, wherein the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, an original reflective image of each reflective workpiece among the plurality of reflective workpieces is used as an input of the first generator, and an original non-reflective image of each reflective workpiece among the plurality of reflective workpieces is used as an input of the second generator;
[0089] Among them, the network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate a non-reflection image of the input reflective workpiece based on the original reflective image of the input reflective workpiece, and the first discriminator is used to determine the similarity between the non-reflection image of the input reflective workpiece generated by the first generator module and the original non-reflection image of the input reflective workpiece; the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflection image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece.
[0090] In some exemplary embodiments, the network training module 830 is specifically used to:
[0091] Randomly select an original reflective image and an original non-reflective image of a target workpiece from the reflective removal data set, wherein the target workpiece is any one of the multiple reflective workpieces;
[0092] Taking the original reflective image of the target workpiece as an input of the first generator, so as to generate a non-reflective image of the target workpiece based on the original reflective image of the target workpiece by the first generator, and taking the original non-reflective image of the target workpiece as an input of the second generator, so as to generate a reflective image of the target workpiece based on the original non-reflective image of the target workpiece by the second generator;
[0093] Using the original reflected image of the target workpiece and the reflected image of the target workpiece as inputs of the first discriminator to determine a first similarity between the original reflected image of the target workpiece and the reflected image of the target workpiece by the first discriminator, and using the original non-reflection image of the target workpiece and the non-reflection image of the target workpiece as inputs of the second discriminator to determine a second similarity between the original non-reflection image of the target workpiece and the non-reflection image of the target workpiece by the second discriminator;
[0094] Based on the first similarity and the second similarity, optimizing network parameters of the network modules of the first generator and the second generator;
[0095] According to the preset training rounds, the steps of randomly selecting an original reflective image and an original non-reflective image of a target workpiece from the reflection removal dataset to optimizing the network parameters of the network modules of the first generator and the second generator are repeatedly performed to train the reflection erasure network.
[0096] In some exemplary embodiments, the encoder is used to perform downsampling operations and feature encoding operations on the input image to obtain a coded feature map, the auxiliary classifier is used to generate a high semantic vector based on the coded feature map, the decoder is used to decode the high semantic vector to obtain an adaptive image feature extraction network, and upsample the adaptive image feature extraction network to obtain an output image.
[0097] The training device 800 for the reflective erasure network can achieve Figure 1 to Figure 4 For details, please refer to Figure 1 to Figure 5 The training method of the reflection erasing network of the illustrated embodiment will not be described in detail.
[0098] Fig. 9 FIG. 9 is a schematic diagram of a reflective erasing device 900 provided in an exemplary embodiment of the present application. Fig. 9 As shown, the device 900 includes: an image acquisition module 910, a reflection detection module 920 and a reflection erasing module 930, wherein:
[0099] An image acquisition module 910 is used to acquire an image of a target workpiece to be reflected and erased;
[0100] A reflection detection module 920 is used to input the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is trained based on a plurality of reflection images and corresponding reflection area annotations;
[0101] The reflection erasing module 930 is used to perform a reflection erasing operation on the target workpiece image based on the reflection erasing network and the reflection detection result of the target workpiece image to obtain the target workpiece image after the reflection erasing.
[0102] Wherein, the reflective erasure network is based on Figure 1 to Figure 5 The reflective erasure network is trained using any of the training methods described in .
[0103] In some exemplary embodiments, the reflective erasing module 930 is specifically used for:
[0104] Based on the reflection detection result in the target workpiece image, determining an area having a pixel value less than a preset pixel value from the target workpiece image;
[0105] Performing grayscale filling on the area where the pixel value is less than the preset pixel value to obtain a plurality of reflective areas in the target workpiece image;
[0106] Determine the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the plurality of reflective areas of the target workpiece image;
[0107] Based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective regions of the target workpiece image, the multiple reflective regions of the target workpiece image are aggregated to obtain the reflective region of the target workpiece image;
[0108] The reflection erasing network performs a reflection erasing operation on the reflection area of the target workpiece image to obtain the target workpiece image after reflection erasing.
[0109] In some exemplary embodiments, the reflective erasing module 930 is specifically used for:
[0110] Using a density peak clustering algorithm, based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective areas of the target workpiece image, the multiple reflective areas of the target workpiece image are clustered to obtain multiple clusters;
[0111] Determine the connected domains of the reflective areas included in each of the multiple clusters, and perform preset processing on the connected domains of the reflective areas included in each of the multiple clusters to obtain the connected domains after the preset processing, wherein the preset processing at least includes: merging the connected domains in the multiple clusters whose intersection-over-union ratio is greater than or equal to a preset threshold;
[0112] Based on the preset processed connected domain, a reflective area of the target workpiece image is determined.
[0113] In some exemplary embodiments, the process of constructing the reflective detection network includes:
[0114] Acquire a plurality of reflective images, where the plurality of reflective images are images of a plurality of reflective workpieces under a plurality of different imaging effects;
[0115] Performing pixel-level mask annotation on the multiple reflective images to obtain pixel-level mask annotations of the multiple reflective images;
[0116] Based on the multiple reflective images, the pixel-level mask annotations of the multiple reflective images and a plurality of preset loss functions, a reflective detection network is trained, wherein the preset loss function is constructed based on the cross entropy loss, the Dice loss of the set similarity function of the two sub-networks, and the coefficients corresponding to the Dice losses of the two sub-networks.
[0117] In some exemplary embodiments, the reflective detection network is constructed based on the target detection network MobileNetV3-Small, the reflective detection network includes the first 10 layers of the network structure of MobileNetV3-Small, and the reflective detection network achieves upsampling through linear interpolation; during training, the reflective detection network guides the training process of the reflective detection network by adding an auxiliary segmentation head and a corresponding loss.
[0118] The reflective erasing device 900 can achieve Figure 5 to Figure 7 For details, please refer to Figure 5 to Figure 7 The reflective erasing method of the illustrated embodiment will not be described in detail.
[0119] The embodiment of the present application also provides an electronic device, including: a processor, a memory and a bus, the memory stores machine-readable instructions executable by the processor, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the method for constructing a defect detection network as described above, or the method for defect detection as described above is executed. Specifically, Fig.10 The following is a schematic diagram of the structure of an electronic device provided by an exemplary embodiment of the present application. Fig.10 As shown, the device includes: a memory 101 and a processor 102 .
[0120] The memory 101 is used to store computer programs and can be configured to store various other data to support operations on the computing device. Examples of such data include instructions for any application or method operating on the computing device, contact data, phone book data, messages, images, videos, etc.
[0121] The processor 102 is coupled to the memory 101 and is used to execute the computer program in the memory 101, so as to: obtain original reflective images of a plurality of reflective workpieces under a plurality of different imaging effects, and original non-reflective images of the plurality of reflective workpieces; establish a mapping relationship between the original reflective image and the original non-reflective image of each of the plurality of reflective workpieces to obtain a reflective erasure network training set; based on the reflective erasure network training set, train a reflective erasure network, the reflective erasure network comprising a first generator, a second generator, a first discriminator and a second discriminator, the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, the original reflective image of each of the plurality of reflective workpieces is used as an input of the first generator, and the original non-reflective image of each of the plurality of reflective workpieces is used as an input of the second generator; wherein, The network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate a non-reflective image of the input reflective workpiece based on the original reflective image of the input reflective workpiece, and the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece; the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece.
[0122] Alternatively, the processor 102 may also be used to: obtain a target workpiece image to be reflectively erased; input the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is obtained by training based on a plurality of reflection images and corresponding reflection area annotations; based on the reflection erasing network and the reflection detection result of the target workpiece image, perform a reflection erasing operation on the target workpiece image to obtain a target workpiece image after reflection erasure, wherein the reflection erasing network is based on Figure 1 to Figure 4 The reflective erasure network is trained using any of the training methods described in .
[0123] Further, if Fig.10 As shown, the electronic device also includes: a communication component 103, a display 104, a power component 105, an audio component 106 and other components. Fig.10 Only some components are shown schematically, which does not mean that the electronic device only includes Fig.10 In addition, depending on the implementation form of the traffic playback device, Fig.10 The components in the dashed box are optional components, not mandatory components. For example, when the electronic device is implemented as a terminal device such as a smartphone, tablet computer or desktop computer, it may include Fig.10 Components in the dashed box; when the electronic device is implemented as a server-side device such as a conventional server, cloud server, data center or server array, it may not include Fig.10 Components within the dashed box.
[0124] Accordingly, an embodiment of the present application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is enabled to implement the training method of the reflective erasure network or the steps in the reflective erasure method embodiment.
[0125] Above Fig.10 The communication component in is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component may also include a near field communication (NFC) module, a radio frequency identification (RFID) technology, an infrared data association (IrDA) technology, an ultra-wideband (UWB) technology, a Bluetooth (BT) technology, etc.
[0126] Above Fig.10 The memory in the embodiment can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0127] Above Fig.10The display in the embodiment includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0128] Above Fig.10 The power supply component in the device provides power to various components of the device where the power supply component is located. The power supply component may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.
[0129] Above Fig.10 The audio component in can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting an audio signal.
[0130] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0131] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0132] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0133] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0134] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0135] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0136] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0137] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0138] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A training method for a reflection erasing network, characterized in that: include: Acquire original reflective images of a plurality of reflective workpieces under a plurality of different imaging effects, and original non-reflective images of the plurality of reflective workpieces; Establishing a mapping relationship between an original reflective image and an original non-reflective image of each reflective workpiece among a plurality of reflective workpieces to obtain a reflection erasing network training set; Based on the reflective erasure network training set, a reflective erasure network is trained, wherein the reflective erasure network includes a first generator, a second generator, a first discriminator, and a second discriminator, wherein the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, an original reflective image of each reflective workpiece among the plurality of reflective workpieces is used as an input of the first generator, and an original non-reflective image of each reflective workpiece among the plurality of reflective workpieces is used as an input of the second generator; The network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate a non-reflective image of the input reflective workpiece based on an original reflective image of the input reflective workpiece, and the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece; the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece; The step of training a reflection erasure network based on the reflection erasure network training set includes: Inputting a target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is trained based on a plurality of reflection images and corresponding reflection area annotations, and the target workpiece image is any one of the original reflection images included in the reflection erasure network training set; Based on the reflection detection result of the target workpiece image, determining an area having a pixel value less than a preset pixel value from the target workpiece image; Performing grayscale filling on the area where the pixel value is less than the preset pixel value to obtain a plurality of reflective areas in the target workpiece image; Determine the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the plurality of reflective areas of the target workpiece image; Based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective regions of the target workpiece image, the multiple reflective regions of the target workpiece image are aggregated to obtain the reflective region of the target workpiece image; Based on the reflection erasure network training set and the reflective area of the original reflective image included in the reflection erasure network training set, a reflection erasure network is trained to obtain.
2. The method according to claim 1, characterized in that The training of the reflection erasure network based on the reflection erasure network training set includes: Randomly select an original reflective image and an original non-reflective image of a target workpiece from the reflective removal dataset, wherein the target workpiece is any one of the multiple reflective workpieces; Taking the original reflective image of the target workpiece as an input of the first generator, so as to generate a non-reflective image of the target workpiece based on the original reflective image of the target workpiece by the first generator, and taking the original non-reflective image of the target workpiece as an input of the second generator, so as to generate a reflective image of the target workpiece based on the original non-reflective image of the target workpiece by the second generator; Using the original reflected image of the target workpiece and the reflected image of the target workpiece as inputs of the first discriminator to determine a first similarity between the original reflected image of the target workpiece and the reflected image of the target workpiece by the first discriminator, and using the original non-reflection image of the target workpiece and the non-reflection image of the target workpiece as inputs of the second discriminator to determine a second similarity between the original non-reflection image of the target workpiece and the non-reflection image of the target workpiece by the second discriminator; Based on the first similarity and the second similarity, optimizing network parameters of the network modules of the first generator and the second generator; According to the preset training rounds, the steps of randomly selecting an original reflective image and an original non-reflective image of a target workpiece from the reflection removal dataset to optimizing the network parameters of the network modules of the first generator and the second generator are repeatedly performed to train the reflection erasure network.
3. The method according to claim 1 or 2, characterized in that The encoder is used to perform downsampling operations on the input image and to perform feature encoding operations through an image feature extraction network to obtain a coded feature map. The auxiliary classifier is used to generate a high semantic vector based on the coded feature map to obtain an attention feature map. The decoder is used to decode the attention feature map to obtain an image to be output, and to upsample the image to be output to obtain an output image, wherein the decoder is composed of a fully connected layer and an adaptive image feature extraction network.
4. A method for erasing reflections, characterized in that: The method comprises: Acquire a target workpiece image to be erased; Inputting the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is trained based on a plurality of reflection images and corresponding reflection area annotations; Based on the reflection detection result of the target workpiece image, determining an area having a pixel value less than a preset pixel value from the target workpiece image; Performing grayscale filling on the area where the pixel value is less than the preset pixel value to obtain a plurality of reflective areas in the target workpiece image; Determine the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the plurality of reflective areas of the target workpiece image; Based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective regions of the target workpiece image, the multiple reflective regions of the target workpiece image are aggregated to obtain the reflective region of the target workpiece image; The reflection erasing network performs a reflection erasing operation on the reflection area of the target workpiece image to obtain the target workpiece image after reflection erasure, and the reflection erasing network is trained based on any one of the methods described in claims 1 to 3.
5. The method according to claim 4, characterized in that The method of performing aggregation processing on the multiple reflective regions of the target workpiece image based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective regions of the target workpiece image to obtain the reflective region of the target workpiece image includes: Using a density peak clustering algorithm, based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangle of the multiple reflective areas of the target workpiece image, the multiple reflective areas of the target workpiece image are clustered to obtain multiple clusters; Determine the connected domains of the reflective areas included in each of the multiple clusters, and perform preset processing on the connected domains of the reflective areas included in each of the multiple clusters to obtain the connected domains after the preset processing, wherein the preset processing at least includes: merging the connected domains in the multiple clusters whose intersection-over-union ratio is greater than or equal to a preset threshold; Based on the preset processed connected domain, a reflective area of the target workpiece image is determined.
6. The method according to claim 4, characterized in that The construction process of the reflective detection network includes: Acquire a plurality of reflective images, where the plurality of reflective images are images of a plurality of reflective workpieces under a plurality of different imaging effects; Performing pixel-level mask annotation on the multiple reflective images to obtain pixel-level mask annotations of the multiple reflective images; Based on the multiple reflective images, the pixel-level mask annotations of the multiple reflective images and a preset loss function, a reflective detection network is trained, and the preset loss function is constructed based on the cross entropy loss, the set similarity function Dice loss of the two sub-networks, and the coefficients corresponding to the Dice losses of the two sub-networks.
7. The method according to claim 6, characterized in that The reflective detection network is constructed based on the target detection network MobileNetV3-Small. The reflective detection network includes the first 10 layers of the MobileNetV3-Small network structure. The reflective detection network achieves upsampling through linear interpolation. During training, the reflective detection network guides the training process of the reflective detection network by adding an auxiliary segmentation head and a corresponding loss.
8. A training device for a reflective erasure network, characterized in that: include: An image acquisition module, used to acquire original reflective images of a plurality of reflective workpieces under a plurality of different imaging effects, and original non-reflective images of the plurality of reflective workpieces; A relationship building module is used to establish a mapping relationship between an original reflective image and an original non-reflective image of each reflective workpiece among a plurality of reflective workpieces, so as to obtain a reflection erasing network training set; a network training module, used for training a reflective erasure network based on the reflective erasure network training set, wherein the reflective erasure network comprises a first generator, a second generator, a first discriminator and a second discriminator, wherein the first generator is connected to the first discriminator, the second generator is connected to the second discriminator, an original reflective image of each reflective workpiece among the plurality of reflective workpieces is used as an input of the first generator, and an original non-reflective image of each reflective workpiece among the plurality of reflective workpieces is used as an input of the second generator; The network module of the first generator and the network module of the second generator have the same network structure, including an encoder, an auxiliary classifier and a decoder; the network module of the first discriminator and the network module of the second discriminator have the same network structure, including an encoder and an auxiliary classifier; the first generator is used to generate a non-reflective image of the input reflective workpiece based on an original reflective image of the input reflective workpiece, and the first discriminator is used to determine the similarity between the non-reflective image of the input reflective workpiece generated by the first generator module and the original non-reflective image of the input reflective workpiece; the second generator is used to generate a reflective image of the input reflective workpiece based on the original non-reflective image of the input reflective workpiece, and the second discriminator is used to determine the similarity between the reflective image of the input reflective workpiece generated by the second generator module and the original reflective image of the input reflective workpiece; The network training module is specifically used to input a target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is obtained by training based on multiple reflection images and corresponding reflection area annotations, and the target workpiece image is any one of the original reflection images included in the reflection erasure network training set; based on the reflection detection result of the target workpiece image, determine an area with a pixel value less than a preset pixel value from the target workpiece image; grayscale fill the area with a pixel value less than the preset pixel value to obtain multiple reflection areas in the target workpiece image; determine the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangles of the multiple reflection areas of the target workpiece image; based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangles of the multiple reflection areas of the target workpiece image, aggregate the multiple reflection areas of the target workpiece image to obtain the reflection area of the target workpiece image; and train the reflection erasure network based on the reflection erasure network training set and the reflection areas of the original reflection images included in the reflection erasure network training set.
9. A reflective erasing device, characterized in that: include: An image acquisition module, used for acquiring an image of a target workpiece to be erased; A reflection detection module, used for inputting the target workpiece image into a reflection detection network to output a reflection detection result in the target workpiece image, wherein the reflection detection network is trained based on a plurality of reflection images and corresponding reflection area annotations; A reflection erasing module, configured to determine, based on a reflection detection result of the target workpiece image, an area having a pixel value less than a preset pixel value from the target workpiece image; Performing grayscale filling on the area where the pixel value is less than the preset pixel value to obtain a plurality of reflective areas in the target workpiece image; Determine the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangles of the multiple reflective areas of the target workpiece image; based on the center point coordinates, width, height and corresponding rotation angle of the circumscribed rectangles of the multiple reflective areas of the target workpiece image, perform aggregation processing on the multiple reflective areas of the target workpiece image to obtain the reflective areas of the target workpiece image; perform a reflection erasing operation on the reflective areas of the target workpiece image through the reflection erasing network to obtain the target workpiece image after reflection erasure, wherein the reflection erasing network is trained based on the method described in any one of claims 1 to 3.
10. An electronic device, characterized in that: include: Memory and processor; The memory is used to store computer programs; The processor, coupled to the memory, is used to execute the computer program to implement the training method of the reflective erasure network as described in any one of claims 1 to 3 or the steps in the reflective erasure method as described in any one of claims 4 to 7.
11. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the processor is caused to implement the steps in the method for training a reflective erasure network as described in any one of claims 1 to 3 or the method for erasing reflective erasure as described in any one of claims 4 to 7.
