Picture compression method and system based on Huffman and GAN feature fusion network

Through the Hoffman encoding and GAN feature fusion network method, the key areas of the picture are intelligently marked and compressed, and non-key areas are generated through GAN, which solves the problems of compression efficiency and mass balance in the existing technology, and achieves efficient and accurate Image compression effect.

CN118945366APending Publication Date: 2024-11-12SOUTH CHINA NORMAL UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410899190.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

Existing image compression technology is difficult to achieve a good balance between high compression rates and maintaining image quality, especially in image application scenarios that contain rich details and important information.

Method used

Using a method based on Hoffmann and GAN feature fusion network, the key areas of the image are marked through the self-attention mechanism, and the lossless compression is used using Hoffmann encoding, and the non-key areas are reasonably supplemented by the GAN generation after decoding to ensure that the image is generated. consistency of style, color and texture.

Benefits of technology

A good balance between high compression rate and visual quality is achieved, important details are retained to the greatest extent, compression efficiency and visual effects are improved, and the generalization ability and robustness of the model are enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945366A_ABST
    Figure CN118945366A_ABST
Patent Text Reader

Abstract

The invention provides a picture compression method and system based on a Huffman and GAN feature fusion network. The method comprises the following steps: preprocessing a picture; marking key areas; performing Huffman compression on the key area; and on the basis of decoding the pictures in the key areas, carrying out picture generation by utilizing the trained GAN model. Compared with a traditional picture compression algorithm, the method has the advantages that key areas in the picture are marked, efficient lossless compression is carried out on the key areas through the Huffman coding technology, and it is ensured that important details are completely reserved. For a non-key area, coding is not carried out, and reasonable and natural supplement is carried out on the non-key area or an information sparse area by means of the strong regeneration capability of the GAN network, so that the whole generated picture keeps consistent with the style, color and texture of an original picture, thereby maximizing the visual quality while ensuring the high compression rate, and improving the image quality. And good balance between the two is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image compression technology, and in particular to a picture compression method and system based on a Huffman and GAN feature fusion network. Background Art

[0002] Compared with text, pictures are more intuitive, accurate, and vivid in transmitting information. With the rapid popularization of smart phones and the rapid development of technologies such as mobile Internet and cloud storage in recent years, quickly transmitting information by taking photos has become an indispensable way of information transmission in people's daily lives. According to statistics, more than 100 million pictures are transmitted every hour on mobile social networks around the world, and the average transmission volume per destination exceeds 3 billion. There are massive amounts of pictures being transmitted through the Internet every moment. Such a large amount of picture data transmission has brought huge challenges to the network bandwidth of the entire computer world.

[0003] On the other hand, with the rapid development of mobile phone camera technology in recent years, the resolution of a single picture has achieved a rapid leap from millions to tens of millions or even hundreds of millions of pixels. Higher picture resolution also means that a single picture requires more storage space. For example, for an uncompressed BMP picture, when the resolution is 12032×9024 and the encoding method is RGBA4448, the memory size required for the file is 12032×9024×4byte=414MB. Even after JPEG compression, the size of the generated JPG file in memory exceeds 40MB. In order to meet people's pursuit of higher and higher picture clarity, the picture compression algorithm must be able to keep pace with the times and continuously improve the speed and compression rate of encoding and decoding.

[0004] Although existing image compression technologies reduce data size to a certain extent, they often fail to achieve an ideal balance between high compression rate and maintaining image quality, especially for images containing rich details and important information. In addition, these technologies may ignore the adaptability to emerging image features, resulting in poor performance in specific application scenarios. Summary of the invention

[0005] Based on the current background, in order to achieve high-definition picture cloud storage and transmission application scenarios, especially mobile phone online photo albums as specific application scenarios, to reduce the storage and transmission costs of picture information and maintain the visual quality of pictures, the present invention provides a picture compression method and system based on Huffman and GAN feature fusion network.

[0006] A first aspect of the present invention provides an image compression method based on a Huffman and GAN feature fusion network, comprising the following steps:

