Image watermarking removing method based on countermeasure networkTechnical Field
The invention relates to the technical field of artificial intelligence and image watermark removal, in particular to an image watermark removal method based on a countermeasure network.
Background
With the popularization of the internet and the rapid development of communication tools, people tend to release photos and videos on the internet to store precious memories and record good moments in life. In order to protect the copyright of pictures or videos, many software adopts a mode of adding watermarks on pictures. At present, artificial intelligence is gradually popularized to various fields, the basis of the artificial intelligence is the learning of large-scale data, watermarks can interfere or destroy the internal information of the data to a certain degree, and the learning of a model is greatly influenced. Meanwhile, various watermarking technologies are different, and the robustness and the anti-interference performance of the watermarking technologies need to be tested. Based on the above two points, the watermark removal technology gradually becomes a big hotspot in the current computer vision field.
Due to the variety of watermark categories and styles, watermark removal technology is still a great challenge at present. Most of the existing methods are based on a target detection technology, a mature target detection framework is used for detecting the position of a watermark, then a watermark area is cut out, and image conversion is carried out by using priori knowledge. But most of this a priori knowledge is designed for a particular pattern watermark, e.g. only one type of mark can be removed. The technologies not only need to manually mark the position of the watermark in the picture, but also need to perform image conversion based on experience design prior knowledge, and are time-consuming and labor-consuming, and because most of the technologies are formed by splicing a plurality of stages, each stage needs to be trained and learned respectively, so that the efficiency is low.
With the development of artificial intelligence, deep learning is gradually applied to various tasks, but deep learning requires a large amount of data as a basis. The watermarked data collected on the network has a great influence on model learning, so that efficient and accurate watermark removal technology is required to clean the data. On the other hand, in order to test the anti-interference performance of different watermarking technologies, the watermarking removal technology provides a powerful test condition. However, the prior art detection-based techniques require a lot of manpower to label the raw data, and are very time-consuming to train due to the multi-stage nature of the techniques. With the advent of anti-neural networks, image transformation techniques have been developed. The anti-neural network can automatically learn the hidden prior knowledge in the image only by inputting the original image and the target image, so that not only is the manpower saved, but also more distinctive information can be learned, and the image conversion effect is greatly improved.
In view of the above situation, the present invention provides a method for image watermarking based on a countermeasure network.
Disclosure of Invention
In order to make up for the defects of the prior art, the invention provides a simple and efficient image watermarking removing method based on a countermeasure network.
The invention is realized by the following technical scheme:
a method for image watermarking based on a countermeasure network is characterized by comprising the following steps:
firstly, a data set containing a picture with a watermark and a corresponding real picture is given, the picture with the watermark is input into a generator of a countermeasure network, and a picture with the watermark eliminated is generated;
secondly, sending the generated image with the watermark removed into a discriminator of the countermeasure network, distinguishing the generated image from a real image through the discriminator, evaluating the difference between the image with the watermark removed and the real image generated by the generator on the image level, and calculating loss;
thirdly, gradually optimizing a countermeasure network model through the countermeasure process of the generator and the discriminator so that the countermeasure network model can generate a high-level watermark-removed picture;
and fourthly, inputting the picture with the watermark into a generator of the trained countermeasure network to generate the picture without the watermark.
The generator aims at generating a watermark-removed picture which is judged as a real picture by a discriminator as much as possible; the goal of the discriminator is to distinguish the actual picture from the generated picture as correctly as possible.
In the first step, the data set is divided into a training set and a testing set, and the watermarked picture and the corresponding real picture are labeled.
In the first step and the fourth step, the RGB three-channel watermark-carrying picture x is input into a generator, and after convolution, activation, regularization and up-sampling operations, an RGB three-channel watermark-removing picture G (x) with the same size as the input picture is generated.
The method is characterized in that a deep learning segmentation network U-net (relational Networks for biological Image segmentation) commonly used in the medical field is used as a generator of the countermeasure network, and the deep learning segmentation network U-net is connected with low-level features and high-level features of the network through a skip structure, so that the network can simultaneously utilize structural information of the low-level features and semantic information of the high-level features.
In the second step, the watermark-removed picture generated by the generator is marked as a negative sample and input into the discriminator, the real picture is marked as a positive sample and input into the discriminator, and the discriminator is gradually trained.
In the second step, the discriminator is used for distinguishing whether the input picture is a real picture or a generated picture, and belongs to the classification problem, so that a pre-training model Resnet-101 is selected as the discriminator, and a feature pyramid structure FPN is added on the basis of the pre-training model Resnet-101 to enhance the network information expression capacity.
In the third step, a picture-level loss function L _1, a conventional cross entropy objective function L _2 and a perceptual loss function L _3 are used, and the three loss functions are used for guiding the training of the confrontation model.
The picture-level loss function L _1 is used for evaluating the difference between the generated picture G (x) and the real picture Y, and the picture-level loss function L _1 adopts the square error loss at the pixel level;
the discriminator objective is to minimize the objective function, the generator objective is to maximize the objective function, and in order to unify the form of three loss functions, the conventional cross-entropy objective function L _2 is inverted, and the countermeasure objective becomes arg (min) _ G (max) _ D ((-L) _ 2);
when the watermark in the image is particularly small, the receptive field of the high-level features of the pre-training model Resnet-101 is too large, and the small watermark features are easy to ignore; in order to avoid neglecting small watermark features in the image, intercepting the final layer of conv5 of the pre-training model Resnet-101, and calculating the perception loss by using the feature map of the generated picture and the feature map of the real picture in the layer, wherein the perception loss function L _3 adopts the pixel-level squared error loss.
In the third step, optimizing the countermeasure network model includes the steps of:
(1) fixing parameters of a discriminator, inputting the picture with the watermark into a generator, and training a k wheel;
(2) fixing generator parameters, inputting the real picture and the generated watermark-removed picture into a discriminator, and training a k wheel;
(3) and (3) alternately performing the step (1) and the step (2), training the generator and the discriminator at the same time, and gradually optimizing the model on the whole.
The invention has the beneficial effects that: the image watermarking removing method based on the countermeasure network does not need to mark the position of the watermark, and reduces the cost of manually marking the position of the data set; the model is simple, and end-to-end training and conjecture can be realized; the watermark removing effect is greatly improved by adopting three loss functions, and the watermark removing method can adapt to watermarks with different scales; and the confrontation model can learn the potential prior knowledge of different types and different styles of watermarks, and the generalization performance is strong.
Drawings
FIG. 1 is a schematic diagram of an image watermarking method based on a countermeasure network.
Detailed Description
In order to make those skilled in the art better understand the technical solution of the present invention, the technical solution in the embodiment of the present invention will be clearly and completely described below with reference to the embodiment of the present invention. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The image watermarking method based on the countermeasure network comprises the following steps:
firstly, a data set containing a picture with a watermark and a corresponding real picture is given, the picture with the watermark is input into a generator of a countermeasure network, and a picture with the watermark eliminated is generated;
secondly, sending the generated image with the watermark removed into a discriminator of the countermeasure network, distinguishing the generated image from a real image through the discriminator, evaluating the difference between the image with the watermark removed and the real image generated by the generator on the image level, and calculating loss;
thirdly, gradually optimizing a countermeasure network model through the countermeasure process of the generator and the discriminator so that the countermeasure network model can generate a high-level watermark-removed picture;
and fourthly, inputting the picture with the watermark into a generator of the trained countermeasure network to generate the picture without the watermark.
The generator aims at generating a watermark-removed picture which is judged as a real picture by a discriminator as much as possible; the goal of the discriminator is to distinguish the actual picture from the generated picture as correctly as possible.
In the first step, the data set is divided into a training set and a testing set, and the watermarked picture and the corresponding real picture are labeled.
In the first step and the fourth step, the RGB three-channel watermark-carrying picture x is input into a generator, and after convolution, activation, regularization and up-sampling operations, an RGB three-channel watermark-removing picture G (x) with the same size as the input picture is generated.
The method is characterized in that a deep learning segmentation network U-net (relational Networks for biological Image segmentation) commonly used in the medical field is used as a generator of the countermeasure network, and the deep learning segmentation network U-net is connected with low-level features and high-level features of the network through a skip structure, so that the network can simultaneously utilize structural information of the low-level features and semantic information of the high-level features.
In the second step, the watermark-removed picture generated by the generator is marked as a negative sample and input into the discriminator, the real picture is marked as a positive sample and input into the discriminator, and the discriminator is gradually trained.
In the second step, the discriminator is used for distinguishing whether the input picture is a real picture or a generated picture, and belongs to the classification problem, so that a pre-training model Resnet-101 is selected as the discriminator, and a feature pyramid structure FPN is added on the basis of the pre-training model Resnet-101 to enhance the network information expression capacity.
In the third step, a picture-level loss function L _1, a conventional cross entropy objective function L _2 and a perceptual loss function L _3 are used, and the three loss functions are used for guiding the training of the confrontation model.
The picture-level loss function L _1 is used for evaluating the difference between the generated picture G (x) and the real picture Y, and the picture-level loss function L _1 adopts the square error loss at the pixel level;
the discriminator objective is to minimize the objective function, the generator objective is to maximize the objective function, and in order to unify the form of three loss functions, the conventional cross-entropy objective function L _2 is inverted, and the countermeasure objective becomes arg (min) _ G (max) _ D ((-L) _ 2);
when the watermark in the image is particularly small, the receptive field of the high-level features of the pre-training model Resnet-101 is too large, and the small watermark features are easy to ignore; in order to avoid neglecting small watermark features in the image, intercepting the final layer of conv5 of the pre-training model Resnet-101, and calculating the perception loss by using the feature map of the generated picture and the feature map of the real picture in the layer, wherein the perception loss function L _3 adopts the pixel-level squared error loss.
In the third step, optimizing the countermeasure network model includes the steps of:
(1) fixing parameters of a discriminator, inputting the picture with the watermark into a generator, and training a k wheel;
(2) fixing generator parameters, inputting the real picture and the generated watermark-removed picture into a discriminator, and training a k wheel;
(3) and (3) alternately performing the step (1) and the step (2), training the generator and the discriminator at the same time, and gradually optimizing the model on the whole.
Compared with the prior art, the image watermarking removing method based on the countermeasure network has the following characteristics:
firstly, the data set of the used training model only needs to mark a watermark picture and a real picture, and does not need to mark a watermark position, so that the cost of manually marking the position of the data set is reduced;
secondly, the model is simple, and end-to-end training and conjecture can be realized without complex multi-stage respective training process;
thirdly, the watermark removing effect is greatly improved by adopting three loss functions, and the watermark removing method can adapt to watermarks with different scales;
fourthly, the countermeasure model can learn the potential priori knowledge of different types and different styles of watermarks, and the generalization performance is strong.
A method for image de-watermarking based on a countermeasure network in the embodiment of the present invention is described in detail above. While the present invention has been described with reference to specific examples, which are provided to assist in understanding the core concepts of the present invention, it is intended that all other embodiments that can be obtained by those skilled in the art without departing from the spirit of the present invention shall fall within the scope of the present invention.