Watermark detection model training method, watermark removal method, device and electronic equipment

By obtaining watermark images and logos from the template watermark image library and generating sample images for training, the high cost problem caused by manual labeling in the existing technology is solved, and efficient watermark detection and removal is achieved.

CN114612282BActive Publication Date: 2025-09-09BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210267780.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-17
Publication Date
2025-09-09
Estimated Expiration
2042-03-17

AI Technical Summary

Technical Problem

In the existing technology, training a watermark detection model requires manual annotation of a large number of images, resulting in high model training costs.

Method used

By obtaining watermark images and logos from the template watermark image library and adding them to the specified area of ​​the sample image, sample images for training are generated without manually labeling watermark logos and areas, and adjusting the image transparency and size to improve the display effect and detection accuracy.

Benefits of technology

The model training cost is reduced, the sample image generation efficiency and the accuracy of the watermark detection model are improved, and the background image is not affected when removing the watermark through the difference image, thereby improving the watermark removal effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114612282B_ABST
    Figure CN114612282B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a watermark detection model training method, a watermark removal method, a device, and an electronic device, and belongs to the field of computer technology. The method comprises: obtaining a first watermark image and a first watermark identifier corresponding to the first watermark image from a template watermark image library, wherein the template watermark image library is used to store at least one template watermark image corresponding to a watermark identifier; adding the first watermark image to a sample watermark region in the first image to obtain a sample image; training a watermark detection model based on the sample image, the sample watermark region, and the first watermark identifier, wherein the trained watermark detection model is used to detect a watermark image and a watermark identifier from any image, wherein the watermark identifier is a watermark identifier in the template watermark image library of the watermark contained in the detected watermark image. This method does not require manual labeling of sample images, thereby reducing the training cost of the model and improving the efficiency of generating sample images.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a watermark detection model training method, a watermark removal method, a device, and an electronic device. Background Art

[0002] To indicate the source of an image, a watermark is usually added to the image. However, the watermark will interfere with the original information of the image to a certain extent. In order to avoid the interference of the watermark when processing the downloaded image later, it is necessary to remove the watermark from the image.

[0003] In related technologies, a network model is usually used to detect watermarks in images and then remove the watermarks from the images. However, when training the network model, a large number of images need to be manually labeled, resulting in high model training costs. Summary of the Invention

[0004] The present disclosure provides a watermark detection model training method, a watermark removal method, a device and an electronic device, which do not require manual image annotation and reduce the cost of model training.

[0005] According to one aspect of an embodiment of the present disclosure, a watermark detection model training method is provided, the method comprising:

[0006] Acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from a template watermark image library, wherein the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier;

[0007] Adding the first watermark image to a sample watermark region in the first image to obtain a sample image;

[0008] Based on the sample image, the sample watermark area and the first watermark identifier, a watermark detection model is trained. The trained watermark detection model is used to detect the watermark image and the watermark identifier from any image. The watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library.

[0009] The method provided by the embodiment of the present disclosure adds a first watermark image in a template watermark image library to a sample watermark area in a first image to obtain a sample image for training a watermark detection model. In the process of generating the sample image, the watermark identifier corresponding to the added first watermark image and the sample watermark area containing the watermark in the first image have been determined, that is, the labeling of the sample image is realized, and there is no need to manually label the watermark identifier and the sample watermark area in the sample image, thereby reducing the training cost of the model and improving the efficiency of generating sample images.

[0010] In some embodiments, the transparency of the first watermark image is a first transparency, the transparency of the watermark to be added to the first image is a second transparency, and before adding the first watermark image to the sample watermark region in the first image to obtain the sample image, the method further includes:

[0011] determining a first ratio between the second transparency and the first transparency;

[0012] The first ratio is multiplied by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image.

[0013] In the disclosed embodiment, since the transparency of the first watermark image in the template watermark image library is fixed, and when synthesizing the sample image, the transparency of the watermark to be added may be different from the transparency of the first watermark image, before adding the first watermark image, the transparency of the first watermark image is adjusted so that the transparency of the added watermark is the required transparency, thereby improving the display effect of the generated sample image.

[0014] In some embodiments, before adding the first watermark image to the sample watermark area in the first image to obtain the sample image, the method further includes:

[0015] determining a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold;

[0016] The third transparency is multiplied by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area.

[0017] In the embodiment of the present disclosure, since the first watermark image is directly added to the sample watermark area and the transparency of the first watermark image is an image with a certain transparency, the transparency of the sample watermark area after the first watermark image is added will be inconsistent with the transparency of other areas in the first image. Therefore, by adjusting the transparency of the sample watermark area, after the first watermark image is subsequently added to the sample watermark area, the transparency of the sample watermark area is still consistent with the transparency of other areas in the first image, thereby improving the display effect of the sample image.

[0018] In some embodiments, before adding the first watermark image to the sample watermark area in the first image to obtain the sample image, the method further includes:

[0019] determining the sample watermark region in the first image, wherein the sample watermark region has the same shape as the first watermark image;

[0020] The size of the first watermark image is adjusted to be consistent with the size of the sample watermark area.

[0021] In the disclosed embodiment, since the sample watermark area is directly used as the sample watermark area in the sample image during subsequent training, and the watermark detection model is used to detect the watermark image in the sample image, when the size of the sample watermark area is inconsistent with the size of the first watermark image, the size of the watermark image detected by the watermark detection model is inconsistent with the size of the actually added watermark image, thereby affecting the accuracy of the watermark detection model. Therefore, by adjusting the size of the first watermark image to be consistent with the size of the sample watermark area, the subsequently trained watermark detection model can accurately detect the watermark image from the image, thereby improving the detection accuracy of the watermark detection model.

[0022] In some embodiments, after training the watermark detection model based on the sample image, the sample watermark area, and the first watermark identifier, the method further includes:

[0023] calling the watermark detection model to perform watermark detection on the second image, and obtaining a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image;

[0024] Querying a second watermark image corresponding to the second watermark identifier from the template watermark image library, where the second watermark image contains the watermark;

[0025] The watermark image in the second image is replaced with a difference image between the watermark image and the second watermark image to obtain a third image.

[0026] In the disclosed embodiment, since the first watermark image added to the sample image and the first watermark identifier corresponding to the first watermark image are both stored in the template watermark image library during the training process of the watermark detection model, the second watermark identifier detected by the trained watermark detection model is the watermark identifier stored in the template watermark image library. The detected watermark image has a corresponding template watermark image in the template watermark image library, so the second watermark image corresponding to the second watermark identifier is queried from the template watermark image library, and the watermark in the detected watermark image is removed using the second watermark image, thereby realizing watermark removal. Moreover, the method of obtaining the difference image will not affect the background image in the watermark image while removing the watermark, thereby improving the watermark removal effect.

[0027] In some embodiments, before replacing the watermark image in the first image with a difference image between the watermark image and the second watermark image to obtain a third image, the method further includes:

[0028] The transparency of the second watermark image is adjusted to be consistent with the transparency of the watermark in the watermark image.

[0029] In the disclosed embodiment, by adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image, it is possible to ensure that the watermark is completely removed from the watermark image by subsequently obtaining an interpolated image, thereby improving the watermark removal effect.

[0030] In some embodiments, the transparency of the second watermark image is a fourth transparency, the transparency of the watermark in the watermark image is a fifth transparency, and adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark area includes:

[0031] determining a second ratio between the fourth transparency and the fifth transparency;

[0032] The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

[0033] In the embodiment of the present disclosure, during the transparency adjustment process, the transparency is multiplied by the transparency of each pixel in the image. This adjustment method can ensure that only the transparency of the image is adjusted without affecting other information of the pixels in the image.

[0034] In some embodiments, replacing the watermark image in the second image with a difference image between the watermark image and the second watermark image to obtain a third image includes:

[0035] determining a sixth transparency, where the sum of the sixth transparency and the fifth transparency is a transparency threshold;

[0036] determining a difference image between the watermark image and the second watermark image, and dividing the transparency of each pixel in the difference image by the sixth transparency to obtain an adjusted difference image;

[0037] The watermark image in the second image is replaced with the adjusted difference image to obtain the third image.

[0038] In the disclosed embodiment, the difference image no longer contains a watermark, but the transparency of the difference image also changes during the watermark removal process. Therefore, by adjusting the transparency of the difference image to be consistent with the transparency of the second image, the transparency of each area in the subsequently obtained third image is made consistent, thereby improving the display effect of the third image.

[0039] In some embodiments, before replacing the watermark image in the second image with a difference image between the watermark image and the second watermark image to obtain a third image, the method further includes:

[0040] The size of the second watermark image is adjusted to be consistent with the size of the watermark image.

[0041] In the disclosed embodiment, the size of the second watermark image is adjusted to be consistent with the size of the watermark image, so that the position of the watermark in the second watermark image is consistent with the position of the watermark in the watermark image, thereby ensuring that when the difference image is obtained, the watermark in the second watermark image can completely offset the watermark in the watermark image, thereby improving the watermark removal effect.

