Image Compression Method, Device, Electronic Device and Storage Medium
By building a neural network structure with preset image compression model and multi-task learning, the image codec networks, solving the problem of time-consuming image codecs and achieving efficient image compression.
Patent Information
- Application Number
- CN202210515370.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-11
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2042-05-11
AI Technical Summary
Existing image codecs such as Guetzli encoders take a long time during image compression and have a large CPU requirement, which cannot meet online needs.
By building a preset image compression model, using the neural network structure of multi-task learning, the image codec is networked to achieve efficient processing of the image compression model.
The networking of image codecs is realized, the efficiency of image compression is improved, processing time and memory requirements are reduced, and the efficiency of image compression is improved.
Smart Images

Figure CN114979665B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of artificial intelligence technology, and in particular to an image compression method, device, electronic device, and storage medium. Background Art
[0002] The algorithm implementation process of the Guetzli encoder is an iterative optimization process of the target processed image. During the image compression process, visual information is retained as much as possible, and encoded images with minimal quality loss and a compression rate of 20-30% can be obtained.
[0003] However, when processing images, the Guetzli encoder needs to explore the optimal solution in an iterative process, which is time-consuming. Especially for large images, the Guetzli encoding and decoding process has high CPU requirements, which is not only time-consuming but also occupies a large amount of memory. As a result, in actual applications, it cannot meet online needs. Summary of the Invention
[0004] The present disclosure provides an image compression method, device, electronic device and storage medium to realize the networking of a preset image codec and more efficiently achieve the image compression effect of the preset image codec.
[0005] In a first aspect, an embodiment of the present disclosure provides an image compression method, the method comprising:
[0006] Get the image to be compressed;
[0007] Inputting the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed;
[0008] The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec.
[0009] In a second aspect, an embodiment of the present disclosure further provides an image compression device, the device comprising:
[0010] An image acquisition module, used for acquiring an image to be compressed;
[0011] An image compression module, configured to input the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed;
[0012] The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec.
[0013] In a third aspect, an embodiment of the present disclosure further provides an electronic device, the electronic device comprising:
[0014] one or more processors;
[0015] a storage device for storing one or more programs,
[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the image compression method as described in any one of the embodiments of the present disclosure.
[0017] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium comprising computer-executable instructions, wherein the computer-executable instructions, when executed by a computer processor, are used to execute the image compression method as described in any one of the embodiments of the present disclosure.
[0018] In an embodiment of the present disclosure, after acquiring an image to be compressed, the image to be compressed is input into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed; wherein the preset image compression model is a model generated by training a sample set consisting of sample pairs consisting of original sample images and compressed images after compression processing of each original sample image by a preset image codec. Then, the preset image compression model correspondingly has the image compression function of the preset image codec, solves the problem that the image codec takes a long time to perform image compression processing, realizes the networking of the preset image codec, and can improve the efficiency of image compression. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and other features, advantages, and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale.
[0020] Figure 1 This is a flowchart of an image compression method provided by an embodiment of the present disclosure;
[0021] Figure 2 This is a flowchart of an image compression method provided by an embodiment of the present disclosure;
[0022] Figure 3 This is a schematic diagram of a preset image compression network structure provided by an embodiment of the present disclosure;
[0023] Figure 4 This is a schematic diagram of a preset image compression network structure provided by an embodiment of the present disclosure;
[0024] Figure 5This is a flowchart of an image compression method provided by an embodiment of the present disclosure;
[0025] Figure 6 This is a schematic diagram of the entire image compression model training process provided by an embodiment of the present disclosure;
[0026] Figure 7 This is a flowchart of an image compression method provided by an embodiment of the present disclosure;
[0027] Figure 8 This is a schematic diagram of image distortion after compression provided by an embodiment of the present disclosure;
[0028] Figure 9 This is a schematic diagram of the entire image compression model training process provided by an embodiment of the present disclosure;
[0029] Figure 10 is a structural diagram of an image compression device provided by an embodiment of the present disclosure;
[0030] Figure 11 It is a structural diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0032] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0033] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0034] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0035] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0036] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0037] It is understandable that the data involved in this technical solution (including but not limited to the data itself, the acquisition or use of the data) must comply with the requirements of relevant laws, regulations and relevant provisions.
[0038] Figure 1 This is a flow chart of an image compression method provided in an embodiment of the present disclosure. The embodiment of the present disclosure is applicable to situations where image compression processing is performed. The method can be performed by an image compression device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, PC or server, etc.
[0039] like Figure 1 As shown, the image compression method includes:
[0040] S110: Obtain an image to be compressed.
[0041] The image to be compressed can be any image that requires compression in any scenario. For example, in social media applications, when images need to be compressed before transmission, the image to be compressed must first be compressed until it meets the preset image size transmission standard before further image transmission or interaction can be achieved.
[0042] S120: Input the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed.
[0043] Among them, the model training sample pairs of the preset image compression model include original sample images and compressed sample images, and the compressed sample images are images obtained by compressing the original sample images using the preset image codec. That is, the preset image compression model is a model generated by training a sample set composed of preset model training sample pairs. The preset image compression model is the networking result of the preset image codec, has the image compression function of the preset image encoder, and can achieve the same image compression effect as the preset image encoder. Therefore, the preset image compression model can quickly and efficiently realize image compression, overcoming the shortcomings of low timeliness and high memory requirements of the preset image codec for online use. Specifically, the preset image codec can be any image codec in the field of image compression, such as Guetzli, HEVC or Webp image codecs.
[0044] In an optional embodiment, a preset image compression model includes an image preprocessing module, an image compression module, and an image integration module. During the compression process of an image to be compressed by the preset image compression model, the image preprocessing module first performs image preprocessing on the image to be compressed to obtain multiple sub-image blocks of a preset size. This is because the sizes of images to be compressed uploaded by different users vary significantly, and there is no fixed image size for different device models and image compression scenarios. Therefore, the image preprocessing process first pads the edges of the image to be compressed to obtain an image of a target size. The target size refers to an image that can be cut to a preset size, meaning that the target size is an integer multiple of the preset size in the corresponding dimension. The target sizes of different images to be processed may be the same or different. The edge-padded target size image is then cut to the preset size to obtain one or more sub-image blocks of the preset size. This ensures that the image input to the image compression module is a sub-image block of uniform size. After obtaining the one or more sub-image blocks corresponding to the image to be compressed, each sub-image block is input into the preset image compression neural network of the image compression module for image compression, obtaining the corresponding sub-image compression result. Finally, the image integration module performs image splicing on the compression results of each sub-image to obtain a target compressed image with the same image compression effect as that of the preset image codec.
[0045] It can be understood that a bitmap image is a collection of pixels, whose basic unit is a pixel, and the representation format of each pixel information is usually expressed in RGB or YUV. Different image codecs will process the image based on pixel information of different representation formats when encoding and decoding the image. Therefore, when using a pre-trained preset image compression model for image compression, it is necessary to consider whether the image to be compressed is consistent with the image pixel information representation format adapted by the preset image compression model. That is, before the image to be compressed is input into the preset image compression model, when the first pixel information representation format of the image to be compressed is different from the second pixel information representation format adapted to the preset image compression model, the pixel information representation format of the image to be compressed is converted to the second pixel information representation format; accordingly, after obtaining the target compressed image, the pixel information representation format of the target compressed image is also converted to the first pixel information representation format; wherein the second pixel information representation format is the pixel information representation format adapted to the preset image codec. For example, the Guetzli codec performs image processing based on YUV information of image pixels. The input image to the pre-set image codec obtained by networking the Guetzli codec is pixel information represented in YUV format. If the pixel information of the image to be compressed is represented in RGB format, a pixel information format conversion is required.
[0046] The technical solution of the embodiment of the present disclosure is as follows: after obtaining the image to be compressed, the pixel representation format of the image to be compressed is converted into a pixel representation format corresponding to a preset image codec; then, the image to be compressed after format conversion is input into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed; wherein the preset image compression model is a model generated by training a sample set consisting of sample pairs consisting of each original sample image and a compressed image after each original sample image is compressed by a preset image codec, then the preset image compression model correspondingly has the image compression function of the preset image codec, solves the problem of long time spent on image compression processing by the image codec, realizes the networking of the preset image codec, and can improve the efficiency of image compression.
[0047] Figure 2 This is a flow chart of another image compression method provided by an embodiment of the present disclosure. In the process of implementing this method flow, the training process of the image compression model is further described, and the structure of the model is introduced in detail. The specific technical content of this image compression method can be combined with the above-mentioned image compression method. The method can be performed by an image compression device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC, or a server.
[0048] like Figure 2 As shown, the image compression method includes:
[0049] S210. Acquire multiple original sample images, and input each of the original sample images into a preset image codec to obtain a corresponding paired compressed image. Each of the original sample images and the corresponding paired compressed image is used as a set of sample pairs to obtain a first sample set.
[0050] The original sample images can be images collected in various application scenarios, such as avatars, video cover images, and images from various theme collections. Each original sample image is usually stored in a lossless compression format (such as PNG). Furthermore, each original sample image is input into a preset image codec to obtain the corresponding compressed image, forming a corresponding sample pair. The preset image codec is the target image codec for networking.
[0051] S220: Train an image compression model based on the first sample set to obtain a first image compression model.
[0052] The image compression model is trained, that is, the preset image compression neural network of the image compression module in the image compression model is trained. In an optional embodiment, the structure of the preset image compression neural network is Figure 3 The network structure shown.
[0053] Specifically, Figure 3 The network structure shown here builds on the classic U-net image segmentation model by incorporating multi-task learning. The encoder portion of the image compression neural network is pre-configured to learn upper-layer features shared by multiple tasks, while the decoding portion decouples the different learning tasks into independent tasks. After image preprocessing, the original sample image block is input into the initial image compression neural network and then upsampled three times for feature extraction, resulting in sample encoding features. These encoding features are then fed into two task branches for separate learning. The two learning tasks share the underlying encoder (feature extraction component), while two separate decoders learn different objectives at the top level. This structure increases the weighting of important features during training, thereby improving the model's feature extraction capabilities. Furthermore, because the underlying layers are shared, overfitting is avoided during feature extraction, improving the model's generalization capabilities.
[0054] Furthermore, in the two learning tasks in this network structure, task one is an image compression task, in which the compressed image block corresponding to the original sample image block processed by the preset image codec is used as the expected output, and the mean square error (MSE) loss function is used as the learning quality evaluation of task one. Task two is an auxiliary learning task, in which images with image quality equal to or higher than the original sample image, that is, the original image or the image after super-resolution processing, are selected as the expected output, and the MSE loss function is also selected as the learning quality evaluation of task two. In the process of multi-task learning, a residual learning mechanism is adopted, so that each downsampling is followed by a size-padded convolution layer, and each upsampling is followed by a splicing layer and two layers of the same-size-padded convolution layers, which can reduce information loss in the downsampling process. Optionally, the last layer of all convolutional layers uses a 1x1 convolution kernel, and all convolutional layers except the last layer use a 3x3 convolution kernel.
[0055] The training process of the preset image compression neural network specifically includes: first, inputting the original sample image block in the model training sample pair that has undergone image preprocessing into the encoder in the initial image compression network for feature extraction to obtain sample coding features; then, based on the first preset decoder (task one), feature decoding processing is performed on the sample coding features to obtain a preliminary compressed image block, and a first loss function is calculated based on the preliminary compressed image block and the compressed image block corresponding to the original sample image block and compressed by the preset image codec; at the same time, based on the second preset decoder (task two), feature decoding processing is performed on the sample coding features to obtain a preliminary reconstructed image block, and a second loss function is calculated based on the preliminary reconstructed image block and the original sample image block or the high-resolution original image block corresponding to the original sample image block; and then iteratively updating the initial image compression network according to the results of the first loss function and the second loss function. When the weighted sum of the first loss function and the second loss function meets the preset convergence condition, the model training process is completed to obtain the preset image compression neural network.
[0056] The loss function of the preset image compression neural network can be expressed as: L1 = ∑ n (λ n MES(I,P n ), where n is the number of tasks in multi-task learning. The input original image is I, the output image of task one is P1, and the output image of task two is P2. Backward gradient propagation is used to learn the compressed pixels. P1 serves as the compression result corresponding to the image to be compressed. The first image compression model is obtained by combining the preset image compression neural network with the image preprocessing module and the image integration module.
[0057] S230: Acquire an image to be compressed, and input the image to be compressed into the first image compression model to obtain a target compressed image corresponding to the image to be compressed.
[0058] During the use of the trained first image compression model, the acquired image to be compressed can be directly input into the first image compression model to obtain a corresponding target compressed image.
[0059] S240: Input the target compressed image as a pre-compressed image of the image to be compressed into the preset image compression model and / or an image codec corresponding to a preset image compression format for image compression to obtain a final compressed image.
[0060] In a preferred embodiment, the obtained target compressed image can also be used as a pre-compressed image of the image to be compressed. This is because a neural network is used to learn the association between pixels, thereby finding the redundancy in the pixels in a fundamental sense. In addition, the first image compression model outputs a multidimensional array with pixels as units. Therefore, the target compressed image itself can be compressed multiple times in a cycle, and can also be followed by any traditional codec (HEVC / Webp, etc.). The hybrid superposition compression process can, to a certain extent, solve the problem that multiple compressions of traditional codecs are invalid or even have serious quality degradation. Exemplarily, the target compressed image can be input into the first image compression model as the image to be compressed to obtain a new image compression result, and the new image compression result can even be input into the first image compression model again as the image to be compressed. In addition, the target compressed image can also be input into an image codec of a non-neural network compression model such as HEVC or Webp as the image to be compressed to obtain a corresponding image compression result.
[0061] In another optional embodiment, after obtaining the first sample set, image optimization processing can be performed on the paired compressed images of each original sample image to obtain a compressed optimized image, and each of the original sample images and the corresponding compressed optimized image are respectively used as a group of sample pairs to obtain a second sample set. Furthermore, the image compression model is trained based on the second sample set to obtain a second image compression model. Therefore, the image compression result output by the second image compression model is a target compressed image with higher image quality. Among them, the image optimization processing method can adopt any single or combined image optimization method, including decompression distortion processing, such as denoising, smoothing and demosaicing, as well as image texture enhancement, image clarity adjustment, image sharpening and other operations. The optimal processing method can be selected according to the preset image quality evaluation standard.
[0062] In particular, when using the second sample set to train the image compression model, a simpler network structure can be used to reduce the number of parameters in the model, reduce the complexity of the algorithm, and reduce the memory usage during the image compression process. Because the expected output of the image compression model itself is an optimized model, there is no need to use a multi-task learning network to assist in image compression learning. For example, when using the second sample set to train the image compression model, the following can be used: Figure 4 The network structure shown in the figure is shown in the figure. The preset image compression neural network in the preset image compression model uses a residual learning mechanism, such as a U-net. Specifically, the classic U-net model uses three upsampling and downsampling steps. After each upsampling step, the model is concatenated with a feature map of the same size. This feature concatenation compensates for texture features lost during downsampling, helps integrate contextual information, and combines core low-frequency and high-frequency features, further facilitating image learning.
[0063] The technical solution of the embodiment of the present disclosure is to collect a certain number of original image samples, and then use a preset image codec to continue image compression processing to obtain a compressed image paired with the original image sample to construct a first sample set. The first sample set can also be further optimized to obtain a second sample set. The first or second sample set can be used to train the image compression model to obtain the final image compression model. After obtaining the image to be compressed, the image to be compressed that has undergone format conversion is input into the preset image compression model to obtain a target compressed image corresponding to the image to be compressed. The target compressed image can also be further used as a pre-compressed image to perform multiple cycles of compression to further reduce the image size. This solves the problem of the image codec taking a long time to perform image compression processing, realizes the networking of the preset image codec, and can improve the efficiency of image compression.
[0064] Figure 5 A flowchart of another image compression method provided by an embodiment of the present disclosure further describes an image compression method when the preset image codec is a Guetzli codec, as well as a training process of an image compression model in the process of implementing the method flow. The image compression method shown in the flowchart can be combined with the various image compression schemes described above to form more image compression schemes. The method can be performed by an image compression device, which can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, a PC, or a server.
[0065] like Figure 5 As shown, the image compression method includes:
[0066] S310: Acquire multiple original sample images, and input each of the original sample images into a Guetzli codec to obtain a corresponding Guetzli compressed image. Each of the original sample images and the corresponding Guetzli compressed image is used as a set of sample pairs to obtain a first sample set.
[0067] The Guetzli codec's image compression algorithm can reduce image size by 20-30% while minimizing the loss of encoded image quality. Furthermore, because the Guetzli image codec outputs images in the JPEG format, it offers high compatibility and a wider range of applicable scenarios. Furthermore, during image compression, the Guetzli image codec uses luminance and chrominance quantization tables to attenuate high-frequency information in the image, preserving the color space transformation of JPEG image compression and resulting in a more subjectively visually appealing output compressed image. Therefore, in this embodiment, the Guetzli codec is selected as the target codec for networked processing, resulting in an image compression network with high image compression efficiency, minimal image quality loss, and a higher compatibility of the resulting compressed images.
[0068] In this step, after obtaining the original sample images, each original sample image is input into the Guetzli codec to obtain the corresponding Guetzli compressed image, and a sample pair is constructed to obtain a first sample set for subsequent image compression model training.
[0069] S320: Train an image compression model based on the first sample set to obtain a first image compression model.
[0070] The first image compression model includes an image preprocessing module, an image compression module, and an image integration module. The process of training the first image compression model, i.e., the training process of the image compression module, can adopt the neural network structure based on multi-task learning in the above embodiment, such as Figure 3 The network structure shown is used to train the image compression network.
[0071] The resulting trained first image compression model can replace the existing Guetzli codec, addressing its timeliness and high memory requirements. It achieves image compression processing equivalent to Guetzli in milliseconds, and even produces images of slightly higher quality to some extent. The first image compression model mitigates Guetzli's compression distortion to a certain extent, ultimately improving the image compression ratio and reducing the image bitrate without affecting user perception, thereby reducing bandwidth consumption for image services.
[0072] The overall process of image compression model training for the first sample set can be referred to Figure 6The overall training process is shown. The collected original sample images are stored in lossless PNG format. During model training, the pixel representation of the original sample images, if in RGB format, is converted to YUV format and input into the initial image compression model. The image preprocessing module preprocesses each sample pair to obtain Guetzli-compressed image blocks corresponding to multiple sub-original sample image blocks of preset sizes. Each original sample image block is further input into the initial image compression neural network of the image compression module, which includes a multi-task learning module. The network decoding module, which performs image compression as the task, uses the corresponding Guetzli-compressed image block as the desired output, while the network decoding module, which performs auxiliary learning as the task, uses the corresponding original sample image block or the original sample image block processed with high resolution as the desired output. Finally, the image compression result output by the initial image compression model is compared with the corresponding Guetzli-compressed image block, and a mean squared error loss function is calculated. The parameters of the initial image compression model can be adjusted based on the feedback from the loss function. When the loss function of the image compression model meets the preset convergence condition or reaches the preset number of training times, the model training process ends, resulting in the final first image compression model.
[0073] Furthermore, after the model training is completed, the image compression effect of the first image compression model can be verified by preset indicators. For example, the original sample image and the image compression result of the first image compression model on the original sample image can be respectively input into the HEVC or Webp image codec to compress the image, and the image compression effect is evaluated from multiple evaluation dimensions such as image size (SIZE), peak signal-to-noise ratio (PSNR), structural similarity index measurement (SSIM) and video quality assessment (Video Quality Score, VQscore). It has been verified that the output result of the first image compression model obtained by training in this embodiment can also have a good image compression effect when performing hybrid superposition compression processing.
[0074] S330: Acquire an image to be compressed, and input the image to be compressed into a first image compression model to obtain a target compressed image corresponding to the image to be compressed.
[0075] S340: Input the target compressed image as a pre-compressed image of the image to be compressed into the first image compression model and / or an image codec corresponding to a preset image compression format for image compression to obtain a final compressed image.
[0076] By further compressing the target compressed image multiple times, the problem of significant image quality degradation after multiple compressions by conventional image codecs can be avoided to a certain extent. In addition, the image codec for further compression can be selected according to the specified image format, such as PNG format or JPEG format.
[0077] The technical solution of the embodiment of the present disclosure is to collect a certain number of original image samples, then use a preset image codec to continue image compression processing, obtain a compressed image paired with the original image sample, and construct a first sample set. The first sample set is used to train the image compression model to obtain the final image compression model. During the model training process, based on multi-task learning, the model's ability to learn important features is improved, and the quality of the compressed image is optimized. By combining the visual model and the deep learning network, the Guetzli codec is networked, and image compression equivalent to the Guetzli effect can be achieved at the millisecond level. After obtaining the image to be compressed, the format-converted image to be compressed is input into the preset image compression model to obtain a target compressed image corresponding to the image to be compressed, which solves the problem of long image compression processing time of the image codec, realizes the networking of the preset image codec, and can improve the efficiency of image compression. In addition, since the input and output of the first image compression model are multidimensional arrays, multiple compressions can be performed. At the same time, the problem of multiple compressions being ineffective or even seriously deteriorating image quality is solved.
[0078] Figure 7 This is a flowchart of another image compression method provided by an embodiment of the present disclosure. The implementation of this method further describes the training process of an image compression model when the preset image codec is a Guetzli codec, and the model training samples are sample pairs consisting of a compressed, optimized image compressed with the Guetzli codec and an original sample image. This method can be performed by an image compression device, which can be implemented in software and / or hardware, and optionally by an electronic device such as a mobile terminal, a PC, or a server.
[0079] like Figure 7 As shown, the image compression method includes:
[0080] S410 , obtaining a plurality of original sample images, and inputting each of the original sample images into a Guetzli codec to obtain a corresponding Guetzli compressed image.
[0081] S420: Perform image optimization processing on the Guetzli compressed image to obtain a compressed optimized image, and use each of the original sample images and the corresponding compressed optimized image as a set of sample pairs to obtain a second sample set.
[0082] Generally speaking, the Guetzli codec is more suitable for images with higher image quality, while for images with slightly lower quality, its compression effect is not significant and cracking is obvious. Figure 8 The image processed by the Guetzli codec shown in the figure shows obvious post-compression mosaic artifacts and color shifts near the edges of the face and chin. These artifacts contribute to a decrease in subjective quality. In this embodiment, it is intended to optimize the Guetzli codec compression technology, address the shortcomings of existing technologies in low-quality images, improve compressed image quality, and eliminate compression artifacts. Therefore, based on the above-described embodiment, the Guetzli compressed images are optimized to construct a second sample set.
[0083] Specifically, when constructing the second sample set, a combination of one or more image processing methods, such as deblocking, denoising, smoothing, demosaicing, image sharpening, image texture enhancement, and image clarity adjustment, can be used to improve the image compression effect of the Guetzli codec and enhance the subjective quality of the image. Each original sample image and the corresponding compressed optimized image are then combined to form a sample pair.
[0084] S430: Train an image compression model based on the second sample set to obtain a second image compression model.
[0085] The second image compression model also includes an image preprocessing module, an image compression module, and an image integration module. The image preprocessing module is used to adaptively supplement and cut the edges of the image to be compressed. The process of training the second image compression model is the training process of the image compression module, which can adopt the neural network structure based on multi-task learning in the above embodiment, such as Figure 3 The network structure shown in the figure can be used to train the image compression network. Figure 4 The network structure shown in is used as the network structure of the image compression module for model training.
[0086] In this embodiment, since the compressed image corresponding to the original sample image in the sample pair in the second sample set is the optimized image after compression by the Guetzli codec, the model structure can be adopted. Figure 4The relatively simple structure in the model reduces the number of model parameters and the amount of computation required during operation. The final trained image compression model, the second image compression model, can replace the existing Guetzli codec, addressing its timeliness and high memory requirements. It achieves image compression processing equivalent to Guetzli effects in milliseconds, resulting in images of higher quality than those processed by Guetzli. The second image compression model reduces Guetzli compression distortion to a certain extent, ultimately improving the image compression ratio and reducing the image bitrate without affecting user perception, thereby reducing bandwidth consumption for image services.
[0087] The overall process of image compression model training for the second sample set can be referred to Figure 9 The overall training process is shown in Figure 1. The collected original sample images are stored in lossless PNG format. During model training, the pixel representation of the original sample images, if in RGB format, is converted to YUV format and input into the initial image compression model. The image preprocessing module preprocesses each sample pair to obtain Guetzli-compressed image blocks corresponding to multiple sub-original sample image blocks of preset sizes. Each original sample image block is further input into the image compression module's initial image compression neural network, which uses a typical U-net model with a residual learning mechanism. Specifically, the U-net model performs three upsampling and downsampling steps, and after each upsampling step, the image blocks are concatenated with feature maps of the same size. Feature concatenation compensates for texture features lost during downsampling, helps integrate contextual information, and combines core low-frequency and high-frequency features, further facilitating image learning. The output of the U-net is the Guetzli-compressed optimized image block corresponding to the original sample image block as the desired output, and the mean squared error loss function is calculated. The parameters of the initial image compression model can be adjusted based on the feedback of the loss function results. When the loss function of the image compression model meets the preset convergence conditions or reaches the preset number of training times, the model training process ends and the final second image compression model is obtained. The image integration module will splice the compressed image blocks corresponding to the sub-original sample image blocks of the original sample image into the complete image compression model image compression result.
[0088] Furthermore, after the model training is completed, the image compression effect of the second image compression model can be verified by preset indicators. For example, the original sample image and the image compression results of the second image compression model on the original sample image can be respectively input into the HEVC or Webp image codec to compress the image, and the image compression effect is evaluated from multiple evaluation dimensions such as image size (SIZE), peak signal-to-noise ratio (PSNR), structural similarity index measurement (SSIM) and video quality assessment (Video Quality Score, VQscore). It has been verified that the output result of the second image compression model obtained by training in this embodiment can also have a good image compression effect when performing hybrid superposition compression processing.
[0089] S440: Acquire an image to be compressed, and input the image to be compressed into the second image compression model to obtain a target compressed image corresponding to the image to be compressed.
[0090] S450: Input the target compressed image as a pre-compressed image of the image to be compressed into the second image compression model and / or an image codec corresponding to a preset image compression format for image compression to obtain a final compressed image.
[0091] The technical solution of the disclosed embodiment involves collecting a certain number of original image samples, performing image compression processing using the Guetzli codec, and obtaining a paired compressed image. The compressed image is then optimized to obtain a second sample set. The second sample set is then used to train an image compression model to obtain the final second image compression model. After obtaining the image to be compressed, the format-converted image to be compressed is input into the second image compression model to obtain a target compressed image corresponding to the image to be compressed. This achieves a networked Guetzli codec by combining a visual model and a deep learning network, achieving image compression in milliseconds with compression efficiency superior to that of the Guetzli codec. After obtaining the image to be compressed, the image to be compressed is input into the second image compression model to obtain a target compressed image corresponding to the image to be compressed. This solves the problem of long image compression processing times used by image codecs, achieves networking of preset image codecs, and improves image compression efficiency. Furthermore, because the input and output of the second image compression model are both multidimensional arrays, multiple compression cycles can be performed. This also solves the problem of multiple compression cycles being ineffective or even severely degrading image quality.
[0092] Figure 10This is a structural schematic diagram of an image compression device provided in an embodiment of the present disclosure. The device is suitable for situations where image compression processing is performed. It can be implemented in the form of software and / or hardware. Optionally, it can be implemented by an electronic device, which can be a mobile terminal, PC or server, etc.
[0093] like Figure 10 As shown, the device includes: an image acquisition module 510 and an image compression module 520.
[0094] Among them, the image acquisition module 510 is used to acquire the image to be compressed; the image compression module 520 is used to input the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed; wherein the model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec.
[0095] The technical solution provided by the embodiment of the present disclosure obtains a target compressed image corresponding to the image to be compressed by inputting the image to be compressed into a preset image compression model after obtaining the image to be compressed; wherein the preset image compression model is a model generated by training a sample set consisting of sample pairs consisting of each original sample image and a compressed image after each original sample image is compressed by a preset image codec. Then, the preset image compression model correspondingly has the image compression function of the preset image codec, solves the problem that the image codec takes a long time to perform image compression processing, realizes the networking of the preset image codec, and can improve the efficiency of image compression.
[0096] In an optional implementation, the image compression module 520 is specifically configured to:
[0097] Performing image preprocessing on the image to be compressed to obtain one or more sub-image blocks to be compressed of a preset size;
[0098] Inputting each of the sub-image blocks to be compressed into a preset image compression neural network for image compression to obtain a corresponding sub-image compression result;
[0099] The compression results of the sub-images are stitched together to obtain the target compressed image.
[0100] In an optional embodiment, the image compression device further includes a model training module for training the preset image compression neural network. The specific training process includes:
[0101] Obtaining one or more original sample image blocks and compressed sample image blocks obtained by preprocessing the image of the model training sample pair, and inputting each of the original sample image blocks into an encoder in the initial image compression network to perform feature extraction to obtain corresponding sample encoding features;
[0102] Performing feature decoding processing on the sample coding feature based on a first preset decoder to obtain a preliminary compressed image block, and calculating a first loss function based on the preliminary compressed image block and the corresponding compressed sample image block;
[0103] performing feature decoding processing on the sample encoding feature based on a second preset decoder to obtain a preliminary reconstructed image block, and calculating a second loss function based on the preliminary reconstructed image block and the original sample image block or a high-resolution original image block corresponding to the original sample image block;
[0104] The initial image compression network is iteratively updated according to the results of the first loss function and the second loss function, and the model training process is completed when the weighted sum of the first loss function and the second loss function meets a preset convergence condition.
[0105] In an optional implementation, the image compression module 520 is further configured to:
[0106] Filling the edges of the image to be compressed to obtain an image of a target size;
[0107] The target size image is cut into pieces according to a preset size to obtain a plurality of sub-image blocks to be compressed of the preset size.
[0108] In an optional embodiment, the image compression device further includes a sample construction module, configured to:
[0109] Acquire a plurality of original sample images, and input each of the original sample images into the preset image codec to obtain a corresponding paired compressed image;
[0110] Each of the original sample images and the corresponding paired compressed image is taken as a set of sample pairs to obtain a first sample set.
[0111] In an optional embodiment, the sample construction module is further used to:
[0112] After obtaining the paired compressed images, performing image optimization processing on the paired compressed images to obtain compressed optimized images;
[0113] Each of the original sample images and the corresponding compressed optimized image is taken as a set of sample pairs to obtain a second sample set.
[0114] In an optional embodiment, when the sample pairs in the second sample set are used as training samples of the preset image compression model, the preset image compression neural network in the preset image compression model is a network provided with a residual learning mechanism.
[0115] In an optional embodiment, the image compression device further includes an image depth compression module, configured to:
[0116] The target compressed image is used as a pre-compressed image of the image to be compressed, and is input into the preset image compression model and / or an image codec corresponding to a preset image compression format for image compression to obtain a final compressed image.
[0117] In an optional implementation, the image compression device further includes a pixel information format conversion module, configured to:
[0118] Before inputting the image to be compressed into a preset image compression model, when a first pixel information representation format of the image to be compressed is different from a second pixel information representation format adapted to the preset image compression model, converting the pixel information representation format of the image to be compressed into the second pixel information representation format;
[0119] Accordingly, after obtaining the target compressed image, the pixel information format conversion module is further configured to:
[0120] converting the pixel information representation format of the target compressed image into the first pixel information representation format;
[0121] The second pixel information representation format is a pixel information representation format adapted to the preset image codec.
[0122] In an optional implementation, the preset image codec is a Guetzli codec.
[0123] The image compression device provided by the embodiments of the present disclosure can execute the image compression method provided by any embodiment of the present disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
[0124] It is worth noting that the various units and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present disclosure.
[0125] Figure 11 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. Figure 11, which shows an electronic device (eg Figure 11 The terminal device in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (such as in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 11 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0126] like Figure 11 As shown, the electronic device 600 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the electronic device 600 are also stored in the RAM 603. The processing device 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An edit / output (I / O) interface 605 is also connected to the bus 604.
[0127] Typically, the following devices may be connected to the I / O interface 605: an input device 606 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 607 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 608 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 609. The communication device 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 11 The electronic device 600 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0128] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 609, or installed from the storage device 608, or installed from the ROM 602. When the computer program is executed by the processing device 601, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0129] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0130] The electronic device provided by the embodiment of the present disclosure and the image compression method provided by the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0131] An embodiment of the present disclosure provides a computer storage medium having a computer program stored thereon. When the program is executed by a processor, the image compression method provided by the above embodiment is implemented.
[0132] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0133] In some embodiments, the client and server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0134] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0135] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0136] Get the image to be compressed;
[0137] Inputting the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed;
[0138] The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec.
[0139] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0141] The units involved in the embodiments described in this disclosure may be implemented in software or hardware. In some cases, the name of a unit does not limit the unit itself. For example, the first acquisition unit may also be described as a "unit for acquiring at least two Internet Protocol addresses."
[0142] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0143] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0144] According to one or more embodiments of the present disclosure, [Example 1] provides an image compression method, the method comprising:
[0145] Get the image to be compressed;
[0146] Inputting the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed;
[0147] The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec.
[0148] According to one or more embodiments of the present disclosure, [Example 2] provides an image compression method, further comprising:
[0149] In some optional implementations, the process of compressing the image to be compressed using the preset image compression model includes:
[0150] Performing image preprocessing on the image to be compressed to obtain one or more sub-image blocks to be compressed of a preset size;
[0151] Inputting each of the sub-image blocks to be compressed into a preset image compression neural network for image compression to obtain a corresponding sub-image compression result;
[0152] The compression results of the sub-images are stitched together to obtain the target compressed image.
[0153] According to one or more embodiments of the present disclosure, [Example 3] provides an image compression method, including:
[0154] In some optional implementations, the training process of the preset image compression neural network includes:
[0155] Obtaining one or more original sample image blocks and compressed sample image blocks obtained by preprocessing the image of the model training sample pair, and inputting each of the original sample image blocks into an encoder in the initial image compression network to perform feature extraction to obtain corresponding sample encoding features;
[0156] Performing feature decoding processing on the sample coding feature based on a first preset decoder to obtain a preliminary compressed image block, and calculating a first loss function based on the preliminary compressed image block and the corresponding compressed sample image block;
[0157] performing feature decoding processing on the sample encoding feature based on a second preset decoder to obtain a preliminary reconstructed image block, and calculating a second loss function based on the preliminary reconstructed image block and the original sample image block or a high-resolution original image block corresponding to the original sample image block;
[0158] The initial image compression network is iteratively updated according to the results of the first loss function and the second loss function, and the model training process is completed when the weighted sum of the first loss function and the second loss function meets a preset convergence condition.
[0159] According to one or more embodiments of the present disclosure, [Example 4] provides an image compression method, further comprising:
[0160] In some optional implementations, performing image preprocessing on the format-converted image to be compressed to obtain a plurality of sub-image blocks to be compressed of preset sizes includes:
[0161] Filling the edges of the image to be compressed to obtain an image of a target size;
[0162] The target size image is cut into pieces according to a preset size to obtain a plurality of sub-image blocks to be compressed of the preset size.
[0163] According to one or more embodiments of the present disclosure, [Example 5] provides an image compression method, further comprising:
[0164] In some optional implementations, the process of constructing the model training sample pairs includes:
[0165] Acquire a plurality of original sample images, and input each of the original sample images into the preset image codec to obtain a corresponding paired compressed image;
[0166] Each of the original sample images and the corresponding paired compressed image is taken as a set of sample pairs to obtain a first sample set.
[0167] According to one or more embodiments of the present disclosure, [Example 6] provides an image compression method, further comprising:
[0168] In some optional implementations, the process of constructing the model training sample pairs further includes:
[0169] After obtaining the paired compressed images, performing image optimization processing on the paired compressed images to obtain compressed optimized images;
[0170] Each of the original sample images and the corresponding compressed optimized image is taken as a set of sample pairs to obtain a second sample set.
[0171] According to one or more embodiments of the present disclosure, [Example 7] provides an image compression method, further comprising:
[0172] In some optional implementations, when the sample pairs in the second sample set are used as training samples of the preset image compression model, the preset image compression neural network in the preset image compression model is a network provided with a residual learning mechanism.
[0173] According to one or more embodiments of the present disclosure, [Example 8] provides an image compression method, further comprising:
[0174] In some optional implementations, the image compression method further includes inputting the target compressed image as a pre-compressed image of the image to be compressed into the preset image compression model and / or the image codec corresponding to the preset image compression format for image compression to obtain a final compressed image.
[0175] According to one or more embodiments of the present disclosure, [Example 9] provides an image compression method, further comprising:
[0176] In some optional implementations, before inputting the image to be compressed into a preset image compression model, the method further includes:
[0177] When the first pixel information representation format of the image to be compressed is different from the second pixel information representation format adapted to the preset image compression model, converting the pixel information representation format of the image to be compressed into the second pixel information representation format;
[0178] Accordingly, after obtaining the target compressed image, the method further includes:
[0179] converting the pixel information representation format of the target compressed image into the first pixel information representation format;
[0180] The second pixel information representation format is a pixel information representation format adapted to the preset image codec.
[0181] According to one or more embodiments of the present disclosure, [Example 10] provides an image compression method, further comprising:
[0182] In some optional implementations, the preset image codec is a Guetzli codec.
[0183] According to one or more embodiments of the present disclosure, [Example 11] provides an image compression device, including:
[0184] An image acquisition module, used for acquiring an image to be compressed;
[0185] An image compression module, configured to input the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed;
[0186] The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec.
[0187] According to one or more embodiments of the present disclosure, [Example 12] provides an image compression device, further comprising:
[0188] In an optional implementation, the image compression module is specifically configured to:
[0189] Performing image preprocessing on the image to be compressed to obtain one or more sub-image blocks to be compressed of a preset size;
[0190] Inputting each of the sub-image blocks to be compressed into a preset image compression neural network for image compression to obtain a corresponding sub-image compression result;
[0191] The compression results of the sub-images are stitched together to obtain the target compressed image.
[0192] According to one or more embodiments of the present disclosure, [Example 13] provides an image compression device, further comprising:
[0193] In some optional implementations, the image compression apparatus further includes a model training module for performing a training process on the preset image compression neural network. The specific training process includes:
[0194] Obtaining one or more original sample image blocks and compressed sample image blocks obtained by preprocessing the image of the model training sample pair, and inputting each of the original sample image blocks into an encoder in the initial image compression network to perform feature extraction to obtain corresponding sample encoding features;
[0195] Performing feature decoding processing on the sample coding feature based on a first preset decoder to obtain a preliminary compressed image block, and calculating a first loss function based on the preliminary compressed image block and the corresponding compressed sample image block;
[0196] performing feature decoding processing on the sample encoding feature based on a second preset decoder to obtain a preliminary reconstructed image block, and calculating a second loss function based on the preliminary reconstructed image block and the original sample image block or a high-resolution original image block corresponding to the original sample image block;
[0197] The initial image compression network is iteratively updated according to the results of the first loss function and the second loss function, and the model training process is completed when the weighted sum of the first loss function and the second loss function meets a preset convergence condition.
[0198] According to one or more embodiments of the present disclosure, [Example 14] provides an image compression device, further comprising:
[0199] In some optional implementations, the image compression module is further configured to:
[0200] Filling the edges of the image to be compressed to obtain an image of a target size;
[0201] The target size image is cut into pieces according to a preset size to obtain a plurality of sub-image blocks to be compressed of the preset size.
[0202] According to one or more embodiments of the present disclosure, [Example 15] provides an image compression device, further comprising:
[0203] In some optional implementations, the image compression apparatus further includes a sample construction module configured to:
[0204] Acquire a plurality of original sample images, and input each of the original sample images into the preset image codec to obtain a corresponding paired compressed image;
[0205] Each of the original sample images and the corresponding paired compressed image is taken as a set of sample pairs to obtain a first sample set.
[0206] According to one or more embodiments of the present disclosure, [Example 16] provides an image compression device, further comprising:
[0207] In some optional implementations, the sample construction module is further configured to:
[0208] After obtaining the paired compressed images, performing image optimization processing on the paired compressed images to obtain compressed optimized images;
[0209] Each of the original sample images and the corresponding compressed optimized image is taken as a set of sample pairs to obtain a second sample set.
[0210] According to one or more embodiments of the present disclosure, [Example 17] provides an image compression device, further comprising:
[0211] In some optional implementations, when the sample pairs in the second sample set are used as training samples of the preset image compression model, the preset image compression neural network in the preset image compression model is a network provided with a residual learning mechanism.
[0212] According to one or more embodiments of the present disclosure, [Example 18] provides an image compression device, further comprising:
[0213] In some optional implementations, the image compression apparatus further includes an image depth compression module, configured to:
[0214] The target compressed image is used as a pre-compressed image of the image to be compressed, and is input into the preset image compression model and / or an image codec corresponding to a preset image compression format for image compression to obtain a final compressed image.
[0215] According to one or more embodiments of the present disclosure, [Example 19] provides an image compression device, further comprising:
[0216] In some optional implementations, the image compression apparatus further includes a pixel information format conversion module configured to:
[0217] Before inputting the image to be compressed into a preset image compression model, when a first pixel information representation format of the image to be compressed is different from a second pixel information representation format adapted to the preset image compression model, converting the pixel information representation format of the image to be compressed into the second pixel information representation format;
[0218] Accordingly, after obtaining the target compressed image, the pixel information format conversion module is further configured to:
[0219] converting the pixel information representation format of the target compressed image into the first pixel information representation format;
[0220] The second pixel information representation format is a pixel information representation format adapted to the preset image codec.
[0221] According to one or more embodiments of the present disclosure, [Example 20] provides an image compression device, further comprising:
[0222] In some optional implementations, the preset image codec is a Guetzli codec.
[0223] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0224] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0225] Although the subject matter has been described in language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims.
Claims
1. An image compression method, characterized in that: include: Get the image to be compressed; Inputting the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed; The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec; The training process of the preset image compression model is a training process of a preset image compression neural network, including: Inputting the original sample image into the encoder in the initial image compression network to extract features and obtain sample coding features; Performing feature decoding processing on the sample encoding feature based on a first preset decoder to obtain a preliminary compressed image, and calculating a first loss function based on the preliminary compressed image and the compressed sample image corresponding to the original sample image; performing feature decoding processing on the sample encoding feature based on a second preset decoder to obtain a preliminary reconstructed image, and calculating a second loss function based on the preliminary reconstructed image and the original sample image or a high-resolution original image corresponding to the original sample image; The initial image compression network is iteratively updated according to the results of the first loss function and the second loss function. When the weighted sum of the first loss function and the second loss function meets the preset convergence condition, the model training process is completed to obtain the preset image compression neural network.
2. The method according to claim 1, characterized in that The process of compressing the image to be compressed by the preset image compression model includes: Performing image preprocessing on the image to be compressed to obtain one or more sub-image blocks to be compressed of a preset size; Inputting each of the sub-image blocks to be compressed into a preset image compression neural network for image compression to obtain a corresponding sub-image compression result; The compression results of the sub-images are stitched together to obtain the target compressed image.
3. The method according to claim 2, characterized in that The training process of the preset image compression neural network includes: Obtaining one or more original sample image blocks and compressed sample image blocks obtained by preprocessing the image of the model training sample pair, and inputting each of the original sample image blocks into an encoder in the initial image compression network to perform feature extraction to obtain corresponding sample encoding features; Performing feature decoding processing on the sample coding feature based on a first preset decoder to obtain a preliminary compressed image block, and calculating a first loss function based on the preliminary compressed image block and the corresponding compressed sample image block; performing feature decoding processing on the sample encoding feature based on a second preset decoder to obtain a preliminary reconstructed image block, and calculating a second loss function based on the preliminary reconstructed image block and the original sample image block or a high-resolution original image block corresponding to the original sample image block; The initial image compression network is iteratively updated according to the results of the first loss function and the second loss function, and the model training process is completed when the weighted sum of the first loss function and the second loss function meets a preset convergence condition.
4. The method according to claim 2, characterized in that The performing image preprocessing on the image to be compressed to obtain a plurality of sub-image blocks to be compressed of preset sizes includes: Filling the edges of the image to be compressed to obtain an image of a target size; The target size image is cut into pieces according to a preset size to obtain a plurality of sub-image blocks to be compressed of the preset size.
5. The method according to claim 1, wherein The process of constructing the model training sample pairs includes: Acquire a plurality of original sample images, and input each of the original sample images into the preset image codec to obtain a corresponding paired compressed image; Each of the original sample images and the corresponding paired compressed image is taken as a set of sample pairs to obtain a first sample set.
6. The method according to claim 5, characterized in that The process of constructing the model training sample pairs further includes: After obtaining the paired compressed images, performing image optimization processing on the paired compressed images to obtain compressed optimized images; Each of the original sample images and the corresponding compressed optimized image is taken as a set of sample pairs to obtain a second sample set.
7. The method according to claim 6, characterized in that When the sample pairs in the second sample set are used as training samples of the preset image compression model, the preset image compression neural network in the preset image compression model is a network provided with a residual learning mechanism.
8. The method according to claim 1, characterized in that The method further comprises: The target compressed image is used as a pre-compressed image of the image to be compressed, and is input into the preset image compression model and / or an image codec corresponding to a preset image compression format for image compression to obtain a final compressed image.
9. The method according to any one of claims 1 to 8, characterized in that: Before inputting the image to be compressed into a preset image compression model, the method further includes: When the first pixel information representation format of the image to be compressed is different from the second pixel information representation format adapted to the preset image compression model, converting the pixel information representation format of the image to be compressed into the second pixel information representation format; Accordingly, after obtaining the target compressed image, the method further includes: converting the pixel information representation format of the target compressed image into the first pixel information representation format; The second pixel information representation format is a pixel information representation format adapted to the preset image codec.
10. The method according to any one of claims 1 to 8, characterized in that: The preset image codec is the Guetzli codec.
11. An image compression device, characterized in that: include: An image acquisition module, used for acquiring an image to be compressed; An image compression module, configured to input the image to be compressed into a preset image compression model to obtain a target compressed image corresponding to the image to be compressed; The model training sample pair of the preset image compression model includes an original sample image and a compressed sample image, wherein the compressed sample image is an image obtained by compressing the original sample image using a preset image codec; The training process of the preset image compression model is a training process of a preset image compression neural network, including: Inputting the original sample image into the encoder in the initial image compression network to extract features and obtain sample coding features; Performing feature decoding processing on the sample encoding feature based on a first preset decoder to obtain a preliminary compressed image, and calculating a first loss function based on the preliminary compressed image and the compressed sample image corresponding to the original sample image; performing feature decoding processing on the sample encoding feature based on a second preset decoder to obtain a preliminary reconstructed image, and calculating a second loss function based on the preliminary reconstructed image and the original sample image or a high-resolution original image corresponding to the original sample image; The initial image compression network is iteratively updated according to the results of the first loss function and the second loss function. When the weighted sum of the first loss function and the second loss function meets the preset convergence condition, the model training process is completed to obtain the preset image compression neural network.
12. An electronic device, characterized in that: The electronic device comprises: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the image compression method according to any one of claims 1 to 10.
13. A storage medium comprising computer executable instructions, wherein the computer executable instructions are used to perform the image compression method according to any one of claims 1 to 10 when executed by a computer processor.
Citation Information
Patent Citations
Image compression method and device and storage medium
CN110830807A
Image coding method and device, computer equipment, storage medium and decoding method
CN113949865A