[0007] S1 image preprocessing;

[0008] S2 key area marking;

[0009] S3 performs Huffman compression on key areas;

[0010] S4 generates images based on the decoded images of key areas using the trained GAN model.

[0011] The image compression method of the present invention marks the key areas in the image and implements efficient lossless compression for the key areas through Huffman coding technology, ensuring that important details are fully preserved. For non-key areas, no encoding is performed, but with the help of the powerful regeneration ability of the generative adversarial network (GAN), the non-key areas or information-sparse areas are reasonably and naturally supplemented, so that the entire generated image maintains the consistency of style, color and texture with the original image, thereby maximizing the visual quality while ensuring a high compression rate, and achieving a good balance between the two.

[0012] Preferably, in step S2, the key areas are automatically labeled using the trained self-attention mechanism, and / or the key areas are manually labeled according to user specifications. Using the self-attention mechanism module, more attention weights are allocated to the content of the key areas of the image, which not only improves the compression efficiency, but also ensures that the key information of the compressed image is retained to the greatest extent.

[0013] Preferably, in step S2, the self-attention mechanism is based on the transformer model and adopts a multi-head self-attention module to divide the image information into five dimensions, namely: people in the picture, the middle area of ​​the picture, the colorful part of the picture, the focus area of ​​the camera, and the objects close to the lens in the picture, so as to better retain the detail features.

[0014] Preferably, in step S2, the loss function of the self-attention mechanism is as follows:

[0015]

[0016] Among them, α, β, γ are weight factors, L class represents the classification loss, L loc represents the positioning loss;

[0017] Represents the regularization term of the attention weight.

[0018] Preferably, the multi-head self-attention modules perform self-attention calculations separately, and then concatenate the results and integrate them through a fully connected layer; then the attention score of each head is calculated by scaled dot product and then normalized using the softmax function to obtain the attention weight.

[0019] Preferably, in step S2, the attention weight threshold is set to 0.55.

[0020] Preferably, in step S3, a Huffman tree is constructed by performing frequency statistics of gray values ​​of pixels to compress key areas.

[0021] Preferably, the GAN model in step S4 includes a generator and a discriminator.

[0022] The loss function of the discriminator is L D ,

[0023] L D =L real +L fake (1)

[0024] Among them, L rea1 is the loss function for real samples, L fake is the loss function for fake samples;

[0025]

[0026] Among them, E: expected value, which means the average value, here is for the real data distribution p data Take the average of all samples x in (x);

[0027] p data (x): true data distribution, which represents the actual probability distribution of the training data set;

[0028] log(D(x)): For each true sample x, the discriminator outputs the logarithm of the probability that it is true; the larger this value is, the higher the recognition of the true sample is.

[0029]

[0030] E: Same as (2), but this time for the noise distribution p z The average of the randomly sampled z in (z);

[0031] p z (z): Noise prior distribution, usually a simple distribution such as Gaussian distribution or uniform distribution, used as input to the generator:

[0032] G(z): generator function, which converts the noise vector z into fake samples;

[0033] log(1-D(G(z))): For generated samples, we hope that the logarithm of the probability that the discriminator outputs that it is false is close to 1;

[0034] The generator loss function is L G ,

[0035]

[0036] Among them, E is the same as formula (3), which directly reflects that the generator wants to "cheat" the discriminator so that it gives a higher authenticity score to the generated samples.

[0037] A second aspect of the present invention further provides an image compression system based on a Huffman and GAN feature fusion network, comprising:

[0038] Image acquisition module, used to acquire original images and perform preprocessing;

[0039] Annotation module: used to automatically annotate key areas of an image using a self-attention mechanism module, and / or annotate key areas as specified by a user;

[0040] Compression module: used to compress key areas of the image;

[0041] Decompression module; used to decode the key area pictures;

[0042] GAN network module: Generate images based on the decoded images of key areas.

[0043] According to a third aspect, a computer device is provided, comprising: a processor; the processor is configured to implement the steps of the above method when executing a computer program stored in a memory.

