Task processing and training method of model thereof, image processing method and device

By adjusting the loss error and attention weights of the task processing model through a self-attention mechanism, the problem of high computational load and low efficiency caused by the increase of network layers in large models is solved, achieving more efficient task processing model training and better task processing results.

CN117236404BActive Publication Date: 2026-05-19BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING BAIDU NETCOM SCI & TECH CO LTD
Filing Date
2023-09-18
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

When existing task processing models add network layers to extract rich features, the computational load becomes large and the efficiency is low, which affects the accuracy of the model. This is especially true for large models, where it is difficult to improve the overall performance.

Method used

A self-attention mechanism is used to determine the loss error and attention weight of the target task sub-model and the auxiliary task sub-model respectively. The model parameters are adjusted by global loss to achieve adaptive training of the target task sub-model and the auxiliary task sub-model.

Benefits of technology

It improves the flexibility and robustness of model training, enhances the overall performance of task processing models, especially in tasks such as image shadow removal and voiceprint recognition, and improves the accuracy and ability to adapt to complex scenes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117236404B_ABST
    Figure CN117236404B_ABST
Patent Text Reader

Abstract

The present disclosure provides a task processing method and a model training method thereof, an image processing method and device, an electronic device, a storage medium and a computer program product, relates to the technical field of data processing, and in particular to the field of data processing based on a large model of artificial intelligence. The specific implementation scheme is as follows: a self-attention mechanism is used to determine a first attention weight of a first loss error of a target task submodel and a second attention weight of a second loss error of an auxiliary task submodel; a global loss of the task processing model is calculated according to the first loss error, the second loss error, the first attention weight and the second attention weight; and model parameters of the task processing model are adjusted according to the global loss.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of data processing technology, and more particularly to the field of data processing based on artificial intelligence. Background Technology

[0002] With the development of artificial intelligence (AI) technology, task processing models based on AI algorithms have been widely developed. Currently, to improve the accuracy of task processing models, the common approach is to increase the number of network layers to extract richer features. However, this approach leads to a large computational load and the extraction of many redundant features. Especially for large models with already large network architectures, adding more network layers results in lower efficiency in feature extraction, which is detrimental to improving the overall accuracy and performance of the task processing model. Summary of the Invention

[0003] This disclosure provides a method for task processing and training models, an image processing method and apparatus, an electronic device, a storage medium, and a computer program product.

[0004] According to a first aspect of this disclosure, a method for training a task processing model is provided, the task processing model including a target task sub-model and an auxiliary task sub-model; the training method includes:

[0005] A self-attention mechanism is used to determine the first attention weight of the first loss error of the target task sub-model and the second attention weight of the second loss error of the auxiliary task sub-model.

[0006] The global loss of the task processing model is calculated based on the first loss error, the second loss error, the first attention weight, and the second attention weight.

[0007] The model parameters of the task processing model are adjusted based on the global loss.

[0008] According to a second aspect of this disclosure, a task processing method is provided, comprising:

[0009] Obtain the data to be processed for the target task;

[0010] The data to be processed is input into the task processing model to obtain the task processing result corresponding to the target task; wherein the task processing model is obtained according to the training method of the task processing model described in the first aspect.

[0011] According to a third aspect of this disclosure, an image processing method is provided, comprising:

[0012] Obtain the document image to be processed;

[0013] The document image is input into the shadow removal model to obtain a shadow-removed document image. The shadow removal model is trained on the shadow removal sub-model and the auxiliary task sub-model using a global loss. The global loss is calculated based on the first loss error of the shadow removal sub-model, the second loss error of the auxiliary task sub-model, the first attention weight of the first loss error, and the second attention weight of the second loss error. The first attention weight and the second attention weight are obtained using a self-attention mechanism and based on the target task prediction data output by the shadow removal sub-model and the auxiliary task prediction data output by the auxiliary task sub-model.

[0014] According to a fourth aspect of this disclosure, a training apparatus for a task processing model is provided, the task processing model including a target task sub-model and an auxiliary task sub-model; the training apparatus includes:

[0015] The weight calculation module is used to determine the first attention weight of the first loss error of the target task sub-model and the second attention weight of the second loss error of the auxiliary task sub-model using a self-attention mechanism.

[0016] The loss calculation module is used to calculate the global loss of the task processing model based on the first loss error, the second loss error, the first attention weight, and the second attention weight.

[0017] An adjustment module is used to adjust the model parameters of the task processing model based on the global loss.

[0018] According to a fifth aspect of this disclosure, a task processing apparatus is provided, comprising:

[0019] The data acquisition module is used to acquire the data to be processed for the target task;

[0020] The data input module is used to input the data to be processed into the task processing model to obtain the task processing result corresponding to the target task; wherein the task processing model is obtained according to the training method of the task processing model described in the first aspect.

[0021] According to a sixth aspect of this disclosure, an image processing apparatus is provided, comprising:

[0022] The image acquisition module is used to acquire images of the document to be processed.

[0023] An image input module is used to input the document image into a shadow removal model to obtain a shadow-removed document image. The shadow removal model is trained using a global loss on a shadow removal sub-model and an auxiliary task sub-model. The global loss is calculated based on a first loss error of the shadow removal sub-model, a second loss error of the auxiliary task sub-model, a first attention weight for the first loss error, and a second attention weight for the second loss error. The first and second attention weights are obtained using a self-attention mechanism based on the target task prediction data output by the shadow removal sub-model and the auxiliary task prediction data output by the auxiliary task sub-model.

[0024] According to a seventh aspect of this disclosure, an electronic device is provided, comprising:

[0025] At least one processor; and

[0026] A memory communicatively connected to the at least one processor; wherein,

[0027] The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method described in the first aspect or the second aspect.

[0028] According to an eighth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method according to the first or second aspect.

[0029] According to a ninth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method according to the first or second aspect.

[0030] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0031] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:

[0032] Figure 1 This is a flowchart of a training method for a task processing model provided according to an exemplary embodiment of the present disclosure;

[0033] Figure 2a This is a flowchart of a training method for another task processing model provided according to an exemplary embodiment of the present disclosure;

[0034] Figure 2b yes Figure 2a The detailed flowchart of step 104;

[0035] Figure 3 This is a flowchart of a task processing method provided according to an exemplary embodiment of the present disclosure;

[0036] Figure 4 This is a flowchart of an image processing method provided according to an exemplary embodiment of the present disclosure;

[0037] Figure 5a This is a schematic diagram of a training apparatus for a task processing model provided according to an exemplary embodiment of the present disclosure;

[0038] Figure 5b This is a schematic diagram of a training apparatus for another task processing model provided according to an exemplary embodiment of the present disclosure;

[0039] Figure 6 This is a schematic diagram of a task processing apparatus provided according to an exemplary embodiment of the present disclosure;

[0040] Figure 7 This is a schematic diagram of a module of an image processing apparatus provided according to an exemplary embodiment of the present disclosure;

[0041] Figure 8 This is a block diagram of an electronic device provided according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0042] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0043] This disclosure provides a method for training a task processing model, which includes a target task sub-model and an auxiliary task sub-model. The target task sub-model is used to achieve a target task, and the auxiliary task sub-model can optimize the result of the target task. See also Figure 1 The training method includes the following steps:

