Task model migration method and device, computer readable storage medium, and terminal

By constructing a loss function based on the source and target color spaces, the task model is retrained, which solves the problem of inaccurate output caused by inconsistent color spaces in image processing, and achieves efficient task model transfer and accurate output results.

CN115170833BActive Publication Date: 2026-02-24BEIJING SPREADTRUM HI TECH COMM TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210752950.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-29
Publication Date
2026-02-24
Estimated Expiration
2042-06-29

AI Technical Summary

Technical Problem

Existing technologies in image processing suffer from inaccurate output results due to the inconsistency between the color space of the input image and the task model. Furthermore, existing solutions suffer from high computational overhead, long processing time, or high uncertainty.

Method used

By constructing a first loss function based on the source domain color space and the target domain weight values ​​in the target domain color space, a second loss function is constructed. The task model is then retrained using the target domain color space image until the second loss function converges, thus achieving the transfer of the task model.

Benefits of technology

While reducing computational and R&D complexity, it improves the adaptability of the task model in the target domain color space and the accuracy of the output results, while reducing computational overhead and time costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115170833B_ABST
    Figure CN115170833B_ABST
Patent Text Reader

Abstract

A task model migration method and device, computer readable storage medium and terminal, the method comprises: obtaining a first loss function when a source domain color space image is used as original training data to train the task model; determining target domain weight values of loss functions of each target domain color channel of a target domain color space, constructing a second loss function using an expression of the first loss function and the target domain weight values, wherein the expression of the first loss function comprises a first-level expression of the first loss function composed of loss functions of each source domain color channel of a source domain color space and a second-level expression of the loss functions of each source domain color channel; based on the second loss function, using a target domain color space image as new training data to train the task model to obtain a migrated task model. The above scheme can effectively migrate the task model on the basis of reducing the operation or research and development complexity and improving the efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a task model transfer method and apparatus, a computer-readable storage medium, and a terminal. Background Technology

[0002] In deep learning tasks aimed at improving image quality, some tasks are significantly correlated with the color space of the image, such as tone mapping and style transfer. These tasks are generally applied in the RGB color space. However, the input data or output results of some tasks may be in the YUV color space or other types of color spaces (hereinafter referred to as the target domain color space). In this case, the target domain color space and the source domain color space of the task model (which is also the color space of the sample images used to train the task model) are inconsistent. If an image in the RGB space is directly input into the task model, the inconsistent color space between the input image and the task model may result in inaccurate and effective output results, leading to a decrease in the performance of the task model.

[0003] In existing technologies, the following solutions are often adopted:

[0004] The first approach involves directly converting the color space of the input data (target domain color space) to the color space of the task model (source domain color space) before inputting it into the task model, and then converting the output of the task model from the source domain color space to the target domain color space. This approach will result in significant computational overhead and time costs.

[0005] The second approach involves modifying the task model or loss function. This means modifying the model's structure and parameters based on the original task model, such as changing convolutional layer parameters or activation functions. Alternatively, parameters can be added to the original loss function or a new loss function can be introduced. Another approach is to try entirely new task models one by one to complete the task and select a suitable task model based on the output results. However, all of these approaches involve significant uncertainties, high costs, and long processing times.

[0006] Therefore, there is an urgent need for a task model transfer method that can effectively transfer task models while reducing computational or R&D complexity and improving efficiency, so that the transferred task model can adapt to input data in the target domain color space and improve the accuracy of the output results. Summary of the Invention

[0007] One of the objectives of this invention is to achieve effective transfer of the task model while reducing computational or R&D complexity and improving efficiency, so that the transferred task model can adapt to input data in the target domain color space and improve the accuracy of the output results.

[0008] To achieve the above objectives, embodiments of the present invention provide a task model transfer method, comprising the following steps: obtaining a first loss function when training the task model using source domain color space images as original training data, wherein the first loss function is a weighted sum of the loss functions of each source domain color channel in the source domain color space; determining the target domain weight values ​​of the loss functions of each target domain color channel in the target domain color space; constructing a second loss function using the expression of the first loss function and the target domain weight values, wherein the expression of the first loss function includes a first-level expression of the first loss function composed of the loss functions of each source domain color channel in the source domain color space and a second-level expression of the loss functions of each source domain color channel; and training the task model using target domain color space images as new training data based on the second loss function until the second loss function converges, thereby obtaining the transferred task model.

