Watermark embedding method and device based on model quantification, equipment and storage medium
By determining the watermark quantization step based on the feature channel smoothing coefficient during the model quantization process and embedding the watermark information, the problem that the watermark information is easily destroyed during the model quantization process is solved, and the reliability and integrity of the watermark are improved.
Patent Information
- Application Number
- CN202411672389.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-11-21
AI Technical Summary
During the process of model quantization, the watermark information is easily destroyed or becomes difficult to detect, resulting in the quantized model being unable to effectively maintain the existence and integrity of the watermark, reducing the reliability of the watermark.
By obtaining the initial model and watermark information of the watermark to be embedded, the characteristic channel smoothing coefficient of the initial model is determined, and the watermark quantization step is determined based on the parameters of these channels, and the watermark information is embedded in the model parameters to ensure the integrity and reliability of the watermark information.
Without affecting the quantization accuracy of the model, the embedding and quantization of watermark information is completed, which improves the reliability and integrity of watermarks in the quantized model.
Smart Images

Figure CN119579386A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of watermark embedding technology, and in particular to a watermark embedding method, device, equipment and storage medium based on model quantization. Background Art
[0002] Model quantization is a method of compressing network parameters, which converts the floating-point algorithm of the neural network into a fixed-point algorithm to reduce the size of the model and speed up the inference. Watermark embedding refers to embedding specific identification information (watermark) into the relevant model to verify copyright, integrity, or track the source and use of the model when necessary.
[0003] In the process of model quantization in related technologies, the weights and structures of the model are usually compressed and simplified. This process may cause the watermark information embedded in the model to be destroyed or become difficult to detect, making it impossible for the quantized model to effectively maintain the existence and integrity of the watermark, thereby reducing the reliability of the watermark in the quantized model. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a watermark embedding method, device, equipment and storage medium based on model quantization, which can improve the reliability of the watermark in the quantized model.
[0005] To achieve the above purpose, a first aspect of an embodiment of the present application proposes a watermark embedding method based on model quantization, the method comprising:
[0006] Obtaining an initial model to be embedded with a watermark and watermark information used to embed the initial model;
[0007] Determine the channel smoothing coefficient corresponding to each feature channel in any processing layer of the initial model, and determine the feature channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial feature channel;
[0008] Determine a watermark quantization step size based on a plurality of first initial parameters of the initial feature channel, and embed watermark information into the plurality of first initial parameters based on the watermark quantization step size to obtain corresponding first target parameters;
[0009] Determine a standard quantization step size based on a plurality of second initial parameters of the initial feature channel, and perform quantization processing on the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain corresponding second target parameters;
[0010] According to the first target parameter and the second target parameter, a target model is obtained after watermark information embedding and model quantization are completed.
[0011] In some embodiments, the first initial parameter is determined by the following steps, comprising:
[0012] Using multiple weight parameters of the initial feature channel as multiple first initial parameters representing static invariance; or,
[0013] Sample input data for quantization training of the initial model is obtained, and the product of the sample input data and each weight parameter is used as a plurality of first initial parameters representing dynamic changes.
[0014] In some embodiments, after obtaining the target model after the watermark information is embedded and the model is quantized, the method further includes:
[0015] Obtain verification watermark parameters and verification quantization parameters corresponding to sample input data;
[0016] When the difference between the first target parameter and the verification watermark parameter is less than a preset first threshold, and the difference between the second target parameter and the verification quantization parameter is less than a preset second threshold, it is determined that the quantization accuracy of the target model meets the standard.
[0017] In some embodiments, determining the watermark quantization step size based on a plurality of first initial parameters of the initial feature channel comprises:
[0018] Obtain the quantitative range information of the initial model;
[0019] Determine a first maximum value parameter with the largest value and a second maximum value parameter with the smallest value from a plurality of first initial parameters of the initial characteristic channel;
[0020] A first parameter difference between the first maximum parameter and the second maximum parameter is calculated, and a watermark quantization step for quantizing the first initial parameter is obtained according to a ratio of the first parameter difference to the quantization range information.
[0021] In some embodiments, embedding watermark information into a plurality of first initial parameters based on the watermark quantization step size to obtain corresponding first target parameters includes:
[0022] The watermark information is divided into a plurality of sub-watermark information, and the watermark quantization step size is updated based on the plurality of sub-watermark information to obtain a plurality of updated quantization step sizes;
[0023] For each first initial parameter, a second parameter difference between the first initial parameter and the second maximum parameter is calculated, and a ratio between the second parameter difference and any updated quantization step is determined as a sub-watermark model parameter obtained after embedding the first initial parameter watermark;
[0024] Determine a plurality of sub-watermark model parameters obtained by embedding based on all updated quantization step sizes as complete first target parameters.
[0025] In some embodiments, the watermark quantization step size is updated based on the multiple sub-watermark information to obtain multiple updated quantization step sizes, including:
[0026] Amplifying the watermark quantization step to obtain an amplified quantization step, wherein the amplified quantization step includes a plurality of original quantization information arranged in sequence from high to low bits;
[0027] Performing information conversion processing on the sub-watermark information to obtain watermark quantization information;
[0028] Clearing a preset replacement number of original quantization information under the low position of the enlarged quantization step, and replacing the cleared original quantization information with the watermark quantization information to obtain a replacement enlarged quantization step;
[0029] The replaced enlarged quantization step size is scaled to obtain an updated quantization step size.
[0030] In some embodiments, the first target parameter includes a head parameter characterizing a starting position of the first target parameter, and a tail parameter characterizing an ending position of the first target parameter;
[0031] After embedding the watermark information into a plurality of first initial parameters based on the watermark quantization step length to obtain corresponding first target parameters, the method further includes:
[0032] Inserting preset start identification information before the header parameter, the start identification information is used to identify the start position of the first target parameter;
[0033] Preset end identification information is inserted after the tail parameter, and the end identification information is used to identify the end position of the first target parameter.
[0034] In some embodiments, after obtaining the target model after the watermark information is embedded and the model is quantized, the method further includes:
[0035] Extracting encoding information from the multiple model parameters after quantization one by one;
[0036] When the encoded information identical to the starting identification information is extracted, the watermark information is extracted starting from the next model parameter;
[0037] When the encoded information identical to the end identification information is extracted, the extraction of the watermark information is completed.
[0038] To achieve the above purpose, a second aspect of an embodiment of the present application proposes a watermark embedding device based on model quantization, the device comprising:
[0039] An acquisition module, used for acquiring an initial model to be embedded with a watermark, and watermark information for embedding the initial model;
[0040] A channel determination module is used to determine the channel smoothing coefficient corresponding to each feature channel in any processing layer of the initial model, and determine the feature channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial feature channel;
[0041] A first target parameter determination module, used to determine a watermark quantization step size based on a plurality of first initial parameters of an initial feature channel, and embed watermark information into the plurality of first initial parameters based on the watermark quantization step size to obtain a corresponding first target parameter;
[0042] A second target parameter determination module, used in the watermark model parameter determination module, is used to determine a standard quantization step size based on a plurality of second initial parameters of the initial feature channel, and to quantize the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain corresponding second target parameters;
[0043] The target quantization module is used to obtain the target model after the watermark information is embedded and the model is quantized according to the first target parameter and the second target parameter.
[0044] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the method of the above-mentioned first aspect when executing the computer program.
[0045] To achieve the above objectives, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the method of the first aspect is implemented.
[0046] The watermark embedding method, device, equipment and storage medium based on model quantization proposed in the present application obtain an initial model to be embedded with a watermark, and watermark information for embedding the initial model; determine the channel smoothing coefficient corresponding to each feature channel in any processing layer of the initial model, and determine the feature channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial feature channel, and implement watermark embedding by selecting the feature channel containing smoother parameters, thereby improving the reliability of the embedded watermark and helping to improve the stability of the target model finally obtained; determine the watermark quantization step size based on multiple first initial parameters of the initial feature channel, and embed the watermark information into the multiple first initial parameters based on the watermark quantization step size to obtain the corresponding first target parameter; determine the standard quantization step size based on multiple second initial parameters of the initial feature channel, and quantize the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain the corresponding second target parameter; obtain the target model after the watermark information is embedded and the model is quantized according to the first target parameter and the second target parameter, so that the present application can embed the watermark information without affecting the model quantization accuracy, while ensuring the integrity of the embedded watermark information and thus ensuring its reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 This is an optional flow chart of a watermark embedding method based on model quantization provided in an embodiment of the present application;
[0048] Figure 2 This is an optional first initial parameter determination flow chart of the watermark embedding method based on model quantization provided in an embodiment of the present application;
[0049] Figure 3 yes Figure 1 A flowchart of an implementation of step 103 in FIG.
[0050] Figure 4 yes Figure 1 Another implementation flow chart of step 103 in FIG.
[0051] Figure 5 yes Figure 4 Another implementation flow chart of step 401 in FIG.
[0052] Figure 6 yes Figure 1 An implementation flow chart after step 105 in FIG. 1 ;
[0053] Figure 7 yes Figure 1 An implementation flow chart after step 103 in FIG. 1 ;
[0054] Figure 8 yes Figure 1Another implementation flow chart after step 105 in;
[0055] Fig. 9 It is an optional PTQ static weight quantization flow chart of the watermark embedding method based on model quantization provided in the embodiment of the present application;
[0056] Fig.10 This is an optional flow chart of a watermark embedding device based on model quantization provided in an embodiment of the present application;
[0057] Fig.11 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0059] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0060] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0061] In model deployment, model quantization is an important optimization step. A streamlined model can reduce the requirements for the video memory and computing power of edge devices. It converts the floating-point algorithm of the neural network into a fixed-point algorithm by compressing the network parameters to reduce the size of the model and speed up the reasoning speed. For example, an edge intelligent control system is embedded in different devices. Since the computing power resources and memory resources of different devices are different, the corresponding model of the edge intelligent control system needs to be quantized so that each model based on different degrees of quantization can be efficiently operated in the corresponding device.
[0062] Furthermore, model watermark embedding is a technology used for model copyright protection, which identifies the owner of the model by embedding specific watermark information in the model to prevent unauthorized copying and use. Model quantization brings significant challenges to model watermark embedding. In the process of model quantization in related technologies, the weights and structure of the model are usually compressed and simplified. This process may cause the watermark information embedded in the model to be destroyed or become difficult to detect, making it impossible for the quantized model to effectively maintain the existence and integrity of the watermark, reducing the reliability of the watermark in the quantized model.
[0063] Based on this, the embodiments of the present application provide a watermark embedding method, apparatus, device and storage medium based on model quantization, which can improve the reliability of the watermark in the quantized model.
[0064] It should be noted that in the embodiments of the present application, when it comes to information related to user characteristics such as user basic information or user identity, the user's permission or consent will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards. In addition, when the embodiments of the present application need to obtain sensitive personal information of the user, the user's separate permission or consent will be obtained first. After the user's separate permission or consent is clearly obtained, the necessary data for the normal operation of the embodiments of the present application will be obtained. For example, when the embodiments of the present application obtain the initial model to be embedded with the watermark, the consent of the relevant manager of the initial model will be obtained first; when the embodiments of the present application obtain the watermark information embedded in the initial model, since the watermark information may be the ID number, name characters, etc. of the relevant manager, the consent of the user involved in the watermark information will also be obtained first; otherwise, the initial model and watermark information of the embodiments of the present application cannot be applied. In addition, the other relevant data obtained by the item recommendation device of the present application are all legal and authorized data, which will not be repeated here.
[0065] In the embodiment of the present application, the watermark embedding device based on model quantization (for the convenience of description, it may also be referred to as "watermark embedding device" below) is described. The watermark embedding model device can be integrated into a computer device, such as a server. Figure 1 As shown, Figure 1 is an optional flow chart of a watermark embedding method based on model quantization provided in an embodiment of the present application (for the convenience of description, it may also be referred to as “watermark embedding method” hereinafter). Figure 1 The method may include but is not limited to the following steps 101 to 105. When the watermark embedding device executes the prediction method, the specific process is as follows. It should be noted that the present embodiment Figure 2The order of step 101 to step 105 is not specifically limited, and the order of steps can be adjusted or some steps can be reduced or added according to actual needs.
[0066] Step 101: Acquire an initial model to be embedded with a watermark and watermark information used to embed the initial model.
[0067] The following is a detailed description of step 101.
[0068] Among them, in the scenario of model watermark embedding, the initial model refers to the original carrier to be embedded with the watermark. The initial model can have different instances according to actual conditions. For example, the initial model can be an image processing model, a video encoding model or an audio analysis model. The embodiment of the present application does not limit the type of the initial model.
[0069] The watermark information used to identify the identification information (such as copyright information) can be the name, ID card information, passport information and other related identifying information of the owner of the initial model, and in order to embed the watermark information into the initial model, the watermark information will also be converted, such as converting the watermark information into a binary bit stream. It should be noted that the watermark information can be specifically selected according to the actual situation, and the processing operation implemented on the watermark information can also be adaptively adjusted according to the actual situation, and the embodiment of the present application does not limit this.
[0070] In some embodiments, since the parameters to be quantized depend on the structure and quantization granularity of the initial model, it is necessary to first analyze the selected initial model to adaptively determine the watermark information suitable for embedding in the initial model. Exemplarily, the parameters to be quantized of a certain initial model include 48 convolution weight tensors, 48 pairs of batch normalization parameter tensors, 1 fully connected weight tensor, and 33 dynamically generated activation value tensors, from which the following information can be obtained:
[0071] 1) For weight quantization based on tensor dimensions, there are at most about 100 quantization parameters;
[0072] 2) For weight quantization based on channel dimension, according to the number of channels in the statistical convolutional layer, there may be tens of thousands of weight quantization parameters;
[0073] 3) For tensor-based activation quantization, there are up to 33 quantization parameters;
[0074] 4) For activation value quantization based on channel granularity, there are hundreds of quantization parameters.
[0075] Furthermore, since the parameters to be quantized of different initial models are usually different, it is necessary to determine the amount of quantization information by analyzing the initial model, and then select watermark information for embedding in the initial model from multiple candidate watermark information based on the quantization information amount.
[0076] In an practicable manner, in order to minimize the impact of watermark embedding on other quantization parameters of the initial model, the length (bit length) of the watermark information is limited to 5% of the length (bit length) of all quantization parameters. For example, the total amount of information to be quantized = 256 (convolutional layer) + 128 (fully connected layer) + 64 (activation layer) = 448 bits; then, the maximum length of the embedded watermark information = 448*5% = 22.4 bits (in actual applications, integer bits such as 22 bits or 23 bits are often used, depending on the specific implementation method and not limited); and then, the length of the watermark information that is less than the maximum length of the embedded watermark information can be selected from multiple candidate watermark information as the watermark information for embedding in the initial model.
[0077] Furthermore, if there are multiple watermark information whose lengths are all less than the maximum length of the watermark information, in consideration of enhancing the copyright protection of the model and supporting more complex copyright tracking and authentication, the one with a longer watermark information length is preferred; or, if the maximum length of the watermark information allows, multiple watermark information are spliced together to maximize the watermark identification without affecting the quantization accuracy of the model. It should be noted that the total limit length of the watermark information in the initial model and the number of identification information contained in the watermark information are set according to the actual situation. The embodiments of this application are only for illustrative purposes and are not specifically limited to this.
[0078] Step 102, determining the channel smoothing coefficient corresponding to each feature channel in any processing layer of the initial model, and determining the feature channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial feature channel.
[0079] The following is a detailed description of step 102.
[0080] Among them, the initial model includes multiple processing layers, such as convolutional layers, activation layers, and fully connected layers, and multiple feature channels are screened according to a preset smoothing threshold. Specifically, the channel smoothing coefficient is used to characterize the smoothness of the data in the corresponding feature channel. A higher channel smoothing coefficient means that the data in the feature channel changes relatively smoothly, without obvious fluctuations or mutations; conversely, a lower smoothing coefficient means that the data in the feature channel fluctuates greatly and there is more uncertainty; based on this, the feature channel with a channel smoothing coefficient less than the preset smoothing threshold is determined as the initial feature channel, and watermark embedding is implemented by selecting a feature channel containing smoother parameters, thereby improving the reliability of the embedded watermark and helping to improve the stability of the final target model.
[0081] For example, by the following formula <1> The corresponding channel smoothness index (SmoothnessIndex) of each feature channel is calculated:
[0082]
[0083] Among them, N is used to represent the total number of parameter points in the feature channel, x i Used to represent the i-th parameter point.
[0084] It should be noted that the preset smoothing threshold is set according to actual conditions, and the embodiments of the present application do not limit this.
[0085] Step 103: determine a watermark quantization step size based on a plurality of first initial parameters of the initial feature channel, and embed the watermark information into the plurality of first initial parameters based on the watermark quantization step size to obtain corresponding first target parameters.
[0086] The following is a detailed description of step 103.
[0087] Among them, the parameters in the initial feature channel are called the first initial parameters. In the process of model quantization embedding watermark, the corresponding watermark quantization step is adaptively determined based on the first initial parameters of each initial feature channel, which greatly reduces the probability of watermark information distortion, thereby ensuring that the watermark information is not easily lost or tampered with during transmission or processing, and improving the robustness of the embedded watermark.
[0088] In some embodiments, Figure 2 As shown, Figure 2 This is an optional first initial parameter determination flow chart of the watermark embedding method based on model quantization provided in an embodiment of the present application. The first initial parameter is determined by following steps 201 to 202:
[0089] Step 201: multiple weight parameters of the initial feature channel are used as multiple first initial parameters representing static invariance.
[0090] Step 202, alternatively, obtain sample input data for quantization training of the initial model, and use the product of the sample input data and each weight parameter as a plurality of first initial parameters characterizing dynamic changes.
[0091] Steps 201 to 202 are described in detail below.
[0092] The initial model includes a plurality of different types of first initial parameters, for example, the first initial parameter may be a static weight parameter, or an activation value parameter that changes dynamically with the processing process. When implementing watermark embedding, the weight parameter may be directly used as the first initial parameter to be processed, or during the quantization training of the initial model, the multiplication value (activation value parameter) of the sample input data used for quantization training and the weight parameter may be used as the first initial parameter to be processed; or, the first initial parameter may be either a weight parameter or an activation value parameter, in which case the watermark information will be embedded into the first initial parameter characterized as the weight parameter and the activation value parameter at the same time.
[0093] Furthermore, model quantization includes the following two common methods:
[0094] (1) Post-training quantization (PTQ): A method for quantizing an initial model after training. PTQ does not require retraining the model, so it can be applied to models that have already been deployed or trained by other methods. PTQ usually uses a small amount of calibration data to adjust the weights and activation values in the model to ensure that the quantized model still has high accuracy during the inference phase.
[0095] (2) Quantization-Aware Training (QAT): A method that takes quantization effects into account during the initial model training process. Unlike PTQ, QAT introduces quantization operations during the training process. The model takes quantization errors into account during training. PTQ usually simulates quantization operations during training and adjusts the model weights through the back-propagation algorithm, so that the model can maintain high accuracy in the inference stage after quantization.
[0096] Under different model quantization methods, different types of first initial parameters will be selected to implement watermark embedding, which will correspond to different complete quantization processes. The following example uses the PTQ static weight quantization watermark embedding method (assuming channel quantization is used) to explain the same parts of several complete quantization processes in detail, and the differences will be explained after the same parts are explained:
[0097] In some embodiments, Figure 3 As shown, Figure 3 yes Figure 1 A flowchart for implementing step 103 in the embodiment of the present invention, determining the watermark quantization step size based on multiple first initial parameters of the initial feature channel, comprising the following steps 301 to 303:
[0098] Step 301, obtaining the quantization range information of the initial model.
[0099] Step 302, determining a first maximum parameter with the largest value and a second maximum parameter with the smallest value from a plurality of first initial parameters of the initial feature channel.
[0100] Step 303: Calculate a first parameter difference between the first maximum parameter and the second maximum parameter, and obtain a watermark quantization step for quantizing the first initial parameter according to a ratio of the first parameter difference to the quantization range information.
[0101] Steps 301 to 303 are described in detail below.
[0102] In some embodiments, by the formula <2> Calculate and determine the watermark quantization step size origin_step of the initial feature channel:
[0103]
[0104] Among them, (2 n -1) represents the quantization range information of the initial model; max_val is the first maximum parameter, min_val is the second maximum parameter; (max_val-min_val) is the first parameter difference.
[0105] In some embodiments, Figure 4 As shown, Figure 4 yes Figure 1 Another implementation flow chart of step 103 in the embodiment of the present invention, embedding watermark information into a plurality of first initial parameters based on the watermark quantization step length to obtain corresponding first target parameters, includes the following steps 401 to 403:
[0106] Step 401: divide the watermark information into a plurality of sub-watermark information, and update the watermark quantization step size based on the plurality of sub-watermark information to obtain a plurality of updated quantization step sizes.
[0107] The following is a detailed description of step 401.
[0108] In some embodiments, a single first initial parameter is usually unable to embed the complete watermark information, so the watermark information needs to be preprocessed first, including dividing the watermark information into a plurality of sub-watermark information with smaller lengths; generally, the sub-watermark information is selected in sequence according to the order in which the complete watermark information can be assembled, and then the watermark quantization step determined in step 303 is updated based on the selected sub-watermark information to obtain an updated quantization step for quantizing the first initial parameter. The specific steps are as follows:
[0109] In some embodiments, Figure 5 As shown, Figure 5 yes Figure 4Another implementation flow chart of step 401 in the embodiment of the present invention is to update the watermark quantization step size based on multiple sub-watermark information to obtain multiple updated quantization step sizes, including the following steps 501 to 504:
[0110] Step 501, amplify the watermark quantization step to obtain an amplified quantization step, wherein the amplified quantization step includes a plurality of original quantization information arranged in sequence from high to low.
[0111] Step 502: Perform information conversion processing on the sub-watermark information to obtain watermark quantization information.
[0112] Step 503: clear the preset replacement number of original quantization information at the lower bits of the enlarged quantization step, and replace the cleared original quantization information with the watermark quantization information to obtain a replacement enlarged quantization step.
[0113] Step 504: Scaling the replaced enlarged quantization step size to obtain an updated quantization step size.
[0114] Steps 501 to 504 are described in detail below.
[0115] In some embodiments, by embedding the watermark information into the enlarged watermark quantization step, and then using the quantization step after the watermark embedding and scaling to quantize the first initial parameter, it is possible to reduce the perception of the watermark information by the quantized model while achieving model quantization watermark embedding.
[0116] Exemplarily, the updated quantization step size is obtained through the following steps ① to ③:
[0117] ① step_int = int(origin_step*(2**24)), the origin_step obtained in step 303 is enlarged to a fixed-point number representation (assuming that the fixed-point number is set to 2**24) to obtain an enlarged quantization step length, and a plurality of original quantization information arranged in sequence from high to low bits constitutes the enlarged quantization step length;
[0118] ②updated_step=(step_int&~(0b111111))|watermark_bits, wherein watermark_bits is the watermark quantization information obtained by performing information conversion processing on the sub-watermark information, and the information conversion processing is used to convert the sub-watermark information into a bit string that is easy to embed; by performing a bitwise inversion operation (~) on step_int in step ①, and then performing a bitwise AND operation (&) with the binary mask 0b111111, the preset replacement number of original quantization information under the low bit is cleared; then, watermark_bits (watermark quantization information) is inserted into the cleared bit of step_int through a bitwise OR operation (|) to obtain an updated replacement enlarged quantization step length updated_step; it should be noted that here, clearing the lower 6 bits is used as an example, and the original quantization information actually cleared is specifically set according to the length of the sub-watermark information after conversion, and the embodiment of the present application does not limit it;
[0119] ③watermark_scale=updated_step / (2**24), according to the scale of the amplification process, the replacement amplification quantization step size step_int is scaled to obtain the updated quantization step size watermark_scale.
[0120] It can be understood that, although the updated quantization step and the initial watermark quantization step are almost unchanged in floating point representation, quantizing the first initial parameter using the watermark quantization step can ensure that the accuracy of model quantization is not affected while embedding watermark information.
[0121] Step 402, for each first initial parameter, calculate the second parameter difference between the first initial parameter and the second maximum parameter, and determine the sub-watermark model parameter obtained after embedding the first initial parameter watermark based on the ratio between the second parameter difference and any updated quantization step.
[0122] Step 403: Determine that multiple sub-watermark model parameters obtained by embedding based on all updated quantization step sizes are complete first target parameters.
[0123] After knowing the method for determining the updated quantization step size, following step 401 , steps 402 to 403 are described in detail.
[0124] In some embodiments, by the formula <3> Determine the sub-watermark model parameter quant_weight obtained after each first initial parameter is embedded in the watermark information and quantized:
[0125]
[0126] Among them, round represents the rounding function; watermark_scal is the updated quantization step size; current val is the first initial parameter currently selected; min val is the second maximum parameter with the smallest value among the multiple first initial parameters of the current initial feature channel; val -min val ) is the second parameter difference.
[0127] Furthermore, for each first initial parameter, a watermark embedding quantization process is performed using different update quantization steps to obtain multiple sub-watermark model parameters, thereby forming a first target parameter after complete watermark embedding quantization. If the first initial parameter of a single processing layer cannot complete the embedding of the complete watermark information, then the first initial parameter of the new processing layer is then subjected to watermark embedding process to continue embedding the remaining watermark information. The specific implementation method of the watermark embedding process for the first initial parameter of the new processing layer is similar to step 103 and will not be repeated here.
[0128] Furthermore, in order to facilitate embedding and subsequent extraction of watermark information, multiple first initial parameters are subjected to watermark embedding quantization processing in sequence according to a specified order. The specified order may be the logical order in which the processing layer processes the input data, or the initial feature channels from the beginning to the end.
[0129] Step 104, determining a standard quantization step size based on a plurality of second initial parameters of the initial feature channel, and quantizing the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain corresponding second target parameters.
[0130] Step 105, obtaining a target model after watermark information embedding and model quantization according to the first target parameter and the second target parameter.
[0131] Steps 104 and 105 are described in detail below.
[0132] In some embodiments, parameters in the remaining feature channels other than the initial feature channel are determined as parameters that do not require embedding watermark information as second initial parameters; a standard quantization step size is calculated based on a method similar to steps 301 to 303, and the quantization range information used to determine the standard quantization step size is usually the same as the quantization range information used to determine the watermark quantization step size; a second target parameter obtained after quantizing the second initial parameter is determined based on a method similar to steps 402 to 403.
[0133] Furthermore, based on the first target parameter after the watermark information is embedded and the second target parameter obtained after the standard quantization operation, a watermark embedding method based on model quantization is completed to obtain the target model.
[0134] In the related art, directly embedding watermarks into the low-precision model after quantization will greatly affect the accuracy of the quantized model, thereby affecting the actual application effect of the quantized model and limiting the practicality of the embedded watermark information. In comparison, the watermark embedding method proposed in the embodiment of the present application can embed watermark information without affecting the quantization accuracy of the model, while ensuring the integrity of the embedded watermark information and thus ensuring its reliability.
[0135] In some embodiments, Figure 6 As shown, Figure 6 yes Figure 1 A flowchart for implementing the process after step 105 in the embodiment of the present invention, after obtaining the target model after the watermark information is embedded and the model is quantized, further includes the following steps 601 to 602:
[0136] Step 601: Obtain verification watermark parameters and verification quantization parameters corresponding to sample input data.
[0137] Step 602: When the difference between the first target parameter and the verification watermark parameter is less than a preset first threshold, and the difference between the second target parameter and the verification quantization parameter is less than a preset second threshold, it is determined that the quantization accuracy of the target model meets the standard.
[0138] Steps 601 to 602 are described in detail below.
[0139] In some embodiments, in order to evaluate the performance of the model after watermark embedding and quantization, the quantization accuracy of the target model needs to be verified, wherein the verification of the quantization accuracy includes two aspects: watermark embedding quantization verification and standard quantization verification.
[0140] Furthermore, the sample input data is data used to test or verify the quantization accuracy of the target model, and the sample input data can be randomly generated or can come from a specific data set. The verification watermark parameter is used to characterize the expected output result after the sample input data watermark is embedded and quantized, and the verification quantization parameter is used to characterize the expected output result after the standard quantization operation of the sample input data without embedding a watermark.
[0141] Furthermore, the first threshold is used to characterize the acceptable degree of difference between the first target parameter and the verification watermark parameter, and the second threshold is used to characterize the acceptable degree of difference between the second target parameter and the verification quantization parameter. When these two conditions are met at the same time, it means that the target model can complete the embedding of watermark information without affecting the parameter quantization accuracy.
[0142] In some embodiments, Figure 7 As shown, Figure 7 yes Figure 1 The implementation flow chart after step 103 in the embodiment further includes the following steps 701 to 702 after the watermark information is embedded into a plurality of first initial parameters based on the watermark quantization step length to obtain the corresponding first target parameters:
[0143] Step 701: insert preset start identification information before the header parameter, where the start identification information is used to identify the start position of the first target parameter.
[0144] Step 702: insert preset end identification information after the tail parameter, where the end identification information is used to identify the end position of the first target parameter.
[0145] Steps 701 to 702 are described in detail below.
[0146] In some embodiments, the first target parameter includes a header parameter representing the starting position of the first target parameter and a tail parameter representing the ending position of the first target parameter. The starting identification information and the ending indication information are both represented by unique data such as a unique string, a digital sequence or a special symbol, so as to be accurately identified when the watermark information is subsequently extracted without being confused with other parameters.
[0147] The header parameter is composed of a preset number of characters of the header of the first target parameter, and the tail parameter is composed of a preset number of characters of the tail of the first target parameter. Further, according to the embedding order of the multiple sub-watermark information, the first embedded one is the header, and the later embedded one is the tail.
[0148] Exemplarily, if the head parameter of the first target parameter is at the Y position, the start identification information obtained by special encoding processing is directly inserted at (Y-3), (Y-2), and (Y-1), or the lowest 6 bits of the quantization step at these three places are set to a specific 18-bit string; similarly, if the tail parameter of the first target parameter is at the Z position, the end identification information obtained by special encoding processing is directly inserted at (Z+1), (Z+2), and (Z+3), or the lowest 6 bits of the quantization step at these three places are set to a specific 18-bit string.
[0149] In some embodiments, Figure 8 As shown, Figure 8 yes Figure 1 Another implementation flow chart after step 105 in the embodiment of the present invention further includes the following steps 801 to 803 after the target model after watermark information embedding and model quantization is obtained:
[0150] Step 801 , extracting coding information one by one from a plurality of model parameters after quantization processing.
[0151] Step 802: When the encoded information identical to the start identification information is extracted, watermark information is extracted starting from the next model parameter.
[0152] Step 803: When the encoded information identical to the end identification information is extracted, the extraction of the watermark information is completed.
[0153] Steps 801 to 803 are described in detail below.
[0154] Among them, the model parameters refer to the parameters in the target model obtained after the model is quantized. Usually, it is impossible to distinguish which model parameters are embedded with watermark information based on the naked eye. Therefore, it is necessary to identify the location of the watermark information through the start identification information and the end identification information. When the encoded information identical to the start identification information is extracted, it means that the watermark information is embedded in the subsequent model parameters, and the watermark information is extracted from the next model parameter; usually, if the watermark information is embedded in the lower 6 bits of the first initial parameter, the embedded content is restored based on the lower 6 bits of the model parameter until the encoded information identical to the end identification information is extracted, and it is determined that the extraction of the watermark information is completed. For the embodiment of the present application, the model parameters can be the watermark quantization step size and the standard quantization step size.
[0155] Furthermore, for the extraction of the weighted quantized step watermark of PTQ, it depends on the 18-bit bit string mark encoding of the watermark start embedding, the weighted amplified fixed-point number, and the preset smoothing threshold; for the extraction of the activation value quantized step watermark of PTQ, it depends on the calibration data set and the weighted amplified fixed-point number; for the extraction of the quantized step watermark of QAT, it depends on the weighted amplified fixed-point number. The following takes the extraction of the weighted quantized step watermark of PTQ as an example. The watermark extraction of the other two methods lacks the positioning of the watermark embedding start position;
[0156] (1) Read the quantization step lengths of the three channels in sequence, read the combined 18-bit bit string, and determine whether it is consistent with the 18-bit bit string mark encoding of the watermark start embedding. If it is consistent, it means that the starting position of the watermark embedding has been found;
[0157] (2) Starting from the next quantization step, determine whether the smoothness index of the inverse quantized channel weight is less than the WM embedding threshold. If so, it means that the current quantization step has embedded the watermark, and extract it;
[0158] (3) Read the last three quantization steps, read the combined 18-bit bit string, and determine whether it is consistent with the 18-bit bit string mark encoding for the end of watermark embedding. If it is consistent, it means that the end position of watermark embedding has been found.
[0159] like Fig. 9 As shown, Fig. 9This is an optional PTQ static weight quantization flow chart of the watermark embedding method based on model quantization provided in an embodiment of the present application. When PTQ is selected as the model quantization method of the initial model and the static weight is selected as the target quantization and watermark embedding object (the first case), the target model is obtained by the following steps:
[0160] (1) If the channel smoothness index of the current X-th feature channel is less than the preset smoothness threshold, the feature channel is determined to be the initial feature channel;
[0161] (2) determining a watermark quantization step size based on a plurality of first initial parameters in the initial feature channel;
[0162] (3) embedding the watermark information based on the watermark quantization step size. If the watermark information cannot be completely embedded in a single first initial parameter, the watermark information is split, and the split sub-watermark information is embedded into multiple first initial parameters;
[0163] (4) After the current watermark information is embedded, check whether the preset watermark information is completely embedded. If not, repeat steps (1) to (4); if yes, proceed to step (5);
[0164] (5) obtaining a first target parameter for embedding the complete watermark information, and inserting an identification letter as a marker before the start position and after the end position of the watermark information;
[0165] (6) performing standard quantization processing on other second initial parameters that do not need to be embedded with watermark information to obtain second target parameters;
[0166] (7) Obtain and save the target model based on the first target parameter and the second target parameter.
[0167] In some embodiments, when PTQ is selected as the model quantization method of the initial model, and the dynamic activation value is selected as the target quantization and watermark embedding object (the second case), compared with the first case, the activation value in the second case will change differently with different input data, so it can embed watermark information at the activation value based on the verification data to achieve tracking or verification of model usage and ensure that the model is correctly applied to the specified data set. That is, in the second case, when determining the watermark quantization step size, it is necessary to dynamically determine the maximum activation value, so as to determine the watermark quantization step size in this case. The maximum value calculation method for different data sets is as follows:
[0168] ① Global minimum and maximum method:
[0169] min=min(min1,...,minx), max=max(max1,...,maxx); where min represents the minimum value function, mini(i=1, 2......x); max represents the minimum value function, maxi(i=1, 2......x);
[0170] ②Batch maximum and minimum method:
[0171] min=average(min1,...,minx),max=average(max1,...,maxx); where average is the average function;
[0172] ③Percentile method: min=10%th(sort(min1,...,minx,max1,...,maxx)); max=90%th(sort(min1,...,minx,max1,...,maxx)); where 10%th represents the top 10%, 90%th represents the top 90%, and sort is the sorting function;
[0173] ④KL divergence method: first collect the floating-point histogram of the activation values of each processing layer, and then use the KL divergence method to find the truncation point where the difference between the quantized distribution and the original distribution is the smallest. By adjusting the interval of the histogram, find the mini and maxi values that minimize the quantization error. It should be noted that these values may not be extreme points in the activation values, but are the results of statistical optimization.
[0174] Furthermore, in the second case, different extreme value calculation methods need to be selected according to different data sets to determine the standard quantization step size for quantizing the second initial parameter. Of course, the extreme value calculation methods for different data sets can be set according to actual conditions, and the embodiment of the present application does not limit this. The other steps of obtaining the target model in the second case are similar to those in the first case, and will not be repeated here.
[0175] In some embodiments, when QTA is selected as the model quantization method of the initial model and static weights are selected as the target quantization and watermark embedding objects (the third case), the processing steps are similar to those of the first case. The difference is that since QTA takes the impact of the quantization operation into account during the model training process, the third case does not need to evaluate the model reasoning accuracy after the watermark is embedded, that is, the start and end positions of the watermark information are directly marked after the watermark information is completely embedded.
[0176] In some embodiments, when QTA is selected as the model quantization method of the initial model and the dynamic activation value is selected as the target quantization and watermark embedding object (the fourth case), the processing steps are similar to those of the second case. The difference is that since QTA takes the impact of the quantization operation into account during the model training process, the fourth case does not need to evaluate the model reasoning accuracy after the watermark is embedded, that is, the start and end positions of the watermark information are directly marked after the watermark information is completely embedded.
[0177] like Fig.10 As shown, Fig.10 This is an optional flow chart of a watermark embedding device based on model quantization provided in an embodiment of the present application. The watermark embedding device includes the following modules 901 to 906:
[0178] The acquisition module 901 is used to acquire the initial model to be embedded with a watermark and the watermark information used to embed the initial model.
[0179] The channel determination module 902 is used to determine the channel smoothing coefficient corresponding to each characteristic channel in any processing layer of the initial model, and determine the characteristic channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial characteristic channel.
[0180] The first target parameter determination module 903 is used to determine the watermark quantization step based on multiple first initial parameters of the initial feature channel, and embed the watermark information into the multiple first initial parameters based on the watermark quantization step to obtain the corresponding first target parameter.
[0181] The second target parameter determination module 904 is used for the watermark model parameter determination module, which is used to determine the standard quantization step size based on multiple second initial parameters of the initial feature channel, and quantize the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain the corresponding second target parameters.
[0182] The target quantization module 905 is used to obtain the target model after the watermark information is embedded and the model is quantized according to the first target parameter and the second target parameter.
[0183] The watermark embedding method, device, equipment and storage medium based on model quantization proposed in the present application obtain an initial model to be embedded with a watermark, and watermark information for embedding the initial model; determine the channel smoothing coefficient corresponding to each feature channel in any processing layer of the initial model, and determine the feature channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial feature channel, and implement watermark embedding by selecting the feature channel containing smoother parameters, thereby improving the reliability of the embedded watermark and helping to improve the stability of the target model finally obtained; determine the watermark quantization step size based on multiple first initial parameters of the initial feature channel, and embed the watermark information into the multiple first initial parameters based on the watermark quantization step size to obtain the corresponding first target parameter; determine the standard quantization step size based on multiple second initial parameters of the initial feature channel, and quantize the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain the corresponding second target parameter; obtain the target model after the watermark information is embedded and the model is quantized according to the first target parameter and the second target parameter, so that the present application can embed the watermark information without affecting the model quantization accuracy, while ensuring the integrity of the embedded watermark information and thus ensuring its reliability.
[0184] The specific implementation of the watermark embedding device is basically the same as the specific implementation of the watermark embedding method described above, and will not be described in detail here.
[0185] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above watermark embedding method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0186] like Fig.11 As shown, Fig.11 : is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application, the electronic device includes:
[0187] The processor 1001 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0188] The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1002, and the processor 1001 calls and executes the watermark embedding method of the embodiment of this application;
[0189] Input / output interface 1003, used to implement information input and output;
[0190] The communication interface 1004 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WIFI, Bluetooth, etc.);
[0191] A bus 1005 , which transmits information between various components of the device (e.g., the processor 1001 , the memory 1002 , the input / output interface 1003 , and the communication interface 1004 );
[0192] The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .
[0193] The embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the watermark embedding method is implemented.
[0194] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0195] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0196] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0197] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0198] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0199] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0200] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0201] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0202] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0203] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0204] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0205] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A watermark embedding method based on model quantization, characterized in that: The method comprises: Acquire an initial model to be embedded with a watermark, and watermark information used to embed the initial model; Determine the channel smoothing coefficient corresponding to each feature channel in any processing layer of the initial model, and determine the feature channel whose channel smoothing coefficient is less than a preset smoothing threshold as the initial feature channel; Determining a watermark quantization step size based on a plurality of first initial parameters of the initial feature channel, and embedding the watermark information into the plurality of first initial parameters based on the watermark quantization step size to obtain corresponding first target parameters; Determine a standard quantization step size based on a plurality of second initial parameters of the initial feature channel, and perform quantization processing on the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain corresponding second target parameters; According to the first target parameter and the second target parameter, a target model after the watermark information embedding and model quantization is completed is obtained.
2. The method according to claim 1, characterized in that The first initial parameter is determined by the following steps, which include: Using the multiple weight parameters of the initial feature channel as the multiple first initial parameters representing static invariance; or, Sample input data for quantization training of the initial model is obtained, and the product of the sample input data and each of the weight parameters is used as a plurality of the first initial parameters representing dynamic changes.
3. The method according to claim 2, characterized in that After obtaining the target model after the watermark information is embedded and the model is quantized, the method further includes: Obtaining verification watermark parameters and verification quantization parameters corresponding to the sample input data; When the difference between the first target parameter and the verification watermark parameter is less than a preset first threshold, and the difference between the second target parameter and the verification quantization parameter is less than a preset second threshold, it is determined that the quantization accuracy of the target model meets the standard.
4. The method according to claim 1, characterized in that: The determining of the watermark quantization step size based on a plurality of first initial parameters of the initial feature channel comprises: Acquiring quantization range information of the initial model; Determine a first maximum parameter with the largest value and a second maximum parameter with the smallest value from the plurality of first initial parameters of the initial characteristic channel; A first parameter difference between the first maximum parameter and the second maximum parameter is calculated, and the watermark quantization step used to quantize the first initial parameter is obtained according to a ratio of the first parameter difference to the quantization range information.
5. The method according to claim 4, characterized in that The step of embedding the watermark information into a plurality of the first initial parameters based on the watermark quantization step to obtain corresponding first target parameters includes: Dividing the watermark information into a plurality of sub-watermark information, and updating the watermark quantization step size based on the plurality of sub-watermark information to obtain a plurality of updated quantization step sizes; For each of the first initial parameters, calculating a second parameter difference between the first initial parameter and the second maximum parameter, and determining a ratio between the second parameter difference and any of the updated quantization steps as a sub-watermark model parameter obtained after embedding the first initial parameter watermark; Determine that the plurality of sub-watermark model parameters obtained by embedding based on all the updated quantization step sizes are complete first target parameters.
6. The method according to claim 5, characterized in that The updating of the watermark quantization step size based on the plurality of sub-watermark information to obtain a plurality of updated quantization step sizes comprises: Amplifying the watermark quantization step to obtain an amplified quantization step, wherein the amplified quantization step includes a plurality of original quantization information arranged in sequence from high to low bits; Performing information conversion processing on the sub-watermark information to obtain watermark quantization information; Clearing a preset replacement number of the original quantization information at the lower bits of the enlarged quantization step, and replacing the cleared original quantization information with the watermark quantization information to obtain a replacement enlarged quantization step; The replacement enlarged quantization step size is scaled to obtain the updated quantization step size.
7. The method according to claim 6, characterized in that The first target parameter includes a head parameter representing a starting position of the first target parameter and a tail parameter representing an ending position of the first target parameter; After embedding the watermark information into the plurality of first initial parameters based on the watermark quantization step to obtain corresponding first target parameters, the method further includes: Inserting preset start identification information before the header parameter, wherein the start identification information is used to identify the start position of the first target parameter; Preset end identification information is inserted after the tail parameter, and the end identification information is used to identify the end position of the first target parameter.
8. The method according to claim 7, characterized in that After obtaining the target model after the watermark information is embedded and the model is quantized, the method further includes: Extracting encoding information from the multiple model parameters after quantization one by one; When the encoded information identical to the starting identification information is extracted, extracting watermark information from the next model parameter; The extraction of the watermark information is completed when the encoding information identical to the end identification information is extracted.
9. A watermark embedding device based on model quantization, characterized in that: The device comprises: An acquisition module, used for acquiring an initial model to be embedded with a watermark, and watermark information for embedding the initial model; A channel determination module, used to determine a channel smoothing coefficient corresponding to each characteristic channel in any processing layer of the initial model, and determine a characteristic channel whose channel smoothing coefficient is less than a preset smoothing threshold as an initial characteristic channel; A first target parameter determination module, configured to determine a watermark quantization step size based on a plurality of first initial parameters of the initial feature channel, and embed the watermark information into the plurality of first initial parameters based on the watermark quantization step size to obtain a corresponding first target parameter; A second target parameter determination module, used in the watermark model parameter determination module, is used to determine a standard quantization step size based on a plurality of second initial parameters of the initial feature channel, and to quantize the second initial parameters of the remaining feature channels except the initial feature channel based on the standard quantization step size to obtain corresponding second target parameters; The target quantization module is used to obtain the target model after the watermark information is embedded and the model is quantized according to the first target parameter and the second target parameter.
10. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Logarithm quantization-based information hiding method, logarithm quantization-based information extraction method and related device
CN107977921A
Device for embedding electronic watermark information
JP2002304184A
Securing a neural network runtime engine
US20240070266A1