An image processing method based on a group quantization visual Transformer model

By using a group quantization method for the Transformer model and dynamically adjusting the statistical characteristics and parameters of the activation values ​​within a group, the accuracy and efficiency issues of the quantization method on resource-limited devices are resolved, thus improving the model's performance in visual recognition tasks.

CN120047328BActive Publication Date: 2026-03-27UNIT 32002 OF THE CHINESE PEOPLES LIBERATION ARMY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-31
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing hierarchical quantization techniques have insufficient generalization ability in Transformer models, making it difficult to maintain efficient computation and accuracy requirements on resource-limited devices, especially resulting in significant accuracy loss in visual recognition tasks.

Method used

A group-based quantization approach is adopted to dynamically group the activation mappings of each layer of the Transformer model. The scaling factor and zero point are calculated using statistical properties. The quantization parameters are optimized using the expectation-maximization algorithm, and the group size is adjusted under bit operation constraints to ensure the consistency of activation values ​​within each group.

Benefits of technology

It improves the generalization ability and accuracy of quantization methods, reduces computational costs, and enhances inference speed and the ability of models to be applied in real time on resource-constrained devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120047328B_ABST
    Figure CN120047328B_ABST
Patent Text Reader

Abstract

The application discloses an image processing method based on a group quantization visual Transformer model, and belongs to the technical field of image processing. The method comprises the following steps: S1, generating an image data set, and dividing the image data set into a training set and a test set; wherein the image data set comprises a plurality of image instances; S2, performing group quantization training on a visual Transformer model by using the image instances in the training set and the bit operation of a processor carrying the visual Transformer model, to obtain a group quantization visual Transformer model; and S3, testing the image instances in the test set by using the group quantization visual Transformer model. The application is used for improving the application performance of the Transformer model in a resource-limited environment in the image processing process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of image processing technology, and particularly relates to an image processing method based on a visual Transformer model with group quantization. Background Technology

[0002] In recent years, Transformer models have made significant progress in the field of image processing. The self-attention mechanism of Transformers enables them to efficiently handle long-range dependencies and global features, demonstrating powerful capabilities, especially in Natural Language Processing (NLP), where they excel in tasks such as text generation, summarization, translation, and question answering. However, these large-scale Transformer models rely on substantial computational resources, massive amounts of training data, and long training times, making them difficult to apply directly in resource-constrained scenarios.

[0003] In practical applications, resource-constrained devices such as embedded systems, drones, and edge devices place extremely high demands on model computation. These devices require models to strike a balance between storage space, inference speed, and energy consumption to meet real-time response requirements. However, large Transformer models are difficult to deploy effectively on these devices due to their high computational complexity. To address this issue, researchers have developed various model compression and optimization techniques, particularly quantization methods, to reduce computational costs and improve operational efficiency.

[0004] Quantization techniques significantly reduce storage requirements and computational complexity by compressing model parameters and activation values ​​from high-precision floating-point numbers to low-precision integer representations. Low-bit quantization methods are particularly important, as they greatly improve inference speed and reduce power consumption by compressing model weights and activation values ​​to lower numbers of bits (e.g., 4 bits or less). Meanwhile, group quantization techniques are also widely used, dividing weights or activation values ​​into multiple groups and quantizing them separately, thereby further improving efficiency and reducing precision loss.

[0005] Hierarchical quantization, a technique in Post-Training Quantization (PTQ), has garnered significant attention due to its advantages in reducing computational complexity and storage requirements. This technique effectively reduces computational resource consumption by converting model parameters and activation values ​​from high-precision floating-point numbers to low-bit values. However, hierarchical quantization faces numerous challenges in practical applications, particularly in its widespread adoption across various Transformer model architectures. Its generalization ability is insufficient, making it difficult to achieve stable performance improvements across diverse Transformer architectures.

[0006] Specifically, hierarchical quantization often exhibits inconsistent results when handling weights and activation values ​​at different levels. Furthermore, low-bit quantization leads to a significant decrease in model accuracy, particularly in complex tasks like visual recognition, where performance degradation is more pronounced. This accuracy loss is especially significant in resource-constrained edge devices or applications with high real-time requirements, where models must not only meet accuracy requirements but also possess efficient inference speeds. However, the accuracy degradation caused by hierarchical quantization makes it difficult for models to operate reliably in these demanding application scenarios.

[0007] Therefore, how to reduce the accuracy loss caused by quantization while maintaining computational efficiency has become an important problem that researchers urgently need to solve. Improving quantization methods to enhance their generalization ability and accuracy will be a key direction for future research on Transformer model quantization. Summary of the Invention