[0009] Optionally, before training the task model using the target domain color space image as new training data, the method further includes: determining the target domain color space image.

[0010] Optionally, determining the target domain color space image includes: acquiring the source domain color space image as the original training data; and performing color space conversion on the source domain color space image to obtain the target domain color space image.

[0011] Optionally, the source color space is different from the target color space and satisfies one or more of the following: the source color space is selected from: RGB color space, YUV color space, HSB color space, LAB color space; the target color space is selected from: RGB color space, YUV color space, HSB color space, LAB color space.

[0012] Optionally, the first loss function is selected from any of the following: L1 loss function, L2 loss function, and mean squared MSE loss function.

[0013] Optionally, determining the target domain weight value of the loss function for each target domain color channel in the target domain color space includes: determining the target domain weight value of the loss function for each target domain color channel in the target domain color space based on the color space transformation matrix between the source domain color channel and the target domain color channel.

[0014] Optionally, the target domain weight values ​​of the loss function for each target domain color channel are determined using the following color space transformation matrix:

[0015]

[0016] Where r1, r2...r n The source domain weights, r, are used to indicate the loss functions of each source domain color channel in the source domain color space. 1_new r 2_new ...r n_new R is used to indicate the target domain weight value of the loss function for each target domain color channel in the target domain color space, and R is used to indicate the color space transformation matrix.

[0017] Optionally, the loss function of each source domain color channel in the source domain color space is determined based on the label value of multiple pixels in the source domain color channel and the pixel value in the source domain color channel.

[0018] Optionally, constructing the second loss function using the expression of the first loss function and the target domain weight value includes: using the label value and pixel value of multiple pixels in the target domain color space in each target domain color channel to replace the label value and pixel value of multiple pixels in the source domain color space in each source domain color channel, thereby obtaining the loss function for each target domain color channel; and performing a weighted operation on the obtained loss function for each target domain color channel and its corresponding target domain weight value based on the expression of the first loss function to obtain the second loss function.

[0019] Optionally, multiple pixels in the target color space are the same as multiple pixels in the source color space.

[0020] Optionally, the loss function for each source domain color channel in the source domain color space is the L1 loss function:

[0021]

[0022] Where loss() is the L1 loss function, used to indicate the loss function of the source domain color channel, f() is used to indicate the task model, and x i f(x) is used to indicate the pixel value of the i-th pixel in the source domain color channel and serves as input data for the task model. i ) is x i The output result after inputting the task model, y i The label value of the i-th pixel in the source domain color channel is used to indicate the label value of the i-th pixel, and n is used to indicate the number of pixels.

[0023] Optionally, the second loss function can be obtained by weighting the loss functions of each target domain color channel and their corresponding target domain weight values ​​based on the expression of the first loss function using the following formula:

[0024] Loss=r1×loss1+r2×loss2+…+r n ×loss n ;

[0025] Loss_new=r 1_new ×loss 1_new +r 2_new ×loss 2_new +…+r m_new ×loss m_new ;

[0026] Wherein, Loss is used to indicate the first loss function, loss1, loss2, ... loss n The loss function r1, r2...r used to indicate the loss function of each source domain color channel in the source domain color space. n The source domain weights of the loss function are used to indicate the source domain color channels. `Loss_new` is used to indicate the second loss function. 1_new loss 2_new ...loss m_new The loss function r is used to indicate the color channels of each target domain in the target domain color space. 1_new r 2_new ...r m_new The target domain weight value used to indicate the loss function for each target domain color channel.

[0027] This invention also provides a task model transfer apparatus, comprising: a source domain color space loss function acquisition module, configured to acquire a first loss function when training the task model using a source domain color space image as the original training data, wherein the first loss function is a weighted sum of the loss functions of each source domain color channel in the source domain color space; a target domain color space loss function determination module, configured to determine the target domain weight values ​​of the loss functions of each target domain color channel in the target domain color space, and construct a second loss function using the expression of the first loss function and the target domain weight values, wherein the expression of the first loss function includes a first-level expression of the first loss function composed of the loss functions of each source domain color channel in the source domain color space and a second-level expression of the loss functions of each source domain color channel; and a model training module, configured to train the task model using a target domain color space image as new training data based on the second loss function, until the second loss function converges and training stops, thereby obtaining the transferred task model.

[0028] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when run by a processor, executes the steps of the task model migration method described above.

[0029] This invention also provides a terminal, including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the steps of the task model migration method described above when running the computer program.