[0044] In a fourth aspect, a computer-readable storage medium is also provided, on which computer instructions are stored, and when the computer instructions are executed by a processor, the steps of the above method are implemented.

[0045] The beneficial effects of the present invention are:

[0046] (1) The image compression method and system of the present invention overcomes the problem of detail loss of key information in image compression by automatically identifying "key areas" or user-defined "key areas". Furthermore, by using the self-attention mechanism module, more attention weights are allocated to the content of the key areas of the image, which not only improves the compression efficiency, but also ensures that the key information of the compressed image is retained to the greatest extent.

[0047] (2) The image compression method and system of the present invention implements efficient lossless compression for key areas through Huffman coding technology to ensure that important details are fully preserved. At the same time, with the help of the powerful regeneration ability of the generative adversarial network (GAN), non-key areas or information-sparse areas are reasonably and naturally supplemented, so that the entire generated image maintains consistency with the style, color and texture of the original image, thereby maximizing the visual quality while ensuring a high compression rate, achieving a good balance between the two, and effectively improving the generalization ability of the model.

[0048] (3) The image compression method and system of the present invention realizes intelligent and efficient compression of key areas of the image through Huffman coding, thereby maintaining the integrity of key information. In the post-decompression stage, the GAN generator can also be used to perform targeted detail enhancement and correction on key areas that are damaged by slight distortion during compression or transmission, thereby maintaining a high compression ratio while ensuring the visual quality of the image and the reliability of the data, thereby improving the accuracy and robustness of the model in image compression. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 A brief flowchart of a picture compression method according to an embodiment of the present invention;

[0050] Figure 2 A Huffman coding flow chart of an embodiment of the present invention;

[0051] Figure 3 This is a GAN network framework diagram of an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiment is a module embodiment of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0053] refer to Figure 1 The present invention provides a picture compression method based on Huffman and GAN feature fusion network, comprising the following steps:

[0054] S1 Image preprocessing.

[0055] Preprocessing mainly involves standardizing the acquired original images through operations such as noise reduction and image size unification to enhance the recognition ability of the model.

[0056] For example, in some embodiments, noise is removed by combining Gaussian filtering and bilateral filtering, and the image size is unified to 224*224*3. The advantage of the Gaussian filter is that its system function is relatively reliable, and it can effectively smooth the generated system noise to avoid undesirable ringing; bilateral filtering can provide good protection for image processing with a relatively wide frequency domain, and has strong nonlinear processing capabilities, good local processing effects, and no iteration in the calculation process. For images, the advantages of Gaussian filtering and bilateral filtering complement each other, and their respective limitations are effectively compensated when used in combination. The combination of the two is more effective in denoising.

[0057] S2 key area marking.

[0058] By marking key areas, key information can be retained and the problem of detail loss in image compression can be overcome.

[0059] This can be done by automatically identifying key areas or by user-defined key areas, or a combination of both.

[0060] By automatically identifying key areas, the self-attention mechanism module can be used to assign more attention weights to the content in key areas of the image. This not only improves the compression efficiency, but also ensures that the key information of the compressed image is retained to the greatest extent.

[0061] Customer-defined key areas refer to users requiring key areas in images to be marked according to their own needs (key areas refer to areas that users need to perform lossless compression on) to meet their personalized needs.

[0062] Preferably, a combination of the two is adopted to take into account both efficiency and personalized needs. Specifically, the steps may include:

[0063] S21 users can manually mark key areas; users can circle key areas in the picture with the mouse on the computer according to their needs, such as people in the picture, the most colorful parts, etc.

[0064] S22 self-attention mechanism automatically marks key areas. The specific steps include the following:

[0065] S221. Build a self-attention mechanism.