[0008] To address the aforementioned technical problems, this invention proposes an image processing scheme based on a visual Transformer model using grouped quantization.

[0009] The first aspect of this invention discloses an image processing method based on a grouped quantization visual Transformer model, the method comprising:

[0010] Step S1: Generate an image dataset and divide the image dataset into a training set and a test set; wherein, the image dataset includes several image instances;

[0011] Step S2: Perform group quantization training on the visual Transformer model using image instances in the training set and bit operations of the processor carrying the visual Transformer model to obtain a visual Transformer model based on group quantization.

[0012] Step S3: Use the group-quantized visual Transformer model to test the image instances in the test set.

[0013] According to a method of a first aspect of the present invention, the visual Transformer model includes an input layer, a normalization layer, an attention layer, a softmax layer, a linear transformation layer, a feedforward neural network layer, an activation function layer, a Transformer processing layer, and an output layer; wherein:

[0014] In step S2, when performing group quantization training on the visual Transformer model, for all layers except the input and output layers, the following is performed: for image instances in the training set, the channels in the activation mapping of each layer are dynamically divided into multiple groups, and the activation values ​​in each group have the same statistical characteristics, thereby reducing the error introduced during the quantization process.

[0015] According to the method of the first aspect of the present invention, step S2 further includes:

[0016] For each group, calculate the minimum activation value min(A) and the maximum activation value max(A) within the group, where A represents the activation mapping of the current group;

[0017] Based on the calculated minimum and maximum values, determine the scaling factor s and zero point z for each group during the quantization process. The calculation formula is as follows:

[0018]

[0019] Where n is the quantization bit width, representing the allowed quantization levels, the scaling factor s describes the ratio between the real activation value and the quantized integer value, and the zero point z is used to adjust the activation value so that the minimum activation value can be mapped to a non-negative integer value within the quantization range. The calculation formula is:

[0020]

[0021] Each activation value A(i) within the group is quantized into an integer value q(i):

[0022]

[0023] Within a group, activation values ​​are mapped within a limited quantization range.

[0024] According to the method of the first aspect of the present invention, step S2 further includes: quantizing the scaling factor and zero point of each group using the expectation-maximization (EM) algorithm; wherein:

[0025] The scaling factor s(0) and the zero point z(0) in the initial state are determined by the min(A) and max(A) of the activation values ​​within the group;

[0026] The activation values ​​within the group are quantized into discrete integers q based on the current scaling factor and zero point. (k) (i), the calculation formula is:

[0027]

[0028] Recalculate the optimized scaling factor and zero point, and minimize the quantization error A(i)-A′(i), where A′(i) represents the activation value after dequantization, calculated using the following formula:

[0029] A′(i)=s (k+1) *(q (k) (i)-z (k+1) )

[0030] By iteratively optimizing the scaling factor s and the zero point z, the parameters that minimize the quantization error are obtained.

[0031] According to the method of the first aspect of the present invention, step S2 further includes:

[0032] Given the constraints of bit operations on a processor equipped with a visual Transformer model, determine the optimal number of groups for each layer. The bit operations are calculated as follows:

[0033] BOP = G*C*H*W*n

[0034] Where C, H, and W are the number of channels of the image instance, the height and width of the image size, respectively, and n is the bit width of each group;

[0035] The optimal number of groups G* is determined through an iterative algorithm, ensuring that the statistical characteristics of activation values ​​within each group remain consistent under the constraints of bit operations, while maximizing quantization precision. The constraint of bit operations is represented as: BOP ≤ BOP max BOP max This represents the maximum allowed bit operations.

[0036] According to the method of the first aspect of the present invention, in step S3, the image instances in the test set are tested using the group-quantized visual Transformer model to perform an image classification task or an image detection task.

[0037] According to the method of the first aspect of the present invention, the visual Transformer model includes ViT-S, DeiT-T, Swin-S, GPT-3, and BERT models; the image dataset includes the image atlases corresponding to ImageNet, COCO, GLUE, and SQuAD.

[0038] A second aspect of this invention discloses an image processing system based on a grouped quantization visual Transformer model, the system comprising a processing unit configured to perform:

[0039] An image dataset is generated and divided into a training set and a test set; wherein the image dataset includes several image instances;

[0040] The visual Transformer model is trained by group quantization using image instances in the training set and bit operations of the processor carrying the visual Transformer model, resulting in a visual Transformer model based on group quantization.