[0044] Step 101: Use a self-attention mechanism to determine the first attention weight of the first loss error of the target task sub-model and the second attention weight of the second loss error of the auxiliary task sub-model.

[0045] During model training, a self-attention mechanism is employed to recalculate the first attention weights for the first loss error and the second attention weights for the second loss error in each iteration or at intervals of n iterations. This allows the target task sub-model and the auxiliary task sub-model to adaptively adjust their attention to sample pairs during training. Here, n is a positive integer greater than 1, and can be set according to actual conditions; n can be a fixed value or a dynamic value.

[0046] Since the target task sub-model and the auxiliary task sub-model are trained simultaneously, they are interconnected, and their training results can influence each other. For example, if the input to the target task sub-model includes auxiliary task prediction data output by the auxiliary task sub-model, inputting auxiliary task prediction data from an untrained auxiliary task sub-model into the target task sub-model will affect its training results, causing it to fail to converge or perform poorly. Therefore, during model training, it is necessary to adjust the first attention weights for the first loss error and the second attention weights for the second loss error in real time to improve the model training effect.

[0047] Understandably, if the number of first loss errors is at least two, the first attention weight for each first loss error is determined, and the number of first loss errors matches the number of first attention weights; if the number of second loss errors is at least two, the second attention weight for each second loss error is determined, and the number of second loss errors matches the number of second attention weights.

[0048] It should be noted that the calculation steps for loss error and attention weights are not limited to... Figure 1 The example shown calculates the loss error first, and then the attention weight; in other implementations, the loss error and attention weight can be calculated simultaneously; or the attention weight can be calculated first, and then the loss error can be calculated. This embodiment does not impose any particular limitation on this.

[0049] Step 102: Calculate the global loss of the task processing model based on the first loss error, the second loss error, the first attention weight, and the second attention weight.

[0050] In step 102, the weighted result of the first loss error and the second loss error is determined as the global loss.

[0051] Step 103: Adjust the model parameters of the task processing model based on the global loss.

[0052] Step 103 involves adjusting the model parameters of the target task sub-model and the auxiliary task sub-model based on the global loss.

[0053] The task processing model is trained iteratively until the iteration stopping condition is met. Once trained, the task processing model can be used to complete the target task.

[0054] The stopping condition for iteration may include, but is not limited to, at least one of the following: convergence of global loss, reaching a threshold number of iterations, etc.

[0055] In this embodiment, the target task sub-model and the auxiliary task sub-model are trained simultaneously based on global loss. The training process comprehensively considers information from both sub-models, providing more comprehensive guidance and improving overall model performance. By introducing a self-attention mechanism, the attention weights of the target and auxiliary task sub-models are dynamically adjusted. This allows for adaptive adjustment of the attention levels and loss contributions of the target and auxiliary task sub-models to sample pairs during training, making model training more flexible and robust.

[0056] Figure 2a A flowchart of another training method for a task processing model provided as an exemplary embodiment of this disclosure, the training method comprising the following steps:

[0057] Step 201: Obtain sample pairs.

[0058] The sample pair includes sample data and labeled data of the sample data; the labeled data includes target task labeled data that matches the target task corresponding to the target task sub-model and auxiliary task labeled data that matches the auxiliary task corresponding to the auxiliary task sub-model.

[0059] The task processing model of this disclosure can be applied to various scenarios. The architecture of the task processing model can be built according to the application scenario of the task processing model. The number of target task sub-models included in the task processing model can be one or more. Similarly, the number of auxiliary task sub-models can be one or more. This disclosure does not impose any special limitations on this.

[0060] The sample data required for model training, the target task labeled data and the target task sub-model are related to the target task, and the auxiliary task labeled data are related to the auxiliary task.

[0061] For example, if the target task is image shadow removal, the sample data includes the original image, and the target task labeled data includes the image after shadow removal processing of the original image; or the sample data includes the image with shadows superimposed, and the target task labeled data includes the image before shadows are superimposed; the auxiliary task may include, but is not limited to, at least one of the following: image enhancement task of the original image, image enhancement task of the image after shadow removal processing, edge processing task of the original image, edge processing task of the image after shadow removal processing, denoising task of the original image, and denoising task of the image after shadow removal processing. Correspondingly, the auxiliary task labeled data includes at least one of the following: image obtained by image enhancement processing of the original image, image obtained by image enhancement processing of the image after shadow removal processing, image obtained by edge processing of the original image, image obtained by edge processing of the image after shadow removal processing, image obtained by denoising processing of the original image, and image obtained by denoising processing of the image after shadow removal processing.

[0062] If the target task is an object recognition task, the sample data includes the original image, and the target task annotation data includes the object recognition results of the original image; the auxiliary task may include, but is not limited to, at least one of the following: image enhancement task of the original image, edge processing task of the original image, and denoising task of the original image. Correspondingly, the auxiliary task annotation data includes at least one of the following: the image obtained by image enhancement processing of the original image, the image obtained by edge processing of the original image, and the image obtained by denoising processing of the original image.

[0063] If the target task is a voiceprint recognition task, the sample data includes the original audio, and the target task annotation data includes the voiceprint recognition results of the original audio; the auxiliary task may include, but is not limited to, at least one of the following: a denoising task of the original audio, a segmentation task of the original audio, and correspondingly, the auxiliary task annotation data includes at least one of the following: audio obtained by denoising the original audio, and audio obtained by segmenting the original audio.

[0064] Step 202: Input the sample data into the task processing model to obtain the target task prediction data output by the target task sub-model and the auxiliary task prediction data output by the auxiliary task sub-model.

[0065] The input parameters of the target task sub-model and the auxiliary task sub-model are related to the network architecture of the task processing model. If the input of the target task sub-model is connected to the auxiliary task sub-model, the input parameters of the auxiliary task sub-model include sample data, and the input parameters of the target task sub-model include the output of the auxiliary task sub-model. Similarly, if the output of the target task sub-model is connected to the auxiliary task sub-model, the input parameters of the target task sub-model include sample data, and the input parameters of the auxiliary task sub-model include the output of the target task sub-model. If the input of the target task sub-model is connected to auxiliary task sub-model a, and its output is connected to auxiliary task sub-model b, the input parameters of auxiliary task sub-model a include sample data, the input parameters of the target task sub-model include the output of auxiliary task sub-model a, and the input of auxiliary task sub-model b includes the output of the target task sub-model.

[0066] It should be noted that the input of a target task sub-model can be connected to other target task sub-models, and the input of an auxiliary task sub-model can be connected to other auxiliary task sub-models. The network architecture of the task processing model can be set according to the actual situation.

[0067] Step 203: Determine the first loss error between the target task predicted data and the target task labeled data based on the first loss function of the target task sub-model, and determine the second loss error between the auxiliary task predicted data and the auxiliary task labeled data based on the second loss function of the auxiliary task sub-model.