[0030] Compared with the prior art, the technical solution of the embodiments of the present invention has the following beneficial effects:

[0031] In this embodiment of the invention, a first loss function is obtained when training the task model using source domain color space images as original training data. The first loss function is the weighted sum of the loss functions of each source domain color channel in the source domain color space. The target domain weight values ​​of the loss functions of each target domain color channel in the target domain color space are determined. A second loss function is constructed using the expression of the first loss function and the target domain weight values. Based on the second loss function, the task model is trained using target domain color space images as new training data until the second loss function converges, at which point training stops, resulting in the transferred task model. Compared to existing technologies that address the inconsistency between the source domain color space of the task model and the target domain color space of the input data / output results, which often involve first migrating the input data to the source domain color space for task model application and then migrating the output results to the target domain color space (which has high computational overhead and is time-consuming), or methods that directly modify the task model or loss function structure or parameters, or try entirely new task models, these methods involve significant uncertainty, high cost, and long processing time. In this embodiment of the invention, a second loss function is constructed directly based on the expression of the first loss function and the target domain weight values. That is, the second loss function is constructed while keeping the first-level expression of the first loss function and the second-level expressions of the loss functions of each source domain color channel unchanged. Then, based on the second loss function, the task model is retrained using the target domain color space image as training data. This allows for effective transfer of the task model while reducing computational or R&D complexity and improving efficiency. The transferred task model can adapt to input data in the target domain color space and improve the accuracy of the output results.

[0032] Furthermore, constructing the second loss function using the expression of the first loss function and the target domain weight values ​​includes: using the label values ​​and pixel values ​​of multiple pixels in the target domain color space in each target domain color channel to replace the label values ​​and pixel values ​​of multiple pixels in the source domain color space in each source domain color channel, thereby obtaining the loss function for each target domain color channel; based on the expression of the first loss function, performing a weighted operation on the obtained loss functions for each target domain color channel and their corresponding target domain weight values ​​to obtain the second loss function. In this embodiment of the invention, the first-level expression of the second loss function and the second-level expressions for each target domain color channel are the same as the first-level expression of the first loss function and the second-level expressions for each source domain color channel. During the training of the task model based on the second loss function, directly replacing the input parameters in the expression and each second-level expression can significantly reduce computational and development complexity and overhead, improve the efficiency of model transfer, and enable the transferred task model to output accurate and effective results. Attached Figure Description

[0033] Figure 1 This is a flowchart of a task model migration method according to an embodiment of the present invention;

[0034] Figure 2 yes Figure 1 A flowchart of a specific implementation of step S12;

[0035] Figure 3 This is a schematic diagram of the structure of a task model migration device according to an embodiment of the present invention. Detailed Implementation

[0036] As mentioned earlier, in the field of image processing technology, in deep learning tasks used to improve image quality, the color space of the input image / output result (target domain color space) may be inconsistent with the color space of the task model (source domain color space), resulting in the inability to obtain accurate and effective output results and causing a decrease in the performance of the task model.

[0037] In existing technologies, the following solutions are often adopted: The first is to directly convert the color space of the input data (target domain color space) to the color space of the task model (source domain color space) before inputting it into the task model, and then convert the output of the task model to the target domain color space. This solution will bring large computational overhead and time cost. The second is to modify the task model or loss function, that is, to modify the composition structure and parameters of the model based on the original task model, or to add parameters or a new loss function based on the original loss function, or to try completely new task models one by one to complete the task, and select a suitable task model based on the output effect. All of the above solutions have great uncertainty, high cost and long time consumption.

[0038] In this embodiment of the invention, a first loss function is obtained when training the task model using source domain color space images as original training data. The first loss function is the weighted sum of the loss functions of each source domain color channel in the source domain color space. The target domain weight values ​​of the loss functions of each target domain color channel in the target domain color space are determined. A second loss function is constructed using the expression of the first loss function and the target domain weight values. Based on the second loss function, the task model is trained using target domain color space images as new training data until the second loss function converges, at which point training stops, resulting in the transferred task model. Compared to existing technologies that address the inconsistency between the source domain color space of the task model and the target domain color space of the input data / output results, which often involve first migrating the input data to the source domain color space for task model application and then migrating the output results to the target domain color space (which has high computational overhead and is time-consuming), or methods that directly modify the task model or loss function structure or parameters, or try entirely new task models, these methods involve significant uncertainty, high cost, and long processing time. In this embodiment of the invention, a second loss function is constructed directly based on the expression of the first loss function and the target domain weight values. That is, the second loss function is constructed while keeping the first-level expression of the first loss function and the second-level expressions of the loss functions of each source domain color channel unchanged. Then, based on the second loss function, the task model is retrained using the target domain color space image as training data. This allows for effective transfer of the task model while reducing computational or R&D complexity and improving efficiency. The transferred task model can adapt to input data in the target domain color space and improve the accuracy of the output results.

