Model generation method and device, computer equipment and computer readable storage medium

By training, compressing and quantizing the super-resolution model, a model suitable for terminal device operation is generated, which solves the problem of large computational load and high complexity of the model, and achieves hardware acceleration and efficient computing on the terminal device.

CN118780982APending Publication Date: 2024-10-15TCL TECHNOLOGY GROUP CORPORATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310349887.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

Due to the large number of parameters and high computational complexity, existing super-resolution models are difficult to run on terminal devices and difficult to implement hardware acceleration, which affects the user experience.

Method used

By training, compressing, quantizing training and post-training quantification of the preset network model, a target model suitable for terminal device operation is generated, reducing the computational load and complexity of the model, reducing the model size and storage space, and achieving hardware acceleration.

Benefits of technology

It effectively improves the computing speed of the target model while maintaining high-quality super-resolution effects, making it suitable for hardware acceleration on terminal devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118780982A_ABST
    Figure CN118780982A_ABST
Patent Text Reader

Abstract

The invention discloses a model generation method and device, computer equipment and a computer readable storage medium, and the method comprises the steps: training a preset network model based on an obtained training image set, and obtaining a basic model; compressing the basic model to obtain a compressed model; performing quantitative training on the compression model to obtain a compression model after quantitative training; and training and quantizing the compression model after quantitative training to obtain a target model. According to the invention, the operand and complexity of the model can be reduced, and the generated target model is suitable for running in the terminal equipment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a model generation method, device, computer equipment and computer-readable storage medium. Background Art

[0002] Super-resolution is a technology widely used in imaging systems. This technology can reconstruct low-resolution images into high-resolution images through software or hardware. Deep learning is usually used for super-resolution reconstruction. In order to improve the super-resolution effect, people will make the model structure deeper and more complex so that the model can learn feature mapping more effectively. However, although complex super-resolution models can significantly improve the super-resolution effect, such models are difficult to run on terminal devices due to their large number of parameters and high computational complexity.

[0003] Therefore, the existing technology still needs to be improved and developed. Summary of the invention

[0004] The embodiments of the present application provide a model generation method, apparatus, computer device and computer-readable storage medium, which can reduce the amount of computation and complexity of the model, and the generated target model is suitable for running on a terminal device.

[0005] The technical solution adopted by the present invention to solve the problem is as follows:

[0006] In one aspect, the present application provides a model generation method, comprising:

[0007] The preset network model is trained based on the acquired training image set to obtain a basic model;

[0008] Compress the basic model to obtain a compressed model;

[0009] Performing quantization training on the compression model to obtain a quantized trained compression model;

[0010] The compressed model after quantization training is quantized after training to obtain the target model.

[0011] In some embodiments of the present application, the preset network model includes a feature extraction module, a feature mapping module, a first fusion module, an attention module, a feature reconstruction module, a second fusion module, and a deep space module connected in series, and an image processing module connected in parallel with the feature extraction module, the feature mapping module, the first fusion module, the attention module, and the feature reconstruction module;

[0012] The output item of the feature extraction module is the input item of the feature mapping module, the output item of the feature mapping module and the output item of the feature extraction module are the input items of the first fusion module, the output item of the first fusion module is the input item of the attention module, the output item of the attention module is the input item of the feature reconstruction module, the input item of the feature extraction module is the input item of the image processing module, the output item of the image processing module and the output item of the feature reconstruction module are the input items of the second fusion module, and the output item of the second fusion module is the input item of the deep space module.

[0013] In some embodiments of the present application, the training image set includes a plurality of training image groups, each training image group includes a first image and a second image having the same image content, and a resolution of the second image is greater than a resolution of the first image;

[0014] The preset network model is trained based on the acquired training image set to obtain a basic model, including:

[0015] Inputting a first image in the acquired training image set into a preset network model, and outputting a first predicted image of the first image through the preset network model;

[0016] Determining a first loss value and a second loss value based on the first predicted image and the second image; wherein the first loss value is used to characterize the similarity between the first predicted image and the second image, and the second loss value is used to characterize the sharpness of the image edge of the first predicted image;

[0017] The preset network model is trained based on the first loss value and the second loss value to obtain a basic model.

[0018] In some embodiments of the present application, inputting a first image in the acquired training image set into a preset network model, and outputting a first predicted image of the first image through the preset network model includes:

[0019] Inputting the first image in the acquired training image set into the feature extraction module, performing feature extraction on the first image through the feature extraction module to obtain a first feature map;

[0020] Inputting the first feature map into a feature mapping module, and performing feature mapping on the first feature map through the feature mapping module to obtain a mapping feature map;

[0021] Inputting the mapping feature map and the first feature map into a first fusion module, and fusing the mapping feature map and the first feature map through the first fusion module to obtain a first fused feature map;

[0022] Input the first fused feature map into the attention module, generate a weight map of the first fused feature map through the attention module, and multiply the weight map by the first fused feature map pixel by pixel to obtain an attention map;

[0023] The attention map is input into the feature reconstruction module, and the feature reconstruction module is used to reconstruct the features of the attention map to obtain a reconstructed feature map;

[0024] Inputting the first image into an image processing module, and processing the first image through the image processing module to obtain a processed feature map; wherein the number of channels of the processed feature map is the same as the number of channels of the reconstructed feature map;

[0025] Inputting the processed feature map and the reconstructed feature map into a second fusion module, and fusing the processed feature map and the reconstructed feature map through the second fusion module to obtain a second fused feature map;

[0026] The second fused feature map is input into the deep space module, and the second fused feature map is upsampled by the deep space module to obtain a first predicted image of the first image.

[0027] In some embodiments of the present application, the basic model includes a parameterized unit, the parameterized unit includes a first convolution unit, a first convolution layer, a first fusion layer and a second fusion layer, the first convolution unit is connected in parallel with the first convolution layer, the input item of the first convolution unit is the input item of the first convolution layer, the output item of the first convolution layer and the input item of the first convolution layer are the input items of the first fusion layer, and the output item of the first fusion layer and the output item of the first convolution unit are the input items of the second fusion layer;

[0028] The first convolution unit includes a third convolution layer, a fourth convolution layer and a fifth convolution layer, the output item of the third convolution layer is the fourth convolution layer, and the output item of the fourth convolution layer is the input item of the fifth convolution layer.

[0029] In some embodiments of the present application, the basic model is compressed to obtain a compressed model, including:

[0030] Compressing the first convolution unit to obtain a first compression layer;

[0031] Adding the first compression layer to the pre-constructed one to obtain a second compression layer;

[0032] The second compression layer is added to the pre-constructed second convolutional layer to obtain a compression model; wherein the second convolutional layer is constructed based on the first convolutional layer.

[0033] In some embodiments of the present application, compressing the first convolution unit to obtain a first compression layer includes:

[0034] Transforming the position of the convolution parameters of the third convolutional layer to obtain a transformed third convolutional layer;

[0035] Convolution processing is performed on the transformed convolution parameters of the third convolution layer and the convolution parameters of the fourth convolution layer to obtain a third compression layer;

[0036] Transforming the position of the convolution parameters of the third compression layer to obtain a transformed third compression layer;

[0037] A convolution operation is performed on the transformed convolution parameters of the third compression layer and the convolution parameters of the fifth convolution layer to obtain a first compression layer.