[0068] In one embodiment, the target task prediction data and target task labeled data are substituted into the first loss function to calculate the first loss error. Similarly, the auxiliary task prediction data and auxiliary task labeled data are substituted into the first loss function to calculate the first loss error.

[0069] In one embodiment, the product of the target task prediction data and the first attention weight, along with the target task labeled data, is substituted into the first loss function to calculate the first loss error. Similarly, the product of the auxiliary task prediction data and the second attention weight, along with the auxiliary task labeled data, is substituted into the second loss function to calculate the second loss error. This further enables the target task sub-model and auxiliary task sub-model to adaptively adjust their attention to sample pairs during model training, as well as the adaptive adjustment of the contributions of the target task sub-model and auxiliary task sub-model to their losses, thereby further improving the flexibility and robustness of model training.

[0070] The first loss function is the one that matches the target task of the target task sub-model, and the second loss function is the one that matches the auxiliary task of the auxiliary task sub-model. The calculation process for the loss error is detailed in the relevant technical descriptions and will not be repeated here. Selecting different loss functions for the characteristics of different task sub-models allows for full utilization of the capabilities of each sub-model.

[0071] Understandably, if the task processing model contains at least two target task sub-models, the first loss error corresponding to each target task sub-model needs to be determined separately, and the number of first loss errors matches the number of target task sub-models; if the task processing model contains at least two auxiliary task sub-models, the second loss error corresponding to each auxiliary task sub-model needs to be determined separately, and the number of second loss errors matches the number of auxiliary task sub-models.

[0072] Step 204: Using a self-attention mechanism and based on the target task prediction data and the auxiliary task prediction data, determine the first attention weight of the first loss error and the second attention weight of the second loss error.

[0073] During model training, a self-attention mechanism is employed to recalculate the first attention weights for the first loss error and the second attention weights for the second loss error in each iteration or at intervals of n iterations. This allows the target task sub-model and the auxiliary task sub-model to adaptively adjust their attention to sample pairs during training. Here, n is a positive integer greater than 1, and can be set according to actual conditions; n can be a fixed value or a dynamic value.

[0074] Since the target task sub-model and the auxiliary task sub-model are trained simultaneously, they are interconnected, and their training results can influence each other. For example, if the input to the target task sub-model includes auxiliary task prediction data output by the auxiliary task sub-model, inputting auxiliary task prediction data from an untrained auxiliary task sub-model into the target task sub-model will affect its training results, causing it to fail to converge or perform poorly. Therefore, during model training, it is necessary to adjust the first attention weights for the first loss error and the second attention weights for the second loss error in real time to improve the model training effect.

[0075] Understandably, if the number of first loss errors is at least two, the first attention weight for each first loss error is determined, and the number of first loss errors matches the number of first attention weights; if the number of second loss errors is at least two, the second attention weight for each second loss error is determined, and the number of second loss errors matches the number of second attention weights.

[0076] It should be noted that the calculation steps for loss error and attention weights are not limited to... Figure 1 The example shown calculates the loss error first, and then the attention weight; in other implementations, the loss error and attention weight can be calculated simultaneously; or the attention weight can be calculated first, and then the loss error can be calculated. This embodiment does not impose any particular limitation on this.

[0077] Step 205: Calculate the global loss of the task processing model based on the first loss error, the second loss error, the first attention weight, and the second attention weight.

[0078] In step 205, the weighted result of the first loss error and the second loss error is determined as the global loss.

[0079] Step 206: Adjust the model parameters of the task processing model based on the global loss.

[0080] Step 206 involves adjusting the model parameters of the target task sub-model and the auxiliary task sub-model based on the global loss.

[0081] The task processing model is trained iteratively until the iteration stopping condition is met. Once trained, the task processing model can be used to complete the target task.

[0082] The stopping condition for iteration may include, but is not limited to, at least one of the following: convergence of global loss, reaching a threshold number of iterations, etc.

[0083] In this embodiment, the target task sub-model and the auxiliary task sub-model are trained simultaneously based on global loss. The training process comprehensively considers information from both sub-models, providing more comprehensive guidance and improving overall model performance. By introducing a self-attention mechanism, the attention weights of the target and auxiliary task sub-models are dynamically adjusted. This allows for adaptive adjustment of the attention levels and loss contributions of the target and auxiliary task sub-models to sample pairs during training, making model training more flexible and robust.

[0084] In one embodiment, see Figure 2b Step 204 specifically includes:

[0085] Step 204-1: Use a self-attention mechanism to calculate the query matrix, key matrix, and value matrix corresponding to the target task prediction data and the auxiliary task prediction data, respectively.

[0086] For details on the calculation methods of the query matrix, key matrix, and value matrix, please refer to the relevant technical descriptions, which will not be repeated here. The value matrix is ​​the matrix representation of the target task prediction data.

[0087] Step 204-2: Calculate the attention score matrix based on the query matrix and the key matrix.

[0088] The formula for calculating the score matrix can be expressed as follows:

[0089] S=QK^T / √d.

[0090] Where S represents the score matrix; Q represents the query matrix; K represents the key matrix; ^T represents the transpose; √d is a constant for scaling the score; and d is the dimension of the query or key.

[0091] Step 204-3: Calculate the first attention weight and the second attention weight based on the attention score matrix and the value matrix.

[0092] In one embodiment, the score matrix S is softmax normalized to obtain the attention weight matrix A: A = softmax(S). The matrix representation Y1 of the first attention weight is obtained by weighted summation of the attention weight A and the value matrix V1 corresponding to the target task prediction data: Y = AV1. The matrix representation Y2 of the second attention weight is obtained by weighted summation of the attention weight A and the value matrix V2 corresponding to the auxiliary task prediction data: Y = AV2.

[0093] In this embodiment, efficient calculation of the first attention weight and the second attention weight is achieved. The computational complexity of the self-attention mechanism is relatively low, and because attention weights are used, only the necessary parts can be weighted and summed, reducing the amount of computation.

[0094] In one embodiment, a first attention weight and a second attention weight are calculated using a self-attention mechanism model. Specifically, step 204 includes: inputting the target task prediction data and the auxiliary task prediction data into the self-attention mechanism model, so that the self-attention mechanism model outputs the first attention weight and the second attention weight.

[0095] Self-attention mechanism models can be pre-trained or trained independently; this is not disclosed and is not specifically limited.

[0096] When the task processing model includes a target task sub-model and an auxiliary task sub-model, the target task prediction data output by the target task sub-model and the auxiliary task prediction data output by the auxiliary task sub-model are input together into the self-attention mechanism model so that the self-attention mechanism model outputs the first attention weight and the second attention weight.

[0097] When the task processing model includes a target task sub-model and two auxiliary task sub-models (auxiliary task sub-model a and auxiliary task sub-model b), the target task prediction data output by the target task sub-model and the auxiliary task prediction data A output by auxiliary task sub-model a and the auxiliary task prediction data B output by auxiliary task sub-model b are input together into the self-attention mechanism model so that the self-attention mechanism model outputs the first attention weight and the second attention weight.

[0098] In this embodiment of the disclosure, the first attention weight and the second attention weight are accurately and effectively calculated based on the self-attention mechanism model.