[0066] The attention module is integrated on the feature maps of different scales, and the Transformer architecture is used as the basis of the self-attention mechanism. Specifically, the Multi-Head Self-Attention module is used to allow the model to independently focus on different dimensions of image information in different representation subspaces. The image information is mainly divided into five dimensions: the person in the picture, the middle area of ​​the picture, the colorful part of the picture, the focus area of ​​the photo, and the object close to the lens in the picture. These five dimensions are used to enhance the model's ability to capture the key areas of the picture. People in the picture, this dimension can focus attention on the people in the picture and better preserve the details of the people; the middle area of ​​the picture, generally the middle area of ​​the picture is the part that people pay the most attention to, this dimension can focus attention on the details of the picture in the middle area of ​​the picture; the brightly colored part of the picture, this part is often regarded as the focus of the visual scene, focusing attention on this dimension can preserve the attractiveness and expressiveness of the picture; the focus area of ​​the photo, this dimension can better simulate human visual habits, focus attention on the point that is usually focused when taking pictures, so that the model can recognize the key area more accurately; objects close to the lens in the picture, objects close to the lens often carry more information and emotions, and are the main content that the picture wants to convey. Focusing attention on objects close to the lens can better preserve the content that the picture wants to convey. The five dimensions, combined together, make the model recognize the key areas of the picture more accurately.

[0067] The loss function is designed to combine the classification loss, the localization loss, and the regularization term of the attention weight to ensure that the model can not only accurately mark the important areas, but also balance between different types of image features. For example, in one embodiment, the loss function is as follows:

[0068]

[0069] Among them, α, β, γ are weight factors, L class represents the classification loss, L loc represents the positioning loss; Represents the regularization term of the attention weight.

[0070] As in one embodiment of the present invention, the step includes:

[0071] S2211: Image segmentation and serialization. The image is segmented into fixed 16×16 size image blocks and these blocks are flattened into sequences.

[0072] S2212: Patch Embedding and Position Coding: Through a linear transformation (PatchEmbedding), each image block is mapped to a fixed-dimensional vector space, and position coding is added to preserve the position information.

[0073] S2213: Multi-Head Self-Attention Design. The corresponding vector of each image block will be decomposed into three matrices: Query (Q stands for query), Key (K stands for key) and Value (V stands for value); then Multi-Head Self-Attention (MSA) is designed to contain 5 parallel attention heads, each of which will have its own set of weight matrices (W^Q, W^K, W^V). These weight matrices represent five different dimensions, namely the people in the picture, the middle area of ​​the picture, the colorful part of the picture, the focus area of ​​the photo, and the objects close to the lens in the picture. These weight matrices allow each head to focus on different features.

[0074] S2214: Self-attention calculation and integration. Multiple self-attention heads perform self-attention calculations separately, and then concatenate the results and integrate them through a fully connected layer; then the attention score of each head is calculated by scaling the dot product, and then normalized using the softmax function to obtain the attention weight.

[0075] S222. Obtain a general image dataset on the Internet, and divide the dataset into a training set and a test set according to a ratio of 7:3.

[0076] Furthermore, this step also includes the step of preprocessing the training data, specifically including:

[0077] S2221. Obtain a dataset. Obtain a general image dataset from the Internet and divide the dataset into a training set and a test set in a ratio of 7:3. The datasets include CIFAR-10, ImageNet, and MNIST.

[0078] S2222. Data enhancement and preprocessing.

[0079] According to the image information dimension setting of the multi-head attention mechanism mentioned above, the annotations of people in the picture, the annotations of the middle area of ​​the picture, the annotations of the colorful parts of the picture, the annotations of the focus area of ​​the picture, and the annotations of the objects close to the lens in the picture are added to the training set and the test set; then this information is encoded as additional features as part of the input.

[0080] S2223, weight matrix initialization. Initialize the weight matrix (W^Q, W^K, W^V) based on the weights of the Transformer structure model, and then train the weight matrix based on the data set preprocessed in step S2222, so that the weight matrix allows each head to focus on different features, thereby making feature recognition more accurate.

[0081] S223. Train the self-attention mechanism module.

[0082] First, input the image, process it through the self-attention module, and output the attention weight;

[0083] Then, the loss is calculated based on the prediction results and the true annotations;