[0042] According to another aspect of the present disclosure, a watermark removal method is provided, the method comprising:

[0043] determining a watermark image in a second image and a second watermark identifier corresponding to a watermark contained in the watermark image;

[0044] querying a second watermark image corresponding to the second watermark identifier from a template watermark image library, where the second watermark image includes the watermark, and the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier;

[0045] The watermark image in the second image is replaced based on a difference image between the watermark image and the second watermark image to obtain a third image.

[0046] The method provided by the embodiment of the present disclosure realizes watermark removal by determining a watermark image in a second image and a second watermark identifier corresponding to the watermark contained in the watermark image, then searching for the second watermark image corresponding to the second watermark identifier from a template watermark image library, and using the second watermark image to remove the watermark in the detected watermark image. In addition, the method of obtaining a difference image can remove the watermark without affecting the background image in the watermark image, thereby improving the watermark removal effect.

[0047] In some embodiments, before replacing the watermark image in the first image with a difference image between the watermark image and the second watermark image to obtain a third image, the method further includes:

[0048] The transparency of the second watermark image is adjusted to be consistent with the transparency of the watermark in the watermark image.

[0049] In the disclosed embodiment, by adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image, it is possible to ensure that the watermark is completely removed from the watermark image by subsequently obtaining an interpolated image, thereby improving the watermark removal effect.

[0050] In some embodiments, the transparency of the second watermark image is a fourth transparency, the transparency of the watermark in the watermark image is a fifth transparency, and adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark area includes:

[0051] determining a second ratio between the fourth transparency and the fifth transparency;

[0052] The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

[0053] In the embodiment of the present disclosure, during the transparency adjustment process, the transparency is multiplied by the transparency of each pixel in the image. This adjustment method can ensure that only the transparency of the image is adjusted without affecting other information of the pixels in the image.

[0054] In some embodiments, replacing the watermark image in the second image with a difference image between the watermark image and the second watermark image to obtain a third image includes:

[0055] determining a sixth transparency, where the sum of the sixth transparency and the fifth transparency is a transparency threshold;

[0056] determining a difference image between the watermark image and the second watermark image, and dividing the transparency of each pixel in the difference image by the sixth transparency to obtain an adjusted difference image;

[0057] The watermark image in the second image is replaced with the adjusted difference image to obtain the third image.

[0058] In the disclosed embodiment, the difference image no longer contains a watermark, but the transparency of the difference image also changes during the watermark removal process. Therefore, by adjusting the transparency of the difference image to be consistent with the transparency of the second image, the transparency of each area in the subsequently obtained third image is made consistent, thereby improving the display effect of the third image.

[0059] In some embodiments, before replacing the watermark image in the second image with a difference image between the watermark image and the second watermark image to obtain a third image, the method further includes:

[0060] The size of the second watermark image is adjusted to be consistent with the size of the watermark image.

[0061] In the disclosed embodiment, the size of the second watermark image is adjusted to be consistent with the size of the watermark image, so that the position of the watermark in the second watermark image is consistent with the position of the watermark in the watermark image, thereby ensuring that when the difference image is obtained, the watermark in the second watermark image can completely offset the watermark in the watermark image, thereby improving the watermark removal effect.

[0062] According to another aspect of the embodiments of the present disclosure, a watermark detection model training device is provided, the device comprising:

[0063] a template watermark acquisition unit configured to acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from a template watermark image library, wherein the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier;

[0064] a sample image acquiring unit, configured to add the first watermark image to a sample watermark region in the first image to obtain a sample image;

[0065] The training unit is configured to train a watermark detection model based on the sample image, the sample watermark area and the first watermark identifier. The trained watermark detection model is used to detect the watermark image and the watermark identifier from any image. The watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library.

[0066] In some embodiments, the transparency of the first watermark image is a first transparency, the transparency of the watermark to be added to the first image is a second transparency, and the apparatus further comprises:

[0067] a transparency adjustment unit configured to determine a first ratio between the second transparency and the first transparency;

[0068] The transparency adjustment unit is further configured to multiply the first ratio by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image.

[0069] In some embodiments, the apparatus further comprises:

[0070] a transparency adjustment unit configured to determine a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold;

[0071] The transparency adjustment unit is further configured to multiply the third transparency by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area.

[0072] In some embodiments, the apparatus further comprises:

[0073] a size adjustment unit, configured to determine the sample watermark region in the first image, wherein the sample watermark region has a shape consistent with that of the first watermark image;

[0074] The size adjustment unit is further configured to adjust the size of the first watermark image to be consistent with the size of the sample watermark area.

[0075] In some embodiments, the apparatus further comprises:

[0076] a watermark detection unit configured to execute and call the watermark detection model, perform watermark detection on the second image, and obtain a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image;

[0077] a template watermark query unit, configured to query the template watermark image library for a second watermark image corresponding to the second watermark identifier, where the second watermark image contains the watermark;

[0078] The watermark removal unit is configured to replace the watermark image in the second image with a difference image between the watermark image and the second watermark image to obtain a third image.

[0079] In some embodiments, the apparatus further comprises:

[0080] The transparency adjustment unit is configured to adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image.

[0081] In some embodiments, the transparency of the second watermark image is a fourth transparency, the transparency of the watermark in the watermark image is a fifth transparency, and the transparency adjustment unit is configured to perform:

[0082] determining a second ratio between the fourth transparency and the fifth transparency;

[0083] The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

[0084] In some embodiments, the watermark removal unit is configured to perform:

[0085] determining a sixth transparency, where the sum of the sixth transparency and the fifth transparency is a transparency threshold;

[0086] determining a difference image between the watermark image and the second watermark image, and dividing the transparency of each pixel in the difference image by the sixth transparency to obtain an adjusted difference image;

[0087] The watermark image in the second image is replaced with the adjusted difference image to obtain the third image.

[0088] In some embodiments, the apparatus further comprises:

[0089] The size adjustment unit is configured to adjust the size of the second watermark image to be consistent with the size of the watermark image.

[0090] According to another aspect of the present disclosure, a watermark removal device is provided, the device comprising:

[0091] A watermark detection unit is configured to determine a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image;

[0092] a template watermark query unit, configured to query a second watermark image corresponding to the second watermark identifier from a template watermark image library, wherein the second watermark image includes the watermark, and the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier;

[0093] The watermark removal unit is configured to replace the watermark image in the second image based on a difference image between the watermark image and the second watermark image to obtain a third image.

[0094] In some embodiments, the apparatus further comprises:

[0095] The transparency adjustment unit is configured to adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image.

[0096] In some embodiments, the transparency of the second watermark image is a fourth transparency, the transparency of the watermark in the watermark image is a fifth transparency, and the transparency adjustment unit is configured to perform:

[0097] determining a second ratio between the fourth transparency and the fifth transparency;

[0098] The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

[0099] In some embodiments, the watermark removal unit is configured to perform:

[0100] determining a sixth transparency, where the sum of the sixth transparency and the fifth transparency is a transparency threshold;

[0101] determining a difference image between the watermark image and the second watermark image, and dividing the transparency of each pixel in the difference image by the sixth transparency to obtain an adjusted difference image;

[0102] The watermark image in the second image is replaced with the adjusted difference image to obtain the third image.

[0103] In some embodiments, the apparatus further comprises:

[0104] The size adjustment unit is configured to adjust the size of the second watermark image to be consistent with the size of the watermark image.

[0105] According to another aspect of the embodiments of the present disclosure, an electronic device is provided, the electronic device including:

[0106] one or more processors;

[0107] a memory for storing the one or more processor-executable instructions;

[0108] The one or more processors are configured to execute the watermark detection model training method or watermark removal method described in the above aspects.

[0109] According to another aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the watermark detection model training method or the watermark removal method described in the above aspects.

[0110] According to another aspect of the embodiments of the present disclosure, a computer program product is provided, which includes a computer program, and the computer program is executed by a processor to implement the watermark detection model training method or watermark removal method described in the above aspects.

[0111] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0112] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0113] Figure 1 The figure is a flowchart of a watermark detection model training method according to an exemplary embodiment.

[0114] Figure 2 The figure is a flowchart of another watermark detection model training method according to an exemplary embodiment.

[0115] Figure 3 The figure is a schematic diagram showing a template watermark image according to an exemplary embodiment.

[0116] Figure 4 is a schematic diagram showing a detection result according to an exemplary embodiment.

[0117] Figure 5 It is a schematic diagram showing a model training process according to an exemplary embodiment.

[0118] Figure 6 The figure is a schematic diagram showing a method of generating a sample image according to an exemplary embodiment.

[0119] Figure 7 The figure is a flow chart showing a watermark removal method according to an exemplary embodiment.

[0120] Figure 8 The figure is a flow chart showing another watermark removal method according to an exemplary embodiment.

[0121] Figure 9 The figure is a schematic diagram showing an image without watermark removal and an image after watermark removal according to an exemplary embodiment.

[0122] Figure 10 The figure is a schematic diagram showing a watermark removal process according to an exemplary embodiment.