[0099] In one embodiment, the sum of the first product, the second product, and the third product is determined as the global loss; wherein the first product is the product of the first loss error of the image enhancement sub-model and the first attention weight of the first loss error of the image enhancement sub-model, the second product is the product of the second loss error and the second attention weight, and the third product is the product of the first loss error of the edge processing sub-model and the first attention weight of the first loss error of the edge processing sub-model.

[0100] In this embodiment of the disclosure, the global loss calculation comprehensively considers the information of the target task sub-model and the auxiliary task sub-model, and integrates a self-attention mechanism. It can dynamically adjust the attention weights of each task sub-model according to the different features of the input of the task processing model and the input and output of each task sub-model, thereby improving the flexibility and robustness of model training.

[0101] In one embodiment, the formula for calculating the global loss may be, but is not limited to, expressed as follows:

[0102] GMALoss=∑ i (a i *w i *L i );

[0103] Among them, a i The attention weights of the i-th sub-model within the task processing model are represented by w, which are obtained based on a self-attention mechanism. i L represents the loss weight of the i-th sub-model, which is user-defined; i Let represent the loss function of the i-th sub-model.

[0104] In this embodiment of the disclosure, w is added to the formula for calculating the global loss. i It can flexibly weight different parts of the sub-model according to the importance and priority of the target task, thereby allowing for personalized loss weight settings to meet the specific needs of the target task and further improve model performance.

[0105] The task processing model of this disclosure can be applied to various fields. For example, when the task processing model is applied to the field of image shadow removal, the target task of the task processing model is the image shadow removal task, the target task sub-model is the image segmentation sub-model, and the auxiliary task sub-model may include, but is not limited to, the image enhancement sub-model and / or the target task labeled data includes the image segmentation results.

[0106] In the field of image segmentation, the target task of the task processing model is image segmentation, the target task sub-model is image segmentation sub-model, and the auxiliary task sub-model may include, but is not limited to, image enhancement sub-model and / or target task labeled data including image segmentation results.

[0107] The following section uses the image shadow removal task as an example to further explain the training process of the task processing model.

[0108] In one embodiment, the sample data includes document image samples; the target task sub-model includes a shadow removal sub-model, and the auxiliary task sub-model includes an image enhancement sub-model.

[0109] During model training, document image samples are input into the image enhancement sub-model, which performs image enhancement processing on the document image samples and outputs an enhanced prediction image. The enhanced prediction image is then input into the shadow removal sub-model, which performs shadow removal processing on the enhanced prediction image to obtain a shadow removal prediction image.

[0110] The target task prediction data includes shaded prediction images, while the auxiliary task prediction data includes augmented prediction images. The target task annotation data includes shaded annotation images, while the auxiliary task annotation data includes augmented annotation images.

[0111] The first loss error is the loss error between the deshaded predicted image and the deshaded labeled image calculated based on the first loss function, and the second loss error is the loss error between the enhanced predicted image and the enhanced labeled image calculated based on the second loss function.

[0112] The sum of the first and second products is determined as the global loss. The model parameters of the shadow removal sub-model and the image enhancement sub-model are then adjusted based on this global loss until the iteration stops. The trained task processing model can then be used to remove shadows from document images. Here, the first product is the product of the first loss error and the first attention weight, and the second product is the product of the second loss error and the second attention weight.

[0113] In this embodiment, the training process comprehensively considers information from both the shadow removal sub-model and the image enhancement sub-model. This provides a more comprehensive guide to model training and improves the overall performance of the image shadow removal task model. By introducing a self-attention mechanism, the attention weights of the shadow removal sub-model and the image enhancement sub-model are dynamically adjusted, making the shadow removal task model training more flexible and robust. The trained shadow removal task model uses the output of the image enhancement sub-model as its input to perform document shadow removal. The enhancement provided by the image enhancement sub-model allows the shadow removal task model to better preserve image details without loss of content.

[0114] In one embodiment, the sample data includes document image samples; the target task sub-model includes a shadow removal sub-model, and the auxiliary task sub-model includes an edge processing sub-model.

[0115] During model training, document image samples are input into the deshading sub-model, which performs deshading processing on the document image samples to obtain a deshading prediction image; the deshading prediction image is input into the edge processing sub-model, which performs edge processing on the deshading prediction image to obtain an edge-processed deshading image (edge-processed prediction image).

[0116] The target task prediction data includes shaded prediction images, while the auxiliary task prediction data includes edge-processed prediction images. The target task annotation data includes shaded annotation images, and the auxiliary task annotation data includes edge-processed annotation images.

[0117] The first loss error is the loss error between the shadow-removed predicted image and the shadow-removed labeled image calculated based on the first loss function. The second loss error is the loss error between the edge-processing predicted image and the edge-processing labeled image calculated based on the second loss function.

[0118] The sum of the first and second products is determined as the global loss pair. The model parameters of the shadow removal sub-model and the edge processing sub-model are adjusted based on this global loss until the iteration stops. The trained task processing model can then be used to remove shadows from document images. Here, the first product is the product of the first loss error and the first attention weight, and the second product is the product of the second loss error and the second attention weight.

[0119] In this embodiment, the model training process comprehensively considers information from both the shadow removal sub-model and the edge processing sub-model. This provides a more comprehensive guide to model training and improves the overall performance of the image shadow removal task model. By introducing a self-attention mechanism, the attention weights of the shadow removal sub-model and the edge processing sub-model are dynamically adjusted, making model training more flexible and robust. The trained shadow removal task model uses the output of the shadow removal sub-model as the input of the edge processing sub-model to perform document shadow removal, effectively removing edge clutter from text in the image for better shadow removal results.

[0120] In one embodiment, the sample data includes document image samples; the target task sub-model includes a shadow removal sub-model, and the auxiliary task sub-model includes an image enhancement sub-model and an edge processing sub-model. The image enhancement sub-model may, but is not limited to, use NAFNet, the shadow removal sub-model may, but is not limited to, use NAFNet, and the edge processing sub-model may, but is not limited to, use the deep learning semantic segmentation model UNET.

[0121] During model training, document image samples are input into the image enhancement sub-model, which performs image enhancement processing on the document image samples and outputs an enhanced prediction image; the enhanced prediction image is input into the shadow removal sub-model, which performs shadow removal processing on the document image samples to obtain a shadow removal prediction image; the shadow removal prediction image is input into the edge processing sub-model, which performs edge processing on the shadow removal prediction image to obtain a shadow removal image after edge processing.

[0122] The target task prediction data includes deshading prediction images, while the auxiliary task prediction data includes enhancement prediction images and edge processing prediction images.

[0123] The first loss error is the loss error between the deshaded predicted image and the deshaded labeled image calculated based on the first loss function. The second loss error includes the loss error a between the enhanced predicted image and the enhanced labeled image calculated based on the second loss function of the image enhancement sub-model, and the loss error b between the edge-processed deshaded image (edge-processed predicted image) and the edge-processed labeled image calculated based on the second loss function of the edge-processing sub-model.

[0124] The first attention weight of the first loss error, the second attention weight a of the loss error a, and the second attention weight b of the loss error b are obtained by using a self-attention mechanism.