[0039] To make the above-mentioned objectives, features and beneficial effects of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0040] Reference Figure 1, Figure 1 This is a flowchart of a task model migration method according to an embodiment of the present invention. The method may include steps S11 to S13:

[0041] Step S11: Obtain the first loss function when training the task model using source domain color space images as raw training data. The first loss function is the weighted result of the loss functions of each source domain color channel in the source domain color space.

[0042] Step S12: Determine the target domain weight value of the loss function for each target domain color channel in the target domain color space, and construct a second loss function using the expression of the first loss function and the target domain weight value. The expression of the first loss function includes a first-level expression of the first loss function composed of the loss functions of each source domain color channel in the source domain color space and a second-level expression of the loss function of each source domain color channel.

[0043] Step S13: Based on the second loss function, the target domain color space image is used as new training data to train the task model until the second loss function converges, and the training is stopped to obtain the transferred task model.

[0044] In the specific implementation of step S11, the task model can be a machine learning model used in the field of image processing technology to implement image processing, such as a deep learning task model for improving image quality, including but not limited to task models such as depth estimation, super-resolution, tone mapping, and style transfer.

[0045] Understandably, some deep learning tasks have a clear correlation with color spaces. Tasks such as tone mapping and style transfer are generally applied in the RGB color space. Directly transferring to other color spaces, such as the YUV color space, often leads to a decrease in model performance. One reason for this performance degradation is insufficient constraint of the loss function. For example, using RGB as the source color space and YUV as the target color space, and taking the L1 loss function (hereinafter referred to as L1loss) as an example loss function, in the RGB color space, L1Loss can be represented as follows:

[0046] Loss_RGB=1 / 3×LR+1 / 3×LG+1 / 3×LB;

[0047] Where LR represents L1 Loss in the R channel, LG represents L1 Loss in the G channel, and LB represents L1 Loss in the B channel.

[0048] Similarly, in the YUV color space, L1 loss can be represented as follows:

[0049] Loss_YUV=1 / 3×LY+1 / 3×LU+1 / 3×LV;

[0050] Where LY represents L1 Loss in the Y channel, LU represents L1 Loss in the U channel, and LV represents L1 Loss in the V channel.

[0051] When both RGB and YUV values ​​are scaled to the range of [0-255], the conversion formula is generally as follows:

[0052] Y = 0.299R + 0.587G + 0.114B;

[0053] U=-0.169R-0.331G+0.500B+128;

[0054] V=0.500R-0.419G-0.081B+128;

[0055] If the model is directly transferred to the YUV color space, the loss function can be derived from the YUV color space Loss_YUV expression and the color space conversion formula as follows:

[0056] Loss_YUV=1 / 3×0.63×LR-1 / 3×0.163×LG+1 / 3×0.538×LB;

[0057] As can be seen from the above formula, migrating the image to the YUV color space causes the constraints on different channels of the original RGB color space to become inconsistent. Since higher weights result in stronger constraints, we can consider the constraints to be consistent for R and B channels with similar weights. However, for the G channel, due to the significant reduction in weight, the constraints become weaker, which may be a major reason for the reduced model performance.

[0058] In specific implementations, the first loss function can be uniquely determined based on the task model. In some non-limiting embodiments, the first loss function can be selected from any of the following: L1 loss function, L2 loss function, and mean squared MSE loss function, but is not limited to these. In specific implementations, the first loss function may differ depending on the task model to be transferred.

[0059] Furthermore, the source color space is different from the target color space and satisfies one or more of the following: the source color space is selected from: RGB color space, YUV color space, HSB color space, LAB color space; the target color space is selected from: RGB color space, YUV color space, HSB color space, LAB color space; but is not limited to the color spaces listed above. In specific implementations, the source color space (or target color space) may be other different color space types depending on the image processing task (deep learning task) being performed.

[0060] In the specific implementation of step S12, the second loss function is constructed using the expression of the first loss function, wherein the expression of the first loss function can be used to represent the weighted operation of the loss functions of each source domain color channel in the source domain color space.

