Image caption compression learning method based on swin transformer and terminal
By employing an image captioning compression learning method based on Swin Transformer, compressed sensing and feature extraction are performed on the original image, solving the problem of low storage and transmission efficiency in image captioning tasks and achieving efficient image captioning generation.
Patent Information
- Application Number
- CN202310601283.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-25
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-05-25
AI Technical Summary
Existing technologies lack research on compressed learning in image captioning tasks, which makes it impossible to effectively perform multimodal tasks, resulting in low storage space and transmission efficiency.
A compression learning method for image captioning based on Swin Transformer is adopted. The original image is compressed and sensed to obtain measurement values. The image feature extraction module and image captioning module of Swin Transformer are used to interact with features and finally generate image captions.
It significantly saves storage space and improves transmission efficiency while sacrificing a small amount of image captioning quality, making it suitable for image captioning tasks.
Smart Images

Figure CN116823974B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image compression, and more particularly to an image caption compression learning method and terminal based on Swin Transformer. Background Technology
[0002] Compressed learning is a relatively new concept that has emerged in recent years. It refers to compressing an image and then directly using the compressed measurements as input for downstream tasks to learn and infer. Compared to directly captioning the original image, compressed learning may result in the loss of some image information due to image compression, thus affecting the performance of downstream tasks to some extent. However, if sacrificing a small amount of downstream task performance can save significant storage space and increase transmission efficiency, then compressed learning is of great practical significance.
[0003] Current research on compressed learning focuses on classic image tasks such as image classification and semantic segmentation, and has achieved very good results in these tasks. However, there is no relevant research on multimodal tasks.
[0004] Therefore, existing technologies still need improvement. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide an image caption compression learning method and terminal based on SwinTransformer to address the shortcomings of the existing technology, thereby solving the technical problem that traditional compression learning schemes cannot perform multimodal tasks.
[0006] The technical solution adopted by this invention to solve the technical problem is as follows:
[0007] In a first aspect, the present invention provides an image caption compression learning method based on Swing Transformer, comprising:
[0008] Acquire the original image and perform compressed sensing processing on the original image to obtain the measurement value of the original image;
[0009] The measured values are input into the image feature extraction module based on Swin Transformer to obtain the image features of the original image;
[0010] The image features are input into the image captioning module to obtain the image captions of the original image.
[0011] In one implementation, acquiring the original image and performing compressed sensing processing on the original image to obtain the measurement values of the original image includes:
[0012] Obtain the original image;
[0013] The original image is input into the compressed sensing module, and compressed sensing processing is performed on the original image to obtain the compressed sensing measurement sequence of the original image and the corresponding measurement values.
[0014] In one implementation, inputting the original image into the compressed sensing module and performing compressed sensing processing on the original image includes:
[0015] The original image is input into the compressed sensing module, and the original image is subjected to block segmentation and block steering operation to obtain signal X;
[0016] The signal X is subjected to compressed sensing to obtain the measurement sequence Y.
[0017] In one implementation, the signal X is:
[0018] X = F(I)
[0019] Where F is a function for block operations and block-to-vector transformation operations, used to divide the image I into blocks of equal size and convert the corresponding blocks into vectors.
[0020] In one implementation, the measurement sequence Y is:
[0021] Y = AX
[0022] Where A is the measurement matrix of compressed sensing operation, and Y is the measurement sequence obtained by X through compressed sensing.
[0023] In one implementation, the image feature extraction module includes: a linear projection layer, multiple SwinTransformer blocks, and multiple block merging layers.
[0024] In one implementation, the step of inputting the measured value into a Swin Transformer-based image feature extraction module to obtain the image features of the original image includes:
[0025] The linear projection layer projects the measurement sequence obtained by the compressed sensing module onto a new dimension.
[0026] Intra-block and inter-block features are extracted using two consecutive Swin Transformer blocks;
[0027] Adjacent blocks are merged by a block merging layer, and each merged block is downsampled to obtain downsampled features.
[0028] In one implementation, in two consecutive Swing Transformer blocks, the multi-head self-attention layer of the first Swing Transformer block is a window multi-head self-attention layer, and the multi-head self-attention layer of the second Swing Transformer block is a movable window multi-head self-attention layer.
[0029] In a second aspect, the present invention provides a computer terminal, comprising: a processor and a memory, wherein the memory stores an image caption compression learning program based on Swin Transformer, and the image caption compression learning program based on Swin Transformer is executed by the processor to implement the operation of the image caption compression learning method based on Swin Transformer as described in the first aspect.
[0030] Thirdly, the present invention provides a computer-readable storage medium storing a Swin Transformer-based image caption compression learning program, which, when executed by a processor, is used to implement the operation of the Swin Transformer-based image caption compression learning method as described in the first aspect.
[0031] The present invention, by employing the above technical solution, has the following effects:
[0032] This invention uses compressed sensing to compress the original image and obtain measurement values. These compressed sensing measurements are then input into a Swin Transformer-based image feature extraction module to obtain image features. These features are subsequently input into an image captioning module, where they interact with text features to ultimately generate image captions. This invention allows for the storage or transmission of measurement values obtained after compressed sensing of the original image. When image captioning is required, these measurement values can be directly input for inference to obtain image captions. This invention achieves the effect of only slightly sacrificing image captions while saving significant storage space and increasing transmission efficiency, which is very helpful for the practical application of image captioning tasks. Attached Figure Description
[0033] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0034] Figure 1This is a flowchart of an image caption compression learning method based on Swing Transformer in one implementation of the present invention.
[0035] Figure 2 This is a schematic diagram of the architecture of an image caption compression learning model based on Swing Transformer in one implementation of the present invention.
[0036] Figure 3 This is a schematic diagram of the feature extraction module in one implementation of the present invention.
[0037] Figure 4 This is a schematic diagram of two consecutive Swing Transformer blocks in one implementation of the present invention.
[0038] Figure 5 This is an experimental result of offline evaluation on the MSCOCO dataset in one implementation of the present invention.
[0039] Figure 6 This is an experimental result of online evaluation on the MSCOCO dataset in one implementation of the present invention.
[0040] Figure 7 This is a functional schematic diagram of the terminal in one implementation of the present invention. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0042] Exemplary methods
[0043] Current research on compressed learning focuses on classic image tasks such as image classification and semantic segmentation, achieving remarkable results. However, there is a lack of research on multimodal tasks. Therefore, existing techniques require further improvement and development.
[0044] To address the aforementioned technical problems, this invention provides an image caption compression learning method based on Swin Transformer. The method involves compressing the image using sensing to obtain measurement values. These compressed sensing values are then input into a Swin Transformer-based image feature extraction module to obtain image features. Subsequently, these image features are input into an image captioning module, where they interact with the text features to finally obtain the image captions.
[0045] This invention allows for the storage or transmission of measurement values obtained after compressed sensing of the original image. When image captioning is required, the measurement values can be directly input for inference to obtain image captions. This invention achieves the effect of only losing a small amount of image captions, while saving a significant amount of storage space and increasing transmission efficiency, which is very helpful for the practical application of image captioning tasks.
[0046] like Figure 1 As shown, this embodiment of the invention provides an image caption compression learning method based on Swing Transformer, including the following steps:
[0047] Step S100: Acquire the original image and perform compressed sensing processing on the original image to obtain the measurement value of the original image.
[0048] In this embodiment, the image caption compression learning method based on Swing Transformer is applied to a terminal, which includes, but is not limited to, devices such as computers and mobile terminals.
[0049] In this embodiment, the image measurement sequence is first obtained by inputting the image through the compressed sensing module, then the image features are extracted from the image measurement sequence through the feature extraction module, and finally the image features are input into the image captioning module to obtain the image captions.
[0050] Specifically, in one implementation of this embodiment, step S100 includes the following steps:
[0051] Step S101: Obtain the original image;
[0052] Step S102: Input the original image into the compressed sensing module, perform compressed sensing processing on the original image, and obtain the compressed sensing measurement sequence of the original image and the corresponding measurement values.
[0053] In this embodiment, in the image captioning task, even after compressing the original image using compressed sensing, extracting features from the compressed sensing measurement sequence does not significantly degrade the performance of image captioning. Thus, sacrificing a little performance can greatly improve transmission efficiency and save storage space.
[0054] In this embodiment, the focus is primarily on the compressed sensing module and the feature extraction module. Theoretically, extracting image features is effective for any image captioning module based on the Swing Transformer; therefore, specific image captioning modules will not be discussed.
[0055] Specifically, in one implementation of this embodiment, step S102 includes the following steps:
[0056] Step S1021: Input the original image into the compressed sensing module, perform block segmentation and block steering operation on the original image to obtain signal X;
[0057] Step S1022: Compressed sensing is performed on the signal X to obtain the measurement sequence Y.
[0058] like Figure 2 As shown, Figure 2 This diagram illustrates the overall framework of the image caption compression learning based on the Swing Transformer proposed in this embodiment, along with some details of the compressed sensing module. The overall framework mainly includes: a compressed sensing module, a feature extraction module, and an image captioning module.
[0059] In this embodiment, during the processing of the image caption compression learning framework based on Swin Transformer, the image is first input into the compression sensing module for compression to obtain a measurement sequence; then, the measurement sequence is input into the feature extraction module to extract image features; finally, the image features are input into the image caption module to obtain the text description of the image; the following mainly describes the compression sensing module and the feature extraction module:
[0060] The compressed sensing module includes block operations, block-to-vector transformation operations, and compressed sensing operations. The compressed sensing measurement matrix is learnable. The input to the compressed sensing module is image I. Block operations and block-to-vector transformation operations are performed on image I to obtain signal X, as shown in the following formula:
[0061] X = F(I)
[0062] Here, F is a function for block operations and block-to-vector transformation operations, which divides the image I into equal-sized blocks and converts these blocks into vectors. Compressed sensing is applied to the signal X to obtain the measurement sequence Y, as shown in the formula:
[0063] Y = AX
[0064] Where A is the measurement matrix of compressed sensing operation (i.e. Figure 2 The sampling matrix in the image is Y, which is the measurement sequence of X obtained through compressed sensing.
[0065] In this embodiment, storing the measurement sequence Y processed by the compressed sensing module saves storage space compared to directly storing image I. Transmitting the measurement sequence Y processed by the compressed sensing module reduces transmission time compared to directly transmitting image I. Therefore, processing image I using the compressed sensing module is very useful.
[0066] like Figure 1 As shown, in one implementation of this invention, the image caption compression learning method based on Swing Transformer further includes the following steps:
[0067] Step S200: Input the measured value into the image feature extraction module based on Swin Transformer to obtain the image features of the original image.
[0068] In this embodiment, after image I passes through the compressed sensing module, image features are extracted by the image feature extraction module; wherein, the image feature extraction module includes: a linear projection layer, multiple Swing Transformer blocks, and multiple block merging layers.
[0069] Specifically, in one implementation of this embodiment, step S200 includes the following steps:
[0070] Step S201: Project the measurement sequence obtained by the compressed sensing module onto a new dimension through the linear projection layer;
[0071] Step S202: Extract intra-block features and inter-block features from two consecutive Swin Transformer blocks;
[0072] Step S203: Merge adjacent blocks through a block merging layer, and downsample each merged block to obtain downsampled features.
[0073] In this embodiment, the structure of the feature extraction module is almost the same as that of the Swin Transformer, including a linear projection layer, multiple Swin Transformer blocks, and multiple block merging layers.
[0074] The linear projection layer projects the measurement sequence obtained by the compressed sensing module onto a new dimension. Among the multiple SwinTransformer blocks, there are at least two different Swin Transformer blocks, both of which consist of two normalized layers, a multilayer perceptron with a GELU activation function in the middle, multiple residual connections, and a multi-head self-attention mechanism.
[0075] The difference lies in the multi-head self-attention: the first Swing Transformer block uses windowed multi-head self-attention, while the second uses movable-window multi-head self-attention. Each Swing Transformer block with windowed multi-head self-attention is always followed by a Swing Transformer block with movable-window multi-head self-attention. After two consecutive Swing Transformer blocks, intra-block and inter-block features are extracted. Then, a block merging layer is used to first merge four adjacent blocks, and then each merged block is downsampled.
[0076] like Figure 3As shown, Figure 3 This is a schematic diagram of the feature extraction module in this embodiment. The measured value Y (i.e., the measurement sequence Y) is first projected onto the C dimension through a linear projection layer, and then the image features are obtained through multiple Swin-Transformer blocks and block merging layers.
[0077] like Figure 4 As shown, Figure 4 This diagram illustrates two consecutive Swin Transformer blocks in this embodiment. The intermediate features first pass through a Swin-Transformer block consisting of layer normalization, multi-head self-attention of a window, and a multilayer perceptron. Then, new features are obtained by passing through another Swin-Transformer block consisting of layer normalization, multi-head self-attention of a movable window, and a multilayer perceptron.
[0078] like Figure 1 As shown, in one implementation of this invention, the image caption compression learning method based on Swing Transformer further includes the following steps:
[0079] Step S300: Input the image features into the image captioning module to obtain the image captions of the original image.
[0080] In this embodiment, the measurement sequence Y is processed by an image feature extraction module based on the Swing Transformer to obtain image features. These image features are then input into an image captioning module to obtain image captions.
[0081] Existing compressed learning methods are currently limited to classic image tasks, such as image classification and semantic segmentation. This embodiment primarily explores the application of compressed learning to multimodal tasks, implementing compressed learning in image captioning. Specifically, by storing or transmitting the measurement sequence of the image, captions that closely resemble those generated from the original image can be obtained, significantly saving storage space and improving transmission efficiency.
[0082] The model in this embodiment is verified through experiments.
[0083] like Figure 5 As shown, Figure 5 The results are experimental findings from offline evaluation of this invention on the MSCOCO dataset; higher values for all evaluation metrics are preferred. STCL(Swin-Bx) represents the STCL method in this embodiment, with a compression ratio of 'a', a Swin-B feature extraction module, and a PTSN image captioning module. All other methods use the original image as input. This embodiment primarily compares PTSN and STCL; results from other image captioning methods are used for reference.
[0084] like Figure 6As shown, Figure 6 The results are presented as experimental results of the online evaluation of this invention on the MSCOCO dataset. Higher evaluation metrics are preferred. STCL(Swin-Bx) represents the STCL method in this embodiment, with a compression ratio of x, a Swin-B feature extraction module, and a PTSN image captioning module. All other methods use the original image for captioning. This embodiment primarily compares the single-model PTSN and STCL, with the integrated model image captioning method used as a reference.
[0085] This embodiment achieves the following technical effects through the above technical solution:
[0086] This embodiment compresses the original image using compressed sensing to obtain measurement values. These compressed sensing measurements are then input into a Swin Transformer-based image feature extraction module to obtain image features. These features are subsequently input into an image captioning module, where they interact with text features to ultimately generate the image captions. This embodiment allows for the storage or transmission of measurement values obtained after compressed sensing of the original image. When image captioning is required, these measurement values can be directly input for inference to obtain the image captions. This embodiment achieves the effect of only slightly sacrificing image captions while saving significant storage space and increasing transmission efficiency, which is very helpful for the practical application of image captioning tasks.
[0087] Exemplary device
[0088] Based on the above embodiments, the present invention also provides a computer terminal, comprising: a processor, a memory, an interface, a display screen, and a communication module connected via a system bus; wherein, the processor is used to provide computing and control capabilities; the memory includes a storage medium and internal memory; the storage medium stores an operating system and computer programs; the internal memory provides an environment for the operation of the operating system and computer programs in the storage medium; the interface is used to connect to external devices, such as mobile terminals and computers; the display screen is used to display corresponding information; and the communication module is used to communicate with a cloud server or a mobile terminal.
[0089] When the computer program is executed by the processor, it is used to implement an image caption compression learning method based on Swing Transformer.
[0090] It will be understood by those skilled in the art that Figure 7 The block diagram shown is merely a partial structural diagram related to the present invention and does not constitute a limitation on the computer terminal to which the present invention is applied. A specific computer terminal may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0091] In one embodiment, a computer terminal is provided, comprising: a processor and a memory, the memory storing a Swing Transformer-based image caption compression learning program, which, when executed by the processor, is used to implement the operation of the Swing Transformer-based image caption compression learning method as described above.
[0092] In one embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a Swin Transformer-based image caption compression learning program, which, when executed by the processor, is used to implement the operation of the Swin Transformer-based image caption compression learning method as described above.
[0093] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, storage, databases, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory.
[0094] In summary, this invention provides an image captioning compression learning method and terminal based on Swin Transformer. The method includes: acquiring an original image and performing compressed sensing processing on the original image to obtain measurement values of the original image; inputting the measurement values into an image feature extraction module based on Swin Transformer to obtain image features of the original image; and inputting the image features into an image captioning module to obtain image captions of the original image. This invention can store or transmit the measurement values obtained after compressed sensing of the original image. When image captioning tasks are needed, the measurement values can be directly input for inference to obtain image captions, thereby saving a lot of storage space and increasing transmission efficiency, which is very helpful for the practical application of image captioning tasks.
[0095] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A learning method for image caption compression based on Swing Transformer, characterized in that, include: Acquire the original image and perform compressed sensing processing on the original image to obtain the measurement value of the original image; The measured values are input into the image feature extraction module based on Swin Transformer to obtain the image features of the original image; The image features are input into the image captioning module to obtain the image captions of the original image; The step of inputting the original image into the compressed sensing module and performing compressed sensing processing on the original image includes: The original image is input into the compressed sensing module, where it undergoes block segmentation and block steering operations to obtain the signal. ; For the signal Compressed sensing is performed to obtain the measurement sequence. ; The signal for: in, Functions for block operations and block-to-vector transformation operations, used to transform images. Divide the data into equal-sized blocks and convert the corresponding blocks into vectors; The image feature extraction module includes: a linear projection layer, multiple Swing Transformer blocks, and multiple block merging layers; The step of inputting the measured values into the image feature extraction module based on Swin Transformer to obtain the image features of the original image includes: The linear projection layer projects the measurement sequence obtained by the compressed sensing module onto a new dimension. Intra-block and inter-block features are extracted using two consecutive Swin Transformer blocks; Adjacent blocks are merged by a block merging layer, and each merged block is downsampled to obtain downsampled features.
2. The image caption compression learning method based on Swing Transformer according to claim 1, characterized in that, The process of acquiring the original image and performing compressed sensing processing on the original image to obtain the measurement values of the original image includes: Obtain the original image; The original image is input into the compressed sensing module, and compressed sensing processing is performed on the original image to obtain the compressed sensing measurement sequence of the original image and the corresponding measurement values.
3. The image caption compression learning method based on Swing Transformer according to claim 1, characterized in that, The measurement sequence for: in, For the measurement matrix of compressed sensing operations, for Measurement sequences obtained through compressed sensing.
4. The image caption compression learning method based on Swing Transformer according to claim 1, characterized in that, In the two consecutive Swing Transformer blocks, the multi-head self-attention layer of the first Swing Transformer block is a window multi-head self-attention layer, and the multi-head self-attention layer of the second Swing Transformer block is a movable window multi-head self-attention layer.
5. A computer terminal, characterized in that, include: The processor and memory, wherein the memory stores an image caption compression learning program based on Swin Transformer, which, when executed by the processor, is used to implement the operation of the image caption compression learning method based on Swin Transformer as described in any one of claims 1-4.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a SwinTransformer-based image caption compression learning program, which, when executed by a processor, is used to implement the operation of the SwinTransformer-based image caption compression learning method as described in any one of claims 1-4.
Citation Information
Patent Citations
Intelligent image classification method and system based on compressed sensing domain
CN111881941A
Vision Transform-based image compressed sensing reconstruction method and system
CN114820828A