[0125] The sum of the first, second, and third products is determined as the global loss. The model parameters of the image enhancement sub-model, the shadow removal sub-model, and the edge processing sub-model are adjusted based on this global loss until the iteration stops. The trained task processing model can then be used to remove shadows from document images. Specifically, the first product is the product of the first loss error and the first attention weight; the second product is the product of the loss error *a* and the second attention weight *a*; and the third product is the product of the loss error *b* and the second attention weight *b*.

[0126] In this embodiment, the trained shadow removal task model uses the output of the image enhancement sub-model as its input, and the output of the shadow removal sub-model as its input to the edge processing sub-model, to perform document shadow removal. The image enhancement sub-model enhances the shadow removal task model, allowing it to better preserve image details without content loss. The edge processing sub-model effectively removes edge clutter from text in the image, achieving high-quality shadow removal and obtaining a better shadow removal effect. Furthermore, this embodiment follows the order of image enhancement and deblurring before shadow removal to avoid significant degradation of the shadow removal effect due to image enhancement and deblurring.

[0127] Figure 3A flowchart of a task processing method provided for an exemplary embodiment of this disclosure, the task processing method including the following steps:

[0128] Step 301: Obtain the data to be processed for the target task.

[0129] When the target task is image shadow removal, the data to be processed can be an image containing shadows; when the target task is voiceprint recognition, the data to be processed can be audio.

[0130] Step 302: Input the data to be processed into the task processing model to obtain the task processing result corresponding to the target task.

[0131] Understandably, the result of the target task corresponds to the target task. When the target task is image deshading, the result is the image after deshading; when the target task is voiceprint recognition, the result is the voiceprint recognition result.

[0132] The task processing model is obtained according to the training method of the task processing model provided in any of the above embodiments.

[0133] In this embodiment of the disclosure, the trained task processing model has better robustness and higher accuracy. Using this task processing model for task processing results in higher accuracy.

[0134] This disclosure also provides an image processing method for removing shadows from document images, see [link to relevant documentation]. Figure 4 The image processing method includes the following steps:

[0135] Step 401: Obtain the document image to be processed.

[0136] The document image can be obtained by taking a photo or scanning the document.

[0137] Step 402: Input the document image into the shadow removal model to obtain the document image after shadow removal processing.

[0138] The shadow removal sub-model is trained using a global loss to train the shadow removal sub-model and the auxiliary task sub-model. The global loss is calculated based on the first loss error of the shadow removal sub-model, the second loss error of the auxiliary task sub-model, the first attention weight of the first loss error, and the second attention weight of the second loss error. The first attention weight and the second attention weight are obtained using a self-attention mechanism and based on the target task prediction data output by the shadow removal sub-model and the auxiliary task prediction data output by the auxiliary task sub-model.

[0139] The training process for the shadow removal model is described in the training method of the task processing model provided in any of the above embodiments, and will not be repeated here.

[0140] Due to uneven lighting or object occlusion, shadows exist in the obtained document images. These shadows may affect the readability, quality, and subsequent text recognition processing of the document. In this embodiment, a shadow removal model is used to effectively remove shadows from document images. Furthermore, it is applicable to document images in various complex scenarios, such as multiple light sources, non-uniform shadows, and curved document surfaces.

[0141] In one embodiment, the auxiliary task sub-model includes an edge processing sub-model; inputting the document image into the shadow removal sub-model to obtain a shadow-removed document image includes:

[0142] The document image is input into the image enhancement sub-model, which then performs image enhancement processing on the document image and outputs an enhanced image.

[0143] The enhanced image is input into the deshading sub-model, which then performs deshading processing on the enhanced image to obtain the deshaded document image.

[0144] In one embodiment, the auxiliary task sub-model includes an edge processing sub-model; inputting the document image into the shadow removal sub-model to obtain a shadow-removed document image includes:

[0145] The document image is input into the shadow removal sub-model so that the shadow removal sub-model can perform shadow removal processing on the document image;

[0146] The output of the shadow sub-model is input into the edge processing sub-model to obtain a document image that has undergone shadow removal and edge processing.

[0147] In one embodiment, the auxiliary task sub-model includes an image enhancement sub-model and an edge processing sub-model; inputting the document image into the shadow removal sub-model to obtain a shadow-removed document image includes:

[0148] The document image is input into the image enhancement sub-model, which then performs image enhancement processing on the document image and outputs an enhanced image.

[0149] The enhanced image is input into the deshading sub-model so that the enhanced image can be deshaded by the deshading sub-model;

[0150] The output of the shadow sub-model is input into the edge processing sub-model to obtain a document image that has undergone shadow removal and edge processing.

[0151] This disclosure proposes a three-stage shadow removal model to overcome the shortcomings of adaptability to complex scenes and preservation of image details; it also proposes a method for generating high-quality data to overcome the problem of insufficient labeled data.

[0152] In one embodiment, the output of the shadow sub-model is input into the edge processing sub-model, including:

[0153] The output results are registered based on the document images to obtain the registered images.

[0154] The registered image is input into the edge processing sub-model.

[0155] In one embodiment, the registered image is further subjected to super-resolution processing, small threshold adjustment, etc., to further improve the image quality.

[0156] Corresponding to the aforementioned embodiments of the training method, task processing method, and image processing method for the task processing model, this disclosure also provides embodiments of the training device, task processing device, and image processing device for the task processing model.

[0157] This disclosure also provides a training apparatus for a task processing model, the task processing model including a target task sub-model and an auxiliary task sub-model; see also Figure 5a The training device includes:

[0158] The weight calculation module 51 is used to determine the first attention weight of the first loss error of the target task sub-model and the second attention weight of the second loss error of the auxiliary task sub-model using a self-attention mechanism.

[0159] The loss calculation module 52 is used to calculate the global loss of the task processing model based on the first loss error, the second loss error, the first attention weight, and the second attention weight.

[0160] The adjustment module 53 is used to adjust the model parameters of the task processing model according to the global loss.

[0161] Figure 5b This is a schematic diagram of a training apparatus for another task processing model provided according to an exemplary embodiment of the present disclosure, the training apparatus comprising:

[0162] The sample acquisition module 54 is used to acquire sample pairs, wherein the sample pairs include sample data and labeled data of the sample data; the labeled data includes target task labeled data that matches the target task corresponding to the target task sub-model and auxiliary task labeled data that matches the auxiliary task corresponding to the auxiliary task sub-model.

[0163] The sample input module 55 is used to input the sample data into the task processing model to obtain the target task prediction data output by the target task sub-model and the auxiliary task prediction data output by the auxiliary task sub-model.

[0164] The loss calculation module 52 is used to determine the first loss error between the target task prediction data and the target task labeled data according to the first loss function of the target task sub-model, and to determine the second loss error between the auxiliary task prediction data and the auxiliary task labeled data according to the second loss function of the auxiliary task sub-model.

[0165] The weight calculation module 51 is further configured to use a self-attention mechanism and, based on the target task prediction data and the auxiliary task prediction data, determine the first attention weight of the first loss error and the second attention weight of the second loss error.