[0123] Figure 11 The figure is a flow chart showing another watermark removal method according to an exemplary embodiment.

[0124] Figure 12 The figure is a block diagram of a watermark detection model training device according to an exemplary embodiment.

[0125] Figure 13 The figure is a block diagram of a watermark removal device according to an exemplary embodiment.

[0126] Figure 14 The figure is a structural block diagram of a terminal according to an exemplary embodiment.

[0127] Figure 15 The figure is a structural block diagram of a server according to an exemplary embodiment. DETAILED DESCRIPTION

[0128] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.

[0129] It should be noted that the terms "first," "second," and the like in the specification and claims of the present disclosure and the accompanying drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. It should be understood that the terms used in this manner are interchangeable where appropriate so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure as detailed in the appended claims.

[0130] It should be noted that the terms "at least one", "a plurality", "each", "any", etc. used in this disclosure include one, two or more, a plurality includes two or more, each refers to each of the corresponding plurality, and any refers to any one of the plurality. For example, if a plurality of watermark images includes three watermark images, then each watermark image refers to each of the three watermark images, and any refers to any one of the three watermark images, which can be the first, the second, or the third.

[0131] It should be noted that the user information involved in this disclosure (including but not limited to user device information, user personal information, etc.) is all information authorized by the user or fully authorized by all parties.

[0132] The execution subject of the embodiments of the present disclosure is an electronic device. Optionally, the electronic device is a terminal, which can be a portable, pocket-sized, handheld, or other type of terminal, such as a mobile phone, a computer, a tablet computer, etc. Alternatively, the electronic device is a server, which can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center.

[0133] Figure 1 is a flow chart of a watermark detection model training method according to an exemplary embodiment. Figure 1 The method is executed by an electronic device and includes the following steps:

[0134] In step 101, a first watermark image and a first watermark identifier corresponding to the first watermark image are obtained from a template watermark image library, where the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier.

[0135] The first watermark image is any template watermark image in the template watermark image library, the watermark identifier is used to uniquely represent a corresponding template watermark image, and the first watermark identifier is an identifier used to represent the first watermark image.

[0136] In step 102, a first watermark image is added to a sample watermark region in a first image to obtain a sample image.

[0137] The first image is any image that does not contain a watermark, and the sample watermark area in the first image is any area.

[0138] In the embodiment of the present disclosure, a sample image is obtained by adding a first watermark image to a sample watermark area in a first image. In the process of generating the sample image, the first watermark identifier and the sample watermark area corresponding to the added first watermark image have been determined. Therefore, the sample image, the sample watermark area and the first watermark identifier can be directly determined as training samples in the future without the need for manual labeling.

[0139] In step 103, a watermark detection model is trained based on the sample image, the sample watermark area and the first watermark identifier. The trained watermark detection model is used to detect the watermark image and the watermark identifier from any image. The watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library.

[0140] The watermark detection model to be trained is called to perform watermark detection on the sample image to obtain a predicted watermark image and a predicted watermark identifier. The watermark detection model is trained based on the difference between the predicted watermark image and the sample watermark area, and the difference between the watermark identifier and the first watermark identifier.

[0141] The method provided by the embodiment of the present disclosure adds a first watermark image in a template watermark image library to a sample watermark area in a first image to obtain a sample image for training a watermark detection model. In the process of generating the sample image, the watermark identifier corresponding to the added first watermark image and the sample watermark area containing the watermark in the first image have been determined, that is, the labeling of the sample image is realized, and there is no need to manually label the watermark identifier and the sample watermark area in the sample image, thereby reducing the training cost of the model and improving the efficiency of generating sample images.

[0142] exist Figure 1 On the basis of the embodiment shown, in order to ensure that the sample image obtained by adding the first watermark image has a better display effect, it is also necessary to adjust the transparency of the first watermark image. Figure 2 The illustrated embodiment explains this in detail.

[0143] Figure 2 is a flowchart of another watermark detection model training method according to an exemplary embodiment. Figure 2 The method is executed by an electronic device and includes the following steps:

[0144] In step 201, a first watermark image and a first watermark identifier corresponding to the first watermark image are obtained from a template watermark image library.

[0145] The template watermark image library is used to store template watermark images corresponding to at least one watermark identifier. Each watermark identifier is used to uniquely represent a corresponding template watermark image. The watermark identifier is a watermark name, number, or other identifier that uniquely represents a template watermark image. The first watermark image is any template watermark image in the template watermark image library, and the first watermark identifier is the watermark identifier corresponding to the first watermark image in the template watermark image library.

[0146] In some embodiments, the template watermark image in the template watermark image library is an image without transparency, or an image with a certain degree of transparency, and for multiple template watermark images, the transparency of the multiple template watermark images can be the same or different. The disclosed embodiment does not limit the transparency of the template watermark image in the template watermark image library. The size of the template watermark image in the template watermark image library is any size. The disclosed embodiment does not limit the size of the template watermark image in the template watermark image library. The template watermark image in the template watermark image library is of any shape, for example, the template watermark image is any one of a rectangle, a circle, and an ellipse. The disclosed embodiment does not limit the shape of the template watermark image in the template watermark image library.

[0147] In some embodiments, the template watermark image includes a watermark and a blank background image, e.g., see Figure 3 The template watermark image 301 shown is a rectangular image including a watermark “ABCD” and a blank background image.

[0148] In step 202, a sample watermark region in a first image is determined.

[0149] Before determining the sample watermark area in the first image, it is necessary to first obtain the first image. In some embodiments, any image that does not contain a watermark is determined as the first image; or, any image that does not contain a watermark is mirror-inverted or rotated, and the mirror-inverted image or the rotated image is determined as the first image; or, any image that does not contain a watermark is divided into multiple regions, and any region is determined as the first image; or, any image that does not contain a watermark is divided into multiple regions, and each region is mirror-inverted or rotated, and any region after the mirror-inverted or rotated region is determined as the first image. The embodiments of the present disclosure do not limit the method for obtaining the first image.

[0150] In the disclosed embodiment, when training a watermark detection model, multiple images corresponding to one image can be obtained by processing one image, and then sample images can be generated from the multiple images respectively, thereby increasing the amount of data during training.

[0151] In some embodiments, to ensure that the determined sample watermark region can be directly used as the sample watermark region during training, it is necessary to ensure that the shape of the sample watermark region is the same as that of the first watermark image. For example, if both the sample watermark region and the first watermark image are rectangles, then during the subsequent training process, the watermark image detected by the watermark detection model is also a rectangle, that is, a watermark image with the same shape as the first watermark image can be directly detected, facilitating subsequent watermark removal.

[0152] In some embodiments, taking the sample watermark region as a rectangular region as an example, the method for determining the sample watermark region includes any one of the following: determining the upper left corner coordinates and the lower right corner coordinates in the first image, and determining the sample watermark region based on the upper left corner coordinates and the lower right corner coordinates; or, determining the lower left corner coordinates and the upper right corner coordinates in the first image, and determining the sample watermark region based on the lower left corner coordinates and the upper right corner coordinates; or, determining at least one of the center point coordinates, the upper left corner coordinates, the lower left corner coordinates, the upper right corner coordinates or the lower right corner coordinates in the first image and the region size, and determining the sample watermark region based on at least one of the center point coordinates, the upper left corner coordinates, the lower left corner coordinates, the upper right corner coordinates or the lower right corner coordinates and the region size. Correspondingly, the sample watermark region can be represented by coordinates or by coordinates and size subsequently.

[0153] For example, taking the upper left corner of the first image as the origin to establish a coordinate system, the length of the first image is w and the width is h. First, determine the upper left corner coordinates (x1, y1), where 0 < x1 < w - 1 and 0 < y1 < h - 1, and then determine the lower right corner coordinates (x2, y2), where x1 < x2 ≤ w - 1 and y1 < y2 ≤ h - 1.

[0154] In step 203, adjust the size of the first watermark image to be the same as the size of the sample watermark region.

[0155] Enlarge or reduce the first watermark image according to the size of the sample watermark region to adjust the size of the first watermark image to be the same as the size of the sample watermark region.

[0156] In the embodiments of the present disclosure, since the sample watermark region is directly used as the sample watermark region in the sample image during subsequent training, and the watermark detection model is used to detect the watermark image in the sample image. When the size of the sample watermark region is inconsistent with the size of the first watermark image, it causes the size of the watermark image detected by the watermark detection model to be inconsistent with the size of the actually added watermark image, thus affecting the accuracy of the watermark detection model. Therefore, to improve the accuracy of the watermark detection model, the size of the first watermark image is adjusted to be the same as the size of the sample watermark region, so that the subsequently trained watermark detection model can accurately detect the watermark image from the image.

[0157] In step 204, the transparency of the first watermark image and the transparency of the sample watermark area are adjusted.

[0158] In the embodiment of the present disclosure, the smaller the transparency corresponding to the image, the more transparent the image is, and the greater the transparency corresponding to the image, the more opaque the image is. When the transparency corresponding to the image is 0, the image is a completely transparent image. When the transparency of the image is a transparency threshold, the image is a completely opaque image. When the transparency of the image is any value between 0 and the transparency threshold, the image is an image with a certain degree of transparency.

