Method and apparatus for compressing image
AssigneeBaidu Online Network Technology (Beijing) Co., Ltd.
InventorRenliang Weng
Life of this patent
Estimating the term…
Abstract
Embodiments of the present disclosure disclose a method and apparatus for compressing an image. A specific embodiment of the method includes: acquiring a to-be-processed image; and performing feature extraction on the to-be-processed image by using a convolutional neural network corresponding to a trained image compression model to obtain a plurality of feature maps, a difference between the to-be-processed image and a reconstructed image obtained by reconstructing the plurality of feature maps through a deconvolution neural network corresponding to a trained image reconstruction model satisfying a preset condition. This embodiment achieves compression of the data size of an image while ensuring the restoration quality of the image.
Claims11
A method for compressing an image, the method comprising:
- acquiring a to-be-processed image;
- and
- performing feature extraction on the to-be-processed image by using a convolutional neural network corresponding to a trained image compression model to obtain a plurality of feature maps;
- a difference between the to-be-processed image and a reconstructed image obtained by reconstructing the plurality of feature maps through a deconvolution neural network corresponding to a trained image reconstruction model satisfying a preset condition;
- wherein the image compression model and the image reconstruction model are trained as follows:
- acquiring a sample image and performing a comparison step;
- the comparison step comprises:
- inputting the sample image into the image compression model, outputting a plurality of sample feature maps, inputting the plurality of sample feature maps into the deconvolution neural network corresponding to the image reconstruction model to reconstruct the plurality of sample feature maps to obtain a reconstructed image of the sample image, creating a loss function based on a difference between the sample image and the reconstructed image of the sample image, and determining whether a value of the loss function satisfies a preset convergence condition;
- updating at least one of a parameter of the convolutional neural network corresponding to the image compression model or a parameter of the deconvolution neural network corresponding to the image reconstruction model using a gradient descent method based on the loss function, if a result of the comparison step is negative, and performing the comparison step based on the updated parameter;
- and
- outputting the parameter of the convolutional neural network corresponding to the image compression model and the parameter of the deconvolution neural network corresponding to the image reconstruction model, if the result of the comparison step is positive.
An apparatus for compressing an image, the apparatus comprising:
- at least one processor;
- and
- a memory storing instructions, the instructions when executed by the at least one processor, cause the at least one processor to perform operations, the operations comprising:
- acquiring a to-be-processed image;
- and
- performing feature extraction on the to-be-processed image by using a convolutional neural network corresponding to a trained image compression model to obtain a plurality of feature maps;
- a difference between the to-be-processed image and a reconstructed image obtained by reconstructing the plurality of feature maps through a deconvolution neural network corresponding to a trained image reconstruction model satisfying a preset condition;
- wherein the image compression model and the image reconstruction model are trained as follows:
- acquiring a sample image and performing a comparison step;
- the comparison step comprises:
- inputting the sample image into the image compression model, outputting a plurality of sample feature maps, inputting the plurality of sample feature maps into the deconvolution neural network corresponding to the image reconstruction model to reconstruct the plurality of sample feature maps to obtain a reconstructed image of the sample image, creating a loss function based on a difference between the sample image and the reconstructed image of the sample image, and determining whether a value of the loss function satisfies a preset convergence condition;
- updating at least one of a parameter of the convolutional neural network corresponding to the image compression model or a parameter of the deconvolution neural network corresponding to the image reconstruction model using a gradient descent method based on the loss function, if a result of the comparison step is negative, and performing the comparison step based on the updated parameter;
- and
- outputting the parameter of the convolutional neural network corresponding to the image compression model and the parameter of the deconvolution neural network corresponding to the image reconstruction model, if the result of the comparison step is positive.
A non-transitory computer-readable storage medium storing a computer program, the computer program when executed by one or more processors, causes the one or more processors to perform operations, the operations comprising:
- acquiring a to-be-processed image;
- and
- performing feature extraction on the to-be-processed image by using a convolutional neural network corresponding to a trained image compression model to obtain a plurality of feature maps;
- a difference between the to-be-processed image and a reconstructed image obtained by reconstructing the plurality of feature maps through a deconvolution neural network corresponding to a trained image reconstruction model satisfying a preset condition;
- wherein the image compression model and the image reconstruction model are trained as follows:
- acquiring a sample image and performing a comparison step;
- the comparison step comprises:
- inputting the sample image into the image compression model, outputting a plurality of sample feature maps, inputting the plurality of sample feature maps into the deconvolution neural network corresponding to the image reconstruction model to reconstruct the plurality of sample feature maps to obtain a reconstructed image of the sample image, creating a loss function based on a difference between the sample image and the reconstructed image of the sample image, and determining whether a value of the loss function satisfies a preset convergence condition;
- updating at least one of a parameter of the convolutional neural network corresponding to the image compression model or a parameter of the deconvolution neural network corresponding to the image reconstruction model using a gradient descent method based on the loss function, if a result of the comparison step is negative, and performing the comparison step based on the updated parameter;
- and
- outputting the parameter of the convolutional neural network corresponding to the image compression model and the parameter of the deconvolution neural network corresponding to the image reconstruction model, if the result of the comparison step is positive.
Dependencies are inferred from the claim text.