Watermark adding method and device, equipment, storage medium and program product
By decoding and adding watermark features to the images generated by the AIGC model, and using multiple sample images and preset watermark features to train the model, the problem of watermarks affecting image quality in the existing technology has been solved, and efficient and effective processing of images generated by the AIGC model has been achieved. Compatible way to add watermarks.
Patent Information
- Application Number
- CN202410768866.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-17
AI Technical Summary
The method of adding digital watermarks in the prior art affects the quality of images generated by the AIGC model, and adding watermarks to training samples will affect the image quality, which in turn affects the quality of the images generated by the model.
By obtaining image generation features, inputting the trained watermark adding model for decoding processing, adding preset watermark features during the decoding process, using multiple sample images and preset watermark features to train the model, ensuring that the sample images do not have watermark features, thereby reducing impact on image quality.
When adding watermarks to images generated by the AIGC model, the impact on image quality is reduced, ensuring that the watermark features only affect the model generation process and not the image pixel values, and improve the compatibility of watermarks and image generation.
Smart Images

Figure CN118657651A
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a watermark adding method, device, equipment, storage medium and program product. Background Art
[0002] Digital watermarking is a technology that embeds specific information into digital media to protect intellectual property rights. AIGC is a technology that uses machine learning, deep learning, big data and other technical means to automatically generate new content by learning and understanding existing data.
[0003] At present, there are two main methods for adding digital watermarks to images generated by AIGC technology. The first is to add digital watermarks after the image is generated, but this may change the image pixels and affect the image quality. The second is to add digital watermarks to the training sample images of the AIGC model, so that the AIGC model can directly generate images with digital watermarks, but adding digital watermarks to the training sample images will also affect the image quality of the training sample images, and then affect the quality of the images generated by the trained AIGC model.
[0004] In summary, the methods of adding digital watermarks in the prior art have the problem of affecting image quality. Summary of the invention
[0005] The present application provides a watermark adding method, device, equipment, storage medium and program product, which are used to solve the problem that the method of adding digital watermark in the prior art affects the image quality.
[0006] In a first aspect, the present application provides a watermark adding method, comprising:
[0007] Acquire image generation features; the image generation features satisfy Gaussian distribution;
[0008] The image generation feature is input into a trained watermark adding model, the image generation feature is decoded by using the trained watermark adding model, and the preset watermark feature corresponding to the trained watermark adding model is added during the decoding process to obtain and output a target image with the preset watermark feature; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample image does not have the preset watermark feature, and the preset watermark feature is used to determine the loss value of the preset watermark adding model.
[0009] In a possible design, before inputting the image generation feature into the trained watermark adding model, the method further includes:
[0010] Obtaining a preset watermark adding model, multiple sample images and preset watermark features; the sample images do not have the preset watermark features;
[0011] A preset watermark adding model is trained using multiple sample images and preset watermark features, wherein the preset watermark features are used to determine a loss value of the preset watermark adding model until the loss value of the preset watermark adding model reaches a preset loss threshold, thereby obtaining a trained watermark adding model.
[0012] In a possible design, the preset watermark adding model includes a decoding network; the using of multiple sample images and preset watermark features to train the preset watermark adding model includes:
[0013] Extracting sample image features of each of the sample images using a first preset encoding network;
[0014] Using the decoding network to decode each of the sample image features to obtain a restored image corresponding to each of the sample image features;
[0015] Determining the loss value of the preset watermark adding model according to each of the restored images and the preset watermark features;
[0016] The parameters of the preset watermark adding model are adjusted according to the loss value of the preset watermark adding model.
[0017] In a possible design, determining the loss value of the preset watermark adding model according to each of the restored images and the preset watermark features includes:
[0018] Using a second preset encoding network to extract restored image features of each of the restored images;
[0019] The loss value of the preset watermark adding model is determined according to the preset watermark feature and each of the restored image features.
[0020] In a possible design, determining the loss value of the preset watermark adding model according to each of the restored images and the preset watermark features includes:
[0021] Performing transmission simulation processing on each of the restored images to obtain a noisy image corresponding to each of the restored images;
[0022] Using a second preset encoding network to extract restored image features of each of the restored images and noisy image features of each of the noisy images;
[0023] The loss value of the preset watermark adding model is determined according to the preset watermark feature, each of the restored image features and each of the noisy image features.
[0024] In a possible design, after obtaining and outputting the target image with the preset watermark feature, the method further includes:
[0025] Obtain an image to be recognized;
[0026] Extracting features to be identified of the image to be identified;
[0027] According to the preset watermark feature and the feature to be identified, it is determined whether the image to be identified is an image generated by a trained watermark adding model.
[0028] In a second aspect, the present application provides a watermark adding device, comprising:
[0029] An acquisition module, used for acquiring image generation features; the image generation features satisfy a Gaussian distribution;
[0030] A generation module is used to input the image generation features into a trained watermark adding model, use the trained watermark adding model to decode the image generation features, and add the preset watermark features corresponding to the trained watermark adding model during the decoding process to obtain and output a target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample image does not have the preset watermark features, and the preset watermark features are used to determine the loss value of the preset watermark adding model.
[0031] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor, and a memory communicatively connected to the processor;
[0032] The memory stores computer-executable instructions;
[0033] The processor executes the computer-executable instructions stored in the memory to implement the watermark adding method as described in the first aspect and various possible designs of the first aspect.
[0034] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the watermark adding method described in the first aspect and various possible designs of the first aspect is implemented.
[0035] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the watermark adding method described in the first aspect and various possible designs of the first aspect.
[0036] The watermark adding method, apparatus, device, storage medium and program product provided by the present application obtain image generation features; the image generation features satisfy Gaussian distribution; the image generation features are input into a trained watermark adding model, the image generation features are decoded by the trained watermark adding model, and preset watermark features corresponding to the trained watermark adding model are added during the decoding process to obtain and output a target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample images do not have the preset watermark features, and the preset watermark features are used to determine the loss value of the preset watermark adding model. Since the trained watermark adding model is obtained by training the preset watermark adding model using multiple sample images and preset watermark features, and the sample image does not have the preset watermark feature, the preset watermark feature is used to determine the loss value of the preset watermark adding model. Therefore, the image quality of the sample image will not be affected by the preset watermark feature. The preset watermark feature only affects the process of generating the image by the preset watermark adding model, thereby enabling the trained watermark adding model to add the preset watermark feature corresponding to the trained watermark adding model during the decoding process, thereby reducing the impact on the quality of the image generated by the AIGC model. In summary, the present application can reduce the impact on image quality when adding watermark features to the image. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0038] Figure 1 This is an application scenario diagram of the watermark adding method applicable to the embodiment of the present application;
[0039] Figure 2 The process of the watermark adding method provided in the embodiment of the present application Figure 1 ;
[0040] Figure 3 The process of the watermark adding method provided in the embodiment of the present application Figure 2 ;
[0041] Figure 4 The process of the watermark adding method provided in the embodiment of the present application Figure 3 ;
[0042] Figure 5 A schematic diagram of the structure of a watermark adding device provided in an embodiment of the present application;
[0043] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0044] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0045] Exemplary embodiments will be described in detail herein, 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 merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0046] It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0047] First, the prior art involved in this application is described in detail.
[0048] Digital watermarking is a technology that embeds specific information into digital media to protect intellectual property rights. There are two traditional methods for adding digital watermarks: spatial domain algorithms and transform domain algorithms. The spatial domain algorithm uses the superposition method to superimpose the grayscale values of the original image and the grayscale values of the watermark image in a certain proportion to obtain a watermarked image, or adjusts the least significant bit of the original image pixel through the least significant bit (LSB) algorithm to embed the watermark information. The transform domain algorithm uses wavelet transform to convert the image from the spatial domain to the frequency domain, and then embeds the watermark information on the transformed data.
[0049] However, in the above-mentioned methods of adding watermarks, whether directly modifying the pixel values or embedding the watermarks through more complex algorithms, the pixel values of the original image will be changed to a certain extent, thereby causing a decrease in image quality.
[0050] Artificial intelligence generated content (AIGC) is a technology that uses machine learning, deep learning, big data and other technical means to automatically generate new content by learning and understanding existing data. At present, the technology of generating images through AIGC models is widely used. For images generated by AIGC models, digital watermarks can be added to the images generated by AIGC models through traditional digital watermarking methods, or digital watermarks can be added to the training sample images of AIGC models through traditional methods, so that AIGC models can directly generate images with digital watermarks. However, adding digital watermarks to images generated by AIGC models through traditional digital watermarking methods will directly affect the image quality, and adding digital watermarks to training sample images will also affect the image quality of training sample images, thereby affecting the quality of images generated by the trained AIGC model.
[0051] In summary, the methods of adding digital watermarks in the prior art have the problem of affecting image quality.
[0052] In response to the above technical problems in the prior art, the present application proposes the following inventive concept: adding watermarks through traditional methods of adding digital watermarks will affect the image quality, but the image generated by the AIGC model is obtained by decoding the image features. If the digital watermark is not added to the training sample, and the watermark is not added to the image generated by the AIGC model, but the watermark is added during the decoding process, then, compared to directly adding the digital watermark to the training sample, the digital watermark is integrated into the pixels at certain fixed positions of the image. When the digital watermark is added during the decoding process, the digital watermark can be dynamically integrated into the pixels at different positions of the image. As a result, the digital watermark can be more perfectly integrated into the image generated by the AIGC model, which can not only reduce the impact on the quality of the image generated by the AIGC model, but also add the digital watermark to the image generated by the AIGC model.
[0053] Therefore, the present application proposes a watermark adding method, device, equipment, storage medium and program product, the watermark adding method comprising: obtaining image generation features; the image generation features satisfying Gaussian distribution; inputting the image generation features into a trained watermark adding model, decoding the image generation features using the trained watermark adding model, and adding preset watermark features corresponding to the trained watermark adding model during the decoding process to obtain and output a target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model using multiple sample images and preset watermark features, the sample image does not have the preset watermark features, and the preset watermark features are used to determine the loss value of the preset watermark adding model. Since the trained watermark adding model is obtained by training the preset watermark adding model using multiple sample images and preset watermark features, and the sample image does not have the preset watermark feature, the preset watermark feature is used to determine the loss value of the preset watermark adding model. Therefore, the image quality of the sample image will not be affected by the preset watermark feature. The preset watermark feature only affects the process of generating the image by the preset watermark adding model, thereby enabling the trained watermark adding model to add the preset watermark feature corresponding to the trained watermark adding model during the decoding process, thereby reducing the impact on the quality of the image generated by the AIGC model. In summary, the present application can reduce the impact on image quality when adding watermark features to the image.
[0054] Figure 1 This is an application scenario diagram of the watermark adding method provided in the embodiment of the present application. Figure 1 As shown, in an application scenario of the watermark adding method provided in an embodiment of the present application, it includes: a client device 11 and a server device 12.
[0055] The client device 11 may be configured with a client application of the AIGC model, and the user may input description information of the image to be generated in the human-computer interaction interface of the client application. After receiving the description information input by the user, the client device may send an image generation request to the server device 12, and the image generation request includes the description information.
[0056] The server device 12 includes an encoding sub-device 121 and a decoding sub-device 122, and is configured with a server application of the AIGC model, and the encoding sub-device 121 and the decoding sub-device 122 are used to execute the server application of the AIGC model. The encoding sub-device 121 is configured with an encoding network, and the decoding sub-device 122 is configured with a trained watermarking model.
[0057] The server device 12 receives the image generation request sent by the client device 11 .
[0058] The server device 12 inputs the description information into the encoding sub-device 121, and uses the encoding network to convert the description information into image generation features, and the image generation features satisfy the Gaussian distribution.
[0059] Among them, the encoding network can perform text embedding processing on the description information, convert the description information into a continuous embedding vector, and determine the continuous embedding vector as the image generation feature.
[0060] The server device 12 inputs the image generation features into the decoding sub-device 122 .
[0061] The decoding sub-device 122 obtains the image generation feature; inputs the image generation feature into the trained watermark adding model, uses the trained watermark adding model to decode the image generation feature, and adds the preset watermark feature corresponding to the trained watermark adding model during the decoding process, obtains the target image with the preset watermark feature and outputs it. For example, the server device 12 can send an image generation response to the client device 11, and the image generation response can include the target image, so that the client device 11 outputs the target image.
[0062] The trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, and the sample images do not have the preset watermark features.
[0063] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0064] based on Figure 1 In the application scenario shown, the embodiment of the present application also provides a watermark adding method. The execution subject of the watermark adding method provided in the embodiment of the present application is a watermark adding device, and the watermark adding device is located in the electronic device.
[0065] Figure 2 The process of the watermark adding method provided in the embodiment of the present application Figure 1 .like Figure 2 As shown, the watermark adding method includes steps 201 to 202.
[0066] Step 201, obtaining image generation features; the image generation features satisfy the Gaussian distribution.
[0067] Gaussian distribution, also known as normal distribution, is a continuous probability distribution. The image generation feature satisfies Gaussian distribution means that each dimension of the image generation feature follows normal distribution.
[0068] In this embodiment, the electronic device may also include an image generation feature coding network, which is used to convert text description information of the image content into image generation features. Therefore, the electronic device may use the image generation feature coding network to convert text description information of the image content into image generation features. Alternatively, the electronic device may also be connected to the image generation feature coding device for communication and receive the image generation features sent by the image generation feature coding device.
[0069] Step 202, input the image generation features into the trained watermark adding model, use the trained watermark adding model to decode the image generation features, and add the preset watermark features corresponding to the trained watermark adding model during the decoding process to obtain and output the target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, and the sample image does not have the preset watermark features.
[0070] The preset watermark adding model may be a trained AIGC model for generating images, and the trained AIGC model may be obtained by training the preset AIGC model using multiple sample images. The trained AIGC model may be a trained generative adversarial network GAN or a trained variational autoencoder VAE, and both GAN and VAE can generate target images based on image generation features.
[0071] The trained watermark adding model and the preset watermark adding model may have the same network structure and different model parameters. The process of training the preset watermark adding model using multiple sample images and preset watermark features can be understood as the process of adjusting the parameters of the preset watermark adding model.
[0072] When training the preset watermark adding model, since the sample image does not have the preset watermark feature, there is no need to add the preset watermark feature to the sample image, and the image quality of the sample image will not be affected. The preset watermark feature is used to determine the loss value of the preset watermark adding model, and the loss value of the preset watermark adding model is used to adjust the parameters of the preset generation model. Therefore, in the process of training the preset generation model, the image generated by the preset generation model can not only fit the sample image, but also have the preset watermark feature, which can reduce the impact on the quality of the image generated by the preset generation model, but also add the watermark feature to the image generated by the preset generation model.
[0073] The watermark adding method provided in the embodiment of the present application obtains image generation features; the image generation features satisfy Gaussian distribution; the image generation features are input into a trained watermark adding model, the image generation features are decoded by the trained watermark adding model, and preset watermark features corresponding to the trained watermark adding model are added during the decoding process to obtain and output a target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample image does not have the preset watermark features, and the preset watermark features are used to determine the loss value of the preset watermark adding model. Since the trained watermark adding model is obtained by training the preset watermark adding model using multiple sample images and preset watermark features, and the sample image does not have the preset watermark feature, the preset watermark feature is used to determine the loss value of the preset watermark adding model. Therefore, the image quality of the sample image will not be affected by the preset watermark feature. The preset watermark feature only affects the process of generating the image by the preset watermark adding model, thereby enabling the trained watermark adding model to add the preset watermark feature corresponding to the trained watermark adding model during the decoding process, thereby reducing the impact on the quality of the image generated by the AIGC model. In summary, the present application can reduce the impact on image quality when adding watermark features to the image.
[0074] Figure 3 The process of the watermark adding method provided in the embodiment of the present application Figure 2 .like Figure 3 As shown, the watermark adding method provided in the embodiment of the present application, based on the above embodiment, also includes steps 301 to 302 before "inputting the image generation features into the trained watermark adding model" in step 202.
[0075] Step 301, obtaining a preset watermark adding model, multiple sample images and preset watermark features; the sample images do not have the preset watermark features.
[0076] In this embodiment, the preset watermark adding model may include an encoding network and a decoding network. The encoding network of the preset watermark adding model may be an encoder of a variational autoencoder, and the decoding network of the preset watermark adding model may be a decoder of a variational autoencoder. The sample image does not have a preset watermark feature, that is, there is no need to add a preset watermark feature to the sample image.
[0077] Step 302, a preset watermark adding model is trained using multiple sample images and preset watermark features, wherein the preset watermark features are used to determine a loss value of the preset watermark adding model until the loss value of the preset watermark adding model reaches a preset loss threshold, thereby obtaining a trained watermark adding model.
[0078] In this embodiment, the process of the electronic device using multiple sample images and preset watermark features to train the preset watermark adding model may include steps 3021 to 3025.
[0079] In step 3021, the electronic device uses a coding network of a preset watermark adding model to extract sample image features of multiple sample images.
[0080] In step 3022, the electronic device uses a decoding network of a preset watermark adding model to decode each sample image feature to obtain a restored image corresponding to each sample image feature.
[0081] Step 3023: The electronic device determines the loss value of the preset watermark adding model according to each restored image and the preset watermark features.
[0082] Specifically, the electronic device may extract the restored image features of each restored image, calculate the first feature loss value between each restored image feature and the preset watermark feature, and determine the first feature loss value between each restored image feature and the preset watermark feature as the loss value of the preset watermark adding model. The first feature loss value may be the mean square error MSE or the perceptual loss between the restored image feature and the preset watermark feature.
[0083] In step 3024, the electronic device adjusts the parameters of the preset watermark adding model according to the loss value of the preset watermark adding model.
[0084] Specifically, the electronic device may adjust the parameters of the decoder of the preset watermark adding model by using a back propagation algorithm, or adjust the parameters of the encoder and decoder of the preset watermark adding model.
[0085] In step 3024, the electronic device repeatedly executes step 3021 to step 3024 until the loss value of the preset watermark adding model reaches the preset loss threshold, and determines the preset watermark adding model whose loss value reaches the preset loss threshold as the trained watermark adding model.
[0086] The watermark adding method provided in this embodiment embeds watermark features by adjusting the image reconstruction process of the decoder, so that the decoder can adjust its output according to the image generation characteristics and the preset watermark feature pattern while reconstructing the image, so that the watermark features are embedded in the target image, reducing the impact on the quality of the target image.
[0087] Optionally, the preset watermark adding model includes a decoding network, and the “using multiple sample images and preset watermark features to train the preset watermark adding model” in step 302 is further refined to include steps 401 to 404 .
[0088] Step 401: extracting sample image features of each sample image using a first preset encoding network.
[0089] In this embodiment, the first preset encoding network can be an encoder of a variational autoencoder VAE model, or a recurrent neural network RNN, a convolutional neural network CNN, a Transformer, etc.
[0090] The electronic device uses a first preset coding network to extract sample image features of each sample image. The sample image features are vectors.
[0091] Step 402: decode each sample image feature using a decoding network to obtain a restored image corresponding to each sample image feature.
[0092] In this embodiment, the decoding network may be a decoder of a variational autoencoder, and the electronic device uses the decoding network to perform decoding processing on each sample image feature to obtain a restored image corresponding to each sample image feature.
[0093] Step 403: determining the loss value of the preset watermark adding model according to the restored images and the preset watermark features.
[0094] In this embodiment, the electronic device can extract the restored image features of each restored image, calculate the first feature loss value between each restored image feature and the preset watermark feature, and calculate the restoration loss value between each restored image and the corresponding sample image. Then, the electronic device can perform weighted summation calculation on the first feature loss value and the restoration loss value according to the corresponding preset weights to obtain the loss value of the preset watermark adding model. The restoration loss value can be the mean square error MSE or perceptual loss between the restored image and the corresponding sample image.
[0095] Step 404: adjust the parameters of the preset watermark adding model according to the loss value of the preset watermark adding model.
[0096] Specifically, the electronic device may adjust the parameters of the preset watermark adding model by using a gradient descent method.
[0097] Optionally, the electronic device may also use a plurality of sample image features and preset watermark features to train a preset watermark adding model, see steps 402 to 404 for details, which will not be described in detail here.
[0098] The watermark adding method provided in this embodiment determines the loss value of the preset watermark adding model according to each restored image and the preset watermark feature, and adjusts the parameters of the preset watermark adding model according to the loss value of the preset watermark adding model. It can add the preset watermark feature in the process of generating the image without directly operating the pixels of the image, so that the quality of the original image can be kept intact. In addition, the watermark adding is closely integrated with the image generation process without the need for an additional watermark embedding algorithm, which can reduce the computational complexity of adding the watermark and improve the efficiency of embedding the watermark.
[0099] Figure 4 The process of the watermark adding method provided in the embodiment of the present application Figure 3 .like Figure 4 As shown, the watermark adding method provided in the embodiment of the present application is based on the above embodiment, and step 404 "determining the loss value of the preset watermark adding model according to each restored image and the preset watermark features" is refined to include steps 501 to 503.
[0100] Step 501 : Perform transmission simulation processing on each restored image to obtain a noisy image corresponding to each restored image.
[0101] In this embodiment, the transmission simulation processing may include at least one of the following: shearing, rotation, compression and then decompression, and the transmission simulation processing is used to simulate the damage that the image may suffer during the actual transmission process. After the transmission simulation processing, the restored image is added with noise and becomes a noisy image.
[0102] Step 502: Use a second preset encoding network to extract restored image features of each restored image and noisy image features of each noisy image.
[0103] In this embodiment, the second preset encoding network may be the same as the first preset encoding network, and the second preset encoding network is used to extract noisy image features of the noisy image.
[0104] Step 503: determining the loss value of the preset watermark adding model according to the preset watermark feature, each restored image feature and each noisy image feature.
[0105] In this embodiment, the electronic device can calculate the first feature loss value between each restored image feature and the preset watermark feature, and calculate the second feature loss value between each noisy image feature and the preset watermark feature. Furthermore, the electronic device can perform weighted summation calculation on the first feature loss value and the second feature loss value according to the corresponding preset weights to obtain the loss value of the preset watermark adding model. Among them, the second feature loss value can be the mean square error MSE or perceptual loss between the noisy image feature and the preset watermark feature.
[0106] Optionally, the electronic device may calculate a first feature loss value between each restored image feature and a preset watermark feature, calculate a second feature loss value between each noisy image feature and a preset watermark feature, and calculate a restoration loss value between each restored image and a corresponding sample image. Furthermore, the electronic device may perform a weighted sum calculation on the first feature loss value, the second feature loss value, and the restoration loss value according to the corresponding preset weights to obtain a loss value of the preset watermark adding model.
[0107] The watermark adding method provided in this embodiment can simulate the damage that the image may suffer during the actual transmission process by performing transmission simulation processing on each restored image, and then use the second preset coding network to extract the restored image features of each restored image and the noisy image features of each noisy image; determine the loss value of the preset watermark adding model according to the preset watermark features, the features of each restored image and the features of each noisy image, so that the watermark features in the target image will not be destroyed during the transmission process, thereby improving the anti-interference ability of the watermark.
[0108] Optionally, based on any one of the above embodiments, after “obtaining and outputting a target image having a preset watermark feature” in step 202, steps 601 to 604 are also included.
[0109] Step 601: Obtain an image to be recognized.
[0110] In this embodiment, the image to be identified is an image that needs to be identified whether it has a preset watermark feature. The image to be identified can be sent to the electronic device by a client device that is communicatively connected to the electronic device.
[0111] Step 602: extracting features to be identified from the image to be identified.
[0112] In this embodiment, the electronic device can extract the features to be identified of the image to be identified through the encoder of the variational autoencoder VAE model, the recurrent neural network RNN, the convolutional neural network CNN, the Transformer, etc., and the features to be identified have a Gaussian distribution.
[0113] Step 603: Determine whether the image to be identified is an image generated by the trained watermark adding model according to the preset watermark features and the features to be identified.
[0114] In this embodiment, the electronic device can calculate the similarity between the feature to be identified and the preset watermark feature, for example, cosine similarity. If the similarity between the feature to be identified and the preset watermark feature is greater than a preset similarity threshold, it can be determined that the image to be identified is an image generated by the trained watermark adding model; conversely, if the similarity between the feature to be identified and the preset watermark feature is less than the preset similarity threshold, it can be determined that the image to be identified is not an image generated by the trained watermark adding model. In the case where the similarity between the feature to be identified and the preset watermark feature is equal to the preset similarity threshold, it can be determined that the image to be identified is an image generated by the trained watermark adding model, or it can be determined that the image to be identified is not an image generated by the trained watermark adding model, which is not limited here.
[0115] The watermark adding method provided in this embodiment extracts the features to be identified of the image to be identified, and determines whether the image to be identified is an image generated by the trained watermark adding model based on the preset watermark features and the features to be identified. It can quickly and accurately determine whether the image to be identified is an image generated by the trained watermark adding model.
[0116] Figure 5 This is a schematic diagram of the structure of the watermark adding device provided in the embodiment of the present application. Figure 5 As shown, the watermark adding device 50 provided in this embodiment includes: an acquisition module 51 and a generation module 52.
[0117] The acquisition module 51 is used to acquire image generation features; the image generation features satisfy the Gaussian distribution.
[0118] The generation module 52 is used to input the image generation features into the trained watermark adding model, use the trained watermark adding model to decode the image generation features, and add the preset watermark features corresponding to the trained watermark adding model during the decoding process to obtain and output the target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample image does not have the preset watermark features, and the preset watermark features are used to determine the loss value of the preset watermark adding model.
[0119] Optionally, the watermark adding device further comprises a training module, and the training module is used for:
[0120] Obtain a preset watermark adding model, multiple sample images and preset watermark features; the sample image does not have the preset watermark features;
[0121] A preset watermark adding model is trained using multiple sample images and preset watermark features. The preset watermark features are used to determine the loss value of the preset watermark adding model until the loss value of the preset watermark adding model reaches a preset loss threshold, thereby obtaining a trained watermark adding model.
[0122] Optionally, the preset watermark adding model includes a decoding network; the training module is specifically used for:
[0123] Extracting sample image features of each sample image using a first preset encoding network;
[0124] A decoding network is used to decode the features of each sample image to obtain a restored image corresponding to each sample image feature;
[0125] Determine the loss value of the preset watermark adding model according to each restored image and the preset watermark features;
[0126] The parameters of the preset watermark adding model are adjusted according to the loss value of the preset watermark adding model.
[0127] Optionally, the training module is further used to:
[0128] extracting restored image features of each restored image using a second preset encoding network;
[0129] The loss value of the preset watermark adding model is determined according to the preset watermark features and the features of each restored image.
[0130] Optionally, the training module is further used to:
[0131] Performing transmission simulation processing on each restored image to obtain a noisy image corresponding to each restored image;
[0132] A second preset encoding network is used to extract restored image features of each restored image and noisy image features of each noisy image;
[0133] The loss value of the preset watermark adding model is determined according to the preset watermark features, the features of each restored image and the features of each noisy image.
[0134] Optionally, the watermark adding device further includes an identification module, and the identification module is used to:
[0135] Obtain an image to be recognized;
[0136] Extracting features to be identified from the image to be identified;
[0137] According to the preset watermark features and the features to be identified, it is determined whether the image to be identified is an image generated by the trained watermark adding model.
[0138] The watermark adding device provided in this embodiment can execute the watermark adding method provided in any of the above embodiments. The specific implementation method and principle are similar and will not be repeated here.
[0139] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 60 provided in the embodiment of the present application includes: a processor 62 and a memory 61 communicatively connected to the processor 62 .
[0140] The memory 61 stores computer-executable instructions.
[0141] The processor 62 executes the computer-executable instructions stored in the memory 61 to implement a watermark adding method as provided in any of the above embodiments. The specific implementation method and principle are similar and will not be described in detail here.
[0142] The memory 61 and the processor 62 can be connected to each other through a bus. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0143] The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk, etc.
[0144] The electronic device can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to execute the watermark adding method provided in any of the above embodiments.
[0145] The embodiment of the present application also provides a chip for running instructions, which is used to execute the technical solution of the watermark adding method in the above embodiment.
[0146] The embodiment of the present application also provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, they are used to implement the watermark adding method provided in any of the above embodiments, and the specific implementation method and principle are similar, and will not be repeated here. Exemplarily, the computer-readable storage medium can be a read-only memory, a random access memory, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0147] The embodiment of the present application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the watermark adding method provided by any of the above embodiments is implemented. The specific implementation method and principle are similar and will not be repeated here.
[0148] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.
[0149] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.
[0150] In addition, each functional module in each embodiment of the present application can be integrated into one processing unit, or each module can exist physically separately, or two or more modules can be integrated into one unit. The above-mentioned module-composed unit can be implemented in the form of hardware or in the form of hardware plus software functional units.
[0151] The above integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above software function module is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute some steps of the watermark adding method provided in various embodiments of the present application.
[0152] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.
[0153] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0154] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic control unit or a main control device.
[0155] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0156] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
Claims
1. A watermark adding method, characterized in that: include: Acquire image generation features; the image generation features satisfy Gaussian distribution; The image generation feature is input into a trained watermark adding model, the image generation feature is decoded by using the trained watermark adding model, and the preset watermark feature corresponding to the trained watermark adding model is added during the decoding process to obtain and output a target image with the preset watermark feature; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample image does not have the preset watermark feature, and the preset watermark feature is used to determine the loss value of the preset watermark adding model.
2. The method according to claim 1, characterized in that Before inputting the image generation feature into the trained watermark adding model, the method further includes: Obtaining a preset watermark adding model, multiple sample images and preset watermark features; the sample images do not have the preset watermark features; A preset watermark adding model is trained using multiple sample images and preset watermark features, wherein the preset watermark features are used to determine the loss value of the preset watermark adding model until the loss value of the preset watermark adding model reaches a preset loss threshold, thereby obtaining a trained watermark adding model.
3. The method according to claim 2, characterized in that The preset watermark adding model includes a decoding network; the training of the preset watermark adding model using a plurality of sample images and preset watermark features includes: Extracting sample image features of each of the sample images using a first preset encoding network; Using the decoding network to decode each of the sample image features to obtain a restored image corresponding to each of the sample image features; Determining the loss value of the preset watermark adding model according to each of the restored images and the preset watermark features; The parameters of the preset watermark adding model are adjusted according to the loss value of the preset watermark adding model.
4. The method according to claim 3, characterized in that: The determining the loss value of the preset watermark adding model according to each of the restored images and the preset watermark features includes: Using a second preset encoding network to extract restored image features of each of the restored images; The loss value of the preset watermark adding model is determined according to the preset watermark feature and each of the restored image features.
5. The method according to claim 3, characterized in that: The determining the loss value of the preset watermark adding model according to each of the restored images and the preset watermark features includes: Performing transmission simulation processing on each of the restored images to obtain a noisy image corresponding to each of the restored images; Using a second preset encoding network to extract restored image features of each of the restored images and noisy image features of each of the noisy images; The loss value of the preset watermark adding model is determined according to the preset watermark feature, each of the restored image features and each of the noisy image features.
6. The method according to any one of claims 1 to 5, characterized in that: After obtaining and outputting the target image with the preset watermark feature, the method further includes: Obtain an image to be recognized; Extracting features to be identified of the image to be identified; According to the preset watermark feature and the feature to be identified, it is determined whether the image to be identified is an image generated by a trained watermark adding model.
7. A watermark adding device, characterized in that: include: An acquisition module, used for acquiring image generation features; the image generation features satisfy a Gaussian distribution; A generation module is used to input the image generation features into a trained watermark adding model, use the trained watermark adding model to decode the image generation features, and add the preset watermark features corresponding to the trained watermark adding model during the decoding process to obtain and output a target image with the preset watermark features; the trained watermark adding model is obtained by training the preset watermark adding model with multiple sample images and preset watermark features, the sample image does not have the preset watermark features, and the preset watermark features are used to determine the loss value of the preset watermark adding model.
8. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 6 when executed by a processor.
10. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 6 when being executed by a processor.
Citation Information
Cited By
Training method of watermark image generation model, watermark image generation method and equipment
CN120355558A