[0038] In some embodiments of the present application, the compression model includes a sixth convolutional layer, a seventh convolutional layer, a first fusion module, an attention module, an eighth convolutional layer, a second fusion module, a deep space module, and an image processing module connected in series with the sixth convolutional layer, the seventh convolutional layer, the first fusion module, the attention module and the eighth convolutional layer;

[0039] The output item of the sixth convolutional layer is the input item of the seventh convolutional layer, the output item of the seventh convolutional layer and the output item of the sixth convolutional layer are the input items of the first fusion module, the output item of the first fusion module is the input item of the attention module, the output item of the attention module is the input item of the eighth convolutional layer, the input item of the sixth convolutional layer is the input item of the image processing module, the output item of the image processing module and the output item of the eighth convolutional layer are the input items of the second fusion module, and the output item of the second fusion module is the input item of the deep space module.

[0040] In some embodiments of the present application, the compression model includes a layer to be quantized, and quantization training is performed on the compression model to obtain a quantized trained compression model, including:

[0041] Acquire first input data of the layer to be quantized; wherein the first input data is data of a first data type, and the number of bits occupied by the first input data is a first number of bits;

[0042] Performing a quantization operation on the first input data to obtain second input data of a second data type; wherein the number of bits occupied by the second input data is a second number of bits, and the second number of bits is less than the first number of bits;

[0043] Inputting the second input data into the to-be-quantized layer, and outputting first output data of the second data type through the to-be-quantized layer;

[0044] Performing a dequantization operation on the first output data to obtain second output data of the first data type;

[0045] The compression model is quantized and trained based on the second output data to obtain a quantized and trained compression model.

[0046] In some embodiments of the present application, the compression model is quantized and trained by a training image set, and the compression model is quantized and trained based on the second output data to obtain a quantized and trained compression model, including:

[0047] Determine a second predicted image of the first image output by the compression model based on the second output data;

[0048] Determining a third loss value and a fourth loss value based on the second predicted image and the second image; wherein the third loss value is used to characterize the degree of similarity between the second predicted image and the second image, and the fourth loss value is used to characterize the degree of sharpness of the image edge of the second predicted image;

[0049] The compression model is quantized and trained based on the third loss value and the fourth loss value to obtain a quantized and trained compression model.

[0050] In a second aspect, an embodiment of the present invention further provides a model generation device, comprising:

[0051] A model training unit, used to train a preset network model based on the acquired training image set to obtain a basic model;

[0052] A model compression unit, used for compressing the basic model to obtain a compressed model;

[0053] A quantization training unit, used for performing quantization training on the compression model to obtain a quantized trained compression model;

[0054] The model quantization unit is used to perform post-training quantization on the compressed model after quantization training to obtain a target model.

[0055] In a third aspect, the present application further provides a computer device, the computer device comprising:

[0056] one or more processors;

[0057] Memory; and

[0058] One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement any one of the model generation methods in the first aspect.

[0059] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program is loaded by a processor to execute the steps in the model generation method of any one of the first aspects.

[0060] The beneficial effects of the present invention are as follows: compressing the basic model can reduce the amount of calculation and complexity of the model; quantizing the compressed model and performing post-training quantization can further reduce the model size and storage space; the generated target model can be hardware accelerated on the terminal device, effectively improving the calculation speed of the target model while maintaining the high-quality super-resolution effect of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0062] Figure 1 is a flow chart of a model generation method provided by an embodiment of the present invention;

[0063] Figure 2 is a schematic diagram of the structure of a preset network model provided by an embodiment of the present invention;

[0064] Figure 3 is a schematic diagram of the structure of a parameterization module provided in an embodiment of the present invention;

[0065] Figure 4 is a schematic diagram of the structure of a compression model provided by an embodiment of the present invention;

[0066] Figure 5 is a principle block diagram of a model generation device provided by an embodiment of the present invention;

[0067] Figure 6 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0068] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0069] In the description of the present application, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside" and the like indicate positions or positional relationships based on the positions or positional relationships shown in the drawings, which are only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application. In addition, the terms "first", "second", "third", "fourth", and "fifth" are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first", "second", "third", "fourth", and "fifth" may explicitly or implicitly include one or more of the features. In the description of the present application, "multiple" means two or more, and "several" means one or more, unless otherwise clearly and specifically defined.

[0070] In this application, the word "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described in this application as "exemplary" is not necessarily to be construed as being preferred or advantageous over other embodiments. The following description is given to enable any technician in the field to implement and use the present application. In the following description, details are listed for the purpose of explanation. It should be understood that a person of ordinary skill in the art can recognize that the present application can be implemented without using these specific details. In other instances, well-known structures and processes will not be elaborated in detail to avoid obscuring the description of the present application with unnecessary details. Therefore, the present application is not intended to be limited to the embodiments shown, but is consistent with the widest scope consistent with the principles and features disclosed in the present application.

[0071] It should be noted that since the method of the embodiment of the present application is executed in a computer device, the processing objects of each computer device exist in the form of data or information. For example, time is actually time information. It can be understood that if size, quantity, position, etc. are mentioned in subsequent embodiments, they are all corresponding data for processing by the computer device. The details will not be repeated here.

[0072] The inventors have found through research that traditional super-resolution imaging methods generally obtain high-resolution (HR) images through interpolation methods (Bicubic upsampling), and then perform some post-processing, such as noise reduction and sharpening. Although the traditional ultrasonic imaging method has a fast operation speed, the quality of the HR image obtained is poor, for example, the image will become blurred and details will be lost. With the rapid development of neural networks, existing methods use deep learning to perform super-resolution reconstruction. Compared with traditional ultrasonic imaging methods, deep learning networks can learn feature mapping, so that the information between pixels can be accurately restored. The obtained HR images have more details and better sharpness than the HR images obtained by traditional methods.

[0073] In order to improve the super-resolution effect, people will make the model structure deeper and more complex, so that the model can learn feature mapping more effectively. However, a deeper and more complex model structure means a greater amount of calculation and greater computational complexity, making it difficult for such models to run on terminal devices (e.g., mobile phones). In addition, existing super-resolution models are usually floating-point models, which are difficult to hardware-accelerate on terminal devices, resulting in large super-resolution running time and memory usage, affecting the user experience.

[0074] Based on this, in an embodiment of the present application, a preset network model is trained based on an acquired training image set to obtain a basic model; the basic model is compressed to obtain a compressed model; the compressed model is quantized and trained to obtain a compressed model after quantization training; the compressed model after quantization training is quantized to obtain a target model. The present application compresses the basic model to reduce the amount of computation and complexity of the model, and quantizes and quantizes the compressed model after training to further reduce the model size and storage space. The generated target model can be hardware accelerated on the terminal device, which can effectively improve the computational speed of the target model while maintaining the high-quality super-resolution effect of the model.

[0075] The content of this application is further illustrated by describing embodiments in conjunction with the accompanying drawings.

[0076] This embodiment provides a model generation method, such as Figure 1 As shown in , the method includes:

[0077] Step S10: training the preset network model based on the acquired training image set to obtain a basic model.

[0078] Specifically, the model structure of the preset network model is the same as the model structure of the basic model. The difference between the preset network model and the basic model is that the model parameters of the preset network model are preset initial model parameters, and the model parameters of the basic model are model parameters trained based on the training image set.