[0159] In some embodiments, because the transparency of the first watermark image in the template watermark image library is fixed, the transparency of the watermark to be added when synthesizing a sample image may differ from that of the first watermark image. Therefore, to ensure the desired transparency of the added watermark, the transparency of the first watermark image is adjusted before adding the first watermark image. If the transparency of the first watermark image is a first transparency and the transparency of the watermark to be added in the first image is a second transparency, adjusting the transparency of the first watermark image includes: determining a first ratio between the second transparency and the first transparency; and multiplying the first ratio by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image. The first ratio represents the degree of adjustment required to adjust the transparency of the first watermark image to the second transparency, and the second transparency is the desired transparency. For example, if the transparency of each pixel in the first watermark image is 1, meaning the first watermark image is completely opaque, and the second transparency is 0.5, then the transparency of each pixel is multiplied by 0.5 to achieve a transparency of 0.5, resulting in an adjusted transparency of 0.5 for the first watermark image.

[0160] In the embodiment of the present disclosure, the transparency of the first watermark image is adjusted to the required second transparency before adding the first watermark image, so that the transparency of the watermark added to the first image is the required transparency, thereby improving the display effect of the subsequently synthesized sample image.

[0161] In another embodiment, when the first watermark image is directly added to the sample watermark region, and the transparency of the first watermark image is a certain degree of transparency, the transparency of the sample watermark region after the first watermark image is added will be inconsistent with the transparency of other regions in the first image, resulting in a poor display effect of the resulting sample image. Therefore, in order to improve the display effect of the resulting sample image, the transparency of the sample watermark region is adjusted before the first watermark image is added to the sample watermark region. Adjusting the sample watermark region includes: determining a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold; and multiplying the third transparency by the transparency of each pixel in the sample watermark region to obtain an adjusted sample watermark region. The transparency threshold is the transparency corresponding to an image without transparency, for example, the transparency threshold is 1.

[0162] In the embodiment of the present disclosure, during the transparency adjustment process, the transparency is multiplied by the transparency of each pixel in the image. This adjustment method can ensure that only the transparency of the image is adjusted without affecting other information of the pixels in the image, such as RGB (Red Green Blue) information.

[0163] It should be noted that the process of adjusting the transparency of the first watermark image and the transparency of the sample watermark area in step 204 is an optional process. In another embodiment, the transparency of the first watermark image and the transparency of the sample watermark area may not be adjusted, or the transparency of the first watermark image may be adjusted without adjusting the transparency of the sample watermark area, or the transparency of the sample watermark area may be adjusted without adjusting the transparency of the first watermark image.

[0164] In step 205, the adjusted first watermark image is added to the adjusted sample watermark region to obtain a sample image.

[0165] In the embodiment of the present disclosure, the adjusted first watermark image is added to the adjusted sample watermark area, that is, the adjusted first watermark image is superimposed on the adjusted sample watermark area, while other areas of the first image except the sample watermark area remain unchanged, thereby obtaining a sample image, and the watermark in the first watermark image is added to the sample watermark area in the sample image.

[0166] Taking the first watermark image as an image without transparency and the transparency threshold as 1 as an example, the adjusted first watermark image is added to the adjusted sample watermark area using the following formula:

[0167] P1′=S1*α1+P1*(1-α1)

[0168] Among them, P1 represents the sample watermark area, S1 represents the first watermark image, α1 represents the second transparency, S1*α1 represents the adjusted first watermark image, 1-α1 represents the third transparency, P1*(1-α1) represents the adjusted sample watermark area, and P1′ represents the sample watermark area after the adjusted first watermark image is added.

[0169] When α1 is 0, the first watermark image is completely transparent, which is equivalent to not adding the first watermark image. When α1 is 1, the first watermark image is completely opaque, which is equivalent to adding a solid first watermark image. After adding the first watermark image, the first watermark image will completely block the original background image in the sample watermark area.

[0170] In step 206, a watermark detection model is trained based on the sample image, the sample watermark region and the first watermark identifier.

[0171] The sample image is input into the watermark detection model to be trained, and the predicted watermark image and predicted watermark identifier are output based on the watermark detection model. Based on the difference between the sample watermark area and the predicted watermark image, and the difference between the first watermark identifier and the predicted watermark identifier, the model parameters corresponding to the watermark detection model are adjusted.

[0172] In some embodiments, the sample watermark area is represented by coordinates, and the predicted coordinates are output based on the watermark detection model; or, the sample watermark area is represented by coordinates and size, and the predicted coordinates and predicted size are output based on the watermark detection model.

[0173] In some embodiments, the model parameters corresponding to the watermark detection model are updated based on the loss value of the loss function, and the loss value of the loss function is determined based on the loss function, the predicted coordinates and the sample coordinates. The smaller the loss value, the closer the predicted coordinates are to the sample coordinates.

[0174] In some embodiments, the watermark detection model also outputs a confidence level, which indicates the accuracy of the predicted watermark image and the predicted watermark identifier. The higher the confidence level, the more accurate the predicted watermark image and the predicted watermark identifier. For example, see Figure 4 The watermark detection model frames the predicted watermark image in the output image and displays the predicted watermark identifier "1" and confidence level "0.9" corresponding to the watermark image above the watermark image.

[0175] In another embodiment, see Figure 5The training process shown is to first obtain any image, divide the any image into multiple regions, take any region as the first image, and then generate training data based on the first image and the first watermark image, that is, add the first watermark image to the sample watermark region in the first image to obtain a sample image, determine the first watermark identifier corresponding to the sample watermark region and the first watermark image as the watermark label, and train the watermark detection model based on the sample image and the watermark label.

[0176] It should be noted that the embodiment of the present disclosure only takes a sample image as an example and trains the watermark detection model once. In another embodiment, the above embodiment can be used to generate multiple sample images, and the watermark detection model can be trained multiple times based on the multiple sample images until the watermark detection model can accurately detect the watermark image and watermark logo in any image. For example, see Figure 6 , image 601 is mirror-inverted and rotated, and the first watermark image is added to the sample watermark areas in the original image, the rotated image, and the mirror-inverted image to obtain image 602, image 603, and image 604, respectively.

[0177] Another point that needs to be explained is that the watermark detection model in the embodiment of the present disclosure is CNN (Convolutional Neural Networks), Region-CNN (Region with CNN features, applying convolutional neural networks to target detection) or other network structures. This public examination embodiment does not limit the model structure of the watermark detection model.

[0178] The method provided by the embodiment of the present disclosure adds a first watermark image from a template watermark image library to a sample watermark region in a first image to obtain a sample image for training a watermark detection model. During the process of generating the sample image, the watermark identifier corresponding to the added first watermark image and the sample watermark region containing the watermark in the first image are determined, thus achieving annotation of the sample image and eliminating the need to manually annotate the watermark identifier and sample watermark region in the sample image, thereby reducing the training cost of the model and improving the efficiency of generating sample images. Furthermore, during the process of generating the sample image, the transparency of the first watermark image and the transparency of the sample watermark region are adjusted so that after the first watermark image is added to the sample watermark region, the transparency of the sample watermark region remains consistent with the transparency of other regions in the first image, thereby improving the display effect of the sample image.

[0179] above Figure 1 and 2 The process of generating sample images to train the watermark detection model is introduced below. Figure 7The illustrated embodiment illustrates the process of calling the watermark detection model after training the watermark detection model, detecting the watermark in the image, and removing the watermark.

[0180] Figure 7 is a flow chart showing a watermark removal method according to an exemplary embodiment. Figure 7 The method is executed by an electronic device and includes the following steps:

[0181] In step 701, a watermark detection model is called to perform watermark detection on the second image to obtain a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image.

[0182] The second image is any image, and the second image is input into the watermark detection model to obtain the watermark image in the second image and the second watermark identifier corresponding to the watermark contained in the watermark image.

[0183] It should be noted that the embodiment of the present disclosure is only described by taking the second image containing a watermark as an example. In another embodiment, when the second image does not contain a watermark, the watermark detection model is called to detect the second image, and the output result is "empty", which means that the second image does not contain a watermark.

[0184] In step 702, a second watermark image corresponding to a second watermark identifier is searched from a template watermark image library, where the second watermark image contains the watermark.

[0185] Since the first watermark image added to the sample image and the first watermark identifier corresponding to the first watermark image are both stored in the template watermark image library during the training of the watermark detection model, the second watermark identifier detected by the trained watermark detection model is the watermark identifier stored in the template watermark image library. The detected watermark image has a corresponding template watermark image in the template watermark image library. Therefore, based on the correspondence between the watermark identifier and the template watermark image, the second watermark image corresponding to the second watermark identifier can be queried from the template watermark image library, and it can be determined that the watermark contained in the second watermark image is the same as the watermark contained in the watermark image in the second image.

[0186] In step 703, the watermark image in the second image is replaced with a difference image between the watermark image and the second watermark image to obtain a third image.