[0166] The loss calculation module 52 is also used to calculate the global loss of the task processing model based on the first loss error, the second loss error, the first attention weight, and the second attention weight.

[0167] The adjustment module 53 is used to adjust the model parameters of the task processing model according to the global loss.

[0168] Optionally, the weight calculation module is specifically used for:

[0169] A self-attention mechanism is used to calculate the query matrix, key matrix, and value matrix corresponding to the target task prediction data and the auxiliary task prediction data;

[0170] Calculate the attention score matrix based on the query matrix and the key matrix;

[0171] The first attention weight and the second attention weight are calculated based on the attention score matrix and the value matrix.

[0172] Optionally, the weight calculation module is specifically used for:

[0173] The target task prediction data and the auxiliary task prediction data are input into the self-attention mechanism model, so that the self-attention mechanism model outputs the first attention weight and the second attention weight.

[0174] Optionally, the sample data includes document image samples; the target task sub-model includes a shadow removal sub-model, and the auxiliary task sub-model includes an image enhancement sub-model;

[0175] The sample input module is specifically used for:

[0176] The document image sample is input into the image enhancement sub-model so that the image enhancement sub-model can perform image enhancement processing on the document image sample and output an enhanced prediction image;

[0177] The enhanced prediction image is input into the deshading sub-model so that the deshading sub-model can perform deshading processing on the enhanced prediction image to obtain the deshading prediction image;

[0178] The target task prediction data includes the deshading prediction image, and the auxiliary task prediction data includes the enhanced prediction image.

[0179] Optionally, the sample data includes document image samples; the target task sub-model includes a shadow removal sub-model, and the auxiliary task sub-model includes an edge processing sub-model;

[0180] The sample input module is specifically used for:

[0181] The document image sample is input into the shadow removal sub-model so that the shadow removal sub-model can perform shadow removal processing on the document image sample to obtain a shadow removal prediction image;

[0182] The deshading prediction image is input into the edge processing sub-model so that the edge processing sub-model performs edge processing on the deshading prediction image to obtain the edge processing prediction image;

[0183] The target task prediction data includes the deshading prediction image, and the auxiliary task prediction data includes the edge processing prediction image.

[0184] Optionally, the sample data includes document image samples; the target task sub-model includes a shadow removal sub-model, and the auxiliary task sub-model includes an image enhancement sub-model and an edge processing sub-model;

[0185] The sample input module is specifically used for:

[0186] The document image sample is input into the image enhancement sub-model so that the image enhancement sub-model can perform image enhancement processing on the document image sample and output an enhanced prediction image;

[0187] The enhanced prediction image is input into the shadow removal sub-model so that the shadow removal sub-model can perform shadow removal processing on the document image sample to obtain the shadow removal prediction image;

[0188] The shadow removal prediction image is input into the edge processing sub-model, so that the edge processing sub-model performs edge processing on the shadow removal prediction image to obtain a shadow removal image after edge processing;

[0189] The target task prediction data includes the deshading prediction image, and the auxiliary task prediction data includes the enhancement prediction image and the edge processing prediction image.

[0190] Optionally, when calculating the global loss of the task processing model, the loss calculation module is specifically used for:

[0191] The sum of the first product, the second product, and the third product is determined as the global loss; wherein, the first product is the product of the first loss error of the image enhancement sub-model and the first attention weight of the first loss error of the image enhancement sub-model, the second product is the product of the second loss error and the second attention weight, and the third product is the product of the first loss error of the edge processing sub-model and the first attention weight of the first loss error of the edge processing sub-model.

[0192] This disclosure also provides a task processing apparatus, see [link to relevant documentation] Figure 6 The task processing device includes:

[0193] The data acquisition module 61 is used to acquire the data to be processed for the target task;

[0194] The data input module 62 is used to input the data to be processed into the task processing model to obtain the task processing result corresponding to the target task; wherein, the task processing model is obtained according to the training method of the task processing model provided in any of the above embodiments.

[0195] This disclosure also provides an image processing apparatus, see [link to relevant documentation] Figure 7 The image processing apparatus includes:

[0196] Image acquisition module 71 is used to acquire the document image to be processed;

[0197] Image input module 72 is used to input the document image into the shadow removal model to obtain the document image after shadow removal processing; wherein, the shadow removal model is trained on the shadow removal sub-model and the auxiliary task sub-model using a global loss; the global loss is calculated based on the first loss error of the shadow removal sub-model, the second loss error of the auxiliary task sub-model, the first attention weight of the first loss error, and the second attention weight of the second loss error; the first attention weight and the second attention weight are obtained using a self-attention mechanism and based on the target task prediction data output by the shadow removal sub-model and the auxiliary task prediction data output by the auxiliary task sub-model.

[0198] Optionally, the auxiliary task sub-model includes an image enhancement sub-model; the input module is specifically used for:

[0199] The document image is input into the image enhancement sub-model so that the image enhancement sub-model can perform image enhancement processing on the document image and output an enhanced image;

[0200] The enhanced image is input into the deshading sub-model, so that the deshading sub-model performs deshading processing on the enhanced image to obtain a deshading document image.

[0201] Optionally, the auxiliary task sub-model includes an edge processing sub-model; the input module is specifically used for:

[0202] The document image is input into the shadow removal sub-model so that the shadow removal sub-model can perform shadow removal processing on the document image;

[0203] The output of the shadow sub-model is input into the edge processing sub-model to obtain a document image that has undergone shadow removal and edge processing.

[0204] Optionally, the auxiliary task sub-model includes an image enhancement sub-model and an edge processing sub-model; the input module is specifically used for:

[0205] The document image is input into the image enhancement sub-model so that the image enhancement sub-model can perform image enhancement processing on the document image and output an enhanced image;

[0206] The enhanced image is input into the deshading sub-model so that the enhanced image can be deshaded by the deshading sub-model;

[0207] The output of the shadow sub-model is input into the edge processing sub-model to obtain a document image that has undergone shadow removal and edge processing.

[0208] Optionally, the input module includes:

[0209] A configuration unit is configured to perform image registration processing on the output result based on the document image to obtain a registered image;

[0210] An input unit is used to input the registered image into the edge processing sub-model.

[0211] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this disclosure according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0212] The collection, storage, use, processing, transmission, provision, and disclosure of the aforementioned sample data and images in this technical solution comply with relevant laws and regulations and do not violate public order and good morals.

[0213] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.

[0214] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.

[0215] like Figure 8 As shown, device 800 includes a computing unit 801, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 802 or a computer program loaded from storage unit 808 into random access memory (RAM) 803. RAM 803 may also store various programs and data required for the operation of device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via bus 804. Input / output (I / O) interface 805 is also connected to bus 804.

[0216] Multiple components in device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of monitors, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0217] The computing unit 801 can be various general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 801 performs the various methods and processes described above, such as task processing model training methods, task processing methods, and image processing methods. For example, in some embodiments, the task processing model training methods, task processing methods, and image processing methods can be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the task processing model training methods, task processing methods, and image processing methods described above can be performed. Alternatively, in other embodiments, the computing unit 801 may be configured by any other suitable means (e.g., by means of firmware) to perform training methods, task processing methods, or image processing methods for a task processing model.