[0079] The training image set is a pre-acquired image set used to train a preset network model, and the training image set includes multiple training image groups, and the multiple training image groups vary with the functions of the basic model. In a specific implementation, the basic model is used to perform super-resolution reconstruction on the image, and each training image group includes a first image and a second image with the same image content, wherein the resolution of the second image is greater than the resolution of the first image.

[0080] In a specific implementation, step S10 includes:

[0081] Step S11, inputting a first image in the acquired training image set into a preset network model, and outputting a first predicted image of the first image through the preset network model;

[0082] Step S12: determining a first loss value and a second loss value based on the first predicted image and the second image; wherein the first loss value is used to characterize the similarity between the first predicted image and the second image, and the second loss value is used to characterize the sharpness of the image edge of the first predicted image;

[0083] Step S13: training the preset network model based on the first loss value and the second loss value to obtain a basic model.

[0084] The first predicted image is a high resolution (HR) image of the first image predicted by a preset network model, and the second image is an HR image predicted by an expected preset network model. The first loss value is used to characterize the similarity between the first predicted image and the second image, and the second loss value is used to characterize the sharpness of the image edge of the first predicted image.

[0085] In a specific implementation, each training image group includes a first image and a second image having the same image content, and the resolution of the second image is greater than the resolution of the first image. Accordingly, the step of training the preset network model based on the training image set specifically includes: inputting the first image in the acquired training image set into the preset network model, and outputting the first predicted image of the first image through the preset network model; determining the first loss value and the second loss value based on the first predicted image and the second image; and training the preset network model based on the first loss value and the second loss value to obtain a basic model. This embodiment trains the preset network model based on the first loss value and the second loss value, so that the trained model can process the image edges more delicately, and the processed image has a higher sharpening effect.

[0086] Among them, the calculation formula of the first loss value is: in, and Respectively represent the pixel mean and pixel variance of the first predicted image, and denote the pixel mean and pixel variance of the second image respectively, represents the pixel covariance between the first predicted image and the second image, and c1 and c2 are preset very small constants used to ensure the stability of the value.

[0087] The calculation formula for the second loss value is: represents the gradient field of the first predicted image, represents the gradient field of the second image.

[0088] In one implementation of this embodiment, when the preset network model is trained based on the first loss value and the second loss value, the first target loss value is first determined based on the first loss value and the second loss value. When the first target loss value does not meet the preset condition, the model parameters of the preset network model are corrected based on the preset first parameter learning rate, and the steps of inputting the first image in the acquired training image set into the preset network model and outputting the first predicted image of the first image through the preset network model are continued until the first target loss value meets the preset first condition. The first target loss value meeting the preset first condition may be that the first target loss value is less than the preset first threshold value, or the difference between the first target loss values ​​obtained twice before and after is less than the preset second threshold value.

[0089] In one implementation of this embodiment, the calculation formula of the first target loss value is: L1 = α2L ssim1 +α3L GGP1 , where L represents the first target loss value, L ssim1 Represents the first loss value, L GGP1 represents the second loss value, α2 and α3 represent weights, and α2 and α3 can be set as needed. For example, α2 and α3 can be set to 1 and 0.001, respectively.

[0090] In a specific implementation, step S11 includes:

[0091] Step S111, inputting the first image in the acquired training image set into a feature extraction module, and performing feature extraction on the first image through the feature extraction module to obtain a first feature map;

[0092] Step S112: input the first feature map into a feature mapping module, and perform feature mapping on the first feature map through the feature mapping module to obtain a mapping feature map;

[0093] Step S113, inputting the mapping feature map and the first feature map into a first fusion module, and fusing the mapping feature map and the first feature map through the first fusion module to obtain a first fused feature map;

[0094] Step S114, input the first fused feature map into the attention module, generate a weight map of the first fused feature map through the attention module, and multiply the weight map by the first fused feature map pixel by pixel to obtain an attention map;

[0095] Step S115, inputting the attention map into a feature reconstruction module, and performing feature reconstruction on the attention map through the feature reconstruction module to obtain a reconstructed feature map;

[0096] Step S116, inputting the first image into an image processing module, and processing the first image through the image processing module to obtain a processing feature map; wherein the number of channels of the processing feature map is the same as the number of channels of the reconstructed feature map;

[0097] Step S117, inputting the processed feature map and the reconstructed feature map into a second fusion module, and fusing the processed feature map and the reconstructed feature map through the second fusion module to obtain a second fused feature map;

[0098] Step S118: input the second fused feature map into the depth space module, and upsample the second fused feature map through the depth space module to obtain a first predicted image of the first image.

[0099] In a specific implementation, referring to Figure 2 As shown, the preset network model includes a feature extraction module 110, a feature mapping module 120, a first fusion module 130, an attention module, a feature reconstruction module 150, a second fusion module 160, and a deep space module 170 connected in series in sequence, and an image processing module 180 connected in parallel with the feature extraction module 110, the feature mapping module 120, the first fusion module 130, the attention module and the feature reconstruction module 150. Among them, the first image is the input item of the feature extraction module 110, the output item of the feature extraction module 110 is the input item of the feature mapping module 120, the output item of the feature mapping module 120 and the output item of the feature extraction module 110 are the input items of the first fusion module 130, the output item of the first fusion module 130 is the input item of the attention module, the output item of the attention module is the input item of the feature reconstruction module 150, the first image is the input item of the image processing module 180, the output item of the image processing module 180 and the output item of the feature reconstruction module 150 are the input items of the second fusion module 160, and the output item of the second fusion module 160 is the input item of the depth space module 170.

[0100] Correspondingly, the step of outputting a first predicted image of the first image through the preset network model specifically includes: inputting the first image in the acquired training image set into the feature extraction module 110, performing feature extraction on the first image through the feature extraction module 110 to obtain a first feature map; inputting the first feature map into the feature mapping module 120, performing feature mapping on the first feature map through the feature mapping module 120 to obtain a mapping feature map; inputting the mapping feature map and the first feature map into the first fusion module 130, fusing the mapping feature map and the first feature map through the first fusion module 130 to obtain a first fused feature map; inputting the first fused feature map into the attention module, determining the weight map of the first fused feature map through the attention module, and The weight map is multiplied pixel by pixel by the first fused feature map to obtain an attention map; the attention map is input into the feature reconstruction module 150, and the feature reconstruction module 150 performs feature reconstruction on the attention map to obtain a reconstructed feature map; the first image is input into the image processing module 180, and the first image is processed by the image processing module 180 to obtain a processed feature map; the processed feature map and the reconstructed feature map are input into the second fusion module 160, and the processed feature map and the reconstructed feature map are fused by the second fusion module 160 to obtain a second fused feature map; the second fused feature map is input into the depth space module 170, and the second fused feature map is upsampled by the depth space module 170 to obtain a first predicted image of the first image.

[0101] The image processing module 180 is used to process the first image of the RGB three-channel into a processing feature map having the same number of channels as the reconstructed feature map. The image processing module 180 includes a plurality of image processing units. The number of the plurality of image processing units is N is the number of image processing units, and M is the number of channels of the reconstructed feature map. For example, when the reconstructed feature map is a 27-channel feature map, the image processing module includes 9 feature processing units, and the 9 feature processing units are used to process the first image of the three channels into a 27-channel processed feature map. The image processing module 180 enables the model to perform residual learning in the image domain, which can effectively improve the super-resolution effect of the model.