[0041] The image instances in the test set were tested using the grouped quantization-based visual Transformer model.

[0042] A third aspect of this invention discloses an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the image processing method based on a grouped quantization visual Transformer model described in the first aspect of this disclosure.

[0043] A fourth aspect of this invention discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the image processing method based on a grouped quantization visual Transformer model as described in the first aspect of this disclosure.

[0044] In summary, the technical solution proposed in this invention involves: first, instance-based grouping. This stage analyzes the model's internal features and its performance in specific tasks, dividing parameters into different groups for more effective quantization; next, calculating the quantization parameters and using statistical methods to determine the quantization precision of each group to optimize model performance and resource utilization; and finally, implementing a group size allocation strategy. Based on actual needs and system limitations, the size of each group is dynamically adjusted to ensure that the accuracy and efficiency of the model are maintained while reducing computational costs. This invention can improve the performance of the Transformer model in resource-constrained environments during image processing. Attached Figure Description

[0045] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0046] Figure 1 This is a flowchart illustrating the image processing method based on the visual Transformer model using group quantization. Detailed Implementation

[0047] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0048] The first aspect of this invention discloses an image processing method based on a grouped quantization visual Transformer model, the method comprising:

[0049] Step S1: Generate an image dataset and divide the image dataset into a training set and a test set; wherein, the image dataset includes several image instances;

[0050] Step S2: Perform group quantization training on the visual Transformer model using image instances in the training set and bit operations of the processor carrying the visual Transformer model to obtain a visual Transformer model based on group quantization.

[0051] Step S3: Use the group-quantized visual Transformer model to test the image instances in the test set.

[0052] According to a method of a first aspect of the present invention, the visual Transformer model includes an input layer, a normalization layer, an attention layer, a softmax layer, a linear transformation layer, a feedforward neural network layer, an activation function layer, a Transformer processing layer, and an output layer; wherein:

[0053] In step S2, when performing group quantization training on the visual Transformer model, for all layers except the input and output layers, the following is performed: for image instances in the training set, the channels in the activation mapping of each layer are dynamically divided into multiple groups, and the activation values ​​in each group have the same statistical characteristics, thereby reducing the error introduced during the quantization process.

[0054] According to the method of the first aspect of the present invention, step S2 further includes:

[0055] For each group, calculate the minimum activation value min(A) and the maximum activation value max(A) within the group, where A represents the activation mapping of the current group;

[0056] Based on the calculated minimum and maximum values, determine the scaling factor s and zero point z for each group during the quantization process. The calculation formula is as follows:

[0057]

[0058] Where n is the quantization bit width, representing the allowed quantization levels, the scaling factor s describes the ratio between the real activation value and the quantized integer value, and the zero point z is used to adjust the activation value so that the minimum activation value can be mapped to a non-negative integer value within the quantization range. The calculation formula is:

[0059]

[0060] Each activation value A(i) within the group is quantized into an integer value q(i):

[0061]

[0062] Within a group, activation values ​​are mapped within a limited quantization range.

[0063] According to the method of the first aspect of the present invention, step S2 further includes: quantizing the scaling factor and zero point of each group using the expectation-maximization (EM) algorithm; wherein:

[0064] The scaling factor s(0) and the zero point z(0) in the initial state are determined by the min(A) and max(A) of the activation values ​​within the group;

[0065] The activation values ​​within the group are quantized into discrete integers q based on the current scaling factor and zero point. (k) (i), the calculation formula is:

[0066]

[0067] Recalculate the optimized scaling factor and zeros, and minimize the quantization error A(i)-A'(i), where A'(i) represents the activation value after dequantization. The calculation formula is as follows:

[0068] A'(i)=s (k+1) *(q (k) (i)-z (k+1) )

[0069] By iteratively optimizing the scaling factor s and the zero point z, the parameters that minimize the quantization error are obtained.

[0070] According to the method of the first aspect of the present invention, step S2 further includes:

[0071] Given the constraints of bit operations on a processor equipped with a visual Transformer model, determine the optimal number of groups for each layer. The bit operations are calculated as follows:

[0072] BOP = G*C*H*W*n

[0073] Where C, H, and W are the number of channels of the image instance, the height and width of the image size, respectively, and n is the bit width of each group;

[0074] The optimal number of groups G* is determined through an iterative algorithm, ensuring that the statistical characteristics of activation values ​​within each group remain consistent under the constraints of bit operations, while maximizing quantization precision. The constraint of bit operations is represented as: BOP ≤ BOP max BOP max This represents the maximum allowed bit operations.