[0218] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.

[0219] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0220] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0221] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0222] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0223] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.

[0224] The computer-readable storage medium provided in this disclosure is a non-transitory computer-readable storage medium with computer instructions, wherein the computer instructions are used to cause the computer to perform the method provided in any of the above embodiments.

[0225] The computer program product provided in this disclosure includes a computer program that, when executed by a processor, implements the method provided in any of the above embodiments.

[0226] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.

[0227] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for training a task processing model, the task processing model comprising a shadow removal sub-model and an auxiliary task sub-model; The training method includes: A self-attention mechanism is used to determine the first attention weight of the first loss error of the shadow removal sub-model and the second attention weight of the second loss error of the auxiliary task sub-model. Obtain sample pairs, wherein the sample pairs include document image samples and the annotation data of the document image samples; the annotation data includes target task annotation data that matches the target task corresponding to the shadow removal sub-model and auxiliary task annotation data that matches the auxiliary task corresponding to the auxiliary task sub-model; In response to the auxiliary task sub-model including an image enhancement sub-model, the document image sample is input into the image enhancement sub-model so that the image enhancement sub-model performs image enhancement processing on the document image sample and outputs auxiliary task prediction data containing the enhanced prediction image; the enhanced prediction image is input into the deshading sub-model so that the deshading sub-model performs deshading processing on the enhanced prediction image to obtain target task prediction data containing the deshading prediction image. Alternatively, in response to the auxiliary task sub-model including an edge processing sub-model; the document image sample is input into the deshading sub-model to perform deshading processing on the document image sample to obtain target task prediction data containing a deshading prediction image; the deshading prediction image is input into the edge processing sub-model to perform edge processing on the deshading prediction image to obtain auxiliary task prediction data containing an edge processing prediction image; Alternatively, in response to the auxiliary task sub-model including an image enhancement sub-model and an edge processing sub-model; the document image sample is input into the image enhancement sub-model, which performs image enhancement processing on the document image sample and outputs an enhanced prediction image; the enhanced prediction image is input into the deshading sub-model, which performs deshading processing on the document image sample to obtain target task prediction data containing the deshading prediction image; the deshading prediction image is input into the edge processing sub-model, which performs edge processing on the deshading prediction image to obtain a deshading image after edge processing; wherein, the auxiliary task prediction data includes the enhanced prediction image and the edge processing prediction image; The first loss error between the target task prediction data and the target task labeled data is determined according to the first loss function of the shadow removal sub-model, and the second loss error between the auxiliary task prediction data and the auxiliary task labeled data is determined according to the second loss function of the auxiliary task sub-model. The global loss of the task processing model is calculated based on the first loss error, the second loss error, the first attention weight, and the second attention weight. The model parameters of the task processing model are adjusted based on the global loss.

2. The training method for the task processing model according to claim 1, wherein a self-attention mechanism is used to determine the first attention weight of the first loss error of the target task sub-model and the second attention weight of the second loss error of the auxiliary task sub-model, comprising: Using a self-attention mechanism and based on the target task prediction data and the auxiliary task prediction data, the first attention weight of the first loss error and the second attention weight of the second loss error are determined.

3. The training method for the task processing model according to claim 2, wherein, Using a self-attention mechanism and based on the target task prediction data and the auxiliary task prediction data, the first attention weight of the first loss error and the second attention weight of the second loss error are determined, including: A self-attention mechanism is used to calculate the query matrix, key matrix, and value matrix corresponding to the target task prediction data and the auxiliary task prediction data; Calculate the attention score matrix based on the query matrix and the key matrix; The first attention weight and the second attention weight are calculated based on the attention score matrix and the value matrix.

4. The training method for the task processing model according to claim 2, wherein, Using a self-attention mechanism and based on the target task prediction data and the auxiliary task prediction data, the first attention weight of the first loss error and the second attention weight of the second loss error are determined, including: The target task prediction data and the auxiliary task prediction data are input into the self-attention mechanism model, so that the self-attention mechanism model outputs the first attention weight and the second attention weight.

5. The training method for the task processing model according to claim 1, wherein, The global loss of the task processing model is calculated based on the first loss error, the second loss error, the first attention weight, and the second attention weight, including: The sum of the first product, the second product, and the third product is determined as the global loss; wherein, the first product is the product of the first loss error of the image enhancement sub-model and the first attention weight of the first loss error of the image enhancement sub-model, the second product is the product of the second loss error and the second attention weight, and the third product is the product of the first loss error of the edge processing sub-model and the first attention weight of the first loss error of the edge processing sub-model.

6. A task processing method, comprising: Obtain the data to be processed for the target task; The data to be processed is input into the task processing model to obtain the task processing result corresponding to the target task; wherein the task processing model is obtained by the training method of the task processing model according to any one of claims 1-5.

7. An image processing method, comprising: Obtain the document image to be processed; The document image is input into the shadow removal model to obtain a shadow-removed document image. The shadow removal model is trained using a global loss on a shadow removal sub-model and an auxiliary task sub-model. The global loss is calculated based on a first loss error of the shadow removal sub-model, a second loss error of the auxiliary task sub-model, a first attention weight for the first loss error, and a second attention weight for the second loss error. The first and second attention weights are obtained using a self-attention mechanism based on the target task prediction data output by the shadow removal sub-model and the auxiliary task prediction data output by the auxiliary task sub-model. In response to the auxiliary task sub-model including an image enhancement sub-model, inputting the document image into the shadow removal sub-model to obtain a shadow-removed document image includes: inputting the document image into the image enhancement sub-model to perform image enhancement processing on the document image and output an enhanced image; inputting the enhanced image into the shadow removal sub-model to perform shadow removal processing on the enhanced image to obtain a shadow-removed document image. Alternatively, in response to the auxiliary task sub-model including an edge processing sub-model; inputting the document image into the shadow removal sub-model to obtain a shadow-removed document image includes: inputting the document image into the shadow removal sub-model so that the shadow removal sub-model performs shadow removal processing on the document image; inputting the output of the shadow removal sub-model into the edge processing sub-model to obtain a shadow-removed and edge-processed document image; Alternatively, in response to the auxiliary task sub-model including an image enhancement sub-model and an edge processing sub-model, inputting the document image into the shadow removal sub-model to obtain a shadow-removed document image includes: inputting the document image into the image enhancement sub-model to perform image enhancement processing on the document image and output an enhanced image; inputting the enhanced image into the shadow removal sub-model to perform shadow removal processing on the enhanced image; and inputting the output of the shadow removal sub-model into the edge processing sub-model to obtain a shadow-removed and edge-processed document image.

8. The image processing method according to claim 7, wherein, The step of inputting the output of the shadow sub-model into the edge processing sub-model includes: Based on the document image, the output result is subjected to image registration processing to obtain a registered image; The registered image is input into the edge processing sub-model.