[0102] In a specific implementation, continue to refer to Figure 2 As shown, the feature extraction module 110 includes a cascaded second convolution unit 111 and a third convolution unit 112, the feature mapping module 120 includes a plurality of parameterization units 121, and the feature reconstruction module 150 includes a cascaded fourth convolution unit 151 and a fifth convolution unit 152. In a specific embodiment, the second convolution unit 111 and the fourth convolution unit 151 can be composed of 5×5Conv2D, and the third convolution unit 112 and the fifth convolution unit 152 can be composed of 1×1Conv2D. In a specific implementation, continue to refer to Figure 2As shown, the attention module includes a cascaded attention unit 141 and a first fusion unit 142, the first fusion feature map is the input item of the attention unit 141, the output item of the attention unit 141 and the first fusion feature map are the input items of the first fusion unit 142, the attention unit 141 is used to generate a weight map of the first fusion feature map, and the first fusion unit 142 is used to multiply the weight map by the first fusion feature map pixel by pixel. In a specific embodiment, the attention unit 141 can use 1×1Conv2D. The attention module enables the model to enhance the processing of the key parts of the image, making the processing effect of the key parts of the image more prominent.

[0103] Step S20: compress the basic model to obtain a compressed model.

[0104] In order to enable complex models to run on the hardware of terminal devices (e.g., mobile phones), existing methods usually reduce the model size by pruning the model. This model reduction method will greatly reduce the super-resolution effect. For example, when processing some high-frequency features, it will cause the super-resolution (SR) image to lose details. This embodiment can reduce the model by compressing the basic model without affecting the super-resolution effect of the model.

[0105] Specifically, Figure 4 As shown, the compression model in this embodiment includes a sixth convolutional layer 113, a seventh convolutional layer 122, a first fusion module 130, an attention module, an eighth convolutional layer 153, a second fusion module 160, a deep space module 170 connected in series in sequence, and an image processing module 180 connected in parallel with the sixth convolutional layer 113, the seventh convolutional layer 122, the first fusion module 130, the attention module and the eighth convolutional layer 153. Among them, the output item of the sixth convolutional layer 113 is the input item of the seventh convolutional layer 122, the output item of the seventh convolutional layer 122 and the output item of the sixth convolutional layer 113 are the input items of the first fusion module 130, the output item of the first fusion module 130 is the input item of the attention module, the output item of the attention module is the input item of the eighth convolutional layer 153, the input item of the sixth convolutional layer 113 is the input item of the image processing module 180, the output item of the image processing module 180 and the output item of the eighth convolutional layer 153 are the input items of the second fusion module 160, and the output item of the second fusion module 160 is the input item of the deep space module 170.

[0106] Combination Figure 2 and Figure 4As shown, the structure of the compression model obtained in this embodiment is basically the same as that of the basic model. The difference between the structure of the compression model and that of the basic model is that the compression model includes a sixth convolutional layer 113, multiple seventh convolutional layers 122 and an eighth convolutional layer 153. The sixth convolutional layer 113 is obtained by the compression feature extraction module 110, the multiple seventh convolutional layers 122 are obtained by compressing multiple parameterized units 121 in the basic model, and the eighth convolutional layer 153 is obtained by the compression feature reconstruction module 150.

[0107] In a specific implementation, step S20 includes:

[0108] Step S21, compressing the first convolution unit to obtain a first compression layer;

[0109] Step S22, adding the first compression layer to the pre-constructed matrix to obtain a second compression layer;

[0110] Step S23: Add the second compression layer to the pre-constructed second convolutional layer to obtain a compression model; wherein the second convolutional layer is constructed based on the first convolutional layer.

[0111] Continue to refer to Figure 2 As shown, the feature mapping module 120 of the preset network model includes a plurality of parameterization units 121. Since the preset network model has the same model structure as the basic model, the basic model also includes a plurality of parameterization units 121. Figure 3 As shown, the parameterization unit 121 includes a first convolution unit (a third convolution layer, a fourth convolution layer, and a fifth convolution layer connected in series), a first convolution layer 1211, a first fusion layer 1212, and a second fusion layer 1213. The first convolution unit is connected in parallel with the first convolution layer 1211. The input item of the first convolution unit is the input item of the first convolution layer 1211. The output item of the first convolution layer 1211 and the input item of the first convolution layer 1211 are the input items of the first fusion layer 1212. The output item of the first fusion layer 1212 and the output item of the first convolution unit are the input items of the second fusion layer 1213. In other words, the parameterization unit 121 includes three convolution layers connected in series (the third convolution layer, the fourth convolution layer, and the fifth convolution layer), a parallel convolution layer (the first convolution layer), and a residual connection. Among them, the first convolution layer 1211 can use a convolution kernel with a size of 1×1, a stride of 1, a padding of 1, an input channel of 28, and an output channel of 28.

[0112] In a specific implementation, compressing the basic model specifically compresses the parameterization unit 121 in the basic model. Specifically, the first convolution unit is first compressed to obtain a first compression layer, and then the first compression layer is added to a pre-constructed matrix to obtain a second compression layer, and finally the second compression layer is added to a pre-constructed second convolution layer to obtain a compressed model. That is to say, when the parameterization unit 121 is compressed in this embodiment, three convolution layers (the third convolution layer, the fourth convolution layer, and the fifth convolution layer) connected in series are first merged to obtain a first compression layer, and then the first compression layer is merged with the residual connection to obtain a second compression layer, and finally the second compression layer and the parallel convolution layer (the first convolution layer) are merged.

[0113] The matrix is ​​a pre-constructed multidimensional matrix with all zero parameters, and the matrix can be expressed as R(D, A, 3, 3), and the center point of its diagonal parameters ieR(0,0,1,1), R(1,1,1,1),..., R(i,i,1,1) is set to 1. The first compression layer is added to the pre-constructed matrix to realize the merging of the first compression layer and the residual connection. In a specific embodiment, the process of adding the first compression layer to the matrix can be expressed as: ER=E5+R, ER represents the second compression layer, E5 represents the first compression layer, and R represents the matrix.

[0114] The second convolution layer is a pre-constructed convolution layer with all zero parameters. The second convolution layer is constructed based on the first convolution layer. The value of the center point of each convolution in the second convolution layer is set to the convolution weight corresponding to the first convolution layer. The second compression layer and the second convolution layer are added together to realize the merging of the second compression layer and the first convolution layer. In a specific embodiment, the process of adding the second compression layer and the second convolution layer can be expressed as: ERP=ER+E6, ERP represents the convolution layer obtained after the second compression layer and the second convolution layer are added together (i.e., the seventh convolution layer), ER represents the second compression layer, and E6 represents the second convolution layer.

[0115] In a specific implementation, step S21 includes:

[0116] Step S211, performing position transformation on the convolution parameters of the third convolution layer to obtain a transformed third convolution layer;

[0117] Step S212, performing convolution processing on the transformed convolution parameters of the third convolution layer and the convolution parameters of the fourth convolution layer to obtain a third compression layer;

[0118] Step S213, performing position transformation on the convolution parameters of the third compression layer to obtain a transformed third compression layer;