[0187] Since the second watermark image contains the same watermark as the watermark image in the second image, a difference image between the watermark image and the second watermark image can be obtained, that is, the watermark in the second watermark image is used to offset the watermark in the watermark image, so that the obtained difference image no longer contains the watermark, and the watermark image in the second image is replaced by the difference image to obtain a third image, which also no longer contains the watermark, thereby achieving the removal of the watermark in the second image.

[0188] In the disclosed embodiment, since the first watermark image added to the sample image and the first watermark identifier corresponding to the first watermark image are both stored in the template watermark image library during the training process of the watermark detection model, the second watermark identifier detected by the trained watermark detection model is the watermark identifier stored in the template watermark image library. The detected watermark image has a corresponding template watermark image in the template watermark image library, so the second watermark image corresponding to the second watermark identifier is queried from the template watermark image library, and the watermark in the detected watermark image is removed using the second watermark image, thereby realizing watermark removal. Moreover, the method of obtaining the difference image will not affect the background image in the watermark image while removing the watermark, thereby improving the watermark removal effect.

[0189] exist Figure 7 On the basis of the embodiment shown, in order to ensure that the image after watermark removal has a better display effect, it is also necessary to adjust the transparency. Figure 8 The illustrated embodiment explains this in detail.

[0190] Figure 8 is a flow chart showing another watermark removal method according to an exemplary embodiment. Figure 8 The method is executed by an electronic device and includes the following steps:

[0191] In step 801, a watermark detection model is called to perform watermark detection on the second image to obtain a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image.

[0192] In step 802, a second watermark image corresponding to a second watermark identifier is searched from a template watermark image library, where the second watermark image contains the watermark.

[0193] The implementation of step 801-step 802 is similar to the implementation of step 701-step 702 above, and will not be repeated here.

[0194] In step 803, the transparency of the second watermark image is adjusted to be consistent with the transparency of the watermark in the watermark image.

[0195] In the disclosed embodiment, if the transparency of the second watermark image is inconsistent with the transparency of the watermark in the watermark image, the watermark cannot be completely removed. For example, if the transparency of the second watermark image is 0.2, and the transparency of the watermark in the watermark image is 0.5, the two transparency levels are inconsistent. In this case, directly determining the difference image based on the second watermark image and the watermark image will result in the watermark still existing in the difference image, but the transparency of the watermark will be reduced to 0.3. Therefore, in order to ensure that the watermark is completely removed from the watermark image, the transparency of the second watermark image must be consistent with the transparency of the watermark in the watermark image.

[0196] When the transparency of the second watermark image is the fourth transparency and the transparency of the watermark in the watermark image is the fifth transparency, adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark area includes: determining a second ratio between the fourth transparency and the fifth transparency; and multiplying the second ratio by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image. The second ratio represents the degree to which the transparency of the second watermark image needs to be adjusted. The fifth transparency is a preset transparency or a transparency identified from the watermark image. The present disclosure does not limit the method for determining the fifth transparency.

[0197] In the disclosed embodiment, by adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image, it is possible to ensure that the watermark is completely removed from the watermark image by subsequently obtaining an interpolated image, thereby improving the watermark removal effect.

[0198] In step 804, the size of the second watermark image is adjusted to be consistent with the size of the watermark image.

[0199] In the disclosed embodiment, a difference image is obtained between a watermark image and a second watermark image. In the process of obtaining the difference image, the watermark in the second watermark image is used to offset the watermark in the watermark image, thereby obtaining a difference image that does not contain a watermark. However, in order to ensure that the watermark in the second watermark image can completely offset the watermark in the watermark image, it is necessary to ensure that the size of the second watermark image is consistent with the size of the watermark image, the shape of the second watermark image is consistent with the shape of the watermark image, and the position of the watermark in the second watermark image corresponds to the position of the watermark in the watermark image. For example, when the size of the second watermark image and the watermark image is consistent, the coordinates of the position of the watermark in the second watermark image are completely consistent with the coordinates of the position of the watermark in the watermark image.

[0200] Since the shape of the sample watermark region used in the watermark detection model training process is consistent with the shape of the template watermark image in the template watermark image library, and the position of the watermark in the first watermark image added to the sample watermark region is the same as the position of the watermark in the template watermark image, the shape of the watermark image detected by the watermark detection model is consistent with the shape of the second watermark image, and the position of the watermark in the second watermark image corresponds to the position of the watermark in the watermark image. However, it is difficult to ensure that the size of the detected watermark image is consistent with the size of the second watermark image. Therefore, it is necessary to first adjust the size of the second watermark image to be consistent with the size of the watermark image by enlarging or reducing the second watermark image.

[0201] In step 805, a difference image between the watermark image and the adjusted second watermark image is determined, and the transparency of each pixel in the difference image is divided by the sixth transparency to obtain an adjusted difference image.

[0202] Based on the watermark image and the second watermark image, a difference image between the watermark image and the second watermark image is determined. Since the transparency of the adjusted second watermark image is consistent with the transparency of the watermark in the watermark image, the watermark is offset in the difference image. However, during the offsetting process, the transparency of the difference image also changes. Therefore, it is also necessary to adjust the transparency of the difference image to be consistent with the transparency of the second image.

[0203] The sixth transparency is determined based on the fifth transparency, and the sum of the sixth transparency and the fifth transparency is the transparency threshold. For example, if the transparency threshold is 1, the transparency of the watermark image is 1, the transparency of the watermark in the watermark image is 0.2, and the transparency of the adjusted second watermark image is 0.2, the transparency of the difference image becomes 0.8 during the offset process. Therefore, the transparency of each pixel in the difference image needs to be divided by 0.8 to make the transparency of each pixel 1, so that the transparency of the adjusted difference image is consistent with the transparency of the second image.

[0204] Taking the second watermark image as an image without transparency and the transparency threshold as 1 as an example, the following formula is used to determine the difference image between the watermark image and the second watermark image:

[0205] P2′=(P2-α2*S2) / (1-α2)

[0206] Among them, P2′ represents the difference image, P2 represents the watermark image, S2 represents the second watermark image, α2 represents the fourth transparency, α2*S2 represents the adjusted second watermark image, and 1-α2 represents the sixth transparency.

[0207] In the disclosed embodiment, the difference image no longer contains a watermark, but the transparency of the difference image also changes during the watermark removal process. Therefore, by adjusting the transparency of the difference image to be consistent with the transparency of the second image, the transparency of each area in the subsequently obtained third image is made consistent, thereby improving the display effect of the third image.

[0208] In step 806, the watermark image in the second image is replaced with the adjusted difference image to obtain a third image.

[0209] The transparency of the adjusted difference image is consistent with that of the second image. The watermark image in the second image is replaced with the adjusted difference image, so that the transparency of each region in the obtained third image is consistent.

[0210] For example, see Figure 9 The image without watermark removal and the image after watermark removal are shown. Figure 9 It can be seen that the watermark in image 901 does not block the person, and the watermark removal method provided in the embodiment of the present disclosure is used to remove the watermark from image 901 to obtain image 902, from which the watermark is completely removed; the watermark in image 903 blocks the person, and the watermark removal method provided in the embodiment of the present disclosure is used to remove the watermark from image 903 to obtain image 904, from which the watermark is completely removed without affecting the original information of image 903.

[0211] It should be noted that the embodiment of the present disclosure is only described by taking the second image containing one watermark as an example. In another embodiment, the second image contains multiple watermarks. When the second image contains multiple watermarks, the watermark images and watermark identifiers corresponding to the multiple watermarks are detected respectively, and after one of the watermarks is removed by using the implementation method of the above steps 802 to 806, the implementation method of the above steps 802 to 806 is continued to be used to remove other watermarks until all the multiple watermarks in the second image are removed.

[0212] For example, see Figure 10 As shown in the flowchart, the second image is input into the watermark detection model, and it is detected that the second image contains a watermark, that is, the second image contains a watermarked image of the watermark and a second watermark identifier corresponding to the watermark, and a watermark removal algorithm (the above steps 802-806) is used to remove the watermark in the watermarked image. Then, when the number of watermarks is greater than or equal to 2, the watermark removal algorithm is continued to be used to remove the watermark in the watermarked image until a third image is obtained after all watermarks are removed. When it is detected that the second image does not contain a watermark, there is no need to perform the above watermark removal process.

[0213] In the disclosed embodiment, since the first watermark image added to the sample image and the first watermark identifier corresponding to the first watermark image are both stored in the template watermark image library during the training process of the watermark detection model, the second watermark identifier detected by the trained watermark detection model is the watermark identifier stored in the template watermark image library. The detected watermark image has a corresponding template watermark image in the template watermark image library, so the second watermark image corresponding to the second watermark identifier is queried from the template watermark image library, and the watermark in the detected watermark image is removed using the second watermark image, thereby realizing watermark removal. Moreover, the method of obtaining the difference image will not affect the background image in the watermark image while removing the watermark, thereby improving the watermark removal effect.