9. A training apparatus for a task processing model, the task processing model comprising a shadow removal sub-model and an auxiliary task sub-model; The training device includes: The weight calculation module is used to determine the first attention weight of the first loss error of the shadow removal sub-model and the second attention weight of the second loss error of the auxiliary task sub-model using a self-attention mechanism. The sample acquisition module is used to acquire sample pairs, wherein the sample pairs include document image samples and the annotation data of the document image samples; the annotation data includes target task annotation data that matches the target task corresponding to the shadow removal sub-model and auxiliary task annotation data that matches the auxiliary task corresponding to the auxiliary task sub-model. The sample input module, in response to the auxiliary task sub-model including an image enhancement sub-model, is configured to: input the document image sample into the image enhancement sub-model, so that the image enhancement sub-model performs image enhancement processing on the document image sample and outputs auxiliary task prediction data containing an enhanced prediction image; input the enhanced prediction image into the deshading sub-model, so that the deshading sub-model performs deshading processing on the enhanced prediction image to obtain target task prediction data containing a deshading prediction image; or, in response to the auxiliary task sub-model including an edge processing sub-model, the sample input module is configured to: input the document image sample into the deshading sub-model, so that the deshading sub-model performs deshading processing on the document image sample to obtain target task prediction data containing a deshading prediction image; input the deshading prediction image into the edge processing sub-model, so that the image enhancement sub-model performs deshading processing on the enhanced prediction image to obtain target task prediction data containing a deshading prediction image; input the deshading prediction image into the edge processing sub-model, so that the image enhancement sub-model performs deshading processing on the enhanced prediction image to obtain target task prediction data containing a deshading prediction image; and input the edge processing sub-model, so that the image enhancement sub-model performs deshading processing on the enhanced prediction image to obtain target task prediction data containing a deshading prediction image. The model performs edge processing on the deshaded prediction image to obtain auxiliary task prediction data containing the edge-processed prediction image; or, in response to the auxiliary task sub-model including an image enhancement sub-model and an edge processing sub-model; the sample input module is used to: input the document image sample into the image enhancement sub-model, so that the image enhancement sub-model performs image enhancement processing on the document image sample and outputs an enhanced prediction image; input the enhanced prediction image into the deshaded sub-model, so that the deshaded sub-model performs deshading processing on the document image sample to obtain target task prediction data containing the deshaded prediction image; input the deshaded prediction image into the edge processing sub-model, so that the edge processing sub-model performs edge processing on the deshaded prediction image to obtain a deshaded image after edge processing; wherein, the auxiliary task prediction data includes the enhanced prediction image and the edge-processed prediction image; The loss calculation module is used to determine the first loss error between the target task prediction data and the target task labeled data according to the first loss function of the shadow removal sub-model, determine the second loss error between the auxiliary task prediction data and the auxiliary task labeled data according to the second loss function of the auxiliary task sub-model, and calculate the global loss of the task processing model according to the first loss error, the second loss error, the first attention weight and the second attention weight. An adjustment module is used to adjust the model parameters of the task processing model based on the global loss.

10. The training apparatus for the task processing model according to claim 9, wherein the training apparatus further comprises: The weight calculation module is specifically used to determine the first attention weight of the first loss error and the second attention weight of the second loss error by adopting a self-attention mechanism and based on the target task prediction data and the auxiliary task prediction data.

11. The training apparatus for the task processing model according to claim 10, wherein, The weight calculation module is specifically used for: A self-attention mechanism is used to calculate the query matrix, key matrix, and value matrix corresponding to the target task prediction data and the auxiliary task prediction data; Calculate the attention score matrix based on the query matrix and the key matrix; The first attention weight and the second attention weight are calculated based on the attention score matrix and the value matrix.

12. The training apparatus for the task processing model according to claim 10, wherein, The weight calculation module is specifically used for: The target task prediction data and the auxiliary task prediction data are input into the self-attention mechanism model, so that the self-attention mechanism model outputs the first attention weight and the second attention weight.

13. The training apparatus for the task processing model according to claim 9, wherein, When calculating the global loss of the task processing model, the loss calculation module is specifically used for: The sum of the first product, the second product, and the third product is determined as the global loss; wherein, the first product is the product of the first loss error of the image enhancement sub-model and the first attention weight of the first loss error of the image enhancement sub-model, the second product is the product of the second loss error and the second attention weight, and the third product is the product of the first loss error of the edge processing sub-model and the first attention weight of the first loss error of the edge processing sub-model.

14. A task processing apparatus, comprising: The data acquisition module is used to acquire the data to be processed for the target task; The data input module is used to input the data to be processed into the task processing model to obtain the task processing result corresponding to the target task; wherein the task processing model is obtained by the training method of the task processing model according to any one of claims 1-5.

15. An image processing apparatus, comprising: The image acquisition module is used to acquire images of the document to be processed. An image input module is used to input the document image into a shadow removal model to obtain a shadow-removed document image. The shadow removal model is trained using a global loss on a shadow removal sub-model and an auxiliary task sub-model. The global loss is calculated based on a first loss error of the shadow removal sub-model, a second loss error of the auxiliary task sub-model, a first attention weight for the first loss error, and a second attention weight for the second loss error. The first and second attention weights are obtained using a self-attention mechanism and based on the target task prediction data output by the shadow removal sub-model and the auxiliary task prediction data output by the auxiliary task sub-model. In response to the auxiliary task sub-model including an image enhancement sub-model, the image input module is specifically used to: input the document image into the image enhancement sub-model, so that the image enhancement sub-model performs image enhancement processing on the document image and outputs an enhanced image; input the enhanced image into the shadow removal sub-model, so that the shadow removal sub-model performs shadow removal processing on the enhanced image to obtain a shadow-removed document image; Alternatively, in response to the auxiliary task sub-model including an edge processing sub-model, the image input module is specifically configured to: input the document image into the shadow removal sub-model so that the shadow removal sub-model performs shadow removal processing on the document image; input the output result of the shadow removal sub-model into the edge processing sub-model to obtain a document image that has undergone shadow removal and edge processing; Alternatively, in response to the auxiliary task sub-model including an image enhancement sub-model and an edge processing sub-model, the image input module is specifically used to: input the document image into the image enhancement sub-model, so that the image enhancement sub-model performs image enhancement processing on the document image and outputs an enhanced image; input the enhanced image into the shadow removal sub-model, so that the shadow removal sub-model performs shadow removal processing on the enhanced image; and input the output result of the shadow removal sub-model into the edge processing sub-model to obtain a document image that has undergone shadow removal processing and edge processing.

16. The image processing apparatus according to claim 15, wherein, The image input module includes: A configuration unit is configured to perform image registration processing on the output result based on the document image to obtain a registered image; An input unit is used to input the registered image into the edge processing sub-model.

17. An electronic device comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the training method of the task processing model according to any one of claims 1-5, or the task processing method according to claim 6, or the image processing method according to any one of claims 7-8.

18. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the training method of the task processing model according to any one of claims 1-5, or the task processing method according to claim 6, or the image processing method according to any one of claims 7-8.

19. A computer program product comprising a computer program that, when executed by a processor, implements a training method for a task processing model according to any one of claims 1-5, or a task processing method according to claim 6, or an image processing method according to any one of claims 7-8.