[0119] Step S214: performing a convolution operation on the transformed convolution parameters of the third compression layer and the convolution parameters of the fifth convolution layer to obtain a first compression layer.

[0120] Continue to refer to Figure 3 As shown, the first convolution unit includes a third convolution layer 1214, a fourth convolution layer 1215 and a fifth convolution layer 1216 which are cascaded in sequence. When compressing the first convolution unit, the third convolution layer 1214 and the fourth convolution layer 1215 are firstly compressed to obtain a third compressed layer, and then the third compressed layer and the fifth convolution layer 1216 are compressed to obtain a first compressed layer. In a specific embodiment, the third convolutional layer 1214 can adopt a convolution kernel with a size of 1×1, a stride of 1, a padding of 1, an input channel of 28, and an output channel of 256; the fourth convolutional layer 1215 can adopt a convolution kernel with a size of 3×3, a stride of 1, a padding of 0, an input channel of 256, and an output channel of 256; the fifth convolutional layer 1216 can adopt a convolution kernel with a size of 1×1, a stride of 1, a padding of 1, an input channel of 256, and an output channel of 28.

[0121] In a specific implementation, when the third convolutional layer 1214 and the fourth convolutional layer 1215 are compressed to obtain the third compressed layer, the convolution parameters of the third convolutional layer 1214 are first transformed to obtain the transformed third convolutional layer, and then the convolution parameters of the transformed third convolutional layer and the convolution parameters of the fourth convolutional layer 1215 are convolved to obtain the third compressed layer. When the convolution parameters of the third convolutional layer are transformed, the input channel and the output channel of the third convolutional layer are specifically exchanged. This process can be expressed as E1(B, A, 1, 1) → E1(A, B, 1, 1), where E1(B, A, 1, 1) represents the third convolutional layer, E1(A, B, 1, 1) represents the transformed third convolutional layer, and A and B represent the input channel and output channel of the third convolutional layer, respectively. The convolution parameters of the transformed third convolutional layer and the convolution parameters of the fourth convolutional layer are convolved to obtain the third compressed layer. Transpose(E1) represents the transformed third convolutional layer, E2 represents the fourth convolutional layer, E2 can be expressed as E2(C,B,3,3), B and C represent the input channel and output channel of the fourth convolutional layer respectively, E3 represents the third compression layer, A and C represent the input channel and output channel of the third compression layer respectively.

[0122] In a specific implementation, when compressing the third compression layer and the fifth convolution layer 1216 to obtain the first compression layer, the convolution parameters of the third compression layer are first transformed to obtain the transformed third compression layer, and then the convolution parameters of the transformed third compression layer and the convolution parameters of the fifth convolution layer 1216 are convolved to obtain the first compression layer. When the convolution parameters of the third compression layer are transformed, the input channel and the output channel of the third compression layer are specifically exchanged. This process can be expressed as E3(C, A, 3, 3) → E3(A, C, 3, 3), where E3(C, A, 3, 3) represents the third compression layer, E3(A, C, 3, 3) represents the transformed third compression layer, and A and C represent the input channel and output channel of the third compression layer, respectively. The convolution parameters of the transformed third compression layer and the convolution parameters of the fifth convolution layer are convolved as follows: Transpose(E3) represents the transformed third compression layer, E4 represents the fifth convolutional layer, and E4 can be expressed as E4(D,C,3,3), where C and D represent the input channel and output channel of the fifth convolutional layer, respectively. E5 represents the first compression layer, and A and D represent the input channel and output channel of the first compression layer, respectively.