[0084] Next, the model parameters are updated according to the gradient of the loss function, and the forward propagation and back propagation processes are repeated until convergence or the predetermined training rounds are reached, and the training ends.

[0085] S224: Automatically mark key areas.

[0086] According to the trained self-attention mechanism module, the attention weight of each area of ​​the image is calculated and a threshold is set. For example, in one embodiment, the attention weight threshold is set to 0.55, that is, areas with attention weights higher than 0.55 are regarded as key areas, and the key areas are marked.

[0087] S3 performs Huffman compression on key areas.

[0088] The Huffman coding compression process can be referenced Figure 2 Specifically, the following steps may be included:

[0089] S31 performs grayscale processing on the key area image.

[0090] First, convert the color image into a grayscale image. At this time, each pixel can be represented by a single pixel to facilitate the subsequent frequency statistics of the pixels.

[0091] S32: Pixel frequency statistics and Huffman tree construction.

[0092] Perform frequency statistics of grayscale values ​​of pixels in the key area, build a Huffman tree, generate the corresponding Huffman coding table, and package the final coded data and the coding table for decoding.

[0093] In one embodiment, the step specifically includes:

[0094] S321 counts pixel frequency. First, use the image pixel reading function read() of Python's built-in PIL library to obtain all the pixels of the grayscale image. By looping through each pixel, the value of each pixel and its number of occurrences are put into the Python dictionary in the form of key-value pairs.

[0095] S322: Construct a Huffman tree. Traverse the saved pixel frequency dictionary, define all the pixels in the image as leaf nodes, and use the class code and weight to represent the corresponding pixel value and the number of times the pixel appears; at this time, the weights in the leaf nodes are in disorder, and all the leaf nodes are sorted from small to large according to the weight of each leaf node; each time, the two nodes with the smallest weight are the nodes to be replaced, and the weights of the two nodes are added, and then a new node is generated, and the two nodes are removed from the leaf node list, and the newly generated node is put into the leaf node list, and the list is sorted; continue to repeat the previous step until there is only one node left in the list, and this node is the head node.

[0096] S323: Traverse the Huffman coding tree and generate a binary Huffman codeword dictionary. At this point, the Huffman coding tree has been constructed. Traverse the entire tree starting from the leaf node, assigning codeword 1 to the left and codeword 0 to the right, and traverse downward once each time. If the node is not a root node, place the code symbol on the left side of the codeword in turn. If the root node is traversed, the pixel value represented by the leaf node and the corresponding codeword are placed in the codeword dictionary until all leaf nodes have their corresponding binary Huffman codewords.

[0097] S234: compression of key areas of the image; at this time, the codeword dictionary of the pixels has been generated, and the original image is returned. According to the pixel points of the original image, the corresponding codewords are searched in the codeword list in turn, and the codewords corresponding to all the pixel points are spliced ​​together. At this time, the compression of the key areas of the image is completed.

[0098] S4 generates images based on the decoded images of key areas using the trained GAN model.

[0099] Specifically, the steps may include:

[0100] S41: Decoding of key areas of the image.

[0101] The Huffman code is read bit by bit from the compressed file, and the Huffman tree is reversely reconstructed according to the construction rules of the Huffman code (that is, the two nodes with the lowest frequency are merged to generate a new node) using the information in the code table. Each original data value or pixel value obtained by decoding will be placed in the original order, and the picture of the key area will be gradually restored.

[0102] S42: Train GAN. Prepare a high-quality and diverse dataset and train a generative adversarial network (GAN). The GAN network structure framework is shown in the figure below. Figure 3As shown in the figure. GAN usually involves two main components: the generator and the discriminator. The two networks learn by playing against each other, with the goal of making the generator generate realistic samples as much as possible, while the discriminator distinguishes between real samples and generated samples as accurately as possible. The loss function design of GAN is its core part, involving the optimization objectives of both the generator (G) and the discriminator (D).

[0103] As in one embodiment of the present invention,