[0061] Specifically, the expression of the first loss function may include a first-level expression and a second-level expression. The first-level expression is used to represent the weighting operation, and the second-level expression is used to represent the specific parameters to be weighted (such as the loss function of each source domain color channel).

[0062] Taking the weighted summation operation as an example, the first-level expression can be represented by the following formula (non-restrictive):

[0063]

[0064] or,

[0065] Loss=r1×loss1+r2×loss2+…+r n ×loss n ;

[0066] In the first expression, the variable parameters are r1 to r n and loss1 to loss n The values ​​or expressions (also known as second-level expressions) of variable parameters can be determined according to specific needs, r1 to r n The source domain weights, from loss1 to loss1, are used to represent the loss functions for each source domain color channel in the first loss function. n The loss function used to represent the color channels of each source domain.

[0067] Non-restrictive, the second-order expression, i.e., the expression for the loss function of each source domain color channel, can be represented by the following formula:

[0068]

[0069] In this context, based on the determined function f(x), the variable parameter in the second-level expression is x. i and y i The value of the variable parameter or the expression of the variable parameter (also known as a third-level expression) can be determined according to specific needs. i Used to indicate the pixel value of the i-th pixel in the source domain color channel, y i The label value of the i-th pixel in the source domain color channel is used to indicate the label value of the i-th pixel, and n is used to indicate the number of pixels.

[0070] In practice, other appropriate expressions can be used to represent the loss function of each source domain color channel, and it is not limited to the above formula.

[0071] In this embodiment of the invention, by directly using the two-level expression contained in the first loss function to construct the second loss function, the process of determining the appropriate loss function type (i.e., determining the appropriate second-level expression) through analysis and calculation among a large number of optional loss function types is omitted, as is the process of determining the appropriate construction expression (i.e., determining the appropriate first-level expression) through analysis and calculation among a large number of optional loss functions based on various source domain color channels to construct the second loss function. This can effectively reduce the complexity of research and development and improve the computational efficiency.

[0072] Furthermore, determining the target domain weight value of the loss function for each target domain color channel in the target domain color space includes: determining the target domain weight value of the loss function for each target domain color channel in the target domain color space based on the color space transformation matrix between the source domain color channel and the target domain color channel.

[0073] Furthermore, the target domain weight values ​​of the loss function for each target domain color channel can be determined using the following color space transformation matrix:

[0074]

[0075] Where r1, r2...r n The source domain weights, r, are used to indicate the loss functions of each source domain color channel in the source domain color space. 1_new r 2_new ...r n_new R is used to indicate the target domain weight value of the loss function for each target domain color channel in the target domain color space, and R is used to indicate the color space transformation matrix.

[0076] As a non-limiting embodiment, the color space transformation matrix can be expressed using the color space transformation formula as follows:

[0077] B=1.164(Y-16)+2.108(U-128);

[0078] G=1.164(Y-16)-0.183(V-128)-0.391(U-128);

[0079] R=1.164(Y-16)+1.596(V-128);

[0080] The above formula can be determined by performing matrix inverse operation on the conversion formula (conversion matrix) for converting the YUV color space to the RGB color space as exemplarily described in step S11.

[0081] In the specific implementation of step S13, the color space of the target domain color space image, which is the new training data, is different from the color space of the source domain color space image, which is the original training data, but is consistent with the color space of the input image and / or output result in the task to be processed by the task model.

[0082] Furthermore, before training the task model using the target domain color space image as new training data, the method further includes: determining the target domain color space image.

[0083] Furthermore, determining the target domain color space image includes: acquiring the source domain color space image as the original training data; and performing color space conversion on the source domain color space image to obtain the target domain color space image.

[0084] It should be noted that, in specific implementations, the new training data is not limited to obtaining the target domain color space image by color space conversion based on the original training data. Other sample images in the target domain color space that can be applied to the deep learning task of the task model in the field of image processing technology can also be used as the new training data to train the task model. This embodiment of the invention does not limit this.