[0123] In a specific implementation, in addition to compressing the parameterization module 121, the feature extraction module 110 may also be compressed. Figure 2 and Figure 4 As shown, when the second convolution unit 111 and the third convolution unit 112 use a convolution layer, the second convolution unit 111 and the third convolution unit 112 can be combined into one convolution layer ( Figure 4 The merging process of the sixth convolutional layer 113 in the figure can refer to the merging process of the third convolutional layer 1214, the fourth convolutional layer 1215 and the fifth convolutional layer 1216, which will not be described in detail in this application.

[0124] In addition, combined Figure 2 and Figure 4 As shown, when the fourth convolution unit 151 and the fifth convolution unit 152 use a convolution layer, the fourth convolution unit 151 and the fifth convolution unit 152 can also be combined into one convolution layer ( Figure 4 The merging process of the eighth convolutional layer 153) can refer to the merging process of the third convolutional layer 1214, the fourth convolutional layer 1215 and the fifth convolutional layer 1216, which will not be described in detail in this application.

[0125] Step S30: Perform quantization training on the compression model to obtain a quantized trained compression model.

[0126] Quantization training refers to the process of further training the model before quantization by simulating the quantization process of the quantized model on the terminal side with the model before quantization. Considering that the model will cause precision loss after quantization, for example, the conventional 32-bit floating-point operation is converted to 8bit (also called int8 quantization), and the integer value represented by the int8 model is discontinuous, unlike the 32-bit (float32) floating-point model which can represent continuous values, which will cause precision loss. After obtaining the compression model in this embodiment, the compression model is quantized and trained so that the obtained model can adapt to the discontinuous distribution, and the precision loss of the model can be reduced when it is deployed on the terminal device (for example, the mobile phone).

[0127] In a specific implementation, step S30 includes:

[0128] Step S31, obtaining first input data of a layer to be quantized; wherein the first input data is data of a first data type, and the number of bits occupied by the first input data is a first number of bits;

[0129] Step S32, performing a quantization operation on the first input data to obtain second input data of a second data type; wherein the number of bits occupied by the second input data is a second number of bits, and the second number of bits is less than the first number of bits;

[0130] Step S33, inputting the second input data into the to-be-quantized layer, and outputting first output data of the second data type through the to-be-quantized layer;

[0131] Step S34, performing an inverse quantization operation on the first output data to obtain second output data of the first data type;

[0132] Step S35: Perform quantization training on the compression model based on the second output data to obtain a quantized trained compression model.

[0133] The compression model includes a layer to be quantized, and the layer to be quantized is any one or more layers in the compression model. For example, the layer to be quantized can be the sixth convolution layer 113, the seventh convolution layer 122, the first fusion module 130, the attention unit 141, the eighth convolution layer 153, the deep space module 170, etc. in the compression model. Quantization processing refers to converting data of a first data type into data of a second data type, and dequantization processing refers to converting data of a second data type into data of a first data type.

[0134] The first data type and the second data type may include but are not limited to float32 type, float64 type, int8 type, int16 type, int32 type, etc. For example, the first data type is float32 type and the second data type is int8 type, or the first data type is float64 type and the second data type is int8 type, etc.

[0135] In order to reduce the precision loss in the quantization process of the compression model, this embodiment simulates the quantization process of the compression model during the compression model training process. Specifically, the first input data of the first data type of the layer to be quantized is obtained, and then a quantization operation is performed on the first input data to obtain the second input data of the second data type, and then the second input data is input into the layer to be quantized, and the first output data of the second data type is output through the layer to be quantized, and then a dequantization operation is performed on the first output data to obtain the second output data of the first data type, and finally the compression model is quantized and trained based on the second output data to obtain a quantized model. This embodiment performs quantization and dequantization operations on the input data and output data of the layer to be quantized, and can run the forward pass at low precision to train the compression model, but keep the reverse pass at full precision, so that the parameters of the compression model can be accurately adjusted to minimize the effect loss caused by quantization.

[0136] In a specific implementation, the TensorFlow Keras model optimization (tfmot) toolkit can be used to perform quantization training on the compression model. During quantization training, due to the need to follow the specifications required by TensorFlow Keras, there will be some layers in the compression model that cannot be quantized by the toolkit, such as the depth_to_space and clip layers created by the Lambda layer. For these layers that cannot be quantized by the toolkit, before the entire model is quantized, these layers can be quantized separately from the layers in the model that can be quantized by the toolkit.

[0137] In a specific implementation, step S35 includes:

[0138] Step S351: determining a second predicted image of the first image output by the compression model based on the second output data;

[0139] Step S352: determining a third loss value and a fourth loss value based on the second predicted image and the second image; wherein the third loss value is used to characterize the similarity between the second predicted image and the second image, and the fourth loss value is used to characterize the sharpness of the image edge of the second predicted image;

[0140] Step S353: Perform quantization training on the compression model based on the third loss value and the fourth loss value to obtain the compression model after quantization training.

[0141] The second predicted image is a high resolution (HR) image of the first image predicted by the compression model, the third loss value is used to characterize the similarity between the second predicted image and the second image, and the fourth loss value is used to characterize the sharpness of the image edge of the second predicted image.

[0142] In a specific implementation, the compression model is quantized and trained through a training image set. Accordingly, the step of quantizing and training the compression model based on the second output data specifically includes: determining the second predicted image of the first image output by the compression model based on the second output data; determining the third loss value and the fourth loss value based on the second predicted image and the second image; and quantizing and training the compression model based on the third loss value and the fourth loss value to obtain the quantized and trained compression model. This embodiment trains the preset network model based on the first loss value and the second loss value, so that the trained model can process the image edge more carefully, and the processed image has a higher sharpening effect.

[0143] Among them, the calculation formula of the third loss value is: in, and Respectively represent the pixel mean and pixel variance of the second predicted image, and denote the pixel mean and pixel variance of the second image respectively, represents the pixel covariance between the second predicted image and the second image, and c3 and c4 are preset very small constants used to ensure the stability of the values.

[0144] The calculation formula of the fourth loss value is: represents the gradient field of the second predicted image, represents the gradient field of the second image.

[0145] In one implementation of this embodiment, when the preset network model is trained based on the third loss value and the fourth loss value, the second target loss value is first determined based on the third loss value and the fourth loss value. When the second target loss value does not meet the preset condition, the model parameters of the compression model are corrected based on the preset second parameter learning rate, and the step of determining the second predicted image of the first image output by the compression model based on the second output data is continued until the second target loss value meets the preset second condition. The second target loss value meeting the preset second condition may be that the second target loss value is less than the preset third threshold, or the difference between the second target loss values ​​obtained twice before and after is less than the preset fourth threshold.

[0146] In one implementation of this embodiment, the calculation formula of the second target loss value is: L2 = α4L ssim2 +α5L GGP2 , where L2 represents the second target loss value, L ssim2 Represents the third loss value, L GGP2 represents the fourth loss value, α4 and α5 represent weights, and α4 and α5 can be set as needed. For example, α4 and α5 can be set to 1 and 0.001, respectively.

[0147] Step S40: Perform post-training quantization on the quantized trained compression model to obtain a target model.

[0148] Post-training quantization refers to converting high-precision operations in the model to low-precision standards for operation, such as converting model operations based on 32-bit floating point numbers float32 to model operations based on 8-bit integers int8. Compared with unquantized models, it can reduce model size and storage space and speed up model reasoning. For example, int8 quantization can reduce model size by 75%.

[0149] In a specific implementation, when performing post-training quantization on the compression model after quantization training, representative data can be screened out from the training image set as a representative image set, and the model can be verified using the representative image set. After post-training quantization, the operator, input, and output types of the target model can be converted from float32 type to int8 type, thereby reducing the running time and memory of the model on the terminal device, allowing the model to be more efficiently hardware accelerated.

[0150] In a specific embodiment, TFLiteConverter can be used to complete the post-training quantization process. By completing the post-training quantization process with TFLiteConverter, the model can be quantized in the same step and exported as a fully quantized TFLite model, thereby facilitating the deployment of the model on the terminal device.

[0151] In order to better implement the model generation method in the embodiment of the present application, based on the model generation method, the embodiment of the present application also provides a model generation device, such as Figure 5 As shown, the model generating device comprises:

[0152] A model training unit 710 is used to train a preset network model based on the acquired training image set to obtain a basic model;

[0153] A model compression unit 720, used to compress the basic model to obtain a compressed model;

[0154] A quantization training unit 730 is used to perform quantization training on the compression model to obtain a quantized trained compression model;

[0155] The model quantization unit 740 is used to perform post-training quantization on the compression model after quantization training to obtain a target model.

[0156] In the embodiment of the present application, compressing the basic model can reduce the amount of calculation and complexity of the model, and quantizing the compressed model and quantizing it after training can further reduce the model size and storage space. The generated target model can be hardware accelerated on the terminal device, which can effectively improve the calculation speed of the target model while maintaining the high-quality super-resolution effect of the model.

[0157] In some embodiments of the present application, the preset network model includes a feature extraction module, a feature mapping module, a first fusion module, an attention module, a feature reconstruction module, a second fusion module, and a deep space module connected in series, and an image processing module connected in parallel with the feature extraction module, the feature mapping module, the first fusion module, the attention module, and the feature reconstruction module;

[0158] The output item of the feature extraction module is the input item of the feature mapping module, the output item of the feature mapping module and the output item of the feature extraction module are the input items of the first fusion module, the output item of the first fusion module is the input item of the attention module, the output item of the attention module is the input item of the feature reconstruction module, the input item of the feature extraction module is the input item of the image processing module, the output item of the image processing module and the output item of the feature reconstruction module are the input items of the second fusion module, and the output item of the second fusion module is the input item of the deep space module.

[0159] In some embodiments of the present application, the training image set includes multiple training image groups, each training image group includes a first image and a second image having the same image content, and the resolution of the second image is greater than the resolution of the first image. The model training unit 710 is specifically used to:

[0160] Inputting a first image in the acquired training image set into a preset network model, and outputting a first predicted image of the first image through the preset network model;

[0161] Determining a first loss value and a second loss value based on the first predicted image and the second image; wherein the first loss value is used to characterize the similarity between the first predicted image and the second image, and the second loss value is used to characterize the sharpness of the image edge of the first predicted image;

[0162] The preset network model is trained based on the first loss value and the second loss value to obtain a basic model.

[0163] In some embodiments of the present application, the model training unit 710 is further used to:

[0164] Inputting the first image in the acquired training image set into the feature extraction module, performing feature extraction on the first image through the feature extraction module to obtain a first feature map;

[0165] Inputting the first feature map into a feature mapping module, and performing feature mapping on the first feature map through the feature mapping module to obtain a mapping feature map;

[0166] Inputting the mapping feature map and the first feature map into a first fusion module, and fusing the mapping feature map and the first feature map through the first fusion module to obtain a first fused feature map;

[0167] Input the first fused feature map into the attention module, generate a weight map of the first fused feature map through the attention module, and multiply the weight map by the first fused feature map pixel by pixel to obtain an attention map;

[0168] The attention map is input into the feature reconstruction module, and the feature reconstruction module is used to reconstruct the features of the attention map to obtain a reconstructed feature map;

[0169] Inputting the first image into the image processing module, processing the first image through the image processing model to obtain a processed feature map; wherein the number of channels of the processed feature map is the same as the number of channels of the reconstructed feature map;

[0170] Inputting the processed feature map and the reconstructed feature map into a second fusion module, and fusing the processed feature map and the reconstructed feature map through the second fusion module to obtain a second fused feature map;

[0171] The second fused feature map is input into the deep space module, and the second fused feature map is upsampled by the deep space module to obtain a first predicted image of the first image.

[0172] In some embodiments of the present application, the basic model includes a parameterized unit, the parameterized unit includes a first convolution unit, a first convolution layer, a first fusion layer and a second fusion layer, the first convolution unit is connected in parallel with the first convolution layer, the input item of the first convolution unit is the input item of the first convolution layer, the output item of the first convolution layer and the input item of the first convolution layer are the input items of the first fusion layer, and the output item of the first fusion layer and the output item of the first convolution unit are the input items of the second fusion layer;

[0173] The first convolution unit includes a third convolution layer, a fourth convolution layer and a fifth convolution layer, the output item of the third convolution layer is the fourth convolution layer, and the output item of the fourth convolution layer is the input item of the fifth convolution layer.

[0174] In some embodiments of the present application, the model compression unit 720 is specifically used to:

[0175] Compressing the first convolution unit to obtain a first compression layer;

[0176] Adding the first compression layer to the pre-constructed matrix to obtain a second compression layer;

[0177] The second compression layer is added to the pre-constructed second convolutional layer to obtain a compression model; wherein the second convolutional layer is constructed based on the first convolutional layer.

[0178] In some embodiments of the present application, the model compression unit 720 is further used to:

[0179] Transforming the position of the convolution parameters of the third convolutional layer to obtain a transformed third convolutional layer;

[0180] Convolution processing is performed on the transformed convolution parameters of the third convolution layer and the convolution parameters of the fourth convolution layer to obtain a third compression layer;

[0181] Transforming the position of the convolution parameters of the third compression layer to obtain a transformed third compression layer;

[0182] A convolution operation is performed on the transformed convolution parameters of the third compression layer and the convolution parameters of the fifth convolution layer to obtain a first compression layer.

[0183] In some embodiments of the present application, the compression model includes a sixth convolutional layer, a seventh convolutional layer, a first fusion module, an attention module, an eighth convolutional layer, a second fusion module, a deep space module connected in series in sequence, and an image processing module connected in parallel with the sixth convolutional layer, the seventh convolutional layer, the first fusion module, the attention module and the eighth convolutional layer;

[0184] The output item of the sixth convolutional layer is the input item of the seventh convolutional layer, the output item of the seventh convolutional layer and the output item of the sixth convolutional layer are the input items of the first fusion module, the output item of the first fusion module is the input item of the attention module, the output item of the attention module is the input item of the eighth convolutional layer, the input item of the sixth convolutional layer is the input item of the image processing module, the output item of the image processing module and the output item of the eighth convolutional layer are the input items of the second fusion module, and the output item of the second fusion module is the input item of the deep space module.

[0185] In some embodiments of the present application, the compression model includes a layer to be quantized, and the model quantization unit 730 is specifically used to:

[0186] Acquire first input data of the layer to be quantized; wherein the first input data is data of a first data type, and the number of bits occupied by the first input data is a first number of bits;

[0187] Performing a quantization operation on the first input data to obtain second input data of a second data type; wherein the number of bits occupied by the second input data is a second number of bits, and the second number of bits is less than the first number of bits;

[0188] Inputting the second input data into the to-be-quantized layer, and outputting first output data of the second data type through the to-be-quantized layer;

[0189] Performing a dequantization operation on the first output data to obtain second output data of the first data type;

[0190] The compression model is quantized and trained based on the second output data to obtain a quantized and trained compression model.

[0191] In some embodiments of the present application, the compression model is quantized and trained by a training image set, and the model quantization unit 730 is further used to:

[0192] Determine a second predicted image of the first image output by the compression model based on the second output data;

[0193] Determining a third loss value and a fourth loss value based on the second predicted image and the second image; wherein the third loss value is used to characterize the degree of similarity between the second predicted image and the second image, and the fourth loss value is used to characterize the degree of sharpness of the image edge of the second predicted image;

[0194] The compression model is quantized and trained based on the third loss value and the fourth loss value to obtain a quantized and trained compression model.

[0195] The embodiment of the present application further provides a computer device, which integrates any one of the model generation devices provided in the embodiment of the present application, and the computer device includes:

[0196] one or more processors;

[0197] Memory; and

[0198] One or more applications, wherein the one or more applications are stored in a memory and are configured to execute, by a processor, the steps of the model generation method in any of the above-mentioned model generation method embodiments.

[0199] The present application also provides a computer device that integrates any model generation device provided in the present application. Figure 6 As shown, it shows a schematic diagram of the structure of the computer device involved in the embodiment of the present application, specifically:

[0200] The computer device may include one or more processing core processors 801, one or more computer-readable storage media memories 802, a power supply 803, an input unit 804 and other components. Those skilled in the art will appreciate that Figure 6 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:

[0201] The processor 801 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. By running or executing software programs and / or modules stored in the memory 802 and calling data stored in the memory 802, it executes various functions of the computer device and processes data, thereby monitoring the computer device as a whole. Optionally, the processor 801 may include one or more processing cores; preferably, the processor 801 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 801.

[0202] The memory 802 can be used to store software programs and modules. The processor 801 executes various functional applications and data processing by running the software programs and modules stored in the memory 802. The memory 802 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 802 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 802 may also include a memory controller to provide the processor 801 with access to the memory 802.

[0203] The computer device also includes a power supply 803 for supplying power to each component. Preferably, the power supply 803 can be logically connected to the processor 801 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions. The power supply 803 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.

[0204] The computer device may further include an input unit 804, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.

[0205] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 801 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 802 according to the following instructions, and the processor 801 will run the application programs stored in the memory 802, thereby realizing various functions, as follows:

[0206] The preset network model is trained based on the acquired training image set to obtain a basic model;

[0207] Compress the basic model to obtain a compressed model;

[0208] Performing quantization training on the compression model to obtain a quantized trained compression model;

[0209] The compressed model after quantization training is quantized after training to obtain the target model.

[0210] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0211] To this end, an embodiment of the present application provides a computer-readable storage medium, which may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc. A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in any model generation method provided in the embodiment of the present application. For example, the computer program can be loaded by a processor to execute the following steps:

[0212] The preset network model is trained based on the acquired training image set to obtain a basic model;

[0213] Compress the basic model to obtain a compressed model;

[0214] Performing quantization training on the compression model to obtain a quantized trained compression model;

[0215] The compressed model after quantization training is quantized after training to obtain the target model.

[0216] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the detailed description of other embodiments above, and will not be repeated here.

[0217] In specific implementation, the above units or structures can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units or structures can refer to the previous method embodiments, which will not be repeated here.

[0218] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.

[0219] The above is a detailed introduction to a model generation method, device, computer equipment and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A model generation method, characterized in that: include: The preset network model is trained based on the acquired training image set to obtain a basic model; Compressing the basic model to obtain a compressed model; Performing quantization training on the compression model to obtain a quantized trained compression model; The compression model after quantization training is quantized to obtain a target model.

2. The method according to claim 1, characterized in that The preset network model includes a feature extraction module, a feature mapping module, a first fusion module, an attention module, a feature reconstruction module, a second fusion module, and a deep space module connected in series in sequence, and an image processing module connected in parallel with the feature extraction module, the feature mapping module, the first fusion module, the attention module, and the feature reconstruction module; The output item of the feature extraction module is the input item of the feature mapping module, the output item of the feature mapping module and the output item of the feature extraction module are the input items of the first fusion module, the output item of the first fusion module is the input item of the attention module, the output item of the attention module is the input item of the feature reconstruction module, the input item of the feature extraction module is the input item of the image processing module, the output item of the image processing module and the output item of the feature reconstruction module are the input items of the second fusion module, and the output item of the second fusion module is the input item of the depth space module.