[0075] According to the method of the first aspect of the present invention, in step S3, the image instances in the test set are tested using the group-quantized visual Transformer model to perform an image classification task or an image detection task.

[0076] According to the method of the first aspect of the present invention, the visual Transformer model includes ViT-S, DeiT-T, Swin-S, GPT-3, and BERT models; the image dataset includes the image atlases corresponding to ImageNet, COCO, GLUE, and SQuAD.

[0077] First Embodiment

[0078] like Figure 1 As shown, instance-based grouped quantization for Transformer models specifically includes: First, instance-based grouping is performed. This stage involves analyzing the model's internal features and its performance on specific tasks to divide parameters into different groups for more efficient quantization. Next, quantization parameters are calculated, and statistical methods are used to determine the quantization precision for each group to optimize model performance and resource utilization. Finally, a group size allocation strategy is implemented. Based on actual needs and system limitations, the size of each group is dynamically adjusted to ensure that the accuracy and efficiency of the model are maintained while reducing computational costs.

[0079] Second Embodiment

[0080] Existing Transformer model quantization methods primarily employ a hierarchical quantization strategy, quantizing by accumulating data layer by layer. However, this method suffers from cumulative error, especially in deep networks. Furthermore, existing group quantization methods typically divide consecutive channels uniformly into multiple groups, ignoring the dynamic range differences between channels, leading to decreased quantization accuracy. To address these issues, this invention proposes a multi-scaling factor quantization method for visual Transformer models, applicable to image processing.

[0081] S1 Preparation Phase: Start by selecting a full-precision Transformer model that has been pre-trained on a large dataset, such as ViT-S, DeiT-T, Swin-S, GPT-3, BERT, etc., and prepare a calibration dataset (a subset of Image Net, COCO, GLUE, SQuAD). This dataset usually contains hundreds to thousands of images and is used to determine the quantization parameters.

[0082] S2 Instance-Based Grouping: For each input instance in the calibration dataset, channels in the activation map of each layer are dynamically divided into multiple groups to ensure that activation values ​​within a group have similar statistical properties. This step aims to minimize errors that may be introduced during quantization. By analyzing the statistical characteristics of each channel (such as mean, variance, etc.), it is ensured that activation values ​​within a group have high similarity in distribution. This allows the same quantization parameters to be applied to each group, thereby improving overall computational efficiency and reducing model complexity while maintaining quantization accuracy.