[0085] In this embodiment of the invention, the scheme described above and in steps S11 to S13 is adopted. Compared with the prior art, when solving the problem of inconsistency between the source domain color space where the task model is located and the target domain color space where the input data / output results are located, the method often involves first migrating the input data to the source domain color space for task model application, and then migrating the output results to the target domain color space. This method has high computational overhead and is time-consuming. Alternatively, the method may involve directly modifying the task model or loss function structure or parameters, or trying completely new task models one by one, which has significant uncertainty, high cost, and long time consumption. In this embodiment of the invention, a second loss function is constructed directly based on the expression of the first loss function and the target domain weight values. That is, the second loss function is constructed while keeping the first-level expression of the first loss function and the second-level expressions of the loss functions of each source domain color channel unchanged. Then, based on the second loss function, the task model is retrained using the target domain color space image as training data. This allows for effective migration of the task model while reducing computational or R&D complexity and improving efficiency. This enables the migrated task model to adapt to the input data in the target domain color space and improves the accuracy of the output results.

[0086] Reference Figure 2 , Figure 2 yes Figure 1 A flowchart of a specific implementation of step S12 is provided. The construction of the second loss function using the expression of the first loss function and the target domain weight values ​​may include steps S21 to S22, which are described below.

[0087] In step S21, the label values ​​and pixel values ​​of multiple pixels in the target domain color space in each target domain color channel are used to replace the label values ​​and pixel values ​​of multiple pixels in the source domain color space in each source domain color channel, thereby obtaining the loss function of each target domain color channel.

[0088] It should be noted that, in specific implementation, the loss function of each source domain color channel constituting the first loss function is determined based on the label value of multiple pixels in the source domain color space in that source domain color channel and the pixel value in that source domain color channel.

[0089] Specifically, determining the loss function for a source color channel based on the label values ​​of multiple pixels in the source color space in each source color channel and the pixel values ​​in that source color channel includes: determining the function output value (output result of the task model) after inputting the pixel values ​​of multiple pixels in the source color space into the task model; and determining the first loss function based on the difference between the label values ​​of the multiple pixels in the source color channel and the function output value.

[0090] For example, the loss function of the source domain color channel can be determined by averaging or weighting the absolute values ​​of the differences between the label values ​​and the function output values ​​of multiple pixels in the source domain color channel.

[0091] As a non-limiting embodiment, the loss function for each source domain color channel in the source domain color space is an L1 loss function:

[0092]

[0093] Where loss() is the L1 loss function, used to indicate the loss function of the source domain color channel, f() is used to indicate the task model, and x i f(x) is used to indicate the pixel value of the i-th pixel in the source domain color channel and serves as input data for the task model. i ) is x i The output result after inputting the task model, y i The label value of the i-th pixel in the source domain color channel is used to indicate the label value of the i-th pixel, and n is used to indicate the number of pixels.

[0094] In some specific implementations, multiple pixels in the target color space are identical to multiple pixels in the source color space.

[0095] In other specific embodiments, since the function values ​​of the loss functions of each source color channel in the source color space and the function values ​​of the loss functions of each target color channel in the target color space can both be determined by the average of the calculated values ​​of multiple pixels (e.g., L1 loss function), whether the same pixels are used, or even whether the same number of pixels are used, has a limited impact on the function values ​​of the loss functions. Therefore, in the specific calculation process, the multiple pixels in the target color space and the multiple pixels in the source color space may not be the same.

[0096] In step S22, based on the expression of the first loss function, the loss functions of each target domain color channel and their corresponding target domain weight values ​​are weighted and calculated to obtain the second loss function.

[0097] Furthermore, the second loss function can be obtained by weighting the loss functions of each target domain color channel and their corresponding target domain weight values ​​based on the expression of the first loss function using the following formula:

[0098] Loss=r1×loss1+r2×loss2+…+r n ×loss n ;

[0099] Loss_new=r 1_new ×loss 1_new +r 2_new ×loss 2_new +…+r m_new ×loss m_new ;

[0100] Wherein, Loss is used to indicate the first loss function, loss1, loss2, ... loss n The loss function r1, r2...r used to indicate the loss function of each source domain color channel in the source domain color space. n The source domain weights of the loss function are used to indicate the source domain color channels. `Loss_new` is used to indicate the second loss function. 1_new loss 2_new ...loss m_new The loss function r is used to indicate the color channels of each target domain in the target domain color space. 1_new r 2_new ...r m_new The target domain weight value used to indicate the loss function for each target domain color channel.