3. The method according to claim 2, characterized in that The training image set includes a plurality of training image groups, each of the training image groups includes a first image and a second image having the same image content, and a resolution of the second image is greater than a resolution of the first image; The method of training a preset network model based on the acquired training image set to obtain a basic model includes: Inputting a first image in the acquired training image set into a preset network model, and outputting a first predicted image of the first image through the preset network model; Determine a first loss value and a second loss value based on the first predicted image and the second image; wherein the first loss value is used to characterize the similarity between the first predicted image and the second image, and the second loss value is used to characterize the sharpness of the image edge of the first predicted image; Training the preset network model based on the first loss value and the second loss value to obtain a basic model; The step of inputting a first image from the acquired training image set into a preset network model and outputting a first predicted image of the first image through the preset network model comprises: Inputting a first image in the acquired training image set into the feature extraction module, and performing feature extraction on the first image by the feature extraction module to obtain a first feature map; Inputting the first feature map into the feature mapping module, and performing feature mapping on the first feature map by the feature mapping module to obtain a mapping feature map; Inputting the mapping feature map and the first feature map into the first fusion module, and fusing the mapping feature map and the first feature map through the first fusion module to obtain a first fused feature map; Inputting the first fused feature map into the attention module, generating a weight map of the first fused feature map through the attention module, and multiplying the weight map by the first fused feature map pixel by pixel to obtain an attention map; Inputting the attention map into the feature reconstruction module, and performing feature reconstruction on the attention map through the feature reconstruction module to obtain a reconstructed feature map; Inputting the first image into the image processing module, and processing the first image through the image processing module to obtain a processed feature map; wherein the number of channels of the processed feature map is the same as the number of channels of the reconstructed feature map; Inputting the processed feature map and the reconstructed feature map into the second fusion module, and fusing the processed feature map and the reconstructed feature map through the second fusion module to obtain a second fused feature map; The second fused feature map is input into the deep space module, and the second fused feature map is upsampled by the deep space module to obtain a first predicted image of the first image.

4. The method according to claim 1, characterized in that: The basic model includes a parameterized unit, the parameterized unit includes a first convolution unit, a first convolution layer, a first fusion layer and a second fusion layer, the first convolution unit is connected in parallel with the first convolution layer, the input item of the first convolution unit is the input item of the first convolution layer, the output item of the first convolution layer and the input item of the first convolution layer are the input items of the first fusion layer, and the output item of the first fusion layer and the output item of the first convolution unit are the input items of the second fusion layer; The first convolution unit includes a third convolution layer, a fourth convolution layer and a fifth convolution layer, the output item of the third convolution layer is the fourth convolution layer, and the output item of the fourth convolution layer is the input item of the fifth convolution layer.

5. The method according to claim 4, characterized in that The step of compressing the basic model to obtain a compressed model includes: Compressing the first convolution unit to obtain a first compression layer; Adding the first compression layer to a pre-constructed matrix to obtain a second compression layer; Adding the second compression layer to the pre-constructed second convolutional layer to obtain a compression model; wherein the second convolutional layer is constructed based on the first convolutional layer; The compressing the first convolution unit to obtain a first compression layer includes: Transforming the position of the convolution parameters of the third convolutional layer to obtain a transformed third convolutional layer; Performing convolution processing on the transformed convolution parameters of the third convolution layer and the convolution parameters of the fourth convolution layer to obtain a third compression layer; Transforming the position of the convolution parameters of the third compression layer to obtain a transformed third compression layer; A convolution operation is performed on the transformed convolution parameters of the third compression layer and the convolution parameters of the fifth convolution layer to obtain a first compression layer.

6. The method according to claim 1, characterized in that The compression model includes a sixth convolutional layer, a seventh convolutional layer, a first fusion module, an attention module, an eighth convolutional layer, a second fusion module, a deep space module connected in series in sequence, and an image processing module connected in parallel with the sixth convolutional layer, the seventh convolutional layer, the first fusion module, the attention module and the eighth convolutional layer; The output item of the sixth convolutional layer is the input item of the seventh convolutional layer, the output item of the seventh convolutional layer and the output item of the sixth convolutional layer are input items of the first fusion module, the output item of the first fusion module is the input item of the attention module, the output item of the attention module is the input item of the eighth convolutional layer, the input item of the sixth convolutional layer is the input item of the image processing module, the output item of the image processing module and the output item of the eighth convolutional layer are input items of the second fusion module, and the output item of the second fusion module is the input item of the deep space module.

7. The method according to claim 3, characterized in that The compression model includes a layer to be quantized, and the quantization training is performed on the compression model to obtain the compression model after quantization training, including: Acquire first input data of the layer to be quantized; wherein the first input data is data of a first data type, and the number of bits occupied by the first input data is a first number of bits; Performing a quantization operation on the first input data to obtain second input data of a second data type; wherein the number of bits occupied by the second input data is a second number of bits, and the second number of bits is less than the first number of bits; Inputting the second input data into the to-be-quantized layer, and outputting first output data of the second data type through the to-be-quantized layer; Performing a dequantization operation on the first output data to obtain second output data of the first data type; Performing quantization training on the compression model based on the second output data to obtain a quantized trained compression model; The compression model is quantized and trained by the training image set, and the compression model is quantized and trained based on the second output data to obtain the compression model after quantization training, including: Determining a second predicted image of the first image output by the compression model based on the second output data; Determining a third loss value and a fourth loss value based on the second predicted image and the second image; wherein the third loss value is used to characterize the degree of similarity between the second predicted image and the second image, and the fourth loss value is used to characterize the degree of sharpness of the image edge of the second predicted image; The compression model is quantized and trained based on the third loss value and the fourth loss value to obtain a quantized and trained compression model.

8. A model generation device, characterized in that: include: A model training unit, used to train a preset network model based on the acquired training image set to obtain a basic model; A model compression unit, used for compressing the basic model to obtain a compressed model; A quantization training unit, used to perform quantization training on the compression model to obtain a quantized trained compression model; The model quantization unit is used to perform post-training quantization on the compression model after quantization training to obtain a target model.

9. A computer device, characterized in that: The computer device comprises: one or more processors; Memory; and One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to implement the model generation method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the model generation method according to any one of claims 1 to 7.