[0214] Moreover, in the embodiment of the present disclosure, the size of the second watermark image is adjusted to be consistent with the size of the watermark image, so that the position of the watermark in the second watermark image is consistent with the position of the watermark in the watermark image, thereby ensuring that when the difference image is obtained, the watermark in the second watermark image can completely offset the watermark in the watermark image, thereby improving the watermark removal effect.

[0215] In the disclosed embodiment, the difference image no longer contains a watermark, but the transparency of the difference image also changes during the watermark removal process. Therefore, by adjusting the transparency of the difference image to be consistent with the transparency of the second image, the transparency of each area in the subsequently obtained third image is made consistent, thereby improving the display effect of the third image.

[0216] Moreover, compared with the related art that uses a network model for watermark removal, the watermark removal method provided by the embodiment of the present disclosure directly uses a template watermark image to offset the watermark in the watermark image. The watermark removal process is simple, saves calculation amount, and improves the watermark removal speed.

[0217] It should be noted that, in the above embodiment, the watermark detection model is called to perform watermark detection on the second image, and the watermark image in the second image and the second watermark identifier corresponding to the watermark contained in the watermark image are determined as an example. In another embodiment, other methods may be used to determine the watermark image in the second image and the second watermark identifier corresponding to the watermark contained in the watermark image. Figure 11 , Figure 11 This is a flow chart of another watermark removal method according to an exemplary embodiment. The method is performed by an electronic device and includes the following steps:

[0218] In step 1101, a watermark image in a second image and a second watermark identifier corresponding to a watermark contained in the watermark image are determined.

[0219] In step 1102, a second watermark image corresponding to a second watermark identifier is searched from a template watermark image library, where the second watermark image contains the watermark.

[0220] In step 1103, the watermark image in the second image is replaced with a difference image between the watermark image and the second watermark image to obtain a third image.

[0221] The implementation of steps 1102 to 1103 is similar to the implementation of steps 802 to 806 described above, and will not be repeated here.

[0222] The method provided by the embodiment of the present disclosure realizes watermark removal by determining a watermark image in a second image and a second watermark identifier corresponding to the watermark contained in the watermark image, then searching for the second watermark image corresponding to the second watermark identifier from a template watermark image library, and using the second watermark image to remove the watermark in the detected watermark image. In addition, the method of obtaining a difference image can remove the watermark without affecting the background image in the watermark image, thereby improving the watermark removal effect.

[0223] Moreover, compared with the related art that uses a network model for watermark removal, the watermark removal method provided by the embodiment of the present disclosure directly uses a template watermark image to offset the watermark in the watermark image. The watermark removal process is simple, saves calculation amount, and improves the watermark removal speed.

[0224] Figure 12 FIG1 is a block diagram of a watermark detection model training device according to an exemplary embodiment. Figure 12 , the device comprises:

[0225] The template watermark acquisition unit 1201 is configured to acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from a template watermark image library, wherein the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier;

[0226] The sample image acquisition unit 1202 is configured to add the first watermark image to the sample watermark area of ​​the first image to obtain a sample image;

[0227] The training unit 1203 is configured to execute training of a watermark detection model based on the sample image, the sample watermark area and the first watermark identifier. The trained watermark detection model is used to detect a watermark image and a watermark identifier from any image. The watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library.

[0228] The device provided by the embodiment of the present disclosure adds a first watermark image in a template watermark image library to a sample watermark area in a first image to obtain a sample image for training a watermark detection model. In the process of generating the sample image, the watermark identifier corresponding to the added first watermark image and the sample watermark area containing the watermark in the first image have been determined, that is, the labeling of the sample image is realized, and there is no need to manually label the watermark identifier and the sample watermark area in the sample image, thereby reducing the training cost of the model and improving the efficiency of generating sample images.

[0229] In some embodiments, the transparency of the first watermark image is a first transparency, the transparency of the watermark to be added to the first image is a second transparency, and the apparatus further includes:

[0230] a transparency adjustment unit, configured to determine a first ratio between the second transparency and the first transparency;

[0231] The transparency adjustment unit is further configured to multiply the first ratio by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image.

[0232] In some embodiments, the apparatus further comprises:

[0233] a transparency adjustment unit configured to determine a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold;

[0234] The transparency adjustment unit is further configured to multiply the third transparency by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area.

[0235] In some embodiments, the apparatus further comprises:

[0236] a size adjustment unit, configured to determine the sample watermark region in the first image, wherein the sample watermark region has a shape consistent with that of the first watermark image;

[0237] The size adjustment unit is further configured to adjust the size of the first watermark image to be consistent with the size of the sample watermark area.

[0238] In some embodiments, the apparatus further comprises:

[0239] a watermark detection unit configured to execute and call the watermark detection model, perform watermark detection on the second image, and obtain a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image;

[0240] a template watermark query unit configured to query the template watermark image library for a second watermark image corresponding to the second watermark identifier, the second watermark image containing the watermark;

[0241] The watermark removal unit is configured to replace the watermark image in the second image with a difference image between the watermark image and the second watermark image to obtain a third image.

[0242] In some embodiments, the apparatus further comprises:

[0243] The transparency adjustment unit is configured to adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image.

[0244] In some embodiments, the transparency of the second watermark image is a fourth transparency, the transparency of the watermark in the watermark image is a fifth transparency, and the transparency adjustment unit is configured to perform:

[0245] determining a second ratio between the fourth transparency and the fifth transparency;

[0246] The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

[0247] In some embodiments, the watermark removal unit is configured to perform:

[0248] determining a sixth transparency, where the sum of the sixth transparency and the fifth transparency is a transparency threshold;

[0249] determining a difference image between the watermark image and the second watermark image, and dividing the transparency of each pixel in the difference image by the sixth transparency to obtain an adjusted difference image;

[0250] The watermark image in the second image is replaced with the adjusted difference image to obtain the third image.

[0251] In some embodiments, the apparatus further comprises:

[0252] The size adjustment unit is configured to adjust the size of the second watermark image to be consistent with the size of the watermark image.

[0253] Regarding the apparatus in the above embodiment, the specific manner in which each unit performs operations has been described in detail in the embodiment of the method, and will not be elaborated on here.

[0254] Figure 13 FIG1 is a block diagram of a watermark removal device according to an exemplary embodiment. Figure 13 , the device comprises:

[0255] The watermark detection unit 1301 is configured to determine a watermark image in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image;

[0256] The template watermark query unit 1302 is configured to query a second watermark image corresponding to the second watermark identifier from a template watermark image library, where the second watermark image includes the watermark. The template watermark image library is used to store template watermark images corresponding to at least one watermark identifier.

[0257] The watermark removal unit 1303 is configured to replace the watermark image in the second image based on a difference image between the watermark image and the second watermark image to obtain a third image.

[0258] The device provided by the embodiment of the present disclosure realizes watermark removal by determining a watermark image in a second image and a second watermark identifier corresponding to the watermark contained in the watermark image, then searching for the second watermark image corresponding to the second watermark identifier from a template watermark image library, and using the second watermark image to remove the watermark in the detected watermark image. In addition, the method of obtaining a difference image can remove the watermark without affecting the background image in the watermark image, thereby improving the watermark removal effect.

[0259] In some embodiments, the apparatus further comprises:

[0260] The transparency adjustment unit is configured to adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image.

[0261] In some embodiments, the transparency of the second watermark image is a fourth transparency, the transparency of the watermark in the watermark image is a fifth transparency, and the transparency adjustment unit is configured to perform:

[0262] determining a second ratio between the fourth transparency and the fifth transparency;

[0263] The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

[0264] In some embodiments, the watermark removal unit 1303 is configured to perform:

[0265] determining a sixth transparency, where the sum of the sixth transparency and the fifth transparency is a transparency threshold;

[0266] determining a difference image between the watermark image and the second watermark image, and dividing the transparency of each pixel in the difference image by the sixth transparency to obtain an adjusted difference image;

[0267] The watermark image in the second image is replaced with the adjusted difference image to obtain the third image.

[0268] In some embodiments, the apparatus further comprises:

[0269] The size adjustment unit is configured to adjust the size of the second watermark image to be consistent with the size of the watermark image.

[0270] Regarding the apparatus in the above embodiment, the specific manner in which each unit performs operations has been described in detail in the embodiment of the method, and will not be elaborated on here.

[0271] In an exemplary embodiment, an electronic device is provided, which includes one or more processors and a memory for storing instructions executable by the one or more processors; wherein the one or more processors are configured to execute the watermark detection model training method or the watermark removal method in the above-mentioned embodiment.

[0272] In some embodiments, the electronic device is provided as a terminal. Figure 14 FIG1 is a block diagram showing a structure of a terminal 1400 according to an exemplary embodiment. The terminal 1400 includes a processor 1401 and a memory 1402 .

[0273] The processor 1401 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1401 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1401 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1401 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1401 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0274] Memory 1402 may include one or more computer-readable storage media, which may be non-transitory. Memory 1402 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in memory 1402 is used to store at least one program code, which is executed by processor 1401 to implement the watermark detection model training method or watermark removal method provided in the method embodiments of the present disclosure.