[0101] In this embodiment of the invention, the first-level expression of the second loss function and the second-level expressions of each target domain color channel are the same as the first-level expression of the first loss function and the second-level expressions of each source domain color channel. During the training of the task model based on the second loss function, the input parameters in the expression and each second-level expression are directly replaced. This eliminates the need to determine the appropriate loss function type (i.e., the appropriate second-level expression) from a large number of optional loss function types through analysis and calculation, and also eliminates the need to determine the appropriate construction expression (i.e., the appropriate first-level expression) from a large number of optional second loss function construction methods through analysis and calculation. This significantly reduces computational and development complexity and overhead, improves the efficiency of model transfer, and ensures that the transferred task model can output accurate and effective results.

[0102] For more detailed information regarding steps S21 to S22 in the specific implementation, please refer to the preceding text and... Figure 1 The steps described in the document will be executed, and will not be repeated here.

[0103] Reference Figure 3 , Figure 3 This is a schematic diagram of a task model migration device according to an embodiment of the present invention. The task model migration device may include:

[0104] The source domain color space loss function acquisition module 31 is used to acquire the first loss function when training the task model using the source domain color space image as the original training data. The first loss function is the weighted result of the loss function of each source domain color channel in the source domain color space.

[0105] The target domain color space loss function determination module 32 is used to determine the target domain weight value of the loss function of each target domain color channel in the target domain color space, and construct a second loss function using the expression of the first loss function and the target domain weight value. The expression of the first loss function includes a first-level expression of the first loss function composed of the loss functions of each source domain color channel in the source domain color space and a second-level expression of the loss function of each source domain color channel.

[0106] The model training module 33 is used to train the task model based on the second loss function, using the target domain color space image as new training data, until the second loss function converges and training stops, thus obtaining the transferred task model.

[0107] For the principles, implementation details, and beneficial effects of this task model transfer device, please refer to the preceding text. Figures 1 to 2 The descriptions of the task model transfer method shown are not repeated here.

[0108] This invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, performs the steps of the task model migration method described above. The computer-readable storage medium may include non-volatile or non-transitory memory, and may also include optical discs, hard disk drives, solid-state drives, etc.

[0109] Specifically, in this embodiment of the invention, the processor can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0110] It should also be understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0111] This invention also provides a terminal, including a memory and a processor. The memory stores a computer program that can run on the processor. When the processor runs the computer program, it performs the steps of the task model migration method described above. The terminal may include, but is not limited to, terminal devices such as mobile phones, computers, and tablet computers, and may also be servers, cloud platforms, etc.

[0112] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article indicates that the preceding and following related objects have an "or" relationship.

[0113] In the embodiments of this application, "multiple" refers to two or more.

[0114] The descriptions of "first," "second," etc., appearing in the embodiments of this application are for illustrative purposes and to distinguish the objects being described. They have no order and do not indicate any special limitation on the number of devices in the embodiments of this application, nor do they constitute any limitation on the embodiments of this application.

[0115] It should be noted that the sequence number of each step in this embodiment does not represent a limitation on the execution order of each step.

[0116] While the present invention has been disclosed above, it is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of the invention; therefore, the scope of protection of the present invention should be determined by the scope defined in the claims.

Claims

1. A task model transfer method, characterized in that, include: Obtain the first loss function when training the task model using source domain color space images as raw training data. The first loss function is the weighted sum of the loss functions of each source domain color channel in the source domain color space. Determine the target domain weight value of the loss function for each target domain color channel in the target domain color space, and construct a second loss function using the expression of the first loss function and the target domain weight value. The expression of the first loss function includes a first-level expression of the first loss function composed of the loss functions of each source domain color channel in the source domain color space and a second-level expression of the loss function of each source domain color channel. The determination of the target domain weight values ​​of the loss function for each target domain color channel in the target domain color space includes: determining the target domain weight values ​​of the loss function for each target domain color channel in the target domain color space based on the color space transformation matrix between the source domain color channels and the target domain color channels; and using the following color space transformation matrix to determine the target domain weight values ​​of the loss function for each target domain color channel: Where r1, r2...r n The source domain weights, r, are used to indicate the loss functions of each source domain color channel in the source domain color space. 1_new r 2_new ...r n_new The target domain weights of the loss function for each target domain color channel in the target domain color space are used to indicate the target domain weights, and R is used to indicate the color space transformation matrix. Based on the second loss function, the target domain color space image is used as new training data to train the task model until the second loss function converges, at which point training stops and the transferred task model is obtained.

2. The method according to claim 1, characterized in that, Before training the task model using the target domain color space image as new training data, the method further includes: Determine the target domain color space image.

3. The method according to claim 2, characterized in that, Determining the target domain color space image includes: Obtain the source domain color space image used as the original training data; The source domain color space image is converted to a different color space to obtain the target domain color space image.

