Image processing method and related device thereof
By evaluating and screening image blocks, only important image blocks are fused, which solves the problems of large computational complexity and low efficiency of image processing in the existing technology, and achieves more efficient image processing.
Patent Information
- Application Number
- PCT/CN2024/077856
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-21
- Filing Date
- 2024-02-21
- Publication Date
- 2024-08-29
AI Technical Summary
Existing visual multi-layer perceptron models need to fuse each image block during image processing, resulting in large amounts of calculation, long time and low efficiency.
By evaluating image blocks, image blocks with high content importance are selected for fusion operations, reducing unnecessary calculations and improving processing efficiency.
It effectively shortens the overall time of image processing, improves the efficiency of image processing, and does not require the introduction of additional neural network models, saving resources in the model training and application stages.
Smart Images

Figure CN2024077856_29082024_PF_FP_ABST
Abstract
Description
Image processing method and related device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on February 21, 2023, with application number 202310185947.3 and invention name “An image processing method and related equipment”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The embodiments of the present application relate to the field of artificial intelligence (AI) technology, and in particular to an image processing method and related equipment. Background Art
[0003] With the rapid development of computer technology, neural network models in AI are increasingly being used to complete various visual tasks. To explore simpler neural network models, the multilayer perceptron (MLP) model has emerged. As a new type of visual backbone neural network, the MLP has achieved impressive results on a variety of visual tasks.
[0004] Currently, when processing an image for a visual task, the image is first divided into multiple image blocks (tokens) and fed into a visual multi-layer perceptron model. The model then fuses each image block to produce a fusion result of the multiple image blocks. The model then performs a series of processing on the fusion results of the multiple image blocks to produce a processed image result, which can then be used to complete the visual task.
[0005] In the above process, since the visual multi-layer perceptron model needs to fuse each image block, the required amount of calculation is very large, which not only leads to an excessively long overall image processing time, but also leads to low image processing efficiency.
[0006] Summary of the Invention
[0007] The embodiments of the present application provide an image processing method and related equipment, which can effectively reduce the computational complexity of image processing, thereby shortening the overall image processing time and improving the efficiency of image processing.
[0008] A first aspect of an embodiment of the present application provides an image processing method, which can be implemented by a target model. The method includes:
[0009] When a target image in a visual task needs to be processed, the target image can be first divided into N image blocks, where N is a positive integer greater than 2.
[0010] After receiving N image blocks of the target image, the target model can first evaluate each of the N image blocks, thereby obtaining evaluation values for the N image blocks. It should be noted that the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks. For any image block among the N image blocks, the larger the evaluation value of the image block, the more important the content presented by the image block, and the smaller the evaluation value of the image block, the less important the content presented by the image block.
[0011] After obtaining the evaluation values of the N image blocks, the target model can select M image blocks from the N image blocks based on the magnitude relationship of the evaluation values of the N image blocks, where M is a positive integer less than N and greater than or equal to 2. Therefore, among the N image blocks that constitute the target image, the M image blocks selected by the target model can be considered the more important parts of the target image.
[0012] After obtaining M image blocks, the target model can perform a series of fusion operations on only the M image blocks to obtain the fusion results of the M image blocks. After obtaining the fusion results of the M image blocks, the target model can perform a series of processing on the fusion results of the M image blocks to obtain the processing results of the target image. Then, the processing results of the target image can be used to complete the visual task.
[0013] The above method demonstrates that, after receiving N image blocks of a target image, the target model can first evaluate the N image blocks to obtain evaluation values for the N image blocks. Next, the target model can use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. The target model can then fuse the M image blocks to obtain a fused result of the M image blocks. Finally, the target model can perform a series of processing on the fused result of the M image blocks to obtain a processed result of the target image. In the aforementioned process, since the evaluation values of the N image blocks indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are typically the more important portions of the target image. Therefore, when obtaining the processed result of the target image, the target model only performs the fusion operation on these M image blocks, rather than on the remaining NM image blocks. This effectively reduces the amount of computation required, thereby shortening the overall image processing time and improving image processing efficiency.
[0014] In one possible implementation, evaluating N image blocks to obtain evaluation values for the N image blocks includes: performing a first full connection on the N image blocks to obtain first features of the N image blocks; pooling the first features of the N image blocks to obtain second features of the N image blocks; and multiplying the first features of the N image blocks with the second features of the N image blocks to obtain third features of the N image blocks, with the third features of the N image blocks serving as evaluation values for the N image blocks. In the aforementioned implementation, after receiving the N image blocks, the target model may perform a first full connection on the N image blocks to obtain the first features of the N image blocks. After obtaining the first features of the N image blocks, the target model may pool the first features of the N image blocks to obtain second features of the N image blocks. After obtaining the second features of the N image blocks, the target model may multiply the first features of the N image blocks with the second features of the N image blocks to obtain third features of the N image blocks. The third features of the N image blocks may serve as evaluation values for the N image blocks.
[0015] In one possible implementation, N image blocks form an array of X rows and Y columns of image blocks. Based on the evaluation values, determining M image blocks from the N image blocks includes: selecting P image blocks with the largest evaluation values from the i-th row of image blocks, where i = 1, ..., X, M = XP, and P ≥ 1; or selecting K image blocks with the largest evaluation values from the j-th column of image blocks, where j = 1, ..., Y, M = YK, and K ≥ 1. In the aforementioned implementation, the target model can select image blocks in the following manner: after obtaining the evaluation values of the N image blocks, since the N image blocks are presented in the form of X rows of image blocks, the target model can select the P image blocks with the largest evaluation values from the first row of image blocks, the P image blocks with the largest evaluation values from the second row of image blocks, ..., and finally the P image blocks with the largest evaluation values from the Xth row of image blocks. In this way, the target model can select a total of M = XP image blocks horizontally. Of course, the target model can also select image blocks in the following manner: after obtaining the evaluation values of N image blocks, since the N image blocks are presented in the form of Y columns of image blocks, the target model can select the K image blocks with the largest evaluation values in the first column of image blocks, select the K image blocks with the largest evaluation values in the second column of image blocks, ..., select the K image blocks with the largest evaluation values in the Y column of image blocks. In this way, the target model can select a total of M = YK image blocks vertically.
[0016] In one possible implementation, the method further includes: performing a weighted summation of the evaluation values of the N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; multiplying the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain the fifth features of the M image blocks; fusing the M image blocks to obtain the fusion results of the M image blocks, which includes: splicing the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connecting the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks. In the aforementioned implementation, after obtaining the evaluation values of the N image blocks, the target model can also use the evaluation values of the N image blocks as weights, and use these weights to perform a weighted summation of the first features of the N image blocks to obtain the fourth features of the N image blocks. After obtaining the fourth features of the N image blocks, the target model can also multiply the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain the fifth features of the M image blocks. After obtaining the fifth features of the N image blocks, the target model can also concatenate the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks. After obtaining the fifth features of the N image blocks, the target model also fully connects the sixth features of the M image blocks to obtain the seventh features of the M image blocks. The seventh features of the M image blocks are then used as the fusion result of the M image blocks.
[0017] In one possible implementation, based on the fusion results of M image blocks, obtaining the processing results of the target image includes: performing a second full connection on the N image blocks to obtain the eighth features of the N image blocks; performing weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; performing weighted summation on the eighth features of NM image blocks other than the M image blocks and the NM image blocks in the N image blocks to obtain the ninth features of the NM image blocks; processing the ninth features of the N image blocks to obtain the processing results of the target image. In the aforementioned implementation, the target model may also perform a second full connection on the N image blocks to obtain the eighth features of the N image blocks. After obtaining the eighth features of the N image blocks, the target model may also use preset weights to perform a weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks. After obtaining the eighth features of the N image blocks, the target model may further use preset weights to weightedly sum the eighth features of the NM image blocks (excluding the M image blocks) and the NM image blocks in the N image blocks, thereby obtaining the ninth features of the NM image blocks. After obtaining the ninth features of the N image blocks, the target model further processes the ninth features of the N image blocks to obtain a processed result of the target image.
[0018] In one possible implementation, the aforementioned processing includes at least one of the following: normalization, aggregation, or addition. In the aforementioned implementation, the target model may superimpose the ninth feature of the N image blocks with the N image blocks to obtain the tenth feature of the N image blocks. Next, the target model may normalize the tenth feature of the N image blocks to obtain the eleventh feature of the N image blocks. Then, the target model may aggregate the eleventh feature of the N image blocks in the channel dimension to obtain the twelfth feature of the N image blocks. Finally, the target model may superimpose the twelfth feature of the N image blocks with the ninth feature of the N image blocks to obtain the processing result of the target image.
[0019] In one possible implementation, before evaluating the N image blocks and obtaining evaluation values for the N image blocks, the method further includes normalizing the N image blocks to obtain the normalized N image blocks. In the aforementioned implementation, the target model may further first normalize the N image blocks to obtain the normalized N image blocks, and then perform various processing on the normalized N image blocks to obtain the ninth feature of the normalized N image blocks.
[0020] A second aspect of an embodiment of the present application provides a model training method, which includes: inputting a target image into a model to be trained to obtain a processing result of the target image, wherein the model to be trained is used to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, and the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks; based on the evaluation values of the N image blocks, determine M image blocks from the N image blocks, N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; based on the fusion result of the M image blocks, obtain a processing result of the target image; based on the processing result and the actual processing result of the target image, obtain a target loss; based on the target loss, update the parameters of the model to be trained until the model training conditions are met to obtain a target model.
[0021] The target model trained using the above method possesses image processing capabilities. Specifically, after receiving N image blocks of a target image, the target model may first evaluate the N image blocks, thereby obtaining evaluation values for the N image blocks. Next, the target model may use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. The target model may then fuse the M image blocks, thereby obtaining a fusion result of the M image blocks. Finally, the target model may perform a series of processing operations on the fusion result of the M image blocks, thereby obtaining a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are generally the more important portions of the target image content. Therefore, when obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and not on the remaining NM image blocks. This effectively reduces the amount of computation required, thereby shortening the overall image processing time and improving image processing efficiency.
[0022] In one possible implementation, the model to be trained is used to: perform a first full connection on N image blocks to obtain first features of the N image blocks; perform pooling on the first features of the N image blocks to obtain second features of the N image blocks; multiply the first features of the N image blocks and the second features of the N image blocks to obtain third features of the N image blocks, and the third features of the N image blocks are used as evaluation values of the N image blocks.
[0023] In one possible implementation, N image blocks constitute an image block array with X rows and Y columns, and the model to be trained is used to: select P image blocks with the largest evaluation values from the image blocks in the i-th row, where i = 1, ..., X, M = XP, and P ≥ 1; or, select K image blocks with the largest evaluation values from the image blocks in the j-th column, where j = 1, ..., Y, M = YK, and K ≥ 1.
[0024] In one possible implementation, the model to be trained is also used to: perform a weighted sum of the evaluation values of N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; multiply the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain the fifth features of the M image blocks; the model to be trained is used to: splice the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
[0025] In one possible implementation, the model to be trained is used to: perform a second full connection on N image blocks to obtain the eighth features of the N image blocks; perform weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; perform weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain the ninth features of the NM image blocks; and process the ninth features of the N image blocks to obtain the processing results of the target image.
[0026] In one possible implementation, the processing includes at least one of the following: normalization, aggregation, or addition.
[0027] In a possible implementation, the model to be trained is further used to: normalize the N image blocks to obtain N normalized image blocks.
[0028] A third aspect of an embodiment of the present application provides an image processing device, which includes a target model and comprises: a first acquisition module, used to acquire N image blocks of a target image; an evaluation module, used to evaluate the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks; a determination module, used to determine M image blocks from the N image blocks based on the evaluation values of the N image blocks, where N>M≥2; a fusion module, used to fuse the M image blocks to obtain a fusion result of the M image blocks; and a second acquisition module, used to obtain a processing result of the target image based on the fusion result of the M image blocks.
[0029] As can be seen from the above device, after receiving N image blocks of a target image, the target model can first evaluate the N image blocks to obtain evaluation values for the N image blocks. Next, the target model can use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. The target model can then fuse the M image blocks to obtain a fusion result of the M image blocks. Finally, the target model can perform a series of processing on the fusion result of the M image blocks to obtain a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are generally the more important parts of the target image. Therefore, when obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and does not perform the fusion operation on the remaining NM image blocks. This effectively reduces the amount of computation, thereby shortening the overall image processing time and improving image processing efficiency.
[0030] In one possible implementation, the evaluation module is used to: perform a first full connection on N image blocks to obtain first features of the N image blocks; perform pooling on the first features of the N image blocks to obtain second features of the N image blocks; multiply the first features of the N image blocks and the second features of the N image blocks to obtain third features of the N image blocks, and use the third features of the N image blocks as evaluation values of the N image blocks.
[0031] In one possible implementation, N image blocks constitute an image block array with X rows and Y columns, and the determination module is configured to: select P image blocks with the largest evaluation values from the image blocks in the i-th row, where i=1, ..., X, M=XP, and P≥1; or, select K image blocks with the largest evaluation values from the image blocks in the j-th column, where j=1, ..., Y, M=YK, and K≥1.
[0032] In one possible implementation, the device also includes: a summation module, used to perform weighted summation of the evaluation values of N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; a multiplication module, used to multiply the fourth features of the N image blocks and the evaluation values of M image blocks to obtain the fifth features of the M image blocks; a fusion module, used to: splice the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
[0033] In one possible implementation, the second acquisition module is used to: perform a second full connection on the N image blocks to obtain the eighth features of the N image blocks; perform weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; perform weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain the ninth features of the NM image blocks; and process the ninth features of the N image blocks to obtain the processing results of the target image.
[0034] In one possible implementation, the processing includes at least one of the following: normalization, aggregation, or addition.
[0035] In one possible implementation, the device further includes: a normalization module, configured to normalize the N image blocks to obtain N normalized image blocks.
[0036] A fourth aspect of an embodiment of the present application provides a model training device, which includes: an input module, used to input a target image into a model to be trained to obtain a processing result of the target image, wherein the model to be trained is used to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, and the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks; based on the evaluation values of the N image blocks, determine M image blocks in the N image blocks, N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; obtain the processing result of the target image based on the fusion result of the M image blocks; an acquisition module, used to obtain a target loss based on the processing result and the actual processing result of the target image; an update module, used to update the parameters of the model to be trained based on the target loss until the model training conditions are met to obtain the target model.
[0037] The target model trained by the above-mentioned device has image processing capabilities. Specifically, after receiving N image blocks of a target image, the target model can first evaluate the N image blocks to obtain evaluation values for the N image blocks. Next, the target model can use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. The target model can then fuse the M image blocks to obtain a fused result of the M image blocks. Finally, the target model can perform a series of processing on the fused result of the M image blocks to obtain a processed result of the target image. In the aforementioned process, since the evaluation values of the N image blocks indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are generally the more important parts of the target image. Therefore, when obtaining the processed result of the target image, the target model only performs the fusion operation on these M image blocks, and not on the remaining NM image blocks. This effectively reduces the amount of computation required, thereby shortening the overall image processing time and improving image processing efficiency.
[0038] In one possible implementation, the model to be trained is used to: perform a first full connection on N image blocks to obtain first features of the N image blocks; perform pooling on the first features of the N image blocks to obtain second features of the N image blocks; multiply the first features of the N image blocks and the second features of the N image blocks to obtain third features of the N image blocks, and the third features of the N image blocks are used as evaluation values of the N image blocks.
[0039] In one possible implementation, N image blocks constitute an image block array with X rows and Y columns, and the model to be trained is used to: select P image blocks with the largest evaluation values from the image blocks in the i-th row, where i = 1, ..., X, M = XP, and P ≥ 1; or, select K image blocks with the largest evaluation values from the image blocks in the j-th column, where j = 1, ..., Y, M = YK, and K ≥ 1.
[0040] In one possible implementation, the model to be trained is also used to: perform a weighted sum of the evaluation values of N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; multiply the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain the fifth features of the M image blocks; the model to be trained is used to: splice the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
[0041] In one possible implementation, the model to be trained is used to: perform a second full connection on N image blocks to obtain the eighth features of the N image blocks; perform weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; perform weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain the ninth features of the NM image blocks; and process the ninth features of the N image blocks to obtain the processing results of the target image.
[0042] In one possible implementation, the processing includes at least one of the following: normalization, aggregation, or addition.
[0043] In a possible implementation, the model to be trained is further used to: normalize the N image blocks to obtain N normalized image blocks.
[0044] A fifth aspect of an embodiment of the present application provides an image processing device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the image processing device executes the method described in the first aspect or any possible implementation method of the first aspect.
[0045] A sixth aspect of an embodiment of the present application provides a model training device, which includes a memory and a processor; the memory stores code, and the processor is configured to execute the code. When the code is executed, the model training device executes the method described in the second aspect or any possible implementation method of the second aspect.
[0046] A seventh aspect of an embodiment of the present application provides a circuit system, which includes a processing circuit, and the processing circuit is configured to execute the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0047] An eighth aspect of an embodiment of the present application provides a chip system, which includes a processor for calling a computer program or computer instructions stored in a memory so that the processor executes a method as described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0048] In a possible implementation, the processor is coupled to the memory through an interface.
[0049] In one possible implementation, the chip system further includes a memory, in which a computer program or computer instructions is stored.
[0050] A ninth aspect of an embodiment of the present application provides a computer storage medium storing a computer program, which, when executed by a computer, enables the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0051] A tenth aspect of an embodiment of the present application provides a computer program product, which stores instructions that, when executed by a computer, enable the computer to implement the method described in the first aspect, any possible implementation of the first aspect, the second aspect, or any possible implementation of the second aspect.
[0052] In an embodiment of the present application, after receiving N image blocks of a target image, the target model may first evaluate the N image blocks to obtain evaluation values of the N image blocks. Next, the target model may use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. Then, the target model may fuse the M image blocks to obtain a fusion result of the M image blocks. Finally, the target model may perform a series of processing on the fusion result of the M image blocks to obtain a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are usually the more important parts of the content in the target image. Therefore, in the process of obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and does not perform the fusion operation on the remaining NM image blocks, which can effectively reduce the amount of calculation, thereby shortening the overall image processing time and improving the efficiency of image processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 is a schematic diagram of the structure of the artificial intelligence main framework;
[0054] FIG2a is a schematic structural diagram of an image processing system provided in an embodiment of the present application;
[0055] FIG2 b is another schematic structural diagram of the image processing system provided in an embodiment of the present application;
[0056] FIG2c is a schematic diagram of an image processing device according to an embodiment of the present application;
[0057] FIG3 is a schematic diagram of the architecture of the system 100 provided in an embodiment of the present application;
[0058] FIG4 is a schematic diagram of a structure of a target model provided in an embodiment of the present application;
[0059] FIG5 is a flow chart of an image processing method provided in an embodiment of the present application;
[0060] FIG6 is a schematic structural diagram of a dynamic image block unit provided in an embodiment of the present application;
[0061] FIG7 is another schematic diagram of the structure of the dynamic image block unit provided in an embodiment of the present application;
[0062] FIG8 is another schematic diagram of the structure of the target model provided in an embodiment of the present application;
[0063] FIG9 is another schematic diagram of the structure of the target model provided in an embodiment of the present application;
[0064] FIG10 is a flow chart of a model training method provided in an embodiment of the present application;
[0065] FIG11 is a schematic structural diagram of an image processing device provided in an embodiment of the present application;
[0066] FIG12 is a schematic structural diagram of a model training device provided in an embodiment of the present application;
[0067] FIG13 is a schematic diagram of the structure of an execution device provided in an embodiment of the present application;
[0068] FIG14 is a schematic structural diagram of a training device provided in an embodiment of the present application;
[0069] FIG15 is a schematic structural diagram of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0070] The embodiments of the present application provide an image processing method and related equipment, which can effectively reduce the computational complexity of image processing, thereby shortening the overall image processing time and improving the efficiency of image processing.
[0071] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, and this is merely a way of distinguishing the objects of the same attributes when describing them in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.
[0072] With the rapid development of computer technology, a growing number of fields, such as autonomous driving and identity recognition, are using neural network models from AI to complete various visual tasks, such as image classification, object detection, and instance segmentation. To explore more concise neural network models, the Multi-Layer Perceptron (MLP) has emerged. As a new type of visual backbone neural network, the MLP has achieved impressive results on a variety of visual tasks.
[0073] Currently, when processing an image for a visual task, the image can be first divided into multiple image blocks and then input into a visual multi-layer perceptron model. After obtaining the multiple image blocks, the visual multi-layer perceptron model can fuse any one of the multiple image blocks with several surrounding image blocks to obtain a fused image result. The same process can be performed on the remaining image blocks, so the visual multi-layer perceptron model can obtain a fused image result for the multiple image blocks. Subsequently, the visual multi-layer perceptron model can perform a series of processing on the fused image blocks to obtain a processed image result, which can be used to complete the visual task.
[0074] In the above process, since the visual multi-layer perceptron model needs to fuse each image block, the required amount of calculation is very large, which not only leads to an excessively long overall image processing time, but also leads to low image processing efficiency.
[0075] Furthermore, in related technologies, other neural network models can be used to filter out some of the image's multiple image blocks, and then the remaining image blocks are input into a visual multi-layer perceptron model for processing, thereby obtaining the image processing results. Although this can appropriately reduce the computational workload of the visual multi-layer perceptron model, it does require the introduction of additional neural network models, requiring additional work in both the model training and application stages.
[0076] In order to solve the above problems, an embodiment of the present application provides an image processing method, which can be implemented in combination with artificial intelligence (AI) technology. AI technology is a technical discipline that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence. AI technology obtains the best results by perceiving the environment, acquiring knowledge and using knowledge. In other words, artificial intelligence technology is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Using artificial intelligence for data processing is a common application of artificial intelligence.
[0077] First, we will describe the overall workflow of an AI system. See Figure 1, which illustrates a schematic diagram of the AI framework. This framework will be explained from two perspectives: the "intelligent information chain" (horizontal axis) and the "IT value chain" (vertical axis). The "intelligent information chain" reflects the entire process from data acquisition to processing. For example, it could be the general process of intelligent information perception, intelligent information representation and formation, intelligent reasoning, intelligent decision-making, and intelligent execution and output. Throughout this process, data undergoes a condensed journey from "data-information-knowledge-wisdom." The "IT value chain," spanning the underlying infrastructure of human intelligence, information (provided and processed by technology), and the system's industrial ecosystem, reflects the value that AI brings to the information technology industry.
[0078] (1) Infrastructure
[0079] Infrastructure provides computing power for AI systems, enabling communication with the outside world and supporting this through a foundational platform. External communication occurs through sensors; computing power is provided by intelligent chips (CPUs, NPUs, GPUs, ASICs, FPGAs, and other hardware accelerators). The foundational platform includes a distributed computing framework and network-related platform guarantees and support, including cloud storage and computing, and interconnected networks. For example, sensors communicate with the outside world to acquire data, which is then fed into the intelligent chips within the distributed computing system provided by the foundational platform for computation.
[0080] (2) Data
[0081] Data above the infrastructure layer represents data sources for AI. This data includes graphics, images, voice, and text, as well as IoT data from traditional devices. This includes business data from existing systems and sensor data such as force, displacement, liquid level, temperature, and humidity.
[0082] (3) Data processing
[0083] Data processing generally includes data training, machine learning, deep learning, search, reasoning, decision-making, etc.
[0084] Among them, machine learning and deep learning can symbolize and formalize data for intelligent information modeling, extraction, preprocessing, and training.
[0085] Reasoning refers to the process of simulating human intelligent reasoning in computers or intelligent systems, using formalized information to perform machine thinking and solve problems based on reasoning control strategies. Typical functions are search and matching.
[0086] Decision-making refers to the process of making decisions after intelligent information is reasoned, and usually provides functions such as classification, sorting, and prediction.
[0087] (4) General ability
[0088] After the data has undergone the data processing mentioned above, some general capabilities can be further formed based on the results of the data processing, such as algorithms or a general system, for example, translation, text analysis, computer vision processing, speech recognition, image recognition, etc.
[0089] (5) Smart products and industry applications
[0090] Smart products and industry applications refer to the products and applications of artificial intelligence systems in various fields. They are the encapsulation of the overall artificial intelligence solution, which productizes intelligent information decision-making and realizes practical application. Its application areas mainly include: smart terminals, smart transportation, smart medical care, autonomous driving, smart cities, etc.
[0091] Next, several application scenarios of this application are introduced.
[0092] Figure 2a is a schematic diagram of the structure of an image processing system provided in an embodiment of the present application. The image processing system includes a user device and a data processing device. The user device includes an intelligent terminal such as a mobile phone, a personal computer, or an information processing center. The user device is the initiator of image processing and is the initiator of image processing requests, typically initiated by a user through the user device.
[0093] The aforementioned data processing device can be a device or server with data processing capabilities, such as a cloud server, network server, application server, or management server. The data processing device receives image processing requests from smart terminals via an interactive interface and then performs image processing using methods such as machine learning, deep learning, search, reasoning, and decision-making through its memory and data processing processor. The memory in the data processing device is a general term that includes local storage and a database that stores historical data. The database can be located on the data processing device or on other network servers.
[0094] In the image processing system shown in Figure 2a, a user device can receive user instructions. For example, the user device can obtain an image input / selected by the user for a certain visual task, and then initiate a request to a data processing device, causing the data processing device to execute an image processing application on the image obtained by the user device, thereby obtaining a corresponding processing result for the image. For example, the user device can obtain an image input by the user, and then initiate an image processing request to the data processing device, causing the data processing device to perform a series of processing on the image, thereby obtaining a processing result for the image, such as a classification result for the image, a detection box area surrounding a target object in the image, etc. The processing result of the image can then be used to complete the user's visual task.
[0095] In FIG. 2 a , the data processing device may execute the image processing method according to the embodiment of the present application.
[0096] Figure 2b is another structural schematic diagram of the image processing system provided in an embodiment of the present application. In Figure 2b, the user device directly serves as a data processing device. The user device can directly obtain input from the user and directly process it by the hardware of the user device itself. The specific process is similar to that of Figure 2a. Please refer to the above description and will not be repeated here.
[0097] In the image processing system shown in FIG2b , the user device can receive user instructions. For example, the user device can obtain an image input by the user, and then perform a series of processing on the image to obtain a processing result of the image, such as a classification result of the image, a detection frame area surrounding a target object in the image, etc. Therefore, the processing result of the image can be used to complete the user's visual task.
[0098] In FIG2 b , the user equipment itself can execute the image processing method of the embodiment of the present application.
[0099] FIG2c is a schematic diagram of an image processing related device provided in an embodiment of the present application.
[0100] The user device in the above Figures 2a and 2b can specifically be the local device 301 or the local device 302 in Figure 2c, and the data processing device in Figure 2a can specifically be the execution device 210 in Figure 2c, wherein the data storage system 250 can store the data to be processed of the execution device 210, and the data storage system 250 can be integrated on the execution device 210, or it can be set on the cloud or other network servers.
[0101] The processors in Figures 2a and 2b can perform data training / machine learning / deep learning through a neural network model or other models (for example, a model based on a support vector machine), and use the model finally trained or learned from the data to perform image processing applications on the image, thereby obtaining corresponding processing results.
[0102] Figure 3 is a schematic diagram of the system 100 architecture provided in an embodiment of the present application. In Figure 3, the execution device 110 is configured with an input / output (I / O) interface 112 for data interaction with an external device. The user can input data to the I / O interface 112 through the client device 140. The input data can include: various tasks to be scheduled, callable resources and other parameters in the embodiment of the present application.
[0103] When the execution device 110 preprocesses the input data, or when the computing module 111 of the execution device 110 performs calculations and other related processing (such as implementing the functions of the neural network in this application), the execution device 110 can call the data, code, etc. in the data storage system 150 for the corresponding processing, and can also store the data, instructions, etc. obtained from the corresponding processing in the data storage system 150.
[0104] Finally, the I / O interface 112 returns the processing result to the client device 140 so as to provide it to the user.
[0105] It is worth noting that the training device 120 can generate corresponding target models / rules based on different training data for different goals or tasks. The corresponding target models / rules can be used to achieve the above goals or complete the above tasks, thereby providing the user with the desired results. The training data can be stored in the database 130 and come from training samples collected by the data collection device 160.
[0106] In the scenario shown in FIG3 , the user can manually input data, which can be performed through the interface provided by I / O interface 112. Alternatively, client device 140 can automatically send input data to I / O interface 112. If user authorization is required for client device 140 to automatically send input data, the user can set the corresponding permissions in client device 140. The user can view the output of execution device 110 on client device 140, which can be presented in a display, sound, action, or other specific form. Client device 140 can also serve as a data acquisition terminal, collecting input data and output results from I / O interface 112 as new sample data and storing them in database 130. Of course, collection can also be performed without client device 140, with I / O interface 112 directly storing the input data and output results from I / O interface 112 as new sample data in database 130.
[0107] It is worth noting that FIG3 is only a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationship between the devices, components, modules, etc. shown in the figure does not constitute any limitation. For example, in FIG3, the data storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 can also be placed in the execution device 110. As shown in FIG3, a neural network can be trained according to the training device 120.
[0108] The present application also provides a chip including a neural network processor (NPU). The chip can be provided in the execution device 110 shown in FIG3 to complete the computational work of the computation module 111. The chip can also be provided in the training device 120 shown in FIG3 to complete the training work of the training device 120 and output the target model / rule.
[0109] The neural network processor (NPU) is a coprocessor mounted on the host central processing unit (CPU), which assigns tasks to it. The core of the NPU is the arithmetic circuit, which is controlled by a controller to extract data from memory (weight memory or input memory) and perform calculations.
[0110] In some implementations, the arithmetic circuit includes multiple processing engines (PEs). In some implementations, the arithmetic circuit is a two-dimensional systolic array. The arithmetic circuit can also be a one-dimensional systolic array or other electronic circuit capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit is a general-purpose matrix processor.
[0111] For example, consider an input matrix A, a weight matrix B, and an output matrix C. The computational circuit retrieves the corresponding data for matrix B from the weight memory and caches it on each PE within the computational circuit. The computational circuit then performs a matrix operation on the matrix A data from the input memory and matrix B, storing the partial or final matrix results in the accumulator.
[0112] The vector computation unit can further process the output of the arithmetic circuit, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. For example, the vector computation unit can be used for network calculations in non-convolutional / non-FC layers in neural networks, such as pooling, batch normalization, and local response normalization.
[0113] In some implementations, the vector computation unit can store the processed output vectors in a unified buffer. For example, the vector computation unit can apply a nonlinear function to the output of the computation circuit, such as a vector of accumulated values, to generate activation values. In some implementations, the vector computation unit generates normalized values, merged values, or both. In some implementations, the processed output vectors can be used as activation inputs to the computation circuit, such as for use in subsequent layers in a neural network.
[0114] The unified memory is used to store input data and output data.
[0115] The weight data is directly transferred from the external memory to the input memory and / or unified memory through the direct memory access controller (DMAC), the weight data in the external memory is stored in the weight memory, and the data in the unified memory is stored in the external memory.
[0116] The bus interface unit (BIU) is used to implement interaction between the main CPU, DMAC and instruction fetch memory through the bus.
[0117] An instruction fetch buffer connected to the controller, used to store instructions used by the controller;
[0118] The controller is used to call the instructions cached in the memory to control the working process of the computing accelerator.
[0119] Generally, unified memory, input memory, weight memory and instruction fetch memory are all on-chip memories, and external memory is memory outside the NPU, which can be double data rate synchronous dynamic random access memory (DDR SDRAM), high bandwidth memory (HBM) or other readable and writable memory.
[0120] Since the embodiments of the present application involve the application of a large number of neural networks, in order to facilitate understanding, the relevant terms and related concepts such as neural networks involved in the embodiments of the present application are first introduced below.
[0121] (1) Neural Network
[0122] A neural network can be composed of neural units. A neural unit can refer to an operation unit with xs and intercept 1 as input. The output of the operation unit can be:
[0123] Where s = 1, 2, ... n, n is a natural number greater than 1, Ws is the weight of xs, and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into the output signal. The output signal of the activation function can be used as the input of the next convolutional layer. The activation function can be a sigmoid function. A neural network is a network formed by connecting many of the above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected to the local receptive field of the previous layer to extract the features of the local receptive field. The local receptive field can be an area composed of several neural units.
[0124] The operation of each layer in a neural network can be described by the mathematical expression y = a(Wx + b). From a physical perspective, the operation of each layer in a neural network can be understood as transforming the input space (a set of input vectors) into the output space (i.e., from the row space to the column space of a matrix) through five operations. These operations include: 1. Dimensionality increase / decrease; 2. Scaling / reduction; 3. Rotation; 4. Translation; and 5. "Bending." Operations 1, 2, and 3 are performed by Wx, 4 by +b, and 5 by a(). The word "space" is used here because the objects being classified are not individual things, but rather a class of things, and space refers to the collection of all individuals within that class. W is the weight vector, each value in which represents the weight of a neuron in that layer of the neural network. This vector W determines the spatial transformation from input space to output space described above. That is, the weights W of each layer control how the space is transformed. The goal of training a neural network is to ultimately obtain the weight matrix for all layers of the trained neural network (a weight matrix formed by the vectors W of many layers). Therefore, the training process of a neural network is essentially about learning how to control spatial transformations, and more specifically, about learning the weight matrix.
[0125] Because we want the output of the neural network to be as close as possible to the value we really want to predict, we can compare the current network's predicted value with the desired target value, and then update the weight vector of each layer of the neural network based on the difference between the two (of course, there is usually an initialization process before the first update, which is to pre-configure the parameters for each layer in the neural network). For example, if the network's predicted value is too high, the weight vector is adjusted to make it predict a lower value, and this adjustment is continued until the neural network can predict the desired target value. Therefore, it is necessary to pre-define "how to compare the difference between the predicted value and the target value." This is the loss function or objective function, which is an important equation used to measure the difference between the predicted value and the target value. Among them, taking the loss function as an example, the higher the output value (loss) of the loss function, the greater the difference, so the training of the neural network becomes a process of minimizing this loss as much as possible.
[0126] (2) Backpropagation algorithm
[0127] Neural networks can use the back propagation (BP) algorithm to correct the size of the parameters in the initial neural network model during training, reducing the reconstruction error loss of the neural network model. Specifically, the forward propagation of the input signal to the output generates error loss. This error loss information is then backpropagated to update the parameters in the initial neural network model, thereby converging the error loss. The BP algorithm is a backward propagation movement dominated by error loss, aiming to obtain the optimal parameters of the neural network model, such as the weight matrix.
[0128] The method provided in this application is described below from the training side of the neural network and the application side of the neural network.
[0129] The model training method provided in the embodiment of the present application involves the processing of data sequences, and can be specifically applied to methods such as data training, machine learning, and deep learning, and performs symbolic and formalized intelligent information modeling, extraction, preprocessing, and training on the training data (for example, the target image in the model training method provided in the embodiment of the present application), and finally obtains a trained neural network (for example, the target model in the model training method provided in the embodiment of the present application); and the image processing method provided in the embodiment of the present application can use the above-mentioned trained neural network to input the input data (for example, the target image in the image processing method provided in the embodiment of the present application) into the trained neural network to obtain output data (for example, the processing result of the target image in the image processing method provided in the embodiment of the present application). It should be noted that the model training method and image processing method provided in the embodiment of the present application are inventions based on the same concept, and can also be understood as two parts in a system, or two stages of an overall process: such as the model training stage and the model application stage.
[0130] The image processing method provided in the embodiment of the present application can be implemented by a new type of visual multi-layer perceptron model. The new type of visual multi-layer perceptron model will be referred to as the target model later. The target model can have multiple structures. The target model of the first structure will be introduced below. Figure 4 is a structural schematic diagram of the target model provided in the embodiment of the present application. As shown in Figure 4, the target model includes a dynamic multi-layer perceptron (dynamic MLP) module, and the dynamic multi-layer perceptron module includes a dynamic image block (dynamic-token) unit and a processing unit. In order to understand the workflow of the target model shown in Figure 4, the workflow is introduced in conjunction with Figure 5 below. Figure 5 is a flow chart of the image processing method provided in the embodiment of the present application. As shown in Figure 5, the method includes:
[0131] 501. Obtain N image blocks of a target image.
[0132] In this embodiment, when it is necessary to process a target image in a visual task, the target image may be first divided into N image blocks, where the N image blocks may be presented by an image block array of X rows and Y columns (that is, the image block array includes X rows of image blocks, or the image block array includes Y columns of image blocks), where N is a positive integer greater than 2, and X and Y are positive integers greater than or equal to 2.
[0133] After obtaining N image blocks of the target image, the N image blocks can be input into the target model (trained neural network model) to perform a series of processing on the N image blocks through the target model.
[0134] 502. Evaluate the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks are used to indicate the importance of the contents presented by the N image blocks.
[0135] After receiving N image blocks of the target image, the target model can first evaluate the N image blocks separately, thereby obtaining evaluation values of the N image blocks accordingly. It should be noted that the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks (which can also be understood as the richness of the content presented by the N image blocks, or the contribution of the N image blocks to the visual task, etc.). For any image block among the N image blocks, the larger the evaluation value of the image block, the more important the content presented by the image block, and the smaller the evaluation value of the image block, the less important the content presented by the image block.
[0136] Specifically, the target model can obtain the evaluation values of N image blocks in the following way:
[0137] (1) After receiving N image blocks, the dynamic image block unit of the target model can perform a first full connection (FC) on the N image blocks, thereby obtaining the first features of the N image blocks. It should be noted that the height of the whole formed by the N image blocks (i.e., the target image) is the same as the height of the whole formed by the first features of the N image blocks (i.e., the first feature map), and the width of the whole formed by the N image blocks is the same as the width of the whole formed by the first features of the N image blocks. However, for any one of the N image blocks, the number of channels of the image block is greater than the number of channels of the first feature of the image block.
[0138] For example, as shown in FIG6 (FIG. 6 is a schematic structural diagram of a dynamic image block unit provided in an embodiment of the present application), assuming that the target image is divided into 36 image blocks, which are arranged in the form of 6 rows and 6 columns, the total height of the 36 image blocks is H=6, the total width of the 36 image blocks is W=6, and the number of channels of the 36 image blocks is C. After the dynamic image block unit receives the 36 image blocks, the horizontal predictor of the dynamic image block unit can fully connect the 36 image blocks using the following formula, thereby obtaining the horizontal features (the aforementioned first features) of the 36 image blocks, that is, the horizontal feature map (the aforementioned first feature map):
[0139] X h =FC(X,W h ) (2)
[0140] In the above formula, X is the target image, W h The parameters used for full connection, X h is the horizontal feature map, which contains the horizontal features of these 36 image blocks. It should be noted that X h The height is H, X h The width of the horizontal feature is W, X h The number of channels is C / 2.
[0141] At the same time, the vertical predictor of the dynamic image block unit can also perform similar operations on these 36 image blocks, so the vertical feature map X can be obtained. v (the first feature map mentioned above), contains the vertical features of 36 image blocks (the first feature mentioned above). It should be noted that X v The height is H, X v The width is W, X v The number of channels is C / 2.
[0142] (2) After obtaining the first features of the N image blocks, the dynamic image block unit can perform pooling on the first features of the N image blocks to obtain the second features of the N image blocks. It should be noted that after pooling (dimensionality reduction), two situations may occur. In the first case, the height of the whole formed by the first features of the N image blocks is the same as the height of the whole formed by the second features of the N image blocks (i.e., the second feature map), and the width of the whole formed by the first features of the N image blocks is larger than the width of the whole formed by the first features of the N image blocks. However, for any image block in the N image blocks, the number of channels of the first feature of the image block is the same as the number of channels of the second feature of the image block. In the second case, the height of the whole formed by the first features of the N image blocks is larger than the height of the whole formed by the second features of the N image blocks, and the width of the whole formed by the first features of the N image blocks is the same as the width of the whole formed by the first features of the N image blocks. However, for any image block in the N image blocks, the number of channels of the first feature of the image block is the same as the number of channels of the second feature of the image block.
[0143] As in the above example, we get X h After that, the horizontal predictor can be used to predict X h Pooling is performed to obtain a horizontal marker feature map (the aforementioned second feature map), contains the horizontal marking features of these 36 images (the aforementioned second features). It should be noted that, The height is H, The width is 1, The number of channels is C / 2.
[0144] At the same time, get X v After that, the vertical predictor can also be used for X v By performing similar operations, we can obtain the vertical marking feature map (the aforementioned second feature map), contains the vertical marking features of 36 image blocks (the aforementioned second feature). It should be noted that, The height of is 1, The width is W, The number of channels is C / 2.
[0145] (3) After obtaining the second features of the N image blocks, the dynamic image block unit may multiply the first features of the N image blocks and the second features of the N image blocks (for example, dot multiplication, etc.) to obtain the third features of the N image blocks. Then, the third features of the N image blocks may be used as evaluation values of the N image blocks. It should be noted that the height of the whole formed by the first features of the N image blocks is the same as the height of the whole formed by the third features of the N image blocks (i.e., the third feature map), and the width of the whole formed by the first features of the N image blocks is the same as the width of the whole formed by the third features of the N image blocks. However, for any one of the N image blocks, the number of channels of the first feature of the image block is greater than the number of channels of the third feature of the image block.
[0146] As in the above example, we get After that, the horizontal predictor can be calculated by the following formula and X h Perform dot multiplication to obtain a horizontal evaluation value graph:
[0147] In the above formula, S h is the horizontal evaluation value graph, which contains the horizontal evaluation values of these 36 image blocks. h The height is H, S h The width is W, S h The number of channels is 1.
[0148] At the same time, the vertical predictor can also v as well as Perform similar operations, and you can get the vertical evaluation value graph S v , contains the vertical evaluation values of these 36 image blocks. It should be noted that S v The height is H, S v The width is W, S v The number of channels is 1.
[0149] 503. Determine M image blocks from the N image blocks based on the evaluation values of the N image blocks, where N>M≥2.
[0150] After obtaining the evaluation values of the N image blocks, the target model can select M image blocks from the N image blocks based on the magnitude relationship of the evaluation values of the N image blocks, where M is a positive integer less than N and greater than or equal to 2. Then, among the N image blocks that constitute the target image, the M image blocks selected by the target model can be considered the more important parts of the target image, while the remaining NM image blocks that were not selected can be considered the less important parts of the target image.
[0151] Specifically, the target model can select M image blocks in the following way:
[0152] (1) After obtaining the evaluation values of N image blocks, since the N image blocks are presented in the form of X rows of image blocks (each row of image blocks includes Y image blocks), the dynamic image block unit can select P image blocks with the largest evaluation values (P is a positive integer greater than or equal to 1) in the first row of image blocks according to a certain image block selection ratio ρ = P / Y, select P image blocks with the largest evaluation values in the second row of image blocks, ..., select P image blocks with the largest evaluation values in the Xth row of image blocks. In this way, the dynamic image block unit can select a total of M = XP image blocks horizontally.
[0153] (2) After obtaining the evaluation values of the N image blocks, since the N image blocks are presented in the form of Y columns of image blocks (each column of image blocks includes X image blocks), the dynamic image block unit can select the K image blocks with the largest evaluation values in the first column of image blocks (K is a positive integer greater than or equal to 1), select the K image blocks with the largest evaluation values in the second column of image blocks, ..., select the K image blocks with the largest evaluation values in the Y column of image blocks according to a certain image block selection ratio ρ = K / X. In this way, the dynamic image block unit can select a total of M = YK image blocks in the vertical direction.
[0154] As in the above example, we get S h Finally, since these 36 image blocks are presented in the form of 6 rows, the horizontal predictor can select the 3 image blocks with the highest evaluation values from each row according to ρ = 0.5, so a total of 18 image blocks can be obtained horizontally. The set of numbers of these image blocks can be recorded as: id h =Top-ρ(S h ,ρ) (4)
[0155] In the above formula, id h It is a set of numbers of image blocks selected horizontally.
[0156] The set of image blocks selected horizontally can be recorded as:
[0157] In the above formula, is the set of image blocks selected horizontally, is an image block selected horizontally, and u is the number of the image block.
[0158] At the same time, get S vAfter that, since these 36 image blocks are presented in the form of 6 columns, the horizontal predictor can select the 3 image blocks with the highest evaluation value from each column according to ρ = 0.5, so a total of 18 image blocks can be obtained in the vertical direction. Similarly, the set of image blocks selected in the vertical direction can be recorded as
[0159] 504. Fuse the M image blocks to obtain a fusion result of the M image blocks.
[0160] After obtaining the M image blocks, the target model may perform a series of fusion operations on the M image blocks instead of performing these fusion operations on the NM image blocks, thereby obtaining a fusion result of the M image blocks.
[0161] Specifically, the target model can obtain the fusion results of M image blocks in the following way:
[0162] (1) After obtaining the evaluation values of the N image blocks, the dynamic image block unit can also use the evaluation values of the N image blocks as weights, and use these weights to perform weighted summation on the first features of the N image blocks, thereby obtaining the fourth features of the N image blocks. It should be noted that after the weighted summation (dimensionality reduction), two situations may occur. In the first case, the height of the whole formed by the first features of the N image blocks is the same as the height of the whole formed by the fourth features of the N image blocks (i.e., the fourth feature map), and the width of the whole formed by the first features of the N image blocks is larger than the width of the whole formed by the fourth features of the N image blocks. However, for any one of the N image blocks, the number of channels of the first feature of the image block is the same as the number of channels of the fourth feature of the image block. In the second case, the height of the whole formed by the first features of the N image blocks is greater than the height of the whole formed by the fourth features of the N image blocks, and the width of the whole formed by the first features of the N image blocks is the same as the width of the whole formed by the fourth features of the N image blocks. However, for any one of the N image blocks, the number of channels of the first feature of the image block is the same as the number of channels of the fourth feature of the image block.
[0163] As in the above example, we get S h After that, the horizontal predictor can be used to calculate S by the following formula h and X h Perform weighted summation to obtain the global feature map in the horizontal direction:
[0164] In the above formula, is the global feature map in the horizontal direction (the aforementioned fourth feature map), which contains the global features of these 36 image blocks in the horizontal direction (the aforementioned fourth feature). is the evaluation value of the image block in row i, is the horizontal feature of the image block in row i, H=6. It should be noted that The height is H, The width is 1, The number of channels is C / 2.
[0165] At the same time, the vertical predictor can also be used to predict the S v and X v Perform similar operations to obtain a vertical global feature map (the aforementioned fourth feature map), contains the vertical global features of these 36 image blocks (the aforementioned fourth feature). It should be noted that, The height of is 1, The width is W, The number of channels is C / 2.
[0166] (2) After obtaining the fourth features of the N image blocks, the dynamic image block unit may further multiply the fourth features of the N image blocks and the evaluation values of the M image blocks (for example, dot product, etc.), thereby obtaining the fifth features of the M image blocks. It should be noted that the height of the whole formed by the M image blocks is the same as the height of the whole formed by the fifth features of the M image blocks (i.e., the fifth feature map), and the width of the whole formed by the M image blocks is the same as the width of the whole formed by the fifth features of the M image blocks. However, for any one of the M image blocks, the number of channels of the image block is greater than the number of channels of the fifth feature of the image block.
[0167] As in the above example, we get After that, the horizontal predictor can Send to the horizontal mixer (horizontal mixer), similarly, the vertical predictor can also Then, the horizontal mixer can use the following formula to Processing is performed to obtain the first global expanded feature map in the horizontal direction:
[0168] In the above formula, is the first global extended feature map in the horizontal direction (the aforementioned fifth feature map), including the first global extended features (the aforementioned fifth features) of the 18 image blocks selected in the horizontal direction, is the set of evaluation values of 18 image blocks selected horizontally, is the evaluation value of a certain image block that appears in the horizontal direction. It should be noted that The height is H, The width is W×ρ (i.e. 3), The number of channels is C / 2.
[0169] Then, the horizontal mixer can also be calculated by the following formula: Processing is performed to obtain the second global expanded feature map in the horizontal direction:
[0170] In the above formula, It is the second global extended feature map in the horizontal direction (the fifth feature map mentioned above), which contains the second global extended features (the fifth feature mentioned above) of the 18 image blocks selected in the horizontal direction. The height is H, The width is W×ρ (i.e. 3), The number of channels is C / 2.
[0171] Similarly, get After that, the vertical predictor can Send to the vertical mixer (vertical mixer), similarly, the horizontal predictor can also Then, the vertical mixer can also send as well as Perform similar processing to obtain the first global extended feature map in the vertical direction (the fifth feature map mentioned above) and the second global expanded feature map in the vertical direction (the fifth characteristic diagram mentioned above), The first global expansion feature (the fifth feature mentioned above) of 18 image blocks selected vertically, The second global expansion feature (the fifth feature mentioned above) of the 18 image blocks selected vertically is included. The height of is H×ρ (i.e. 3), The width is W, The number of channels is C / 2. The height of is H×ρ (i.e. 3), The width is W, The number of channels is C / 2.
[0172] (3) After obtaining the fifth features of the N image blocks, the dynamic image block unit may further splice the M image blocks with the fifth features of the M image blocks, thereby obtaining the sixth features of the M image blocks. It should be noted that the height of the whole formed by the M image blocks is the same as the height of the whole formed by the sixth features of the M image blocks (i.e., the sixth feature map), and the width of the whole formed by the M image blocks is the same as the width of the whole formed by the sixth features of the M image blocks. However, for any one of the M image blocks, the number of channels of the image block is less than the number of channels of the sixth feature of the image block.
[0173] As in the above example, the horizontal mixer can also as well as Perform splicing to obtain the horizontal splicing feature map (the aforementioned sixth feature map) includes the splicing features of 18 image blocks selected horizontally (the aforementioned sixth feature). It should be noted that, The height is H, The width is W×ρ, The number of channels is 2C. The vertical mixer can also as well as Perform splicing to obtain a vertical splicing feature map (the aforementioned sixth feature map) includes the splicing features of 18 image blocks selected vertically (the aforementioned sixth feature). It should be noted that, The height of is H×ρ, The width is W, The number of channels is 2C.
[0174] (4) After obtaining the fifth features of the N image blocks, the dynamic image block unit further performs full connection on the sixth features of the M image blocks, thereby obtaining the seventh features of the M image blocks. Then, the seventh features of the M image blocks are used as the fusion results of the M image blocks. It should be noted that the height of the whole formed by the M image blocks is the same as the height of the whole formed by the seventh features of the M image blocks (i.e., the seventh feature map), and the width of the whole formed by the M image blocks is the same as the width of the whole formed by the seventh features of the M image blocks. For any image block among the M image blocks, the number of channels of the image block is the same as the number of channels of the seventh feature of the image block.
[0175] Still like the above example, the horizontal mixer can also obtain the fused feature map in the horizontal direction through the following formula:
[0176] In the above formula, It is a fusion feature map in the horizontal direction (the seventh feature map mentioned above), which contains the fusion features of 18 image blocks selected in the horizontal direction (the seventh feature map mentioned above). The height is H, The width is W×ρ, The number of channels is C.
[0177] At the same time, the vertical mixer can also obtain the fusion feature map in the vertical direction (the seventh feature map mentioned above) contains the fusion features of 18 image blocks selected vertically (the seventh feature mentioned above). It should be noted that, The height of is H×ρ, The width is W, The number of channels is C.
[0178] 505. Based on the fusion results of the M image blocks, obtain a processing result of the target image.
[0179] After obtaining the fusion results of the M image blocks, the target model can perform a series of processing on the fusion results of the M image blocks to obtain the processing results of the target image. Then, the visual task can be completed using the processing results of the target image.
[0180] Specifically, the target model can obtain the processing results of the target image in the following ways:
[0181] (1) The dynamic image block unit may further perform a second full connection on the N image blocks, thereby obtaining the eighth features of the N image blocks. It should be noted that the height of the whole formed by the N image blocks is the same as the height of the whole formed by the eighth features of the N image blocks (i.e., the eighth feature map), the width of the whole formed by the N image blocks is the same as the width of the whole formed by the eighth features of the N image blocks, and for any one of the N image blocks, the number of channels of the image block is the same as the number of channels of the eighth feature of the image block.
[0182] (2) After obtaining the eighth features of the N image blocks, the dynamic image block unit may also use preset weights to perform weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks, thereby obtaining the ninth features of the M image blocks. It should be noted that the height of the whole formed by the M image blocks is the same as the height of the whole formed by the eighth features of the M image blocks (i.e., a part of the eighth feature map), the width of the whole formed by the M image blocks is the same as the width of the whole formed by the eighth features of the M image blocks, and for any one of the M image blocks, the number of channels of the image block is the same as the number of channels of the eighth feature of the image block.
[0183] (3) After obtaining the eighth features of the N image blocks, the dynamic image block unit can also use the preset weights to perform weighted summation on the NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks, thereby obtaining the ninth features of the NM image blocks. It should be noted that the height of the whole formed by the NM image blocks is the same as the height of the whole formed by the eighth features of the NM image blocks (i.e., another part of the eighth feature map), the width of the whole formed by the NM image blocks is the same as the width of the whole formed by the eighth features of the NM image blocks, and for any one of the NM image blocks, the number of channels of the image block is the same as the number of channels of the eighth feature of the image block.
[0184] (4) After obtaining the ninth feature of the N image blocks, the dynamic image block unit also sends the ninth feature of the N image blocks to the processing unit, so that the processing unit processes the ninth feature of the N image blocks, thereby obtaining the processing result of the target image. It should be noted that the height of the whole formed by the N image blocks is the same as the height of the whole formed by the ninth feature of the N image blocks (i.e., the ninth feature map), the width of the whole formed by the N image blocks is the same as the width of the whole formed by the eighth feature of the N image blocks, and for any one of the N image blocks, the number of channels of the image block is the same as the number of channels of the ninth feature of the image block.
[0185] For example, as shown in Figure 7 (Figure 7 is another structural diagram of the dynamic image block unit provided in an embodiment of the present application, and Figure 7 is drawn on the basis of Figure 6), after obtaining the fusion features of the 18 image blocks selected horizontally, the fusion features of these 18 images can be combined with the remaining 18 image blocks that are not selected horizontally to form a first new feature map. Similarly, after obtaining the fusion features of the 18 image blocks selected vertically, the fusion features of these 18 images can be combined with the remaining 18 image blocks that are not selected vertically to form a second new feature map. The dynamic image block unit can also perform a full connection operation on the original 36 image blocks to obtain a third new feature map (the aforementioned eighth feature map), which contains certain features of these 36 image blocks (the aforementioned eighth feature). It should be noted that the height of these three new feature maps is H, the width is W, and the number of channels is C. Then, the dynamic image block unit can perform weighted summation on the three new feature maps to obtain the latest feature map (the ninth feature map mentioned above), which includes the latest features of the 36 image blocks (the ninth feature mentioned above).
[0186] The above is a detailed description of the target model of the first structure. The target model of the second structure will be introduced below. As shown in Figure 8 (Figure 8 is another structural diagram of the target model provided by an embodiment of the present application), the target model includes a dynamic multi-layer perceptron module, which includes a dynamic image block unit and a processing unit, wherein the processing unit includes two normalization units, a channel unit, and two skip connection units.
[0187] As can be seen, the first normalization unit can obtain N image blocks of the target image and normalize the N image blocks to obtain new N image blocks (the aforementioned normalized N image blocks). The new N image blocks are then input into the dynamic image block unit for various processing (see the embodiment shown in Figure 5, which will not be described here in detail), thereby obtaining the ninth feature of the new N image blocks. Next, the first skip connection unit can superimpose the ninth feature of the new N image blocks with the N image blocks to obtain the tenth feature of the new N image blocks. Next, the second normalization unit can normalize the tenth feature of the new N image blocks to obtain the eleventh feature of the new N image blocks. Then, the channel unit can aggregate the eleventh feature of the new N image blocks in the channel dimension to obtain the twelfth feature of the new N image blocks. Finally, the second skip connection unit can superimpose the twelfth feature of the new N image blocks with the ninth feature of the new N image blocks to obtain the processing result of the target image.
[0188] The above is a detailed description of the target model of the second structure. The target model of the third structure will be introduced below. As shown in Figure 9 (Figure 9 is another structural diagram of the target model provided in an embodiment of the present application), the target model includes ten dynamic multi-layer perceptron modules and four downsampling modules. These modules are connected in series, and the internal structure of each dynamic multi-layer perceptron module can refer to the structure of the dynamic multi-layer perceptron module shown in Figure 8.
[0189] It should be understood that the embodiments of the present application are only schematically introduced with target models of three structures, and do not constitute a limitation on the structure of the target model provided by the embodiments of the present application. For example, in the target model shown in FIG8 , the number of normalization units and the number of skip connection units can be increased or decreased, and for example, in the target model shown in FIG9 , the number of dynamic multi-layer perceptron modules and downsampling modules can be increased or decreased, and there is no limitation here, and it can be set according to actual needs.
[0190] In addition, the target models provided in the embodiments of the present application (including DynamicMLP-T, DynamicMLP-S, DynamicMLP-B, and DynamicMLP-L in Table 1) can also be compared with models of some related technologies (including the remaining models in Table 1 except DynamicMLP-T, DynamicMLP-S, DynamicMLP-B, and DynamicMLP-L). The comparison results are shown in Table 1:
[0191] Table 1
[0192] Furthermore, the target models provided in the embodiments of the present application (including DynamicMLP-T, DynamicMLP-S, DynamicMLP-B, and DynamicMLP-L in Table 2) can be compared with models of other related technologies (including the remaining models in Table 2 except DynamicMLP-T, DynamicMLP-S, DynamicMLP-B, and DynamicMLP-L). The comparison results are shown in Table 2:
[0193] Table 2
[0194] Based on Table 1 and Table 2, it can be seen that the target model provided by the embodiment of the present application performs better on visual tasks and has less computational complexity (FLOPs).
[0195] In an embodiment of the present application, after receiving N image blocks of a target image, the target model may first evaluate the N image blocks to obtain evaluation values of the N image blocks. Next, the target model may use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. Then, the target model may fuse the M image blocks to obtain a fusion result of the M image blocks. Finally, the target model may perform a series of processing on the fusion result of the M image blocks to obtain a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are usually the more important parts of the content in the target image. Therefore, in the process of obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and does not perform the fusion operation on the remaining NM image blocks, which can effectively reduce the amount of calculation, thereby shortening the overall image processing time and improving the efficiency of image processing.
[0196] Furthermore, the target model provided in the embodiment of the present application can automatically filter the original N image blocks, retaining only M of them for the fusion operation. This shows that this new model has an automatic image block selection function, so there is no need to introduce additional neural network models for the model. Therefore, no additional work is required in the model training phase or the model application phase, which can save various costs and resources.
[0197] The above is a detailed description of the image processing method provided by the embodiment of the present application. The following is an introduction to the model training method provided by the embodiment of the present application. Figure 10 is a flow chart of the model training method provided by the embodiment of the present application. As shown in Figure 10, the method includes:
[0198] 1001. Input a target image into a model to be trained to obtain a processing result of the target image, where the model to be trained is used to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks; based on the evaluation values of the N image blocks, determine M image blocks from the N image blocks, where N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; and obtain a processing result of the target image based on the fusion result of the M image blocks.
[0199] In this embodiment, when a model with image processing capabilities is needed, a model to be trained (i.e., an untrained neural network model) and a batch of training data can be obtained. The batch of training data includes the actual processing results of the target image, which can also be understood as the label of the target image, and the label is known.
[0200] After obtaining the target image, the target image can be divided into N image blocks and input into the model to be trained, so that the N image blocks of the target image are processed by the model to be trained, thereby obtaining the processing result of the target image. The model to be trained is used to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, and the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks; based on the evaluation values of the N image blocks, determine M image blocks from the N image blocks, where N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; and obtain the processing result of the target image based on the fusion result of the M image blocks.
[0201] In one possible implementation, the model to be trained is used to: perform a first full connection on N image blocks to obtain first features of the N image blocks; perform pooling on the first features of the N image blocks to obtain second features of the N image blocks; multiply the first features of the N image blocks and the second features of the N image blocks to obtain third features of the N image blocks, and the third features of the N image blocks are used as evaluation values of the N image blocks.
[0202] In one possible implementation, N image blocks constitute an image block array with X rows and Y columns, and the model to be trained is used to: select P image blocks with the largest evaluation values from the image blocks in the i-th row, where i = 1, ..., X, M = XP, and P ≥ 1; or, select K image blocks with the largest evaluation values from the image blocks in the j-th column, where j = 1, ..., Y, M = YK, and K ≥ 1.
[0203] In one possible implementation, the model to be trained is also used to: perform a weighted sum of the evaluation values of N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; multiply the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain the fifth features of the M image blocks; the model to be trained is used to: splice the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
[0204] In one possible implementation, the model to be trained is used to: perform a second full connection on N image blocks to obtain the eighth features of the N image blocks; perform weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; perform weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain the ninth features of the NM image blocks; and process the ninth features of the N image blocks to obtain the processing results of the target image.
[0205] In one possible implementation, the processing includes at least one of the following: normalization, aggregation, or addition.
[0206] In a possible implementation, the model to be trained is further used to: normalize the N image blocks to obtain N normalized image blocks.
[0207] 1002. Obtain a target loss based on the processing result and the actual processing result of the target image.
[0208] After obtaining the processing result of the target image, since the true processing result of the target image is known, the preset target loss function can be used to calculate the processing result of the target image and the true processing result of the target image, thereby obtaining the target loss. The target loss can be used to indicate the difference between the processing result of the target image and the true processing result of the target image.
[0209] 1003. Based on the target loss, the parameters of the model to be trained are updated until the model training conditions are met to obtain the target model.
[0210] After obtaining the target loss, the model parameters of the model to be trained can be updated based on the target loss to obtain the updated model to be trained, and the next batch of training data can be obtained. The updated model to be trained is trained based on the next batch of training data (i.e., steps 1001 to 1003 are re-executed) until the model training conditions are met (for example, the target loss reaches convergence, etc.), and the target model can be obtained.
[0211] The target model trained in the embodiment of the present application has image processing capabilities. Specifically, after receiving N image blocks of a target image, the target model may first evaluate the N image blocks to obtain evaluation values for the N image blocks. Next, the target model may use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. The target model may then fuse the M image blocks to obtain a fusion result of the M image blocks. Finally, the target model may perform a series of processing on the fusion result of the M image blocks to obtain a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are generally the more important parts of the target image. Therefore, in the process of obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and does not perform the fusion operation on the remaining NM image blocks. This can effectively reduce the amount of computation, thereby shortening the overall image processing time and improving the efficiency of image processing.
[0212] The above is a detailed description of the image processing method and model training method provided in the embodiment of the present application. The image device and model training device provided in the embodiment of the present application will be introduced below. Figure 11 is a structural schematic diagram of the image processing device provided in the embodiment of the present application. As shown in Figure 11, the target model is included. The device includes:
[0213] A first acquisition module 1101 is configured to acquire N image blocks of a target image;
[0214] An evaluation module 1102 is configured to evaluate the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks;
[0215] A determination module 1103 is configured to determine M image blocks from the N image blocks based on the evaluation values of the N image blocks, where N>M≥2;
[0216] A fusion module 1104 is configured to fuse the M image blocks to obtain a fusion result of the M image blocks;
[0217] The second acquisition module 1105 is configured to acquire a processing result of the target image based on the fusion result of the M image blocks.
[0218] In an embodiment of the present application, after receiving N image blocks of a target image, the target model may first evaluate the N image blocks to obtain evaluation values of the N image blocks. Next, the target model may use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. Then, the target model may fuse the M image blocks to obtain a fusion result of the M image blocks. Finally, the target model may perform a series of processing on the fusion result of the M image blocks to obtain a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are usually the more important parts of the content in the target image. Therefore, in the process of obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and does not perform the fusion operation on the remaining NM image blocks, which can effectively reduce the amount of calculation, thereby shortening the overall image processing time and improving the efficiency of image processing.
[0219] In one possible implementation, the evaluation module 1102 is used to: perform a first full connection on N image blocks to obtain first features of the N image blocks; perform pooling on the first features of the N image blocks to obtain second features of the N image blocks; multiply the first features of the N image blocks and the second features of the N image blocks to obtain third features of the N image blocks, and use the third features of the N image blocks as evaluation values of the N image blocks.
[0220] In one possible implementation, N image blocks constitute an image block array with X rows and Y columns. The determination module 1103 is configured to: select P image blocks with the largest evaluation values from the image blocks in the i-th row, where i=1, ..., X, M=XP, and P≥1; or, select K image blocks with the largest evaluation values from the image blocks in the j-th column, where j=1, ..., Y, M=YK, and K≥1.
[0221] In one possible implementation, the device also includes: a summation module, used to perform weighted summation of the evaluation values of N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; a multiplication module, used to multiply the fourth features of the N image blocks and the evaluation values of M image blocks to obtain the fifth features of the M image blocks; a fusion module 1104, used to: splice the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
[0222] In one possible implementation, the second acquisition module 1105 is used to: perform a second full connection on the N image blocks to obtain the eighth features of the N image blocks; perform weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; perform weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain the ninth features of the NM image blocks; and process the ninth features of the N image blocks to obtain the processing results of the target image.
[0223] In one possible implementation, the processing includes at least one of the following: normalization, aggregation, or addition.
[0224] In one possible implementation, the device further includes: a normalization module, configured to normalize the N image blocks to obtain N normalized image blocks.
[0225] FIG12 is a schematic diagram of the structure of a model training device provided in an embodiment of the present application. As shown in FIG12 , the device includes:
[0226] An input module 1201 is configured to input a target image into a model to be trained to obtain a processing result of the target image, wherein the model to be trained is configured to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks indicate the importance of the content presented by the N image blocks; determine M image blocks from the N image blocks based on the evaluation values, where N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; and obtain a processing result of the target image based on the fusion result of the M image blocks.
[0227] An acquisition module 1202 is configured to acquire a target loss based on the processing result and a real processing result of the target image;
[0228] The updating module 1203 is used to update the parameters of the model to be trained based on the target loss until the model training conditions are met to obtain the target model.
[0229] The target model trained in the embodiment of the present application has image processing capabilities. Specifically, after receiving N image blocks of a target image, the target model may first evaluate the N image blocks to obtain evaluation values for the N image blocks. Next, the target model may use the evaluation values of the N image blocks as selection criteria to select M image blocks from the N image blocks. The target model may then fuse the M image blocks to obtain a fusion result of the M image blocks. Finally, the target model may perform a series of processing on the fusion result of the M image blocks to obtain a processing result of the target image. In the aforementioned process, since the evaluation values of the N image blocks are used to indicate the importance of the content presented by the N image blocks, the M image blocks selected by the target model based on the evaluation values are generally the more important parts of the target image. Therefore, in the process of obtaining the processing result of the target image, the target model only performs the fusion operation on these M image blocks, and does not perform the fusion operation on the remaining NM image blocks. This can effectively reduce the amount of computation, thereby shortening the overall image processing time and improving the efficiency of image processing.
[0230] In one possible implementation, the model to be trained is used to: perform a first full connection on N image blocks to obtain first features of the N image blocks; perform pooling on the first features of the N image blocks to obtain second features of the N image blocks; multiply the first features of the N image blocks and the second features of the N image blocks to obtain third features of the N image blocks, and the third features of the N image blocks are used as evaluation values of the N image blocks.
[0231] In one possible implementation, N image blocks constitute an image block array with X rows and Y columns, and the model to be trained is used to: select P image blocks with the largest evaluation values from the image blocks in the i-th row, where i = 1, ..., X, M = XP, and P ≥ 1; or, select K image blocks with the largest evaluation values from the image blocks in the j-th column, where j = 1, ..., Y, M = YK, and K ≥ 1.
[0232] In one possible implementation, the model to be trained is also used to: perform a weighted sum of the evaluation values of N image blocks and the first features of the N image blocks to obtain the fourth features of the N image blocks; multiply the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain the fifth features of the M image blocks; the model to be trained is used to: splice the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
[0233] In one possible implementation, the model to be trained is used to: perform a second full connection on N image blocks to obtain the eighth features of the N image blocks; perform a weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; perform a weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain the ninth features of the NM image blocks; and process the ninth features of the N image blocks to obtain the processing results of the target image.
[0234] In one possible implementation, the processing includes at least one of the following: normalization, aggregation, or addition.
[0235] In a possible implementation, the model to be trained is further used to: normalize the N image blocks to obtain N normalized image blocks.
[0236] It should be noted that the information interaction, execution process, etc. between the modules / units of the above-mentioned device are based on the same concept as the method embodiment of the present application, and the technical effects they bring are the same as those of the method embodiment of the present application. For specific contents, please refer to the description in the method embodiment shown above in the embodiment of the present application, and no further details will be given here.
[0237] The embodiment of the present application also relates to an execution device, and Figure 13 is a structural diagram of the execution device provided by the embodiment of the present application. As shown in Figure 13, the execution device 1300 can be specifically manifested as a mobile phone, a tablet, a laptop computer, an intelligent wearable device, a server, etc., which are not limited here. Among them, the image processing device described in the embodiment corresponding to Figure 11 can be deployed on the execution device 1300 to implement the image processing function in the embodiment corresponding to Figure 5. Specifically, the execution device 1300 includes: a receiver 1301, a transmitter 1302, a processor 1303 and a memory 1304 (wherein the number of processors 1303 in the execution device 1300 can be one or more, and Figure 13 takes one processor as an example), wherein the processor 1303 may include an application processor 13031 and a communication processor 13032. In some embodiments of the present application, the receiver 1301, the transmitter 1302, the processor 1303 and the memory 1304 can be connected via a bus or other means.
[0238] Memory 1304 may include read-only memory and random access memory, and provides instructions and data to processor 1303. A portion of memory 1304 may also include non-volatile random access memory (NVRAM). Memory 1304 stores processor and operation instructions, executable modules, or data structures, or subsets or extended sets thereof. The operation instructions may include various operation instructions for implementing various operations.
[0239] Processor 1303 controls the operation of the execution device. In specific applications, the various components of the execution device are coupled together via a bus system. In addition to a data bus, the bus system may also include a power bus, a control bus, and a status signal bus. However, for clarity, all bus systems are referred to as a bus system in the figure.
[0240] The methods disclosed in the above embodiments of the present application can be applied to or implemented by processor 1303. Processor 1303 can be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits or software instructions in processor 1303. The above processor 1303 can be a general-purpose processor, a digital signal processor (DSP), a microprocessor, or a microcontroller, and can further include an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The processor 1303 can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in conjunction with the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in memory 1304, and processor 1303 reads the information in memory 1304 and, in conjunction with its hardware, completes the steps of the above method.
[0241] Receiver 1301 can be used to receive input digital or character information and generate signal input related to executing device-related settings and function control. Transmitter 1302 can be used to output digital or character information through the first interface. Transmitter 1302 can also be used to send instructions to the disk pack through the first interface to modify data in the disk pack. Transmitter 1302 can also include a display device such as a display screen.
[0242] In an embodiment of the present application, in one case, the processor 1303 is used to obtain a processing result of the target image through the target model in the embodiment corresponding to FIG5 .
[0243] The present application also relates to a training device. FIG14 is a schematic diagram of the structure of the training device provided by the present application. As shown in FIG14 , the training device 1400 is implemented by one or more servers. The training device 1400 may vary significantly due to different configurations or performance. It may include one or more central processing units (CPUs) 1414 (e.g., one or more processors) and memory 1432, and one or more storage media 1430 (e.g., one or more mass storage devices) storing application programs 1442 or data 1444. The memory 1432 and storage medium 1430 may be temporary storage or permanent storage. The program stored in the storage medium 1430 may include one or more modules (not shown), each module may include a series of instruction operations in the training device. Furthermore, the CPU 1414 may be configured to communicate with the storage medium 1430 to execute the series of instruction operations in the storage medium 1430 on the training device 1400.
[0244] The training device 1400 may also include one or more power supplies 1426, one or more wired or wireless network interfaces 1450, one or more input and output interfaces 1458; or, one or more operating systems 1441, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.
[0245] Specifically, the training device can execute the model training method in the embodiment corresponding to Figure 10.
[0246] An embodiment of the present application also relates to a computer storage medium, which stores a program for signal processing. When the computer storage medium is run on a computer, it enables the computer to execute the steps executed by the aforementioned execution device, or enables the computer to execute the steps executed by the aforementioned training device.
[0247] An embodiment of the present application also relates to a computer program product, which stores instructions that, when executed by a computer, enable the computer to execute the steps executed by the aforementioned execution device, or enable the computer to execute the steps executed by the aforementioned training device.
[0248] The execution device, training device or terminal device provided in the embodiments of the present application can specifically be a chip, and the chip includes: a processing unit and a communication unit, the processing unit can be, for example, a processor, and the communication unit can be, for example, an input / output interface, a pin or a circuit, etc. The processing unit can execute the computer execution instructions stored in the storage unit, so that the chip in the execution device executes the data processing method described in the above embodiment, or so that the chip in the training device executes the data processing method described in the above embodiment. Optionally, the storage unit is a storage unit in the chip, such as a register, a cache, etc. The storage unit can also be a storage unit located outside the chip in the wireless access device, such as a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.
[0249] Specifically, see Figure 15 , which is a schematic diagram of the structure of a chip provided in an embodiment of the present application. The chip may be a neural network processor (NPU) 1500. NPU 1500 is mounted on a host CPU (host CPU) as a coprocessor, with tasks assigned by the host CPU. The core of the NPU is arithmetic circuit 1503, which is controlled by controller 1504 to extract matrix data from memory and perform multiplication operations.
[0250] In some implementations, arithmetic circuit 1503 includes multiple processing units (PEs). In some implementations, arithmetic circuit 1503 is a two-dimensional systolic array. Arithmetic circuit 1503 can also be a one-dimensional systolic array or other electronic circuitry capable of performing mathematical operations such as multiplication and addition. In some implementations, arithmetic circuit 1503 is a general-purpose matrix processor.
[0251] For example, assume there are input matrix A, weight matrix B, and output matrix C. The arithmetic circuit retrieves the corresponding data of matrix B from weight memory 1502 and caches it on each PE in the arithmetic circuit. The arithmetic circuit retrieves the data of matrix A from input memory 1501 and performs a matrix operation on matrix B. The partial or final matrix result is stored in accumulator 1508.
[0252] Unified memory 1506 is used to store input and output data. Weight data is directly transferred to weight memory 1502 through the Direct Memory Access Controller (DMAC) 1505. Input data is also transferred to unified memory 1506 through the DMAC.
[0253] BIU stands for Bus Interface Unit, i.e., bus interface unit 1513 , which is used for interaction between the AXI bus, DMAC, and instruction fetch buffer (IFB) 1509 .
[0254] The bus interface unit 1513 (BIU) is used for the instruction fetch memory 1509 to obtain instructions from the external memory, and is also used for the storage unit access controller 1505 to obtain the original data of the input matrix A or the weight matrix B from the external memory.
[0255] DMAC is mainly used to transfer input data in the external memory DDR to the unified memory 1506 or transfer weight data to the weight memory 1502 or transfer input data to the input memory 1501.
[0256] The vector calculation unit 1507 includes multiple operation processing units. When necessary, it further processes the output of the operation circuit 1503, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, etc. It is mainly used for non-convolutional / fully connected layer network calculations in neural networks, such as batch normalization, pixel-level summation, and upsampling of the predicted label plane.
[0257] In some implementations, the vector calculation unit 1507 can store the processed output vector to the unified memory 1506. For example, the vector calculation unit 1507 can apply a linear function or a nonlinear function to the output of the operation circuit 1503, such as linear interpolation of the predicted label plane extracted by the convolution layer, or another example is a vector of accumulated values to generate an activation value. In some implementations, the vector calculation unit 1507 generates a normalized value, a pixel-level summed value, or both. In some implementations, the processed output vector can be used as an activation input to the operation circuit 1503, for example, for use in subsequent layers in a neural network.
[0258] An instruction fetch buffer 1509 connected to the controller 1504 is used to store instructions used by the controller 1504;
[0259] Unified memory 1506, input memory 1501, weight memory 1502, and instruction fetch memory 1509 are all on-chip memories. External memories are private to the NPU hardware architecture.
[0260] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an ASIC, or one or more integrated circuits for controlling the execution of the above program.
[0261] It should also be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separate, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided in this application, the connection relationship between the modules indicates that there is a communication connection between them, which can be specifically implemented as one or more communication buses or signal lines.
[0262] Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course can also be implemented by dedicated hardware including application-specific integrated circuits, dedicated CPUs, dedicated memories, dedicated components, etc. In general, all functions performed by computer programs can be easily implemented with corresponding hardware, and the specific hardware structures used to implement the same function can also be diverse, such as analog circuits, digital circuits, or dedicated circuits. However, for the present application, software program implementation is a better implementation method in most cases. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer's floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk or optical disk, etc., and includes a number of instructions to enable a computer device (which can be a personal computer, training equipment, or network equipment, etc.) to execute the methods described in each embodiment of the present application.
[0263] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.
[0264] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, a computer, a training device or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website, a computer, a training device or a data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium can be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
Claims
1. An image processing method, characterized in that: The method is implemented by a target model, and the method comprises: Obtain N image blocks of the target image; Evaluating the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks are used to indicate the importance of contents presented by the N image blocks; Based on the evaluation values of the N image blocks, determining M image blocks from the N image blocks, N>M≥2; Fusing the M image blocks to obtain a fusion result of the M image blocks; Based on the fusion results of the M image blocks, a processing result of the target image is obtained.
2. The method according to claim 1, characterized in that The step of evaluating the N image blocks to obtain evaluation values of the N image blocks includes: Performing a first full connection on the N image blocks to obtain first features of the N image blocks; Pooling the first features of the N image blocks to obtain second features of the N image blocks; The first features of the N image blocks and the second features of the N image blocks are multiplied to obtain third features of the N image blocks, and the third features of the N image blocks are used as evaluation values of the N image blocks.
3. The method according to claim 1 or 2, characterized in that: The N image blocks constitute an image block array with X rows and Y columns, and determining M image blocks from the N image blocks based on the evaluation values comprises: In the i-th row of image blocks, select the P image blocks with the largest evaluation values, i = 1, ..., X, M = XP, P ≥ 1, or, In the j-th column of image blocks, K image blocks with the largest evaluation values are selected, j=1, ..., Y, M=YK, K≥1.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Performing a weighted summation of the evaluation values of the N image blocks and the first features of the N image blocks to obtain fourth features of the N image blocks; multiplying the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain fifth features of the M image blocks; The fusing the M image blocks to obtain the fusion result of the M image blocks includes: splicing the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; Fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
5. The method according to any one of claims 1 to 4, characterized in that: The step of obtaining the processing result of the target image based on the fusion result of the M image blocks includes: Performing a second full connection on the N image blocks to obtain eighth features of the N image blocks; Performing weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; Performing weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain a ninth feature of the NM image blocks; The ninth features of the N image blocks are processed to obtain a processing result of the target image.
6. The method according to claim 5, characterized in that The processing includes at least one of: normalization, aggregation, or addition.
7. The method according to any one of claims 1 to 6, characterized in that: Before evaluating the N image blocks to obtain evaluation values of the N image blocks, the method further includes: The N image blocks are normalized to obtain N normalized image blocks.
8. A model training method, characterized in that: The method comprises: Inputting a target image into a model to be trained to obtain a processing result of the target image, wherein the model to be trained is used to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, wherein the evaluation values of the N image blocks are used to indicate the importance of the contents presented by the N image blocks; based on the evaluation values of the N image blocks, determine M image blocks from the N image blocks, where N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; and based on the fusion result of the M image blocks, obtain a processing result of the target image; Obtaining a target loss based on the processing result and a real processing result of the target image; Based on the target loss, the parameters of the model to be trained are updated until the model training conditions are met to obtain the target model.
9. The method according to claim 8, characterized in that The model to be trained is used for: Performing a first full connection on the N image blocks to obtain first features of the N image blocks; Pooling the first features of the N image blocks to obtain second features of the N image blocks; The first features of the N image blocks and the second features of the N image blocks are multiplied to obtain third features of the N image blocks, and the third features of the N image blocks are used as evaluation values of the N image blocks.
10. The method according to claim 8 or 9, characterized in that: The N image blocks constitute an image block array with X rows and Y columns, and the model to be trained is used for: In the i-th row of image blocks, select the P image blocks with the largest evaluation values, i = 1, ..., X, M = XP, P ≥ 1, or, In the j-th column of image blocks, K image blocks with the largest evaluation values are selected, j=1, ..., Y, M=YK, K≥1.
11. The method according to any one of claims 8 to 10, characterized in that: The model to be trained is also used for: Performing a weighted summation of the evaluation values of the N image blocks and the first features of the N image blocks to obtain fourth features of the N image blocks; multiplying the fourth features of the N image blocks and the evaluation values of the M image blocks to obtain fifth features of the M image blocks; The model to be trained is used for: splicing the M image blocks with the fifth features of the M image blocks to obtain the sixth features of the M image blocks; Fully connect the sixth features of the M image blocks to obtain the seventh features of the M image blocks, and the seventh features of the M image blocks are used as the fusion results of the M image blocks.
12. The method according to any one of claims 8 to 11, characterized in that: The model to be trained is used for: Performing a second full connection on the N image blocks to obtain eighth features of the N image blocks; Performing weighted summation on the fusion results of the M image blocks and the eighth features of the M image blocks to obtain the ninth features of the M image blocks; Performing weighted summation on NM image blocks other than the M image blocks in the N image blocks and the eighth features of the NM image blocks to obtain a ninth feature of the NM image blocks; The ninth features of the N image blocks are processed to obtain a processing result of the target image.
13. The method according to claim 12, characterized in that The processing includes at least one of: normalization, aggregation, or addition.
14. The method according to any one of claims 8 to 13, characterized in that: The model to be trained is also used for: The N image blocks are normalized to obtain N normalized image blocks.
15. An image processing device, characterized in that: The device comprises a target model, and the device comprises: A first acquisition module, used for acquiring N image blocks of a target image; An evaluation module, used to evaluate the N image blocks to obtain evaluation values of the N image blocks, where the evaluation values of the N image blocks are used to indicate the importance of the contents presented by the N image blocks; A determination module, configured to determine M image blocks from the N image blocks based on the evaluation values of the N image blocks, where N>M≥2; A fusion module, used for fusing the M image blocks to obtain a fusion result of the M image blocks; The second acquisition module is used to acquire the processing result of the target image based on the fusion result of the M image blocks.
16. A model training device, characterized in that: The device comprises: An input module is used to input a target image into a model to be trained to obtain a processing result of the target image, wherein the model to be trained is used to: obtain N image blocks of the target image; evaluate the N image blocks to obtain evaluation values of the N image blocks, wherein the evaluation values of the N image blocks are used to indicate the importance of the contents presented by the N image blocks; based on the evaluation values of the N image blocks, determine M image blocks from the N image blocks, where N>M≥2; fuse the M image blocks to obtain a fusion result of the M image blocks; and based on the fusion result of the M image blocks, obtain a processing result of the target image; An acquisition module, used for acquiring a target loss based on the processing result and a real processing result of the target image; The updating module is used to update the parameters of the model to be trained based on the target loss until the model training conditions are met to obtain the target model.
17. An image processing device, characterized in that: The device includes a memory and a processor; the memory stores codes, and the processor is configured to execute the codes. When the codes are executed, the image processing device performs the method according to any one of claims 1 to 14.
18. A computer storage medium, characterized in that: The computer storage medium stores one or more instructions, which, when executed by one or more computers, enable the one or more computers to implement the method of any one of claims 1 to 14.
19. A computer program product, characterized in that The computer program product stores instructions, which, when executed by a computer, enable the computer to implement the method according to any one of claims 1 to 14.
Citation Information
Patent Citations
Non-reference image quality evaluation method based on convolutional self-coding network
CN109272499A
No-reference screen content image quality evaluation method based on multi-task deep learning
CN112348809A
Image classification method and device, computer equipment and storage medium
CN113989566A
Image fusion method, and training method and device of image fusion model
CN114119378A
Image processing method and device, model training method and device, equipment and medium
CN114693977A