[0104] The loss function of the discriminator is L D ,

[0105] L D =L real +L fake (1)

[0106] Among them, L real is the loss function for real samples, L fake is the loss function for fake samples;

[0107]

[0108] Among them, E: expected value, which means the average value, here is for the real data distribution p data Take the average of all samples x in (x);

[0109] p data (x): true data distribution, which represents the actual probability distribution of the training data set;

[0110] log(D(x)): For each true sample x, the discriminator outputs the logarithm of the probability that it is true; the larger this value is, the higher the recognition of the true sample is.

[0111]

[0112] E: Same as (2), but this time for the noise distribution p z The average of the randomly sampled z in (z);

[0113] p z (z): Noise prior distribution, usually a simple distribution such as Gaussian distribution or uniform distribution, used as the input of the generator;

[0114] G(z): generator function, which converts the noise vector z into fake samples;

[0115] log(1-D(G(z))): For generated samples, we hope that the logarithm of the probability that the discriminator outputs that it is false is close to 1.

[0116] The generator loss function is L G ,

[0117]

[0118] Among them, E is the same as formula (3), which directly reflects that the generator wants to "cheat" the discriminator so that it gives a higher authenticity score to the generated samples.

[0119] S43: Based on the decoded image of the key area, the trained GAN model is used to reasonably and naturally supplement the missing or blurred parts, so that the generated image maintains consistency with the style, color and texture of the original image.

[0120] The testing and adjustment part of S44 image compression.

[0121] The purpose of this part is to continuously improve the accuracy and robustness of model compression.

[0122] S45: Performance evaluation and optimization.

[0123] Use PSNR (Peak Signal-to-Noise Ratio, the larger the value, the smaller the distortion and the higher the image quality) and SSIM (Structural Similarity Index Measure, ranging from -1 to 1, 1 means that the two images are exactly the same, -1 means that the structures of the two images are completely different, and 0 means there is no correlation) to evaluate the compressed image and the original image and quantify the compression effect. According to the evaluation results, adjust and optimize the self-attention mechanism strategy, GAN training parameters, etc., and continue to iterate to achieve the best compression effect.

[0124] The present invention proposes a picture compression method based on Huffman and GAN feature fusion network. The method aims at the contradiction between compression efficiency and visual quality in traditional compression technology. By losslessly compressing key areas, non-key areas are generated by GAN in the decoding stage, so as to achieve a good balance between compression efficiency and visual quality. First, the self-attention mechanism is used to intelligently identify the core details in the picture, allowing users to manually intervene to ensure the accurate labeling of key areas. This strategy improves the recognition ability and pertinence of compression. Secondly, Huffman coding is used to implement lossless compression on these marked key areas. Through lossless data coding, the storage requirements are greatly reduced without damaging the picture quality. For non-key areas in the picture, the present invention uses the powerful generation ability of generative adversarial network (GAN) to generate and optimize, ensuring that these areas can maintain a high degree of consistency with the original image in style, color and texture during the decompression process, effectively improving the generalization ability of the model. More importantly, the present invention not only improves the efficiency and effect of picture compression by combining the efficient lossless characteristics of Huffman coding and the adaptive generation ability of GAN, but also significantly enhances the tolerance to errors in compression, and improves the accuracy and robustness of compressed pictures.

[0125] In summary, the present invention combines the weight of the self-attention mechanism, the efficiency of Huffman coding and the regeneration ability of GAN to design a cutting-edge image compression technology, which is particularly suitable for application scenarios such as mobile phone online photo albums and cloud storage. Therefore, the present invention has far-reaching and broad application prospects.

[0126] The embodiment of the present invention also provides an image compression system based on a Huffman and GAN feature fusion network, including:

[0127] Image acquisition module, used to acquire original images and perform preprocessing;

[0128] Annotation module: used to automatically annotate key areas of an image using a self-attention mechanism module, and / or annotate key areas as specified by a user;

[0129] Compression module: used to compress key areas of the image;

[0130] Decompression module; used to decode the key area pictures;