4. The method according to claim 1, characterized in that, The source color space is different from the target color space, and satisfies one or more of the following: The source color space is selected from: RGB color space, YUV color space, HSB color space, and LAB color space; The target domain color space is selected from: RGB color space, YUV color space, HSB color space, and LAB color space.

5. The method according to claim 1, characterized in that, The first loss function is selected from any of the following: L1 loss function, L2 loss function, mean squared loss function (MSE).

6. The method according to claim 1, characterized in that, The loss function for each source color channel of the source color space is determined based on the label value of multiple pixels in the source color channel and the pixel value in the source color channel.

7. The method according to claim 6, characterized in that, The construction of the second loss function using the expression of the first loss function and the target domain weight values ​​includes: The label values ​​and pixel values ​​of multiple pixels in the target domain color space in each target domain color channel are used to replace the label values ​​and pixel values ​​of multiple pixels in the source domain color space in each source domain color channel, thereby obtaining the loss function of each target domain color channel. Based on the expression of the first loss function, the loss functions of each target domain color channel and their corresponding target domain weight values ​​are weighted and calculated to obtain the second loss function.

8. The method according to claim 7, characterized in that, Multiple pixels in the target color space are identical to multiple pixels in the source color space.

9. The method according to claim 7, characterized in that, The loss function for each source domain color channel in the source domain color space is the L1 loss function: ; Where loss() is the L1 loss function, used to indicate the loss function of the source domain color channel, f() is used to indicate the task model, and x i f(x) is used to indicate the pixel value of the i-th pixel in the source domain color channel and serves as input data for the task model. i ) is x i The output result after inputting the task model, y i The label value of the i-th pixel in the source domain color channel is used to indicate the label value of the i-th pixel, and n is used to indicate the number of pixels.

10. The method according to claim 7, characterized in that, Using the following formula, based on the expression of the first loss function, a weighted operation is performed on the loss functions of each target domain color channel and their corresponding target domain weight values ​​to obtain the second loss function: ; ; Wherein, Loss is used to indicate the first loss function, loss1, loss2, ... loss n The loss function r1, r2...r used to indicate the loss function of each source domain color channel in the source domain color space. n The source domain weights of the loss function are used to indicate the source domain color channels. `Loss_new` is used to indicate the second loss function. 1_new loss 2_new ...loss m_new The loss function r is used to indicate the color channels of each target domain color channel in the target domain color space. 1_new r 2_new ...r m_new The target domain weight value used to indicate the loss function for each target domain color channel.

11. A task model transfer device, characterized in that, include: The source domain color space loss function acquisition module is used to acquire the first loss function when training the task model using the source domain color space image as the original training data. The first loss function is the weighted result of the loss function of each source domain color channel in the source domain color space. The target domain color space loss function determination module is used to determine the target domain weight value of the loss function of each target domain color channel in the target domain color space, and construct a second loss function using the expression of the first loss function and the target domain weight value. The expression of the first loss function includes a first-level expression of the first loss function composed of the loss functions of each source domain color channel in the source domain color space and a second-level expression of the loss function of each source domain color channel. The determination of the target domain weight values ​​of the loss function for each target domain color channel in the target domain color space includes: determining the target domain weight values ​​of the loss function for each target domain color channel in the target domain color space based on the color space transformation matrix between the source domain color channels and the target domain color channels; and using the following color space transformation matrix to determine the target domain weight values ​​of the loss function for each target domain color channel: Where r1, r2...r n The source domain weights, r, are used to indicate the loss functions of each source domain color channel in the source domain color space. 1_new r 2_new ...r n_new The target domain weights of the loss function for each target domain color channel in the target domain color space are used to indicate the target domain weights, and R is used to indicate the color space transformation matrix. The model training module is used to train the task model based on the second loss function, using the target domain color space image as new training data, until the second loss function converges and training stops, thus obtaining the transferred task model.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program is executed by the processor to perform the steps of the task model migration method according to any one of claims 1 to 10.

13. A terminal comprising a memory and a processor, wherein the memory stores a computer program capable of running on the processor, characterized in that, When the processor runs the computer program, it performs the steps of the task model migration method according to any one of claims 1 to 10.

Citation Information

Patent Citations

  • Image processing model training method and device and storage medium

    CN110197229A

  • Region-based self-adaptive model training method and device, image detection method and device, and apparatus and medium

    WO2021120752A1