[0083] S3 calculates quantization parameters: First, calculate the minimum and maximum activation values ​​(min(A) and maximum (max(A)) within the group, where A represents the activation mapping of the current group. These boundary values ​​determine the dynamic range of the activation values ​​in the group. Next, based on the calculated minimum and maximum values, determine the scaling factor (s) and zero point (z) for each group. The scaling factor (s) represents the actual activation value range for each quantization step, calculated using the following formula:

[0084]

[0085] Where n is the quantization bit width (e.g., 8 bits, 4 bits, etc.), representing the available quantization levels. The scaling factor determines the ratio between the real activation value and the quantized integer value. The zero point z is used to adjust the activation value so that the minimum activation value can be mapped to a non-negative integer value within the quantization range. Its formula is:

[0086]

[0087] Zero-point adjustment ensures that negative activation values ​​are also properly represented during quantization without information loss. Ultimately, each activation value A(i) within a group is quantized into an integer value q(i):

[0088]

[0089] This ensures that the activation values ​​within a group can be accurately mapped within a limited quantization range, reducing quantization errors and ensuring improved computational efficiency.

[0090] S4 Optimizes Quantization Parameters: During quantization, the Expectation-Maximization (EM) algorithm can be used to adjust the scaling factor and zeros for each group to reduce quantization error. The specific steps are as follows:

[0091] Step 1 Initialization: The scaling factor s(0) and the zero point z(0) are determined by the in-group activation values ​​min(A) and max(A).

[0092] Step 2 Expectation Step: Based on the current scaling factor and zeros, quantize the activation values ​​within the group into discrete integers q(k)(i), as shown in the formula:

[0093]

[0094] Step 3: Maximization: In this step, the optimized scaling factor and zero point are recalculated to minimize the quantization error A(i) - A′(i), where A′(i) is the dequantized activation value, as shown in the formula:

[0095] A'(i)=s (k+1) *(q (k) (i)-z (k+1) (5)

[0096] By iterating through steps two and three, the scaling factor s and the zero point z are optimized, ultimately yielding parameters that minimize the quantization error.

[0097] S5 Group Size Allocation: Under the constraints of Bit-Operation (BOP), the optimal number of groups for each layer is determined. Accuracy and computational efficiency can be balanced by optimizing the number of groups G. Specifically, BOP can be represented as:

[0098] BOP=G*C*H*W*n (6)

[0099] Here, C, H, and W represent the number of channels and spatial dimension, respectively, and n is the bit width of each group. To minimize the quantization error while satisfying the BOP constraint, the number of groups G needs to be optimized.

[0100] The optimal G* is found through an iterative algorithm, such that the BOP constraint BOP≤BOP is met. max In this way, the statistical characteristics of activation values ​​within each group remain consistent, thereby ensuring maximum quantization accuracy.

[0101] S6 Export Quantization Model: By applying steps two through five to different layers of different Transformer models, the quantization model is finally exported as the output.

[0102] The above outputs are deployed on resource-constrained devices such as drones to perform image classification tasks on the ImageNet dataset and object detection tasks on the COCO dataset for visual Transformer models, and classification and reading comprehension tasks on the GLUE and SQuAD datasets for large language models. This demonstrates that the instance-based group quantization method can quantize Transformer models of different modalities, thereby improving the generalization of the quantization method, and also has good compression effect and significantly improved inference speed.

[0103] A second aspect of this invention discloses an image processing system based on a grouped quantization visual Transformer model, the system comprising a processing unit configured to perform:

[0104] An image dataset is generated and divided into a training set and a test set; wherein the image dataset includes several image instances;

[0105] The visual Transformer model is trained by group quantization using image instances in the training set and bit operations of the processor carrying the visual Transformer model, resulting in a visual Transformer model based on group quantization.

[0106] The image instances in the test set were tested using the grouped quantization-based visual Transformer model.

[0107] A third aspect of this invention discloses an electronic device. The electronic device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the image processing method based on a grouped quantization visual Transformer model described in the first aspect of this disclosure.

[0108] A fourth aspect of this invention discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the image processing method based on a grouped quantization visual Transformer model as described in the first aspect of this disclosure.

[0109] In summary, this invention designs an instance-based grouping quantization method for Transformer models. This method includes instance-based grouping, calculation and optimization of quantization parameters, and group size allocation. The invention employs an instance-based grouping strategy. For each input instance in the calibration dataset, the channels in the activation mapping of each layer are dynamically divided into multiple groups to ensure that the activation values ​​within each group have similar statistical characteristics, thereby reducing the accumulation of subsequent quantization errors and enhancing the generalization ability of this quantization method. Therefore, Transformer models of different modalities can use this quantization method, enabling deployment on resource-constrained devices. The invention also designs a group size allocation strategy. Under the constraints of the positioning operation, the optimal group size and number of groups are determined for each layer. By optimizing the number of groups, accuracy and computational efficiency can be balanced, improving quantization accuracy while minimizing computational efficiency reduction. This results in the quantized Transformer model exhibiting good real-time performance for different tasks.

[0110] In the technical solution proposed in this invention: First, instance-based grouping is performed. This stage involves analyzing the model's internal features and its performance in specific tasks to divide parameters into different groups for more effective quantization. Next, quantization parameters are calculated, and statistical methods are used to determine the quantization precision of each group to optimize model performance and resource utilization. Finally, a group size allocation strategy is implemented, dynamically adjusting the size of each group according to actual needs and system limitations to ensure that the accuracy and efficiency of the model are maintained while reducing computational costs. This invention can improve the performance of the Transformer model in resource-constrained environments during image processing.

[0111] Please note that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. The above embodiments only illustrate several implementation methods of this application, and their descriptions are relatively specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be pointed out that for those skilled in the art, several modifications and improvements can be made without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. An image processing method based on a packet quantization visual Transformer model, characterized in that, The method comprises: Step S1, generating an image dataset and dividing the image dataset into a training set and a test set; wherein the image dataset comprises a plurality of image instances; Step S2, performing grouped quantization training on the visual Transformer model using image instances in the training set and bit operations of a processor carrying the visual Transformer model, to obtain a visual Transformer model based on grouped quantization; Step S3, testing image instances in the test set using the visual Transformer model based on grouped quantization; Wherein step S2 further comprises: For each group, calculate the minimum value min(A) and the maximum value max(A) of the activation values within the group, A representing the activation mapping of the current group; According to the calculated minimum value and maximum value, determine the scaling factor s and the zero point z of each group in the quantization process, the calculation formula being: , where n is the quantization bit-width, represents the allowed quantization levels, the scaling factor s is used to describe the ratio between real-valued activations and quantized integer values, and the zero point z is used to adjust the activations so that the minimum activation value can be mapped to a non-negative integer value within the quantization range, with the calculation formula being: , Each activation value A(i) within a group is quantized to an integer value q(i): , The activation values within the group are mapped within a limited quantization range; Wherein step S2 further comprises: quantizing the scaling factor and the zero point of each group using the expectation maximization (EM) algorithm; wherein: Determine the scaling factor s(0) and the zero point z(0) in the initial state through min(A) and max(A) of the activation values within the group; Quantize the activation values within a group to discrete integers q according to the current scale factor and zero point (k) (i), the calculation formula is: , Re-compute optimized scale factors and zero points and minimize quantization error , denotes the dequantized activation value, and the calculation formula is: , By continuously iterating and optimizing the scaling factor s and the zero point z, the parameters that minimize the quantization error are obtained.

2. The image processing method of claim 1, wherein, The visual Transformer model comprises an input layer, a normalization layer, an attention layer, a softmax layer, a linear transformation layer, a feedforward neural network layer, an activation function layer, a Transformer processing layer, and an output layer; wherein: In step S2, when performing grouped quantization training on the visual Transformer model, for layers other than the input layer and the output layer, the activation mapping of each layer is dynamically divided into a plurality of groups for image instances in the training set, and the activation values within each group have the same statistical properties, thereby reducing errors introduced in the quantization process.

3. The image processing method of claim 2, wherein the method further comprises: Step S2 further comprises: Given the constraints of the bit operation of the processor carrying the visual Transformer model, the optimal group number is determined for each layer, and the calculation method of the bit operation is: , Wherein C, H, and W are the channel number, height, and width of the image instance, respectively, and n is the bit width of each group; The optimal group number G* is solved by an iterative algorithm, so that the activation value statistical characteristics in each group remain consistent under the constraint of bit operation, and the quantization precision is maximized, and the constraint of bit operation is represented as: BOP≤ , is the maximum allowed bit operation.

4. The image processing method of claim 3, wherein the method further comprises: In step S3, the visual Transformer model based on grouped quantization is used to test image instances in the test set, to perform image classification tasks or image detection tasks.

5. The image processing method of claim 4, wherein the method further comprises: The visual Transformer model includes ViT-S, DeiT-T, Swin-S, GPT-3, and BERT models; and the image dataset includes Image Net, COCO, GLUE, and SQuAD corresponding image sets.

6. An image processing system based on a packet-quantized visual Transformer model, characterized by, The system comprises a processing unit configured to perform: Generating an image dataset and dividing the image dataset into a training set and a test set; wherein the image dataset comprises a plurality of image instances; The visual Transformer model is trained by using image instances in the training set and bit operation of a processor carrying the visual Transformer model to perform grouped quantization training on the visual Transformer model, to obtain a visual Transformer model based on grouped quantization. Wherein, for each group, the minimum value min(A) and the maximum value max(A) of the activation values within the group are calculated, A representing the activation mapping of the current group. Based on the calculated minimum and maximum values, a scaling factor s and a zero point z for each group in the quantization process are determined, calculated as: , where n is the quantization bit-width, represents the allowed quantization levels, the scaling factor s is used to describe the ratio between real-valued activations and quantized integer values, and the zero point z is used to adjust the activations so that the minimum activation value can be mapped to a non-negative integer value within the quantization range, with the calculation formula being: , Each activation value A(i) within a group is quantized to an integer value q(i): , The activation values within the group are mapped within a limited quantization range. Wherein, the scaling factor and the zero point of each group are quantized by using an expectation maximization (EM) algorithm; wherein: The scaling factor s(0) and the zero point z(0) in the initial state are determined by min(A) and max(A) of the activation values within the group. Quantize the activation values within a group to discrete integers q according to the current scale factor and zero point (k) (i), the calculation formula is: , Re-compute the optimized scaling factor and zero point and minimize quantization error , denotes the de-quantized activation value, and the calculation formula is: , The scaling factor s and the zero point z are continuously iteratively optimized to obtain parameters that minimize the quantization error. The visual Transformer model based on grouped quantization is used to test image instances in a test set.

7. An electronic device, comprising: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor executes the computer program to implement the image processing method of the visual Transformer model based on grouped quantization according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the image processing method of the visual Transformer model based on grouped quantization according to any one of claims 1-5.