[0275] In some embodiments, terminal 1400 may optionally include a peripheral device interface 1403 and at least one peripheral device. Processor 1401, memory 1402, and peripheral device interface 1403 may be connected via a bus or signal lines. Each peripheral device may be connected to peripheral device interface 1403 via a bus, signal lines, or circuit boards. Specifically, the peripheral device may include at least one of a radio frequency circuit 1404, a display screen 1405, a camera assembly 1406, an audio circuit 1407, and a power supply 1408.

[0276] The peripheral device interface 1403 can be used to connect at least one I / O (Input / Output)-related peripheral device to the processor 1401 and the memory 1402. In some embodiments, the processor 1401, the memory 1402, and the peripheral device interface 1403 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1401, the memory 1402, and the peripheral device interface 1403 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.

[0277] RF circuit 1404 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. RF circuit 1404 communicates with communication networks and other communication devices via electromagnetic signals. RF circuit 1404 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals. RF circuit 1404 optionally includes an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and the like. RF circuit 1404 can communicate with other terminals via at least one wireless communication protocol. Such wireless communication protocols include, but are not limited to, the World Wide Web, metropolitan area networks, intranets, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks, and / or WiFi (Wireless Fidelity) networks. In some embodiments, RF circuit 1404 may also include circuitry related to Near Field Communication (NFC), although this disclosure is not limiting in this regard.

[0278] The display screen 1405 is used to display a UI (User Interface). The UI may include graphics, text, icons, videos, and any combination thereof. When the display screen 1405 is a touch screen display, the display screen 1405 also has the ability to collect touch signals on the surface or above the surface of the display screen 1405. The touch signal can be input as a control signal to the processor 1401 for processing. At this time, the display screen 1405 can also be used to provide virtual buttons and / or virtual keyboards, also known as soft buttons and / or soft keyboards. In some embodiments, there can be one display screen 1405, which is set on the front panel of the terminal 1400; in other embodiments, there can be at least two display screens 1405, which are respectively set on different surfaces of the terminal 1400 or in a folding design; in other embodiments, the display screen 1405 can be a flexible display screen, which is set on the curved surface or folding surface of the terminal 1400. Even more, the display screen 1405 can be set to a non-rectangular irregular shape, that is, a special-shaped screen. The display screen 1405 can be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).

[0279] The camera assembly 1406 is used to capture images or videos. Optionally, the camera assembly 1406 includes a front camera and a rear camera. The front camera is set on the front panel of the terminal, and the rear camera is set on the back of the terminal. In some embodiments, there are at least two rear cameras, which are any one of a main camera, a depth of field camera, a wide-angle camera, and a telephoto camera, so as to realize the fusion of the main camera and the depth of field camera to realize the background blur function, the fusion of the main camera and the wide-angle camera to realize panoramic shooting and VR (Virtual Reality) shooting function or other fusion shooting functions.

[0280] Audio circuit 1407 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, and convert the sound waves into electrical signals that are input to processor 1401 for processing, or input to RF circuit 1404 for voice communication. The speaker is used to convert the electrical signals from processor 1401 or RF circuit 1404 into sound waves.

[0281] Power supply 1408 is used to power various components in terminal 1400. Power supply 1408 can be AC ​​power, DC power, a disposable battery, or a rechargeable battery. When power supply 1408 includes a rechargeable battery, the rechargeable battery can be wired or wirelessly rechargeable. A wired rechargeable battery is charged via a wired line, while a wireless rechargeable battery is charged via a wireless coil. The rechargeable battery can also support fast charging technology.

[0282] In some embodiments, the electronic device is provided as a server. Figure 15 This is a block diagram of a server structure according to an exemplary embodiment. The server 1500 may vary significantly due to different configurations or performance, and may include one or more processors (Central Processing Units, CPUs) 1501 and one or more memories 1502. The memories 1502 store instructions that are loaded and executed by the processors 1501 to implement the methods provided in the above-mentioned various method embodiments. Of course, the server may also have components such as a wired or wireless network interface, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be described in detail here.

[0283] In an exemplary embodiment, a computer-readable storage medium is also provided. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the steps performed by the electronic device in the above-mentioned watermark detection model training method or watermark removal method. Optionally, the computer-readable storage medium can be a ROM (Read Only Memory), RAM (Random Access Memory), CD-ROM (Compact Disc Read-Only Memory), magnetic tape, floppy disk, optical data storage device, etc.

[0284] In an exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program. The computer program is executed by a processor to implement the above-mentioned watermark detection model training method or watermark removal method.

[0285] In some embodiments, the computer program involved in the embodiments of the present disclosure may be deployed and executed on one electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected through a communication network. Multiple electronic devices distributed at multiple locations and interconnected through a communication network may constitute a blockchain system.

[0286] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the disclosure herein. This disclosure is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the following claims.

[0287] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A watermark detection model training method, characterized in that: The method comprises: Acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from a template watermark image library, wherein the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier; determining a sample watermark region in the first image based on at least one of a center point coordinate, an upper left corner coordinate, a lower left corner coordinate, an upper right corner coordinate, or a lower right corner coordinate and a region size determined in the first image; Adjusting the size of the first watermark image to be consistent with the size of the sample watermark area; The transparency of the first watermark image is a first transparency, the transparency of the watermark to be added in the first image is a second transparency, and a first ratio between the second transparency and the first transparency is determined; the first ratio is multiplied by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image, wherein the first ratio represents the degree of adjustment required to adjust the transparency of the first watermark image to the second transparency; determining a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold; multiplying the third transparency by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area, where the transparency threshold is a transparency corresponding to a non-transparent image; adding the adjusted first watermark image to the adjusted sample watermark region, while leaving other regions of the first image except the sample watermark region unchanged, to obtain a sample image, wherein the first image is any image not containing a watermark, and a shape of the sample watermark region is consistent with a shape of the first watermark image; The sample image is input into a watermark detection model to be trained, and a predicted watermark image, a predicted watermark identifier and a confidence level are output based on the watermark detection model. Based on the difference between the sample watermark area and the predicted watermark image, and the difference between the first watermark identifier and the predicted watermark identifier, the model parameters corresponding to the watermark detection model are adjusted, wherein the confidence level indicates the accuracy of the predicted watermark image and the predicted watermark identifier, and a higher confidence level indicates a more accurate predicted watermark image and the predicted watermark identifier. The trained watermark detection model is used to detect a watermark image and a watermark identifier from any image, wherein the watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library; calling the watermark detection model to perform watermark detection on the second image containing multiple watermarks, and obtaining a watermark image corresponding to each watermark in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image; For any watermark included in the second image, query the template watermark image library for a second watermark image corresponding to the second watermark identifier, where the second watermark image includes the watermark; adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image; adjust the size of the second watermark image to be consistent with the size of the watermark image; determine a difference image between the watermark image and the adjusted second watermark image, divide the transparency of each pixel in the difference image by a sixth transparency value to obtain an adjusted difference image, the transparency of the adjusted difference image is consistent with the transparency of the second image, the sum of the fifth transparency and the sixth transparency of the watermark in the watermark image is the transparency threshold, and the difference image does not include the watermark; replace the watermark image in the second image with the adjusted difference image to obtain an image after the watermark is removed; Continue processing the next watermark in the second image until all watermarks in the second image are removed, thereby obtaining a third image that does not include a watermark.

2. The watermark detection model training method according to claim 1, characterized in that: The transparency of the second watermark image is a fourth transparency, and adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image includes: determining a second ratio between the fourth transparency and the fifth transparency; The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

3. A watermark removal method, characterized in that: The method comprises: Invoking a watermark detection model to determine a watermark image corresponding to each watermark in a second image including a plurality of watermarks and a second watermark identifier corresponding to the watermark included in the watermark image; For any watermark included in the second image, query a template watermark image library for a second watermark image corresponding to the second watermark identifier, the second watermark image including the watermark, the template watermark image library being used to store a template watermark image corresponding to at least one watermark identifier; adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image; Adjusting the size of the second watermark image to be consistent with the size of the watermark image; determining a difference image between the watermark image and the adjusted second watermark image, dividing the transparency of each pixel in the difference image by a sixth transparency value to obtain an adjusted difference image, wherein the transparency of the adjusted difference image is consistent with the transparency of the second image, and the sum of the fifth transparency and the sixth transparency of the watermark in the watermark image is a transparency threshold, wherein the transparency threshold is a transparency corresponding to when the image has no transparency, and the difference image does not include the watermark; replacing the watermark image in the second image with the adjusted difference image to obtain an image after the watermark is removed; Continue processing the next watermark in the second image until all watermarks in the second image are removed, thereby obtaining a third image that does not include a watermark; The training process of the watermark detection model includes: Acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from the template watermark image library; determining a sample watermark region in the first image based on at least one of a center point coordinate, an upper left corner coordinate, a lower left corner coordinate, an upper right corner coordinate, or a lower right corner coordinate and a region size determined in the first image; Adjusting the size of the first watermark image to be consistent with the size of the sample watermark area; The transparency of the first watermark image is a first transparency, the transparency of the watermark to be added in the first image is a second transparency, and a first ratio between the second transparency and the first transparency is determined; the first ratio is multiplied by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image, wherein the first ratio represents the degree of adjustment required to adjust the transparency of the first watermark image to the second transparency; determining a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold; multiplying the third transparency by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area; adding the adjusted first watermark image to the adjusted sample watermark region, while leaving other regions of the first image except the sample watermark region unchanged, to obtain a sample image, wherein the first image is any image not containing a watermark, and a shape of the sample watermark region is consistent with a shape of the first watermark image; The sample image is input into the watermark detection model to be trained, and the watermark detection model outputs a predicted watermark image, a predicted watermark identifier and a confidence level. Based on the difference between the sample watermark area and the predicted watermark image, and the difference between the first watermark identifier and the predicted watermark identifier, the model parameters corresponding to the watermark detection model are adjusted. The confidence level indicates the accuracy of the predicted watermark image and the predicted watermark identifier. The higher the confidence level, the more accurate the predicted watermark image and the predicted watermark identifier. The trained watermark detection model is used to detect a watermark image and a watermark identifier from any image, and the watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library.

