Image detection method, device, electronic device and storage medium
The image detection method leverages a pre-trained model with dual networks to determine target images through feature difference, addressing poor generalization and high costs in traditional methods, ensuring efficient and cost-effective image detection.
Patent Information
- Application Number
- CN202210267050.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2042-03-17
AI Technical Summary
Traditional image detection methods rely on manual feature extraction and independent classifier training, leading to poor generalization and high training costs, particularly for diverse video data.
An image detection method using a pre-trained model with a first and second network to extract visual features, determining the detection value based on the feature difference between these networks, eliminating the need for manual feature extraction and reducing training costs.
The method achieves high detection efficiency with reduced manpower costs by utilizing deep feature comparison between networks, effectively identifying target images without relying on large amounts of manually labeled data.
Smart Images

Figure CN114612449B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image detection method, device, electronic device and storage medium. Background Art
[0002] Image detection is an essential step in the information and quality analysis of images and videos. It can be used to receive information about the current image or video and evaluate the quality of the current image or video. Image detection is generally used to confirm whether the image to be detected is the target image. The final output result is the detection probability, and further output can be used to determine whether the current image is the target image.
[0003] The traditional image detection method is to first extract and design manual features of the input image, including gradient features, texture features, etc., and then train an SVM (support vector machines) classifier (or a tree-based classifier) based on the extracted manual features, and use the trained classifier to perform binary classification on whether the current image is the target image. However, there are corresponding defects in the binary classification based on classifiers to achieve image detection. First, the generalization of the extracted manual features is relatively poor. For diverse video data, some harmful features that confuse the subsequent classifiers are often extracted; second, feature extraction and classifier training are performed independently, and the training cost of the model is relatively high. Summary of the invention
[0004] To solve the above technical problems, the embodiments of the present application provide an image detection method and device, an electronic device, and a computer-readable storage medium.
[0005] According to one aspect of an embodiment of the present application, there is provided an image detection method, comprising: inputting an image to be detected into a pre-trained image detection model, and obtaining a detection value corresponding to the image to be detected output by the image detection model, wherein the image detection model comprises a first network for extracting a first visual feature of the image to be detected and a second network for extracting a second visual feature of the image to be detected, and the detection value is obtained according to a feature difference between the first visual feature and the second visual feature; and determining an image to be detected whose detection value is greater than a preset detection threshold as a target image.
[0006] According to one aspect of an embodiment of the present application, there is provided an image detection device, comprising: a detection value acquisition module, configured to input an image to be detected into a pre-trained image detection model, and obtain a detection value corresponding to the image to be detected output by the image detection model, wherein the image detection model comprises a first network for extracting a first visual feature of the image to be detected and a second network for extracting a second visual feature of the image to be detected, and the detection value is obtained according to a feature difference between the first visual feature and the second visual feature; a detection module, configured to determine an image to be detected whose detection value is greater than a preset detection threshold as a target image.
[0007] In one embodiment, the image detection device further includes:
[0008] An image detection model construction module is configured to perform an initial model construction step: construct an initial image detection model, wherein the initial image detection model includes the first network and an initial second network;
[0009] The model training module is configured to repeatedly perform training steps until the pre-trained image detection model is obtained, and the training steps include: inputting the image to be trained into the initial image detection model, and adjusting the weight parameters of the initial second network according to the feature difference between the first training feature output by the first network and the second training feature output by the initial second network.
[0010] In one embodiment, the model training module includes:
[0011] A training feature extraction unit, configured to obtain a first training feature output by a first training network layer from the first network, and to obtain a second training feature output by a second training network layer from the initial second network, wherein the first training network layer corresponds to the second training network layer;
[0012] A weight parameter adjustment unit is configured to adjust the weight parameter of the second training network layer according to the feature difference between the first training feature and the second training feature.
[0013] In one embodiment, the image detection model building module includes:
[0014] A first network construction unit, configured to preset an initial first network;
[0015] A first network initialization unit is configured to extract pre-training data based on a visualization database, and initialize weight parameters of the initial first network according to the pre-training data to obtain the first network;
[0016] An image detection model building unit is configured to build the initial image detection model based on the first network and the initial second network.
[0017] In one embodiment, the detection value acquisition module includes:
[0018] a visual feature extraction unit, configured to input the image to be detected into the image detection model to obtain a plurality of first visual features and a plurality of second visual features, wherein the number of the plurality of first visual features is the same as the number of the plurality of second visual features, the plurality of first visual features are visual features respectively output by a plurality of network layers in the first network, and the plurality of second visual features are visual features respectively output by a plurality of network layers in the second network corresponding to the plurality of network layers in the first network;
[0019] The detection value acquisition unit is configured to calculate the detection value of the image to be detected according to the feature difference between each first visual feature and the corresponding second visual feature.
[0020] In one embodiment, the detection value acquisition unit includes:
[0021] A feature comparison value acquisition module is configured to compare the difference between each first visual feature and the corresponding second visual feature to obtain multiple feature comparison values;
[0022] A weight value allocation section, configured to allocate a weight value to each of the plurality of feature comparison values;
[0023] The detection value acquisition section is configured to calculate the weighted sum between each feature comparison value and the corresponding weight value to obtain the detection value of the image to be detected.
[0024] In one embodiment, the target image is a distorted screen image, and the image detection device further includes:
[0025] A distorted screen image determination module, configured to determine the image to be detected whose detection value is greater than a preset detection threshold as a distorted screen image;
[0026] A screen distortion degree determination module, configured to determine the screen distortion degree of the image to be detected according to a detection difference between the detection value and the detection threshold;
[0027] The distorted screen position determination module is configured to determine the distorted screen position of the image to be detected according to the multiple feature comparison values and the network layer corresponding to each feature comparison value.
[0028] According to one aspect of an embodiment of the present application, an electronic device is provided, comprising one or more processors; and a storage device for storing one or more computer programs, wherein when the one or more computer programs are executed by the one or more processors, the electronic device implements the image detection method as described above.
[0029] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the image detection method as described above.
[0030] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the image detection method provided in the above various optional embodiments.
[0031] According to one aspect of an embodiment of the present application, a computer program product is provided, including a computer program, which implements the steps in the template generation method described above when executed by a processor.
[0032] In the technical solution provided in the embodiments of the present application, based on the difference value between the visual features output by the first network and the second network in the image detection model for the image to be detected, and based on the comparison of the difference value with the preset detection threshold, it is determined whether the image to be detected is the target image. This method does not require manual feature extraction and design, and has low implementation cost; and the detection of the image to be detected can be achieved through the feature difference between the first network and the second network, and has high detection efficiency.
[0033] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0035] Figure 1 It is a schematic diagram of an implementation environment involved in this application;
[0036] Figure 2is a flow chart of an image detection method shown in an exemplary embodiment of the present application;
[0037] Figure 3 is a structural schematic diagram of an image detection model shown in an exemplary embodiment of the present application;
[0038] Figure 4 is a flowchart of an image detection method shown in another exemplary embodiment of the present application;
[0039] Figure 5 yes Figure 4 A flowchart of step S430 in the illustrated embodiment in an exemplary embodiment;
[0040] Figure 6 yes Figure 4 A flowchart of step S410 in the illustrated embodiment in an exemplary embodiment;
[0041] Figure 7 yes Figure 2 A flowchart of step S210 in the illustrated embodiment in an exemplary embodiment;
[0042] Figure 8 yes Figure 7 A flowchart of step S7300 in the illustrated embodiment in an exemplary embodiment;
[0043] Fig. 9 is a flowchart of an image detection method shown in another exemplary embodiment of the present application;
[0044] Fig.10 is a structural schematic diagram of an image detection device shown in an exemplary embodiment of the present application;
[0045] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0046] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.
[0047] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0048] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0049] It should also be noted that the "multiple" mentioned in this application refers to two or more than two. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship.
[0050] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making.
[0051] Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics and other technologies. Artificial intelligence software technology mainly includes computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0052] Machine Learning (ML) is a multi-disciplinary subject that involves probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning usually include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and teaching learning.
[0053] The image detection method and device, electronic device, and storage medium proposed in the embodiments of the present application involve artificial intelligence technology, machine learning and other technologies, and these embodiments will be described in detail below.
[0054] First see Figure 1 , Figure 1 1 is a schematic diagram of an implementation environment involved in the present application. The implementation environment includes a terminal 100 and a server 200, and the terminal 100 and the server 200 communicate with each other via a wired or wireless network.
[0055] It should be understood that Figure 1 The number of the terminal 100 and the server 200 in the embodiment is only for illustration. According to actual needs, there may be any number of the terminal 100 and the server 200.
[0056] In some embodiments of the present application, the image detection method can be executed by the server 200, and accordingly, the image detection device is configured in the server 200. The terminal 100 is used for the image to be detected, which can be an ordinary picture or an image obtained by deframing the video. The terminal 100 also sends the image to be detected to the server 200. Among them, the server 200 inputs the images to be detected into the pre-trained image detection model respectively, and finally the feature difference corresponding to each image to be detected is used to determine whether the image to be detected is the target image according to the feature difference of each image and the preset detection threshold. Then the server 200 also sends the detection result to the terminal 100, and the detection result can be visualized through the display module of the terminal 100.
[0057] Exemplarily, after receiving the image to be detected, the terminal 100 sends the image to be detected to the server 200, and the server 200 detects the image to be detected, such as inputting an image to be detected into a pre-trained image detection model to obtain a detection value corresponding to the image to be detected output by the image detection model, wherein the image detection model includes a first network for extracting a first visual feature of the image to be detected and a second network for extracting a second visual feature of the image to be detected, and the detection value is obtained according to the feature difference between the first visual feature and the second visual feature; the image to be detected whose detection value is greater than a preset detection threshold is determined as a target image.
[0058] Among them, the image detection model is a model established based on artificial intelligence technology, and specifically can be a model established based on computer vision technology for processing images.
[0059] In other embodiments, some terminal devices 100 may have functions similar to those of the server 200 to execute the image detection method provided in the embodiments of the present application.
[0060] Among them, the terminal 100 includes but is not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc., such as smart phones, tablets, laptops, computers, and any other electronic devices that can realize image visualization, which are not limited here. The server end 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, wherein multiple servers can form a blockchain, and the server is a node on the blockchain. The server end 200 can also be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network, content distribution network) and big data and artificial intelligence platforms and other basic cloud computing services, which are not limited here. The embodiments of the present invention can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc., which are not limited here.
[0061] refer to Figure 2 , Figure 2 FIG. 1 is a flow chart of an image detection method according to an exemplary embodiment. Figure 2 As shown, in an exemplary embodiment, the method may include steps S210 to S230, which are described in detail as follows:
[0062] Step S210: input the image to be detected into a pre-trained image detection model to obtain a detection value corresponding to the image to be detected output by the image detection model.
[0063] First of all, it should be noted that the detection of the image to be detected mentioned in this embodiment may include detecting whether the image has a distorted screen, whether the image has missing parts, and whether the markers in the image (such as the QR code, barcode, etc. in the image) are correct, etc., which are not limited here.
[0064] The image to be detected can be a simple image or a video frame in a video. Of course, the detection of video frames in a video can ultimately be regarded as the detection of the video. For example, detecting whether the video frame is distorted can be regarded as detecting the quality of the original video. Detecting whether there is content missing in the video frame can be regarded as detecting whether the original video needs to be modified. There is no limitation here.
[0065] In this embodiment, before detecting the image to be detected, an image detection model is first trained. The structure of the image detection model can be referred to Figure 3 The image detection model mainly includes a first network and a second network. The first network is a teacher network and the second network is a student network. The weight of the teacher network is initialized in advance, and then the weight of the teacher network is guaranteed to remain unchanged. The features output by the teacher network can be used as a strong supervision signal to guide the learning of the student network until the image detection model is obtained.
[0066] Specifically, the first network and the second network are both deep learning networks, such as VGGNet (a convolutional neural network proposed by the Oxford University Computer Vision Group, etc.), DenseNet (Dense Convolutional Network), CNN (Convolutional Neural Networks), etc. The first network and the second network may be the same deep learning network or may not be the same deep learning network.
[0067] For example, in one embodiment, the first network and the second network in the image detection model are both CNN networks; in another embodiment, the first network in the image detection model is a VGG network, and the second network is a CNN network, that is, the first network and the second network are different.
[0068] After the image detection model is built, it is trained with images without screen distortion, images with complete content, and images with correct markers until the model converges. Then, an image detection model that can be used for image detection can be obtained.
[0069] It should be noted that before training the image detection model, the first network needs to be pre-trained separately to initialize the weight parameters of the first network, such as initializing the first network through a database of visual research, or using the weights pre-trained on ImageNet (a large visualization database used for visual object recognition software research) as the weight parameters after the first network is initialized.
[0070] At the same time, according to different image detection methods, the training data used is often different. For example, if you need to obtain an image detection model for detecting whether an image has a distorted screen, use images without distorted screens to train the model; if you need to detect whether the content in the image is complete, use images with complete content for training. During the training process, it is necessary to ensure that the weight parameters of the first network are different, and adjust the weight parameters of the second network through the difference between the features output by the first network for the training image and the features output by the second network for the training image.
[0071] In this embodiment, after the image to be detected is input into the trained image detection model, the first network will output the first visual feature for the image to be detected, and the second network will output the second visual feature for the image to be detected. At this time, since the first network has been pre-trained, it can fully capture the visual features of different levels of the image to be detected, that is, it is difficult for the first visual feature and the second visual feature to be consistent, and the feature difference between the first visual feature and the second visual feature can be used as the detection value for image detection.
[0072] Of course, the image detection model in this embodiment may also include a controller to control the adjustment of the weight parameters of the second network according to the difference between the features output by the first network for the training image and the features output by the second network for the training image when training the image model; and to compare the first visual features and the second visual features of the image to be detected during image detection to obtain the feature difference between the two, that is, the detection value.
[0073] Of course, as mentioned above, when training the image detection model, the adjustment of the weight parameters of the second network and the detection value of the image to be detected can also be controlled by Figure 1 The server 200 or the terminal 100 is implemented.
[0074] Step S230: determining the image to be detected whose detection value is greater than a preset detection threshold as a target image.
[0075] After obtaining the detection value of the image to be detected in step S210, it can be determined whether it is a target image based on the detection value. The target image can be a distorted image, a missing image, a forged image, etc. Different target images are determined according to different detection purposes.
[0076] First, a detection threshold is preset. The detection threshold can be obtained according to different detection purposes and corresponding detection experience data. For example, if it is necessary to determine whether the image to be detected is a flower screen image, a detection threshold can be determined based on the empirical values in the field of flower screen image detection. Similarly, if it is necessary to determine whether the content of the image to be detected is missing, that is, whether it is a missing image, a detection threshold can be determined based on the empirical values in the field of missing image detection. The detection threshold can be any data between 0 and 1, depending on the specific application scenario. Different thresholds can be used to balance the recall rate and accuracy requirements in different scenarios.
[0077] In this embodiment, the detection value of the image to be detected and the corresponding detection threshold are compared. If the detection value is greater than the detection threshold, it proves that the visual features obtained between the first network and the second network are significantly different, that is, the image to be detected is the target image. On the contrary, if the detection value is less than the detection threshold, it proves that the visual features obtained between the first network and the second network are slightly different, that is, the image to be detected is not the target image.
[0078] In this embodiment, the first network is pre-trained so that the first network can fully capture the visual features of different levels of the image to be detected, and the first network is used as a strong supervisory signal to guide the learning of the second network, so that the features output by the second network are as close as possible to the features output by the first network in the training of the image detection model; and when the image to be detected is detected, since the second network is not trained with the data of the image to be detected when it is a target image, it is difficult for the visual features output by the first network and the visual features output by the second network to be approximate or consistent when the image to be detected is a target image, that is, the feature difference obtained between the first network and the second network can be used as a basis for evaluating whether the image to be detected is a target image.
[0079] Currently, commonly used image detection also sends the original image into a network structure for feature extraction, and then uses a fully connected layer for classification. However, this method also needs to rely on a large amount of manually labeled data when training the network, and even requires high-quality manually labeled information. However, obtaining a certain amount of high-quality manually labeled data is relatively expensive and requires a lot of manpower costs.
[0080] The image detection method proposed in this embodiment does not require manual feature extraction and does not rely on a large amount of manually annotated image detection data. It can meet the image detection needs in different scenarios only through deep feature comparison between the first network and the second network, which can greatly save manpower. On the other hand, the training of the image detection model only needs to cover the normal images corresponding to the detection purpose, and the acquisition method is relatively easy. Images can be selected or videos can be deframed, which can greatly reduce the training and development costs of the model. At the same time, the image detection method can stably and reliably output the detection results of the image to be detected, and can also be used in fields such as video quality assessment.
[0081] Figure 4 FIG. 1 is a flow chart of an image detection method according to another exemplary embodiment. Figure 4 As shown, in an exemplary embodiment, the method can be implemented in Figure 2 Before step S210, the method may include steps S410 to S450, which are described in detail as follows:
[0082] Step S410: Initial model construction step: construct an initial image detection model.
[0083] Figure 4 A training method for an image detection model is proposed in , and the structure of the image detection model obtained can be referred to Figure 3 .
[0084] In this step, an initial model building step is performed, and firstly, an initial first network and a second network are determined, and the initial first network and the second network are one of deep learning networks.
[0085] After the initial first network is obtained, the first network is pre-trained using a large amount of pre-training image data to initialize weight parameters in the first network. The pre-training image data may be image data in various large-scale visualization databases.
[0086] An image detection model is constructed based on the pre-trained first network and the second network.
[0087] Step S430: Training step: input the image to be trained into the initial image detection model, and adjust the weight parameters of the initial second network according to the feature difference between the first training feature output by the first network and the second training feature output by the initial second network.
[0088] In this step, a training step is performed to train the initial image detection model established in step S410 using the image to be trained.
[0089] In this embodiment, the image to be trained is selected according to the detection purpose of the image to be detected. For example, if it is necessary to determine whether the image to be detected is a distorted image, an image without distorted images is used as the image to be trained for model training; if it is necessary to determine whether the image to be detected is a missing image, an image with complete content is used as the image to be trained for model training.
[0090] Of course, the image to be detected may also be an image obtained by de-framing the video.
[0091] In this embodiment, in the image detection model with the output value of the image to be trained being initialized, the first network and the initial second network will respectively output training features for the image to be detected. Since the first network has been pre-trained, the weight parameters in the first network are guaranteed to remain unchanged during the training of the image detection model. Then, the feature difference between the first training feature output by the first network and the second training feature output by the initial second network is used as the supervision signal of the second network in the training stage, and the weight parameters of the initial second network are adjusted. In the process of training the initial image detection model with the image to be trained, the weight parameters of the second network are adjusted so that after the image detection model receives the image to be trained, the difference in the training features output by the first network and the second network gradually decreases.
[0092] Of course, for Figure 3 In the image detection model structure, when the input is the image to be trained, it is in the training stage of the image detection model, corresponding to Figure 3 The dotted arrows in the figure point to the direction. The image to be trained is input into the first network and the second network respectively. The training feature difference is obtained by the features output by each layer in the first network and the features of the corresponding layer in the second network to update the parameters of the corresponding layer in the second network. When the input is the image to be detected, that is, the image detection model has been trained and can be used for image detection, corresponding to Figure 3 If the solid arrow in the figure points to the direction, then at this time, the image to be detected is input into the first network and the second network respectively, and the detection value is obtained by comparing the features output by each layer in the first network with the features of the corresponding layer in the second network. By comparing the detection value with the preset detection threshold, it can be determined whether the image to be detected is the target image.
[0093] Step S450: Repeat the training step until the pre-trained image detection model is obtained.
[0094] In this embodiment, the initial image detection model in step S410 is trained multiple times by the method described in step S430 until the second network converges, thereby obtaining an image detection model that can be finally applied to image detection.
[0095] In this embodiment, the loss function of the image detection model during the training process is:
[0096] L n (x)=|F tn (x)-F sn (x)|,n∈N
[0097] Where x represents the input image to be trained, and N represents the number of features to be compared, that is, the number of feature layers output by the first network and the second network. This number can be set by yourself, as shown in the reference Figure 3 As shown in , N = 3, it is proved that the features output by three feature layers in the first network and the features output by the corresponding three feature layers in the second network are selected to obtain the feature difference, F tn represents the nth output feature of the first network (the first training feature), F sn Represents the nth output feature of the second network (the second training feature).
[0098] The calculation method of the training features in the first network and the second network can be expressed as:
[0099] F(x)=f(x|θ)
[0100] Among them, θ is the parameter of the second network, which performs a series of nonlinear feature calculations on x.
[0101] Then, the final loss function can be expressed as:
[0102]
[0103] Among them, α n The weight value of the difference value of each feature layer is used to adjust the proportion of loss caused by features in different layers. The final loss function can be obtained by adding the difference values of N feature layers.
[0104] In this embodiment, the first network is pre-trained so that the first network can fully capture the visual features of different levels of the image to be detected. At the same time, the first network is used as a strong supervisory signal to guide the learning of the second network, so that the features output by the second network are as close as possible to the features output by the first network in the training of the image detection model, thereby obtaining an image detection model that can be used for image detection. The image detection model can be used for different image detection needs, such as detecting distorted images, missing images, etc., and can also be used to detect video quality and whether the video has been modified.
[0105] Figure 5 yes Figure 4 The flowchart of step S430 in the embodiment shown is in an exemplary embodiment. Figure 5As shown, in an exemplary embodiment, step S430 inputs the image to be trained into the initial image detection model, and the process of adjusting the weight parameter of the initial second network according to the feature difference between the first training feature output by the first network and the second training feature output by the initial second network may include steps S510 to S530, which are described in detail as follows:
[0106] Step S510: obtaining a first training feature output by a first training network layer from the first network, and obtaining a second training feature output by a second training network layer from the initial second network.
[0107] In this embodiment, the first training network layer is a network layer in the first network, the second training network layer is a network layer in the second network, and the first training network layer corresponds to the second training network layer, that is, the two training network layers have the same function or structure.
[0108] In this embodiment, multiple network layers in the first network can be selected as training network layers. For example, when the first network is CNN, the convolution layer, pooling layer, and activation function layer in the first network are selected as training network layers, and the respective training features of these training network layers are obtained. Then, corresponding to the training network layer selected in the first network, a training network layer with the same function is selected from the second network. If the second network and the first network are the same deep learning network, a training network layer with the same structure as that in the first network is selected. If the second network is different from the first network, a network layer with the same function as the training network layer in the first network is selected in the second network as the training network layer.
[0109] For example, when the second network is different from the first network, three training network layers with the same functions as the convolution layer, pooling layer, and activation function layer in the first network are selected in the second network.
[0110] For different network training layers, their respective training features will be output for the image to be trained. For example, when an image to be trained outputs the image detection model in the training stage, the convolution layer, pooling layer, and activation function layer in the first network will output three training features for the image to be trained, and the corresponding three training network layers in the second network will also output three training features for the image to be trained.
[0111] Step S530: adjusting the weight parameters of the second training network layer according to the feature difference between the first training feature and the second training feature.
[0112] In this embodiment, a difference is made between the training features output by the corresponding network layers of the first network and the second network, and the feature difference is used as a supervisory signal to adjust the weight parameters in the corresponding network layer in the second network, thereby ultimately achieving the purpose of training the weight parameters in the second network.
[0113] Exemplary, reference Figure 3 , if 3 training network layers are selected in the first network, and the corresponding 3 training network layers are selected in the second network, the 3 training network layers in the first network will output F t1 、F t2 、F t3 The three training features shown in the figure, the three training network layers in the second network output are as follows: s1 、F s2 、F s3 The three training features shown, where the output F t1 The training network layer and output F s1 The training network layer corresponds to the output F t2 The training network layer and output F s2 The training network layer corresponds to the output F t3 The training network layer and output F s3 Therefore, the weight parameters of the training network layer in the second network can be adjusted by the difference in training features output by the corresponding training network layers in the first network and the second network.
[0114] Specifically, F t1 and F s1 The characteristic difference between them is used to adjust the output F s1 The weight parameters of the training network layer are obtained by t2 and F s2 The characteristic difference between them is used to adjust the output F s2 The weight parameters of the training network layer are obtained by t3 and F s3 The characteristic difference between them is used to adjust the output F s3 The weight parameters of the training network layer.
[0115] Of course, in this embodiment, three training network layers are given as an example. In other embodiments, other numbers can be set to increase or decrease the number of layers used for feature comparison.
[0116] In this embodiment, by selecting training network layers in the first network and the second network, feature comparison between training network layers with the same functions can be achieved, so that the weight parameters of the training network layers in the second network can be accurately adjusted according to the functions of the training network layers, so that the training network layers in the second network can accurately approach the corresponding training network layers in the first network, thereby improving the accuracy of subsequent image detection through the image detection model.
[0117] Figure 6 yes Figure 4 The flowchart of step S410 in the embodiment shown is in an exemplary embodiment. Figure 6As shown, in an exemplary embodiment, the process of constructing the initial image detection model in step S410 may include steps S610 to S650, which are described in detail as follows:
[0118] Step S610: Preset an initial first network.
[0119] In this embodiment, the first network can be one of deep learning networks such as VGGNet, DenseNet, CNN, etc., and is not limited here.
[0120] Step S630: extracting pre-training data based on the visualization database, and initializing weight parameters of the initial first network according to the pre-training data to obtain the first network.
[0121] In this embodiment, the visual database is an object-oriented technology, and multimedia technology is applied to the database system.
[0122] After obtaining the initial first network, its weight parameters need to be trained. Pre-training data can be extracted from the visualization database, and the initial first network is trained based on the pre-training data. The pre-training data can be a part of the image data in the visualization database, or can be all the image data in the visualization database.
[0123] The visual database can be a database such as ImageNet (a large visual database used for research on visual object recognition software).
[0124] The weight parameters of the initial first network are initialized based on the pre-training data to obtain the first network that can capture visual features of different levels of the image.
[0125] Step S650: constructing an initial image detection model based on the first network and the initial second network.
[0126] In this embodiment, the initial second network is one of deep learning networks such as VGGNet, DenseNet, CNN, etc., and the network structure of the second network is the same as that of the first network, and may also be different from the network structure selected from the first network.
[0127] In this embodiment, an initial image detection model is constructed based on the trained first network and the initial second network. Since the first network has been pre-trained, the features extracted by the first network can be used as a strong supervisory signal to guide the learning of the second network, thereby achieving the initial construction of the image detection model. As a result, an image detection model for various types of image detection can be obtained, and the obtained image detection model has low training cost and high detection accuracy.
[0128] Figure 7 yes Figure 2The flowchart of step S210 in the embodiment shown is in an exemplary embodiment. Figure 7 As shown, in an exemplary embodiment, step S210 inputs the image to be detected into a pre-trained image detection model, and the process of obtaining the detection value corresponding to the image to be detected may include steps S710 to S730, which are described in detail as follows:
[0129] Step S710: input the image to be detected into the image detection model to obtain a plurality of first visual features and a plurality of second visual features.
[0130] In this embodiment, the number of multiple first visual features is the same as the number of multiple second visual features. The multiple first visual features are visual features respectively output by multiple network layers in the first network, and the multiple second visual features are visual features respectively output by multiple network layers in the second network corresponding to the multiple network layers in the first network.
[0131] Specifically, the trained image detection model includes a first network and a second network. After receiving the image to be detected, at least one network layer in the first network can be selected to extract visual features of the image to be detected, and different network layers extract different visual features.
[0132] At the same time, corresponding to the network layer selected in the first network, at least one network layer of the corresponding function is also selected in the second network, and the visual features of the image to be detected are extracted through the network layer selected in the second network. Thus, the visual features extracted by the network layers corresponding to the functions in the first network and the second network can be compared.
[0133] In this embodiment, the selection of the network layer can refer to Figure 5 In the embodiment shown, the training network layer selected when training the image detection model can be used as the network layer for extracting the visual features of the image to be detected, such as Figure 5 The three training network layers proposed in the embodiment, when the image detection model is used to detect the image to be detected, the three training network layers during training are selected as the network layers for extracting the features of the image to be detected, and finally the three first visual features output by the first network for the image to be detected and the three second visual features output by the second network for the image to be detected are obtained.
[0134] Of course, the above selection of network layers for image detection is only an example. In other embodiments, the training network layers during partial model training or other network layers in the first network may be selected to perform feature extraction on the image to be detected.
[0135] Step S730: Calculate the detection value of the image to be detected according to the feature difference between each first visual feature and the corresponding second visual feature.
[0136] In this embodiment, for the multiple visual features output by the first network and the second network, the visual features in the first network and the second network can be compared based on the function of the network layer that outputs the visual features to obtain the detection value of the image to be detected.
[0137] Specifically, according to each network layer that outputs the first visual feature, a network layer corresponding to the function is selected in the second network, and the second visual feature corresponding to the output of the network layer is selected, and then the feature difference between the corresponding first visual feature and the second visual feature is compared to obtain a feature comparison value corresponding to a functional network layer. In this way, all first visual features are compared with the corresponding second visual features respectively, and multiple feature comparison values of the detection image in multiple network layers can be obtained. Then, the detection value of the image to be detected can be calculated according to the weight value assigned to each network layer and each feature comparison value.
[0138] In this embodiment, different visual features of the image to be detected are extracted according to different functional network layers in the first network and the second network, so as to obtain the visual features of the image to be detected from different feature levels, so that the feature difference values of the image to be detected at different levels can be obtained by comparing the visual features output by the first network and the second network. The image to be detected is detected by the detection differences corresponding to multiple visual features, which can greatly improve the accuracy of image detection.
[0139] Figure 8 yes Figure 7 The flowchart of step S730 in the embodiment shown is in an exemplary embodiment. Figure 8 As shown, in an exemplary embodiment, the process of calculating the detection value of the image to be detected according to the feature difference between each first visual feature and the corresponding second visual feature in step S730 may include steps S810 to S850, which are described in detail as follows:
[0140] Step S810: respectively comparing the difference between each first visual feature and the corresponding second visual feature to obtain a plurality of feature comparison values.
[0141] In one embodiment, each feature comparison value is a feature difference between features output by corresponding network layers in the first network and the second network, such as a feature comparison value A, which is obtained based on the feature difference between a first visual feature output by the t1 network layer in the first network and a second visual feature output by the corresponding s1 network layer in the second network, wherein the t1 network layer and the s1 network layer have the same function.
[0142] Step S830: assigning a weight value to each of the plurality of feature comparison values.
[0143] In this embodiment, the corresponding network layer is determined according to each feature comparison value, and then the weight value of the feature comparison value corresponding to different network layers is set according to the characteristics of each network layer and empirical data. Of course, the weight value can also be set according to the detection purpose of the image to be detected, and no specific restrictions are made here.
[0144] Step S850: Calculate the weighted sum between each feature comparison value and the corresponding weight value to obtain the detection value of the image to be detected.
[0145] In this embodiment, after obtaining multiple feature comparison values and the weight values corresponding to each feature comparison value, each feature comparison value is multiplied by the corresponding weight value, and then all the products are added. The numerical value obtained after the addition is used as the detection value of the image to be detected, and the detection value and the preset detection threshold are used to confirm whether the image to be detected is the target image.
[0146] In this embodiment, weights are assigned to feature comparison values corresponding to different network layers to adjust the proportion of visual features output by different network layers for the image to be detected, so that more accurate detection value data for characterizing the image to be detected can be obtained, thereby improving the accuracy of image detection.
[0147] In this embodiment, an image detection method is also proposed, that is, a detection score threshold is preset for the network layer corresponding to each feature comparison value among multiple feature comparison values, and the feature comparison value of each network layer is compared with the corresponding detection score threshold. If there is a feature comparison value greater than the detection score threshold, the image to be detected is determined to be a target image.
[0148] Specifically, after obtaining a plurality of feature comparison values, different detection thresholds may be set according to network layer functions corresponding to the feature comparison values.
[0149] For example, for the feature comparison value A proposed above, a detection threshold can be determined for the feature comparison value A based on the network layer functions of t1 and s1, supplemented by the detection purpose of the image to be detected (that is, whether the detection purpose is a flowery image, a missing image, etc.) and empirical values in the field of image detection.
[0150] Different feature comparison values set different detection thresholds according to their corresponding network layers. Of course, the detection threshold can be any data between 0 and 1 to balance the recall rate and accuracy requirements under different network layers.
[0151] Compare the feature comparison values and the corresponding detection thresholds. If there is a feature comparison value that is greater than the corresponding detection threshold, it proves that under the visual features corresponding to the feature comparison value, the visual features output by the corresponding network layer of the second network are significantly different from the visual features output by the corresponding network layer of the first network, which proves that the detection image is the target image.
[0152] In this embodiment, different detection thresholds are set according to the network layer functions corresponding to the feature comparison values, so as to detect the image to be detected from multiple feature directions, which can effectively improve the accuracy of detecting the image to be detected.
[0153] Fig. 9 FIG. 1 is a flow chart of an image detection method according to another exemplary embodiment. Fig. 9 As shown, in an exemplary embodiment, the target image is a flower screen image, and the method can be implemented in Figure 8 After step S850, the method includes steps S910 to S950, which are described in detail as follows:
[0154] Step S910: determining the image to be detected whose detection value is greater than a preset detection threshold as a distorted screen image.
[0155] In this embodiment, if the purpose of detection is to confirm whether it is a flower screen image, the method proposed in the above embodiment is used to confirm whether the image to be detected is a flower screen image. When the obtained detection value is greater than the preset detection threshold, it is determined that the image to be detected is a flower screen image.
[0156] Step S930: determining the degree of screen distortion of the image to be detected according to the detection difference between the detection value and the detection threshold.
[0157] In this embodiment, after confirming that the image to be detected is a distorted screen image, the degree of the distorted screen may also be confirmed through the detection value of the image to be detected.
[0158] For example, the difference between the detection value and the detection threshold can be obtained. If the difference between the detection value and the detection threshold is larger, it can be proved that the confidence of the distorted screen of the image to be detected is higher, that is, the degree of distorted screen is larger. Conversely, the smaller the difference is, the smaller the degree of distorted screen is.
[0159] Step S950: Determine the position of the distorted screen of the image to be detected according to the multiple feature comparison values and the network layer corresponding to each feature comparison value.
[0160] In this embodiment, after determining that the image to be detected is a flower screen image, the feature comparison values of the flower screen image output at different network layers can be detected. Obviously, the network layer with a higher feature comparison value proves that under this network layer, the feature difference between the second visual feature output in the second network and the first visual feature output by the first network is too large. For different network layers, the extracted features are also different. Therefore, it can be known what kind of features of the image to be detected are extracted by the network layer with a higher feature comparison value, and the flower screen position of the flower screen image is determined according to the network layer that outputs the feature comparison value.
[0161] Of course, there is no order between step S930 and step S950 in this embodiment, and they can be performed simultaneously or separately.
[0162] In one embodiment, if a plurality of detection thresholds are preset and the target image is determined by comparing each feature comparison value and the size of the corresponding detection threshold, the degree and position of the screen distortion can be determined based on the detection difference between each feature comparison value and the corresponding detection threshold.
[0163] If there is an image to be detected, and multiple feature comparison values are obtained, and all of its feature comparison values are greater than the corresponding detection score threshold, and at the same time, by comparing the difference between each feature comparison value and the corresponding detection score threshold, it is found that the difference corresponding to each feature comparison value is large, then it can be proved that the confidence level of the screen distortion of the image to be detected is high, that is, the degree of screen distortion is large.
[0164] If there is an image to be detected, and multiple feature comparison values are obtained, and there is only one feature comparison value that is greater than the corresponding detection score threshold, and at the same time, the difference between the feature comparison value and the corresponding detection score threshold is compared, and the difference corresponding to the feature comparison value is smaller, then it can be proved that the confidence level of the screen distortion of the image to be detected is low, that is, the degree of screen distortion is low.
[0165] After the image to be detected is determined to be a flowery screen image, the more feature comparison values that are greater than the corresponding detection threshold, the higher the degree of flowery screen; the greater the detection difference between the feature comparison value greater than the detection threshold and the detection threshold, the higher the degree of flowery screen.
[0166] In this embodiment, the flower screen position of the image to be detected can also be determined by the detection difference between the feature comparison value and the corresponding detection threshold. For example, when the image to be detected is confirmed to be a flower screen image, the detection difference between the feature comparison value of the image to be detected and the corresponding detection threshold is obtained. If the detection difference is positive, it proves that the feature comparison value corresponding to the detection difference is greater than the detection threshold. Otherwise, it proves that the feature comparison value corresponding to the detection difference is less than the detection threshold.
[0167] A detection difference with a positive value is selected, and based on the first visual feature and the second visual feature corresponding to the detection difference, the network layer in the first network that outputs the first visual feature and the corresponding network layer in the second network can be determined. At this time, the location of the flower screen can be determined according to the function of the network layer.
[0168] In this embodiment, a method is proposed for confirming the degree and position of the distorted screen of the target image to be detected, which is a distorted screen image. In this way, the image to be detected can be processed according to the distorted screen information, such as repairing the image, improving the image clarity, etc. If the image to be detected is a video frame in a video, the video can also be processed according to the distorted screen information of the image to be detected.
[0169] Fig.10 FIG. 1 is a schematic diagram showing the structure of an image detection device according to an exemplary embodiment. Fig.10As shown, in an exemplary embodiment, the image detection device includes:
[0170] The detection value acquisition module 1010 is configured to input the image to be detected into a pre-trained image detection model to obtain a detection value corresponding to the image to be detected output by the image detection model, wherein the image detection model includes a first network for extracting a first visual feature of the image to be detected and a second network for extracting a second visual feature of the image to be detected, and the detection value is obtained according to a feature difference between the first visual feature and the second visual feature;
[0171] The detection module 1030 is configured to determine the image to be detected whose detection value is greater than a preset detection threshold as a target image.
[0172] In this embodiment, the image detection device with the above structure can complete the image detection without manual labeling.
[0173] In one embodiment, the image detection device further includes:
[0174] An image detection model building module is configured to perform an initial model building step: building an initial image detection model, the initial image detection model comprising a first network and an initial second network;
[0175] The model training module is configured to repeatedly perform training steps until the pre-trained image detection model is obtained, and the training steps include: inputting the image to be trained into the initial image detection model, and adjusting the weight parameters of the initial second network according to the feature difference between the first training feature output by the first network and the second training feature output by the initial second network.
[0176] In one embodiment, the model training module includes:
[0177] A training feature extraction unit is configured to obtain a first training feature output by a first training network layer from the first network, and to obtain a second training feature output by a second training network layer from an initial second network, wherein the first training network layer corresponds to the second training network layer;
[0178] The weight parameter adjustment unit is configured to adjust the weight parameter of the second training network layer according to the feature difference between the first training feature and the second training feature.
[0179] In one embodiment, the image detection model building module includes:
[0180] A first network construction unit, configured to preset an initial first network;
[0181] A first network initialization unit is configured to extract pre-training data based on a visualization database, and initialize weight parameters of an initial first network according to the pre-training data to obtain a first network;
[0182] The image detection model building unit is configured to build an initial image detection model based on the first network and the initial second network.
[0183] In one embodiment, the detection value acquisition module 1010 includes:
[0184] a visual feature extraction unit configured to input the image to be detected into the image detection model to obtain a plurality of first visual features and a plurality of second visual features, wherein the number of the plurality of first visual features is the same as the number of the plurality of second visual features, the plurality of first visual features are visual features respectively output by a plurality of network layers in the first network, and the plurality of second visual features are visual features respectively output by a plurality of network layers in the second network corresponding to the plurality of network layers in the first network;
[0185] The detection value acquisition unit is configured to calculate the detection value of the image to be detected according to the feature difference between each first visual feature and the corresponding second visual feature.
[0186] In one embodiment, the detection value acquisition unit includes:
[0187] A feature comparison value acquisition module is configured to compare the difference between each first visual feature and the corresponding second visual feature to obtain multiple feature comparison values;
[0188] A weight value allocation section, configured to allocate a weight value to each of the plurality of feature comparison values;
[0189] The detection value acquisition section is configured to calculate the weighted sum between each feature comparison value and the corresponding weight value to obtain the detection value of the image to be detected.
[0190] In one embodiment, the target image is a distorted screen image, and the image detection device further includes:
[0191] A distorted screen image determination module, configured to determine the image to be detected whose detection value is greater than a preset detection threshold as a distorted screen image;
[0192] A screen distortion degree determination module, configured to determine the screen distortion degree of the image to be detected according to a detection difference between the detection value and the detection threshold;
[0193] The distorted screen position determination module is configured to determine the distorted screen position of the image to be detected according to the multiple feature comparison values and the network layer corresponding to each feature comparison value.
[0194] It should be noted that the image detection device provided in the above embodiment and the image detection method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment and will not be repeated here.
[0195] An embodiment of the present application also provides an electronic device, including: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the electronic device implements the image detection method provided in the above-mentioned embodiments.
[0196] Fig.11 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown.
[0197] It should be noted that Fig.11 The computer system 1100 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0198] like Fig.11 As shown, the computer system 1100 includes a central processing unit (CPU) 1101, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1102 or the program loaded from the storage part 1108 to the random access memory (RAM) 1103, such as executing the method in the above embodiment. In the RAM 1103, various programs and data required for system operation are also stored. The CPU 1101, the ROM 1102 and the RAM 1103 are connected to each other through the bus 1104. The input / output (I / O) interface 1105 is also connected to the bus 1104.
[0199] The following components are connected to the I / O interface 1105: an input section 1106 including a keyboard, a mouse, etc.; an output section 1107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to the I / O interface 1105 as needed. A removable medium 1111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1110 as needed so that a computer program read therefrom is installed into the storage section 1108 as needed.
[0200] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1109, and / or installed from a removable medium 1111. When the computer program is executed by a central processing unit (CPU) 1101, various functions defined in the system of the present application are executed.
[0201] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium can be any tangible medium containing or storing a program, which can be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium can include a data signal propagated in a baseband or as a part of a carrier wave, wherein a computer-readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0202] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0203] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0204] Another aspect of the present application also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the image detection method as described above is implemented. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0205] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the image detection method provided in each of the above embodiments.
[0206] The above content is only a preferred exemplary embodiment of the present application and is not intended to limit the implementation scheme of the present application. A person skilled in the art can easily make corresponding changes or modifications based on the main concept and spirit of the present application. Therefore, the scope of protection of the present application shall be based on the scope of protection required by the claims.
Claims
1. An image detection method, characterized in that: include: Inputting an image to be detected into a pre-trained image detection model to obtain a detection value corresponding to the image to be detected output by the image detection model, wherein the image detection model includes a first network for extracting a first visual feature of the image to be detected and a second network for extracting a second visual feature of the image to be detected, and the detection value is obtained according to a feature difference between the first visual feature and the second visual feature; Determine the image to be detected whose detection value is greater than a preset detection threshold as a target image; The method further comprises: Initial model construction step: presetting an initial first network; extracting pre-training data based on a visual database, and initializing weight parameters of the initial first network according to the pre-training data to obtain the first network; constructing the initial image detection model based on the first network and the initial second network; Training step: inputting the image to be trained into the initial image detection model, and adjusting the weight parameter of the initial second network according to the feature difference between the first training feature output by the first network and the second training feature output by the initial second network, wherein the image to be trained does not include the target image; The training steps are repeated until the pre-trained image detection model is obtained.
2. The method according to claim 1, characterized in that The step of inputting the image to be trained into the initial image detection model, and adjusting the weight parameters of the initial second network according to the feature difference between the first training feature output by the first network and the second training feature output by the initial second network, comprises: Acquire a first training feature output by a first training network layer from the first network, and acquire a second training feature output by a second training network layer from the initial second network, wherein the first training network layer corresponds to the second training network layer; The weight parameter of the second training network layer is adjusted according to the feature difference between the first training feature and the second training feature.
3. The method according to claim 1, characterized in that The step of inputting the image to be detected into a pre-trained image detection model to obtain a detection value corresponding to the image to be detected includes: Inputting the image to be detected into the image detection model to obtain a plurality of first visual features and a plurality of second visual features, wherein the number of the plurality of first visual features is the same as the number of the plurality of second visual features, the plurality of first visual features are visual features respectively output by a plurality of network layers in the first network, and the plurality of second visual features are visual features respectively output by a plurality of network layers in the second network corresponding to the plurality of network layers in the first network; The detection value of the image to be detected is calculated according to the feature difference between each first visual feature and the corresponding second visual feature.
4. The method according to claim 3, characterized in that: The step of calculating the detection value of the image to be detected according to the feature difference between each first visual feature and the corresponding second visual feature includes: Comparing the difference between each first visual feature and the corresponding second visual feature respectively to obtain a plurality of feature comparison values; Assigning a weight value to each of the plurality of feature comparison values; The weighted sum between each feature comparison value and the corresponding weight value is calculated to obtain the detection value of the image to be detected.
5. The method according to claim 4, characterized in that The target image is a flower screen image; after calculating the weighted sum between each feature comparison value and the corresponding weight value to obtain the detection value of the image to be detected, the method further includes: Determine the image to be detected whose detection value is greater than a preset detection threshold as a flower screen image; Determine the degree of screen distortion of the image to be detected according to the detection difference between the detection value and the detection threshold; The screen distortion position of the image to be detected is determined according to the multiple feature comparison values and the network layer corresponding to each feature comparison value.
6. An image detection device, characterized in that: include: A detection value acquisition module, configured to input an image to be detected into a pre-trained image detection model, and obtain a detection value corresponding to the image to be detected output by the image detection model, wherein the image detection model includes a first network for extracting a first visual feature of the image to be detected and a second network for extracting a second visual feature of the image to be detected, and the detection value is obtained according to a feature difference between the first visual feature and the second visual feature; A detection module, configured to determine an image to be detected whose detection value is greater than a preset detection threshold as a target image; The image detection device also includes: An image detection model construction module is configured to perform an initial model construction step: construct an initial image detection model, wherein the initial image detection model includes the first network and an initial second network; A model training module is configured to repeatedly perform a training step until the pre-trained image detection model is obtained, the training step comprising: inputting an image to be trained into the initial image detection model, and adjusting a weight parameter of the initial second network according to a feature difference between a first training feature output by the first network and a second training feature output by the initial second network, wherein the image to be trained does not include the target image; The image detection model building blocks include: A first network construction unit, configured to preset an initial first network; A first network initialization unit is configured to extract pre-training data based on a visualization database, and initialize weight parameters of the initial first network according to the pre-training data to obtain the first network; An image detection model building unit is configured to build the initial image detection model based on the first network and the initial second network.
7. An electronic device, characterized in that: include: one or more processors; A storage device, used to store one or more computer programs, when the one or more computer programs are executed by the one or more processors, enables the electronic device to implement the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method according to any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