[0131] GAN network module: Generate images based on the decoded images of key areas.

[0132] An embodiment of the present invention also provides a computer device, including: a processor; the processor is used to execute a computer program stored in a memory, and when the program instructions are executed by the computer, the computer executes an image compression method based on a Huffman and GAN feature fusion network provided by any possible implementation method, for example, including: image preprocessing; key area labeling; Huffman compression of key areas; and image generation based on the decoded key area image using a trained GAN model.

[0133] An embodiment of the present invention further provides a computer-readable storage medium having computer instructions stored thereon, wherein the computer instructions enable the computer to execute an image compression method based on a Huffman and GAN feature fusion network provided in any possible implementation, for example, including: image preprocessing; key area labeling; Huffman compression of key areas; and image generation based on decoding of key area images using a trained GAN model.

[0134] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods of each embodiment or some parts of the embodiment.

[0135] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions provided according to the embodiments of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the aforementioned embodiments, it can be understood by those of ordinary skill in the art that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit provided according to the embodiments of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles provided according to the embodiments of the present invention should be included in the protection scope provided according to the embodiments of the present invention.

Claims

1. A picture compression method based on Huffman and GAN feature fusion network, characterized in that: The steps include: S1 image preprocessing; S2 key area marking; S3 performs Huffman compression on key areas; Based on the decoding of the key area images, S4 uses the trained GAN model to generate images.

2. The image compression method according to claim 1, characterized in that: In step S2, the key areas are automatically labeled using the trained self-attention mechanism, and / or the key areas are manually labeled according to user specifications.

3. The image compression method according to claim 2, characterized in that: In step S2, the self-attention mechanism is based on the transformer model and adopts a multi-head self-attention module to divide the image information into five dimensions, namely: the people in the picture, the middle area of ​​the picture, the colorful part of the picture, the focus area of ​​the photo, and the objects close to the lens in the picture.

4. The image compression method according to claim 3, characterized in that: In step S2, the loss function of the self-attention mechanism is as follows: Among them, α, β, γ are weight factors, L class represents the classification loss, L loc represents the positioning loss; Represents the regularization term of the attention weight.

5. The image compression method according to claim 4, characterized in that: In step S2, multiple self-attention heads perform self-attention calculations separately, and then concatenate the results and integrate them through a fully connected layer; then the attention score of each head is calculated by scaled dot product and then normalized using the softmax function to obtain the attention weight.

6. The image compression method according to claim 5, characterized in that: In step S2, the attention weight threshold is set to 0.

55.

7. The image compression method according to claim 1, characterized in that: In step S4, the GAN model includes a generator and a discriminator. The loss function of the discriminator is L D , L D =L real +L fake (1), Among them, L real is the loss function for real samples, L fake is the loss function for fake samples; Among them, E: expected value, which means the average value, here is for the real data distribution p data Take the average of all samples x in (x); p data (x): true data distribution, which represents the actual probability distribution of the training data set; log(D(x)): For each true sample x, the discriminator outputs the logarithm of the probability that it is true; E: Same as (2), but this time for the noise distribution p z The average of the randomly sampled z in (z); p z (z): Noise prior distribution, used as input to the generator; G(z): generator function, which converts the noise vector z into fake samples; The generator loss function is L G , Wherein, E is the same as formula (3).

8. An image compression system based on Huffman and GAN feature fusion network, characterized in that: include: Image acquisition module, used to acquire original images and perform preprocessing; A key area labeling module is used to automatically label key areas of an image using a self-attention mechanism module, and / or to label key areas according to user specifications; Compression module; Used to perform Huffman compression on key areas of the image; Decompress the module; Used to decode images in key areas; Image generation module; Based on the decoded images of the key areas, the GAN network module is used to generate images.

9. A computer device, characterized in that: The computer device comprises: a processor; The processor is used to implement the steps of the method according to any one of claims 1 to 7 when executing the computer program stored in the memory.

10. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Picture processing method and related device

    CN119645278A