4. The watermark removal method according to claim 3, characterized in that: The transparency of the second watermark image is a fourth transparency, and adjusting the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image includes: determining a second ratio between the fourth transparency and the fifth transparency; The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

5. A watermark detection model training device, characterized in that: The device comprises: a template watermark acquisition unit configured to acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from a template watermark image library, wherein the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier; The sample image acquisition unit is configured to determine a sample watermark area in the first image based on at least one of the center point coordinates, the upper left corner coordinates, the lower left corner coordinates, the upper right corner coordinates, or the lower right corner coordinates determined in the first image, and the area size; adjust the size of the first watermark image to be consistent with the size of the sample watermark area; the transparency of the first watermark image is a first transparency, the transparency of the watermark to be added in the first image is a second transparency, and determine a first ratio between the second transparency and the first transparency; multiply the first ratio by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image, wherein the first ratio represents the ratio of the transparency of the first watermark image to the transparency of each pixel in the first watermark image. The transparency of the first watermark image is adjusted to the degree to which it needs to be adjusted to the second transparency; a third transparency is determined, where the sum of the third transparency and the second transparency is a transparency threshold; the third transparency is multiplied by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area, where the transparency threshold is the transparency corresponding to when the image has no transparency; the adjusted first watermark image is added to the adjusted sample watermark area, while other areas of the first image except the sample watermark area remain unchanged, to obtain a sample image, where the first image is any image that does not contain a watermark, and the shape of the sample watermark area is consistent with the shape of the first watermark image; A training unit is configured to input the sample image into a watermark detection model to be trained, output a predicted watermark image, a predicted watermark identifier, and a confidence score based on the watermark detection model, and adjust model parameters corresponding to the watermark detection model based on a difference between the sample watermark region and the predicted watermark image, and a difference between the first watermark identifier and the predicted watermark identifier, wherein the confidence score indicates the accuracy of the predicted watermark image and the predicted watermark identifier, and a higher confidence score indicates a more accurate predicted watermark image and the predicted watermark identifier; the trained watermark detection model is used to detect a watermark image and a watermark identifier from any image, wherein the watermark identifier is a watermark identifier of a watermark contained in the detected watermark image in the template watermark image library; a watermark detection unit configured to execute and call the watermark detection model, perform watermark detection on the second image containing multiple watermarks, and obtain a watermark image corresponding to each watermark in the second image and a second watermark identifier corresponding to the watermark contained in the watermark image; a template watermark query unit configured to query, for any watermark included in the second image, a second watermark image corresponding to the second watermark identifier from the template watermark image library, the second watermark image including the watermark; a transparency adjustment unit, configured to adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image; a size adjustment unit, configured to adjust the size of the second watermark image to be consistent with the size of the watermark image; The watermark removal unit is configured to determine a difference image between the watermark image and the adjusted second watermark image, divide the transparency of each pixel in the difference image by a sixth transparency value to obtain an adjusted difference image, wherein the transparency of the adjusted difference image is consistent with the transparency of the second image, the sum of the fifth transparency and the sixth transparency of the watermark in the watermark image is the transparency threshold, and the difference image does not include the watermark; replace the watermark image in the second image with the adjusted difference image to obtain an image after the watermark is removed; and continue processing the next watermark in the second image until all watermarks in the second image are removed to obtain a third image that does not include the watermark.

6. The watermark detection model training device according to claim 5, characterized in that: The transparency of the second watermark image is a fourth transparency, and the transparency adjustment unit is further configured to execute: determining a second ratio between the fourth transparency and the fifth transparency; The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

7. A watermark removal device, characterized in that: The device comprises: A watermark detection unit is configured to execute a call to a watermark detection model to determine a watermark image corresponding to each watermark in a second image including a plurality of watermarks and a second watermark identifier corresponding to the watermark included in the watermark image; a template watermark query unit configured to query a second watermark image corresponding to the second watermark identifier from a template watermark image library for any watermark included in the second image, wherein the second watermark image includes the watermark, and the template watermark image library is used to store a template watermark image corresponding to at least one watermark identifier; a transparency adjustment unit, configured to adjust the transparency of the second watermark image to be consistent with the transparency of the watermark in the watermark image; a size adjustment unit, configured to adjust the size of the second watermark image to be consistent with the size of the watermark image; a watermark removal unit configured to determine a difference image between the watermark image and the adjusted second watermark image, divide the transparency of each pixel in the difference image by a sixth transparency value to obtain an adjusted difference image, wherein the transparency of the adjusted difference image is consistent with the transparency of the second image, wherein the sum of the fifth transparency and the sixth transparency of the watermark in the watermark image is a transparency threshold, wherein the transparency threshold is a transparency corresponding to when the image has no transparency, and the difference image does not include the watermark; replace the watermark image in the second image with the adjusted difference image to obtain an image after the watermark is removed; and continue processing the next watermark in the second image until all watermarks in the second image are removed to obtain a third image that does not include the watermark; The training process of the watermark detection model includes: Acquire a first watermark image and a first watermark identifier corresponding to the first watermark image from the template watermark image library; determining a sample watermark region in the first image based on at least one of a center point coordinate, an upper left corner coordinate, a lower left corner coordinate, an upper right corner coordinate, or a lower right corner coordinate and a region size determined in the first image; Adjusting the size of the first watermark image to be consistent with the size of the sample watermark area; The transparency of the first watermark image is a first transparency, the transparency of the watermark to be added in the first image is a second transparency, and a first ratio between the second transparency and the first transparency is determined; the first ratio is multiplied by the transparency of each pixel in the first watermark image to obtain an adjusted first watermark image, wherein the first ratio represents the degree of adjustment required to adjust the transparency of the first watermark image to the second transparency; determining a third transparency, where the sum of the third transparency and the second transparency is a transparency threshold; multiplying the third transparency by the transparency of each pixel in the sample watermark area to obtain an adjusted sample watermark area; adding the adjusted first watermark image to the adjusted sample watermark region, while leaving other regions of the first image except the sample watermark region unchanged, to obtain a sample image, wherein the first image is any image not containing a watermark, and a shape of the sample watermark region is consistent with a shape of the first watermark image; The sample image is input into the watermark detection model to be trained, and the watermark detection model outputs a predicted watermark image, a predicted watermark identifier and a confidence level. Based on the difference between the sample watermark area and the predicted watermark image, and the difference between the first watermark identifier and the predicted watermark identifier, the model parameters corresponding to the watermark detection model are adjusted. The confidence level indicates the accuracy of the predicted watermark image and the predicted watermark identifier. The higher the confidence level, the more accurate the predicted watermark image and the predicted watermark identifier. The trained watermark detection model is used to detect a watermark image and a watermark identifier from any image, and the watermark identifier is the watermark identifier of the watermark contained in the detected watermark image in the template watermark image library.

8. The watermark removal device according to claim 7, characterized in that: The transparency of the second watermark image is a fourth transparency, and the transparency adjustment unit is configured to perform: determining a second ratio between the fourth transparency and the fifth transparency; The second ratio is multiplied by the transparency of each pixel in the second watermark image to obtain an adjusted second watermark image.

9. An electronic device, characterized in that: The electronic device comprises: one or more processors; a memory for storing the one or more processor-executable instructions; The one or more processors are configured to execute the watermark detection model training method according to any one of claims 1 to 2, or are configured to execute the watermark removal method according to any one of claims 3 to 4.

10. A computer-readable storage medium, characterized in that When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the watermark detection model training method as described in any one of claims 1 to 2, or to execute the watermark removal method as described in any one of claims 3 to 4.

11. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, it implements the watermark detection model training method described in any one of claims 1 to 2, or implements the watermark removal method described in any one of claims 3 to 4.

Citation Information

Patent Citations

  • Image recognition model training method and device, image recognition method and device, and electronic equipment

    CN111476284A

  • Watermark detection model training method and system, watermark detection method and system, equipment and medium

    CN112232431A