Image processing method, device and electronic equipment
By splitting the target weight size of the convolution kernel into support sizes, and using the dividing judgment rule and zero-complement method, the problem that electronic device hardware facilities cannot support convolution kernels of arbitrary sizes is solved, and the image processing of convolutional neural networks is improved Effect.
Patent Information
- Application Number
- CN202011070211.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-30
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2040-09-30
AI Technical Summary
The hardware facilities of existing electronic devices cannot support convolution kernels of any size, resulting in poor results in image processing and inability to achieve ideal image quality.
By splitting the target weight size into the support size corresponding to multiple channels, using the divisor judgment method and zero-complement method, convolutional operations are performed without changing the hardware design, and the image processing effect of the convolutional neural network is improved.
Without changing the hardware design, convolution kernels with arbitrary weight sizes are implemented to perform convolution operations, which improves the output image quality of the convolution neural network and solves the problem of poor image processing results caused by hardware design limitations.
Smart Images

Figure CN112215745B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic equipment, and in particular to an image processing method, device and electronic equipment. Background Art
[0002] As one of the important methods of machine learning, convolutional neural networks are widely used in image recognition, object tracking, speech processing and other fields. In particular, they have excellent performance in processing large images, which has attracted a large number of scholars to engage in research.
[0003] Currently, in practical applications, convolutional layers are a crucial component of neural networks, participating in over 90% of their computational operations. Convolutional kernels, as the core of these layers, play a crucial role in neural network models. Common neural network models use a wide range of convolutional kernel weight sizes and strides, ranging from the common 3×3 and 7×7 to 11×11 and 15×15, and even potentially even full-image-sized weight sizes. However, conventional hardware designs typically support only fixed weight size ranges, such as 1–15 or 1–255, with limited support for arbitrary weight sizes. Consequently, when the weight size of a neural network model's convolutional kernel exceeds the maximum supported by the hardware, image processing performance suffers, failing to achieve the desired image processing results. This limits hardware applications. Summary of the Invention
[0004] The embodiments of the present application provide an image processing method, device, and electronic device, which can implement convolution operations using convolution kernels of arbitrary weight sizes in the convolutional neural network model of the current device without changing the hardware design or with only minor changes in the hardware design, thereby improving the image effect output by the convolutional neural network.
[0005] In the first aspect, the present application provides an image processing method, which uses an electronic device to perform a convolution operation on an image. The image processing method includes: obtaining a first weight size, which is the target weight size of the convolution kernel in the convolutional neural network; splitting the first weight size into a second weight size corresponding to M*N channels, where M*N is an integer greater than 1, and the second weight size is the weight size of the convolution kernel that the current hardware facilities of the electronic device can support for the convolution operation; obtaining first image data corresponding to the corresponding number of channels and performing a convolution operation with the second weight size, and accumulating the obtained convolution results to obtain a convolution result obtained by using the first weight size to perform a convolution operation on the original image data, where the first image data is the image data in the original image data.
[0006] The embodiment of the present application splits the first weight size that the current hardware facilities of the electronic device cannot support for convolution operations into second weight sizes corresponding to M*N channels, obtains the first image data corresponding to each of the M*N channels, performs convolution operations with the corresponding second weight sizes and accumulates them to obtain a convolution result obtained by performing convolution operations on the original image data using the first weight size. This makes it possible to use convolution kernels of any weight size for convolution operations in the convolution neural network model of the current device without changing the hardware design or with only minor changes in the hardware design, thereby improving the image effect output by the convolution neural network and effectively solving the problem that the application of convolution neural networks is limited due to hardware design.
[0007] In the second aspect, the present application provides an image processing device, including: a first weight size acquisition unit, used to obtain a first weight size, the first weight size is the target weight size of the convolution kernel in the convolutional neural network; a weight size splitting unit, used to split the first weight size into a second weight size corresponding to M*N channels, where M*N is an integer greater than 1, and the second weight size is the weight size of the convolution kernel that the current hardware facilities of the electronic device can support for convolution operations; a convolution operation unit, used to obtain first image data corresponding to the corresponding number of channels and perform convolution operations with the second weight size, and accumulate the obtained convolution results to obtain the convolution result obtained by using the first weight size to perform convolution operations on the original image data, where the first image data is the image data in the original image data.
[0008] In a third aspect, the present application provides an electronic device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method described in the first aspect or any optional method of the first aspect is implemented.
[0009] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the method described in the first aspect or any optional method of the first aspect.
[0010] In a fifth aspect, an embodiment of the present application provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute the steps of the image processing method described in the first aspect above.
[0011] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the embodiments or descriptions of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0013] Figure 1 This is a flowchart of an image processing method provided by an embodiment of the present application;
[0014] Figure 2 The embodiment of the present application provides a schematic diagram of image data in which a convolution operation is performed on original image data using a weight size of 33×33 and a weight size of 11×11 corresponding to 9 channels;
[0015] Figure 3 is a flowchart of a method for performing a convolution operation using an updated second weight size provided in an embodiment of the present application;
[0016] Figure 4 is a schematic diagram of the positional relationship between a set of first image data and original image data provided in an embodiment of the present application;
[0017] Figure 5 Schematic diagram of coordinate relationship for performing convolution operation using the updated second weight size provided in an embodiment of the present application;
[0018] Figure 6 is a flowchart of a method for calculating a starting position of first image data provided by an embodiment of the present application;
[0019] Figure 7 This is a flow chart of a method for updating a first coordinate offset value and a second coordinate offset value provided in an embodiment of the present application.
[0020] Figure 8 is a structural diagram of an image processing device provided in an embodiment of the present application;
[0021] Figure 9 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0022] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0023] It should be understood that the term "and / or" used in this specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations. In addition, in the description of this specification and the appended claims, the terms "first," "second," "third," etc. are used only to distinguish descriptions and are not to be understood as indicating or implying relative importance.
[0024] It should also be understood that references to "one embodiment" or "some embodiments" in the present specification mean that one or more embodiments of the present application include a particular feature, structure, or characteristic described in conjunction with that embodiment. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0025] The electronic devices involved in the embodiments of this application may be mobile phones, tablet computers, desktop computers, laptop computers, notebook computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, personal digital assistants (PDAs), wearable electronic devices, virtual reality devices, etc. This application does not limit the specific types of electronic devices.
[0026] Currently, common convolutional neural networks (CNNs) have convolution kernels with various weight sizes, such as 3×3, 7×7, and 15×15, and even sizes up to the full image size. However, the larger the convolution kernel weight size, the greater the computational complexity of the CNN, and the correspondingly higher hardware requirements for the device. However, the hardware designs for different devices are already largely finalized, and any subsequent design changes would be very costly. The convolution kernel weight sizes supported by different device hardware generally fall within a fixed range, such as 1–15 or 1–255. When it is necessary to support convolution kernels of arbitrary weight sizes for convolution operations under the current hardware facilities of the device, it may result in the inability to obtain correct convolution results on the current device, resulting in poor image quality output by the neural network model and failure to achieve the image quality it should actually achieve. In order to solve this problem, the present application provides an image processing method based on the above-mentioned electronic device, so that convolution kernels of arbitrary weight sizes can be used for convolution operations in the convolution neural network model of the current device without changing the hardware design, effectively solving the problem of poor image quality output by the convolution neural network due to the limitations of the hardware design of the electronic device.
[0027] The following is an illustrative example of the image processing method provided by this application. Figure 1 , Figure 1 This is an image processing method provided by an embodiment of the present application, which specifically includes:
[0028] Step S101: The electronic device obtains a first weight size.
[0029] In the embodiment of the present application, the first weight size is the target weight size of the convolution kernel in the convolutional neural network, that is, the actual size of the convolution kernel in the convolutional neural network. For example, assuming the image input data is 1×64×64 and the convolution kernel size is 1×1×33×33, that is, the number of input channels is 1 and the number of output channels is 1, the weight size is 33×33.
[0030] Step S102: The electronic device splits the first weight size into second weight sizes corresponding to M*N channels.
[0031] In the embodiments of the present application, M and N are both integers greater than or equal to 1, where M is the number of channels split along the first direction, and N is the number of channels split along the second direction. M and N can be the same integer, for example, M and N can both be the same integer greater than 1. M and N can also be different integers, for example, when M is 1, N is an integer greater than 1; when M is an integer greater than 1, N is 1; or M and N can both be two different integers greater than 1.
[0032] It should be noted that when the first direction is the x-direction in the image coordinate system, the second direction is the y-direction in the image coordinate system. When the first direction is the y-direction in the image coordinate system, the second direction is the x-direction in the image coordinate system. The following description assumes that the first direction is the x-direction in the image coordinate system and the second direction is the y-direction in the image coordinate system.
[0033] In an embodiment of the present application, the second weight size is the weight size of the convolution kernel that can be supported by the current hardware facilities of the electronic device for performing convolution operations.
[0034] Specifically, the second weight size can be the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations, and the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations is a weight size set during the hardware design process, which can be determined specifically according to the hardware resource situation. It can also be any weight size that is smaller than the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations. For the selection of the second weight size, a fixed second weight size can be selected according to a pre-set rule, or it can be a weight size calculated according to a preset calculation rule. No specific limitation is made here.
[0035] It should be noted that due to problems with the hardware design of the electronic device, the current hardware of the electronic device cannot support the convolution kernel of the first weight size for convolution operations, that is, the first weight size is greater than the maximum weight size of the convolution kernel that the current hardware facilities of the electronic device can support for convolution operations. If the electronic device uses the convolution kernel of the first weight size for convolution operations, it may lead to erroneous convolution results, so that the image quality finally output by the convolution neural network cannot achieve the ideal effect, the image quality is poor, or the convolution neural network cannot be used for convolution operations. In order to avoid the occurrence of this problem, the embodiment of the present application splits the first weight size into a second weight size corresponding to M*N channels, so that the current hardware facilities of the electronic device can support the convolution neural network to complete the convolution kernel of the first weight size for convolution operations and obtain accurate convolution results.
[0036] It should also be noted that the M*N channels obtained by splitting here do not increase the number of channels of the input data, but increase the number of convolution channels, or it can be said that the number of convolutions is increased, and the channels of the input data remain unchanged. For example, the original number of channels of the input data is 1, and after the first weight size is split, the number of channels of the input data is still one; the original number of channels of the input data is 2, and after the first weight size is split, the number of channels of the input data is still 2.
[0037] It should also be noted that each channel corresponds to a second weight size, and the convolution feature parameters of each second weight size are not the same. When the convolution feature parameters of the second weight size corresponding to M*N channels are added together, the convolution feature parameters of the convolution kernel corresponding to the first weight size can be obtained.
[0038] like Figure 2 As shown in the figure, assuming the image input data is 1×64×64 and the convolution kernel size is 1×1×33×33, that is, the number of input channels is 1, the number of output channels is 1, and the weight size is 33×33. Furthermore, assuming that the maximum weight size supported by the current electronic device hardware is 11×11, then the first weight size 33×33 can be split into a second weight size 11×11 corresponding to 3*3 channels. In other words, the first weight size 1×1×33×33 is split into 1×9×11×11. After the split, the number of input channels becomes 9, the number of output channels becomes 1, and the weight size is 11×11.
[0039] If we use a 33×33 weight size to calculate the convolution, the calculation formula for a point in the image is as follows:
[0040]
[0041] When split into 9 channels corresponding to the 11×11 weight size to calculate the convolution, the calculation formula for a point in the image is as follows:
[0042]
[0043] Among them, result is the convolution result, c is the number of input channels, num is the number of channels of the split convolution kernel, k_h is the height of the convolution kernel, k_w is the width of the convolution kernel, i≤k_h, j≤k_w, w cij is the weight of the convolutional neural network, d cij For input data.
[0044] For example, in some specific embodiments, the first weight size is split into second weight sizes corresponding to M*N channels, with each channel corresponding to a second weight size. Specifically, the first weight size can be split into second weight sizes corresponding to M*N channels using an integer divisibility rule, i.e., the result obtained by multiplying the second weight size by M*N is the same as the first weight size. For example, the first weight size can be split into second weight sizes corresponding to M*N channels along the x-direction and / or the y-direction using an integer divisibility rule.
[0045] It can be understood that the use of the integer divisibility rule can quickly determine the number of channels for splitting the first weight size into the second weight size, thereby improving the efficiency and accuracy of channel splitting, thereby correspondingly improving the processing efficiency of the convolutional neural network.
[0046] It can also be understood that further utilizing the integer divisibility rule to split the first weight size into second weight sizes corresponding to M*N channels along the x direction and / or y direction can further improve the channel splitting efficiency, reduce the probability of incomplete reading of image data that may be caused by the splitting, maintain the integrity of the image data blocks corresponding to each channel, and improve the accuracy of the convolutional neural network in processing image data.
[0047] The following combination Figure 2 , a detailed description is given of splitting the first weight size into second weight sizes corresponding to M*N channels along the x direction and / or the y direction using the integer divisibility rule.
[0048] In an application scenario, the target weight size of the convolution kernel in a convolutional neural network is 33×33, while the current hardware facilities of electronic devices can support a maximum convolution kernel weight size of 11×11 for convolution operations. The first number between 33×33 and 11×11 is regarded as the weight size in the x direction, and the second number between 33×33 and 11×11 is regarded as the weight size in the y direction. Using the integer divisibility rule, the number of channels split along the x direction is 33 / 11, that is, M=3; the number of channels split along the y direction is 33 / 11, that is, N=3. In this way, the present application realizes the use of the integer divisibility rule to split the first weight size 33×33 into a second weight size 11×11 corresponding to M*N channels along the x and y directions.
[0049] In another application scenario, the target weight size of the convolution kernel in the convolutional neural network is 22×33, while the current hardware facilities of electronic devices can support a maximum convolution kernel weight size of 11×11 for convolution operations. Using the divisibility rule, the number of channels split along the x-direction is 22 / 11, that is, M=2; the number of channels split along the y-direction is 33 / 11, that is, N=3. In this way, the present application realizes the use of the divisibility rule to split the first weight size 22×33 into a second weight size 11×11 corresponding to 2*3 channels along the x-direction and y-direction.
[0050] In another application scenario, the target weight size of the convolution kernel in the convolutional neural network is 22×33, while the current hardware facilities of electronic devices can support a maximum convolution kernel weight size of 11×33 for convolution operations. Using the divisibility rule, the number of channels split along the x direction is 22 / 11, that is, M=2; the number of channels along the y direction remains unchanged, that is, N=1. In this way, the present application realizes the use of the divisibility rule to split the first weight size 22×33 along the x direction into a second weight size 11×33 corresponding to 2*1 channels. Similarly, only the number of channels along the y direction can be split.
[0051] In other specific embodiments, in the process of splitting the first weight size into a second weight size corresponding to M*N channels using the integer divisibility rule, if the first weight size cannot be divided by the second weight size, the first weight size is adjusted by the zero-padding method to obtain an updated third weight size, and then the third weight size is split into a second weight size corresponding to M*N channels, wherein the third weight size is larger than the first weight size.
[0052] For example, the first weight size is 37×37, which cannot be divided by the second weight size 11×11. At this time, 7 zeros can be added to the width and height of the first weight size respectively, and the updated first weight size is 44×44, which is divisible by the second weight size 11×11.
[0053] In other embodiments of the present application, the weight size of the convolution kernel that the hardware facilities of the electronic device can support for the convolution operation can be a specific numerical range. In this case, the divisibility rule is used to obtain a second weight size that can divide the first weight size from this specific numerical range. Since there are many values contained in the numerical range, there may be multiple second weight sizes that meet the preset conditions, that is, second weight sizes that can divide the first weight size. At this time, according to the preset rules, any second weight size can be selected from multiple second weight sizes that meet the preset conditions as the final second weight size, and then the number of split channels can be calculated based on the final second weight size. For example, the largest second weight size is selected as the final second weight size. This can effectively reduce the repeated calculation of redundant data and improve the efficiency of the convolution operation.
[0054] It can be understood that when the hardware facilities of the electronic device can support the weight size of the convolution kernel for convolution operation, which can be in a specific numerical range, and there is no second weight size that can divide the first weight size, the zero-padding method is also used to adjust the first weight size so that the updated first weight size can be divided by the second weight size.
[0055] It should be noted that when the present application uses the integer divisibility rule to split the first weight size into a second weight size corresponding to M*N channels along the x direction and / or along the y direction, the channels split along the x direction and the channels split along the y direction are independent of each other and do not interfere with each other.
[0056] It should also be noted that the weight size in the embodiment of the present application includes a first size and a second size, wherein the first size and the second size correspond to the width and height of the convolution kernel. For example, when the first size is the width of the convolution kernel, the second size corresponds to the height of the convolution kernel. When the first size is the height of the convolution kernel, the second size corresponds to the width of the convolution kernel. The embodiment of the present application is described below with the first size as the width of the convolution kernel and the second size corresponding to the height of the convolution kernel.
[0057] In some specific embodiments, when the first size of the first weight size cannot be divided evenly by the first size of the second weight size, the first size of the first weight size is adjusted by a zero-padding method so that the value corresponding to the first size of the updated third weight size can be divided evenly by a first value corresponding to the first size that is smaller than the fourth weight size, and the value corresponding to the first size of the second weight size is adjusted to the first value.
[0058] When the second size of the first weight size cannot be divided evenly by the second size of the second weight size, the second size of the first weight size is adjusted by the zero-padding method so that the value corresponding to the second size of the updated third weight size can be divided evenly by the second value corresponding to the second size that is smaller than the fourth weight size, and the value corresponding to the second size of the second weight size is adjusted to the second value.
[0059] When the first size of the first weight size cannot be divided by the first size of the second weight size and the second size of the first weight size cannot be divided by the second size of the second weight size, the first size and the second size of the first weight size are adjusted simultaneously by the zero-padding method, so that the first size of the updated third weight size can be divided by a first value smaller than the first size of the fourth weight size, and the second size of the updated third weight size can be divided by a second value smaller than the second size of the fourth weight size, and the first of the first size in the second weight size is adjusted to the first value, and the y of the second size in the second weight size is adjusted to the second value.
[0060] It should be noted that the fourth weight size is the weight size of the maximum convolution kernel that can be supported by the current hardware facilities of the electronic device for convolution operations.
[0061] The following is an explanation with a specific example.
[0062] For example, the first weight size is 7×11, and the second weight size, such as the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations, is 3×5. At this time, the first weight size cannot be divided by the second weight size, and the first size and the second size of the first weight size cannot be divided by the first size and the second size of the second weight size. When the first size of the first weight size is padded with zeros and adjusted to 8, it can be divided by the first value 2 corresponding to the first size smaller than the second weight size (2<3); when the second size of the first weight size is padded with zeros and adjusted to 12, it can be divided by the second value 4 corresponding to the second size smaller than the second weight size (4<5). At this time, the adjusted first weight size is 8×12, and the second weight size is 2*3, that is, the first weight size 7×11 is split into the second weight size 2×3 corresponding to the 4*4 number of channels.
[0063] Step S103: The electronic device obtains the first image data corresponding to the corresponding number of channels and performs a convolution operation with the second weight size, and accumulates the convolution results to obtain a convolution result obtained by performing a convolution operation on the original image data using the first weight size, where the first image data is the image data in the original image data.
[0064] In an embodiment of the present application, after splitting to obtain the second weight size corresponding to M*N channels, it is not necessary to traverse the entire image data to perform convolution operations for the second weight size of each channel. In order for the electronic device to use the M*N convolution kernels corresponding to the second weight size corresponding to the split M*N channels to perform convolution operations on the original image data and obtain correct convolution results, the hardware facilities need to process the starting position of each channel data so that the convolution kernel corresponding to the second weight size of each channel can extract the appropriate image data, i.e., the first image data, from the original image data to perform convolution operations with the second weight size, so that the convolution neural network can output higher quality images.
[0065] See also Figure 3 , Figure 3 This is a specific implementation process of the method for performing a convolution operation using the updated second weight size provided in an embodiment of the present application, which is detailed as follows:
[0066] Step S201: The electronic device obtains the original image data input into the convolutional neural network.
[0067] In the embodiment of the present application, the original image data is the data input by the input channel of the convolution kernel. In the embodiment of the present application, the original image data does not need to be preprocessed or resized. The present application does not impose any specific restrictions on the number of input channels.
[0068] Step S202: The electronic device extracts, from the original image data, first image data having a second weight size corresponding to each channel and performing a convolution operation thereon.
[0069] like Figure 2 As shown, the first weight size of the convolution kernel is 33×33. After splitting the first weight size 33×33 into 9 channels corresponding to the second weight size 11×11, the first weight size 33×33 is split into 9 channels with a second weight size of 11×11. In this embodiment of the application, the 9 channels obtained by splitting are named A0, A1, ..., A8 in order from left to right and from bottom to top, and the second weight size corresponding to each channel is 11×11.
[0070] Assuming the stride of the current convolution kernel is 1, when performing a convolution operation using a convolution kernel with a first weight size of 33×33, the entire original image needs to be scanned. However, when performing a convolution operation using a second weight size of 11×11 corresponding to different channels, the entire original image does not need to be scanned, and only a portion of the original image data can be scanned.
[0071] For example, in order to obtain suitable image data and perform convolution operation with the second weight size corresponding to A0, A1, ..., A8 of the M*N channels obtained after splitting, in an embodiment of the present application, it is necessary to extract the first image data for convolution operation with the second weight size corresponding to each channel from the original image data.
[0072] In some specific embodiments, the present application calculates the data storage address of the first image data, and then, based on the calculated data storage address, extracts the corresponding first image data from the original image. Calculating the data storage address of the first image data requires knowing the starting position of the first image data corresponding to each channel, and then using a preset data storage calculation formula to calculate the data storage address of the first image data based on the starting position of the first image data corresponding to each channel.
[0073] The above preset data storage calculation formula is as follows:
[0074] address=y*img_width+x
[0075] Wherein, address is the data storage address of the first image data, (x, y) is the coordinate corresponding to any pixel point in the image data, and img_width is the image width of the original image data.
[0076] It is understandable that after the starting position of the first image data is calculated, the data storage address of the first image data can be calculated according to the above preset data storage calculation formula.
[0077] like Figure 4 The figure shows a schematic diagram of the positional relationship between a set of first image data and original image data provided in an embodiment of the present application. The white and gray boxes represent original image data of size 1×64×64, and the gray box represents the first image data. The image data represented by the gray boxes in Figures (a) to (i) correspond to the positions of the first image data corresponding to channels A0, A1, ..., A8 in the original image, and the image size of the first image data corresponding to each channel is 42×42.
[0078] The following combination Figure 5 , the calculation process of the first image data corresponding to the A0 channel is specifically described. Figure 5 As shown, the size of the original image data is 1×64×64, and the image coordinate system is established with the lower left corner of the original image data as the origin of the coordinate system. When the second weight size corresponding to the A0 channel is convolved with a step size of 1, the coordinates of the last pixel point finally calculated are (41, 41), that is, the image data convolved with the second weight size corresponding to the A0 channel is the B0 part in the original image. Similarly, the first image data convolved with the second weight size corresponding to each channel is obtained.
[0079] like Figure 5 As shown, when calculating the starting position of the first image data corresponding to each channel, the following can be calculated based on the current number of calculation channels: Figure 5 The starting position (x, y) of the first image data corresponding to each channel is shown, and then the data storage address corresponding to the first image data is calculated according to the starting position by using a preset data storage address calculation formula.
[0080] from Figure 4 and Figure 5 It can be seen that for each channel, the size of the first image data corresponding to each channel becomes 42×42. For example, for the first channel A0, it is only necessary to scan x: 0~41, y: 0~41; for the second channel A1, it is only necessary to scan x: 11~52, y: 0~41. In other words, the input data can be regarded as a 42×42 size input data.
[0081] It can be understood that the embodiment of the present application does not change the input image data, but instead calculates the data storage address of the first image data corresponding to each channel, and then extracts the corresponding data from the original image data according to the calculated data storage address to perform a convolution operation.
[0082] In order to facilitate the calculation of the starting position (x, y) of the first image data corresponding to each channel, the first image data corresponding to each channel is regarded as a whole, and the original image data can be regarded as image data composed of M*N image data blocks. For example, in the x direction, the number of image data blocks is M, and in the y direction, the number of image data blocks is N.
[0083] It can be understood that the image data blocks mentioned here correspond to the first image data corresponding to each channel.
[0084] In an embodiment of the present application, two registers are designed: a first coordinate offset value register and a second coordinate offset value register. The first coordinate offset value register is used to record and update the coordinate value of the image data block in the first direction, and the coordinate value is recorded as the first coordinate offset value; the second coordinate offset value register is used to record and update the coordinate value of the image data block in the second direction, and the coordinate value is recorded as the second coordinate offset value. After obtaining the first coordinate offset value and the second coordinate offset value corresponding to each image block, the starting position (x, y) of each data block, i.e., the first image data, can be obtained based on the product of the first coordinate offset value and the second coordinate offset value and the second weight size of the channel corresponding to the image data block.
[0085] In the embodiment of the present application, the number S of input channels of the original image data can be any value, such as 1 or 2, and is not specifically limited here.
[0086] It should be noted that when the original number of channels, that is, the number of input channels of the original image data, is S, after the first weight size is split into M*N channels corresponding to the second weight size, the number of corresponding image data blocks is the product of S and M*N. For example, when the original number of channels S is 2 and the second weight size is 9 channels, the corresponding first image data has 18 channels, that is, the number of corresponding image data blocks is 18.
[0087] See also Figure 6 , Figure 6 : is a flow chart of a method for calculating a starting position of first image data provided by an embodiment of the present application, the method comprising:
[0088] Step S301: The electronic device obtains the original channel number.
[0089] Step S302: The electronic device calculates and updates the first coordinate offset value and the second coordinate offset value according to the original channel number.
[0090] In an embodiment of the present application, in order to accurately record the starting position (x, y) of the first image data corresponding to different input channels, the electronic device in the embodiment of the present application is provided with an original channel number counter, the initial value of the original channel number counter is 0, and when calculating the starting position of the first image data corresponding to each channel, if the result after subtracting the third value from the original channel number is the same as the initial value of the original channel number counter, the first coordinate offset value register and the second coordinate offset value register are triggered to update the first coordinate offset value and the second coordinate offset value, otherwise, the first coordinate offset value and the second coordinate offset value remain unchanged. At the same time, the result after adding the third value to the value recorded by the original channel number counter is used to continue to determine whether the value recorded by the updated original channel number counter is equal to the result after subtracting the third value from the original channel number. If equal, the first coordinate offset value register and the second coordinate offset value register are triggered to update the first coordinate offset value and the second coordinate offset value, otherwise, the value recorded by the original channel counter is set to zero, and the above steps are continued until the first coordinate offset value and the second coordinate offset value corresponding to all image data blocks are obtained.
[0091] Exemplarily, if the difference between the original channel number and the third value is equal to the value recorded by the original channel number counter, the first coordinate offset value register and the second coordinate offset value register are triggered to update the first coordinate offset value and the second coordinate offset value. If the difference between the original channel number and the third value is not equal to the value recorded by the original channel number counter, the current coordinate values of the first coordinate offset value register and the second coordinate offset value register are maintained unchanged, and the value recorded by the original channel counter is reset to zero.
[0092] It should be noted that the third value is generally 1. In practical applications, the third value can also be any value and is not specifically limited here.
[0093] In an embodiment of the present application, in the process of updating the coordinate values of the first coordinate offset value register and the second coordinate offset value register, if the updated first coordinate offset value is equal to the number of channels split along the first direction, the second coordinate offset value is updated and the updated first coordinate offset value is set to zero; otherwise, the first coordinate offset value continues to be updated.
[0094] like Figure 7As shown, when the first weight size is split into the second weight size corresponding to 9 channels, assuming that the original number of channels is 1, the first value is 1, the initial value of the original channel number counter is zero, and the initial values of the first coordinate offset value and the second coordinate offset value are 0. At this time, the result of subtracting 1 from the original channel number is equal to the value of the original channel number counter, and the electronic device will trigger the first coordinate offset value register and the second coordinate offset value register to update the first coordinate offset value and / or the second coordinate offset value. For example, when the updated first coordinate offset value is not equal to the split channel in the first direction, the current value of the first coordinate offset value is added by 1, changing from 0 to 1, and the second coordinate offset value remains unchanged; when the updated first coordinate offset value is equal to the split channel number in the first direction, the current value of the second coordinate offset value is added by 1, changing from 0 to 1, and the current value of the first coordinate offset value is set to zero. After obtaining the first coordinate offset value and the second coordinate offset value corresponding to the 9 image data blocks, the first coordinate offset value and the second coordinate offset value shown in Table 1 will be obtained.
[0095] Table 1
[0096]
[0097] Assuming that the original number of channels is 2, the first value is 1, the initial value of the original channel number counter is zero, and the initial values of the first coordinate offset value and the second coordinate offset value are 0, after obtaining the first coordinate offset value and the second coordinate offset value corresponding to 18 image data blocks, the first coordinate offset value and the second coordinate offset value shown in Table 2 will be obtained.
[0098] Table 2
[0099]
[0100] Step S303: The electronic device calculates the starting position of the first image data corresponding to each channel according to the first coordinate offset value and the second coordinate offset value.
[0101] In the embodiment of the present application, after the first coordinate offset value and the second coordinate offset value are calculated, the corresponding x starting coordinate and y starting coordinate can be obtained, that is, the starting position of the first image data is the x starting coordinate and the y starting coordinate.
[0102] Specifically, the calculated first coordinate offset value and the second coordinate offset value are multiplied by their respective weight sizes to obtain the x starting coordinate and y starting coordinate corresponding to the current calculation channel. For example, as shown in Table 1 or Table 2, the first size and the second size of the weight size are both 11. The obtained first coordinate offset value and the second coordinate offset value are multiplied by the weight size (11, 11) corresponding to each channel to obtain the starting position (x, y) of the first image data corresponding to each channel as shown in Table 1 or Table 2, that is, the x starting coordinate and the y starting coordinate.
[0103] Step S203: The electronic device performs a convolution operation on the second weight size of each channel and the first image data corresponding thereto to obtain M*N convolution results.
[0104] In an embodiment of the present application, a current calculation channel number counter is also provided. When the electronic device uses a convolutional neural network to perform a convolution operation, the current calculation channel number counter is increased by 1. If the current calculation channel number is equal to the product of the original channel number S and the second weight size corresponding to the split M*N channels minus 1, the current calculation channel number counter is cleared. At the same time, the convolutional neural network ends the convolution operation and accumulates the obtained S*M*N convolution results.
[0105] Step S204: The electronic device accumulates the M*N convolution results to obtain a convolution result obtained by performing a convolution operation on the original image data using the first weight size.
[0106] like Figure 4 and Figure 5 As shown, after splitting to obtain the second weight size corresponding to M*N channels and obtaining the first image data corresponding to the second weight size of each channel, the corresponding second weight size is convolved with the first image data. For example, the second weight size of the A0 channel is convolved with the corresponding first image data B0 to obtain the first convolution result. After the second weight sizes corresponding to all channels are calculated, M*N convolution results are obtained. The M*N convolution results are accumulated to obtain the convolution result obtained by actually using the convolution kernel of the first weight size to perform the convolution operation on the original image data.
[0107] It should be noted that the embodiment of the present application extracts the first image data of the second weight size corresponding to each channel from the original image for convolution operation, without changing the input data of the convolutional neural network. That is, the input data of the convolutional neural network is still the original image data, and the original image does not need to be preprocessed, thereby improving the efficiency and accuracy of image processing.
[0108] The embodiment of the present application splits the first weight size that the current hardware facilities of the electronic device cannot support for convolution operations into second weight sizes corresponding to M*N channels, obtains the first image data corresponding to each of the M*N channels, performs convolution operations with the corresponding second weight sizes and accumulates them to obtain a convolution result obtained by performing convolution operations on the original image data using the first weight size. This makes it possible to use convolution kernels of any weight size for convolution operations in the convolution neural network model of the current device without changing the hardware design or with only minor changes in the hardware design, thereby improving the image effect output by the convolution neural network and effectively solving the problem that the application of convolution neural networks is limited due to hardware design.
[0109] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0110] Based on the image processing method provided by the above embodiment, the embodiment of the present invention further provides an embodiment of a device for implementing the above method embodiment.
[0111] See Figure 8 , Figure 8 Schematic diagram of the image processing device provided by the embodiment of the present application. The units included are used to perform Figure 1 Each step in the corresponding embodiment. Please refer to Figure 1 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 8 , the image processing device comprises:
[0112] A first weight size acquisition unit 81 is used to acquire a first weight size, where the first weight size is a target weight size of a convolution kernel in a convolutional neural network;
[0113] a weight size splitting unit 82 for splitting the first weight size into a second weight size corresponding to M*N channels, where M*N is an integer greater than 1, and the second weight size is a weight size of a convolution kernel that can be supported by the current hardware facilities of the electronic device for performing a convolution operation;
[0114] The convolution operation unit 83 is used to obtain the first image data corresponding to the corresponding number of channels and perform a convolution operation with the second weight size, and accumulate the convolution results to obtain the convolution result obtained by convolving the original image data using the first weight size, where the first image data is the image data in the original image data.
[0115] Exemplarily, the weight size splitting unit 82 is specifically configured to:
[0116] The first weight size is split into second weight sizes corresponding to M*N channels by using an integer divisibility rule, where the first weight size is M*N times the second weight size.
[0117] Exemplarily, the weight size splitting unit 82 is specifically configured to:
[0118] Using the integer divisibility rule, the first weight size is split into second weight sizes corresponding to M*N channels along the first direction and / or the second direction, where M is the number of channels split along the first direction and N is the number of channels split along the second direction.
[0119] Exemplarily, the weight size splitting unit 82 is further configured to:
[0120] When the first weight size cannot be divided evenly by the second weight size, adjusting the first weight size by a zero-padding method to obtain an updated third weight size, where the third weight size is greater than the first weight size;
[0121] The third weight size is split into second weight sizes corresponding to M*N channels.
[0122] Exemplarily, the weight size splitting unit 82 is further configured to:
[0123] When the first size of the first weight size cannot be divided evenly by the first size of the second weight size, the first size of the first weight size is adjusted by the zero-padding method so that the value corresponding to the first size of the updated third weight size can be divided evenly by the first value corresponding to the first size that is smaller than the fourth weight size, and the value corresponding to the first size in the second weight size is adjusted to the first value, where the fourth weight size is the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations.
[0124] When the second size of the first weight size cannot be divided evenly by the second size of the second weight size, the second size of the first weight size is adjusted by the zero-padding method so that the value corresponding to the second size of the updated third weight size can be divided evenly by the second value corresponding to the second size that is smaller than the fourth weight size, and the value corresponding to the second size of the second weight size is adjusted to the second value, where the fourth weight size is the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations.
[0125] When the first size of the first weight size cannot be divided by the first size of the second weight size, and the second size of the first weight size cannot be divided by the second size of the second weight size, the first size and the second size of the first weight size are adjusted simultaneously by the zero-padding method, so that the value corresponding to the first size of the updated third weight size can be divided by the first value smaller than the first size of the fourth weight size, and the value corresponding to the second size of the updated third weight size can be divided by the second value smaller than the second size of the fourth weight size, and the value corresponding to the first size of the second weight size is adjusted to the first value, and the value corresponding to the second size of the second weight size is adjusted to the second value, wherein the fourth weight size is the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations.
[0126] Exemplarily, the convolution operation unit 83 includes:
[0127] An image data acquisition subunit, configured to acquire the original image data input into the convolutional neural network;
[0128] an image data extraction subunit, configured to extract, from the original image data, first image data for performing convolution operation with a second weight size corresponding to each channel;
[0129] A first convolution operation subunit is used to perform a convolution operation on the second weight size of each channel and the first image data corresponding thereto to obtain M*N convolution results;
[0130] The second convolution operation subunit accumulates the M*N convolution results to obtain a convolution result obtained by performing a convolution operation on the original image data using the first weight size.
[0131] Exemplarily, the image data extraction subunit is specifically configured to:
[0132] Calculate the data storage address of the first image data;
[0133] The first image data is extracted from the original image according to the data storage address.
[0134] Exemplarily, the image data extraction subunit is further configured to:
[0135] Calculate the starting position of the first image data corresponding to each channel according to the current number of calculation channels;
[0136] The data storage address of the first image data is calculated according to the starting position using a preset data storage address calculation formula.
[0137] Exemplarily, the image data extraction subunit is further configured to:
[0138] Obtaining the original channel number, where the original channel number is the input channel number of the original image data;
[0139] Calculating and updating a first coordinate offset value and a second coordinate offset value according to the original channel number;
[0140] The starting position of the first image data corresponding to each channel is calculated according to the first coordinate offset value and the second coordinate offset value.
[0141] Exemplarily, the image data extraction subunit is further configured to:
[0142] If the updated first coordinate offset value is equal to the number of channels split along the first direction, the second coordinate offset value is updated and the updated first coordinate offset value is set to zero; otherwise, the first coordinate offset value is continued to be updated.
[0143] Exemplarily, the image data extraction subunit is further configured to:
[0144] If the difference between the original channel number and the third value is equal to the value recorded by the original channel number counter, the first coordinate offset value register and the second coordinate offset value register are triggered to update the first coordinate offset value and the second coordinate offset value. If the difference between the original channel number and the third value is not equal to the value recorded by the original channel number counter, the current coordinate values of the first coordinate offset value register and the second coordinate offset value register are maintained unchanged, and the value recorded by the original channel counter is reset to zero.
[0145] It should be noted that the information interaction, execution process and other contents between the above modules are based on the same concept as the method embodiment of this application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0146] Figure 9 Schematic diagram of an electronic device provided in an embodiment of the present application. Figure 9 As shown, the electronic device 9 of this embodiment includes: a processor 90, a memory 91, and a computer program 92 stored in the memory 91 and capable of running on the processor 90, such as an image processing program. When the processor 90 executes the computer program 92, the steps in the above-mentioned various image processing method embodiments are implemented, such as Figure 1 Alternatively, when the processor 90 executes the computer program 92, the functions of the modules / units in the above-mentioned device embodiments are realized, for example, Figure 8 The functions of units 81-83 are shown.
[0147] Exemplarily, the computer program 92 can be divided into one or more modules / units, and the one or more modules / units are stored in the memory 91 and executed by the processor 90 to complete the present application. The one or more modules / units can be a series of computer program instruction segments that can perform specific functions, and the instruction segments are used to describe the execution process of the computer program 92 in the electronic device 9. For example, the computer program 92 can be divided into a first weight size acquisition unit 81, a weight size splitting unit, and a convolution operation unit 83. For the specific functions of each unit, please refer to Figure 8 The relevant descriptions in the corresponding embodiments are not repeated here.
[0148] The electronic device may include, but is not limited to, a processor 90 and a memory 91. Those skilled in the art will understand that Figure 9 It is only an example of the electronic device 9 and does not constitute a limitation of the electronic device 9. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0149] The processor 90 may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0150] The memory 91 may be an internal storage unit of the electronic device 9, such as a hard disk or memory of the electronic device 9. The memory 91 may also be an external storage device of the electronic device 9, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 9. Furthermore, the memory 91 may include both an internal storage unit of the electronic device 9 and an external storage device. The memory 91 is used to store the computer program and other programs and data required by the electronic device. The memory 91 may also be used to temporarily store data that has been output or is about to be output.
[0151] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned image processing method can be implemented.
[0152] An embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device can implement the above-mentioned image processing method when executing the computer program product.
[0153] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0154] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0155] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0156] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection of the present application.
Claims
1. An image processing method, applied to an electronic device, for performing a convolution operation on an image, characterized in that: The image processing method comprises: Obtaining a first weight size, where the first weight size is a target weight size of a convolution kernel in a convolutional neural network; Splitting the first weight size into second weight sizes corresponding to M*N channels, where M and N are integers greater than or equal to 1, and the second weight size is a weight size of a convolution kernel that can be supported by the current hardware facilities of the electronic device for performing a convolution operation; Obtaining first image data corresponding to a corresponding number of channels and performing a convolution operation with the second weight size, and accumulating the obtained convolution results to obtain a convolution result obtained by performing a convolution operation on the original image data using the first weight size, wherein the first image data is image data in the original image data; The splitting of the first weight size into second weight sizes corresponding to M channels includes: using an integer division rule to split the first weight size into second weight sizes corresponding to M*N channels, the first weight size being M*N times the second weight size; The splitting of the first weight size into second weight sizes corresponding to M*N channels includes: when the first weight size cannot be divided by the second weight size, adjusting the first weight size by a zero padding method to obtain an updated third weight size, wherein the third weight size is greater than the first weight size; splitting the third weight size into second weight sizes corresponding to M*N channels; The weight size includes a first size and a second size, the first size and the second size correspond to the width and height of the convolution kernel, and the zero-padding method is used to adjust the first weight size to obtain an updated third weight size, including: when the first size of the first weight size cannot be divided by the first size of the second weight size, the zero-padding method is used to adjust the first size of the first weight size so that the value corresponding to the first size of the updated third weight size can be divided by the first value corresponding to the first size that is smaller than the fourth weight size, and the corresponding value of the first size in the second weight size is adjusted to the largest value among the first values, wherein the fourth weight size is the weight size of the largest convolution kernel that the current hardware facilities of the electronic device can support for convolution operations.
2. The image processing method according to claim 1, characterized in that: The method of using the integer divisibility rule to split the first weight size into second weight sizes corresponding to M*N channels includes: By using the integer divisibility rule, the first weight size is split into second weight sizes corresponding to M*N channels along the first direction and / or the second direction, where M is the number of channels split along the first direction, and N is the number of channels split along the second direction.
3. The image processing method according to claim 1, characterized in that: The step of adjusting the first weight size by using a zero-padding method to obtain an updated third weight size includes: When the second size of the first weight size cannot be divided by the second size of the second weight size, the second size of the first weight size is adjusted by a zero-padding method so that the value corresponding to the second size of the updated third weight size can be divided by a second value corresponding to a second size that is smaller than the fourth weight size, and the value corresponding to the second size of the second weight size is adjusted to the second value, wherein the fourth weight size is the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations.
4. The image processing method according to claim 1, wherein: The acquiring of the first image data corresponding to the corresponding number of channels and the second weight size for convolution operation, and accumulating the obtained convolution results to obtain the convolution result obtained by using the first weight size for convolution operation on the original image data, includes: Obtaining original image data input into the convolutional neural network; Extracting, from the original image data, first image data for convolution operation with a second weight size corresponding to each channel; Perform convolution operation on the second weight size of each channel and the first image data corresponding thereto to obtain M*N convolution results; The M*N convolution results are accumulated to obtain a convolution result obtained by performing a convolution operation on the original image data using the first weight size.
5. The image processing method according to claim 4, characterized in that: The step of extracting first image data for performing convolution operation on a second weight size corresponding to each channel from the original image data comprises: Calculate the data storage address of the first image data; The first image data is extracted from the original image according to the data storage address.
6. The image processing method according to claim 5, characterized in that: The calculating the data storage address of the first image data comprises: Calculate the starting position of the first image data corresponding to each channel according to the original number of channels; The data storage address of the first image data is calculated according to the starting position using a preset data storage address calculation formula.
7. The image processing method according to claim 6, characterized in that: The calculating, according to the original number of channels, the starting position of the first image data corresponding to each channel comprises: Obtaining the original channel number, where the original channel number is the input channel number of the original image data; Calculate and update the first coordinate offset value and the second coordinate offset value according to the original channel number; The starting position of the first image data corresponding to each channel is calculated according to the first coordinate offset value and the second coordinate offset value.
8. The image processing method according to claim 7, characterized in that: The calculating and updating the first coordinate offset value and the second coordinate offset value according to the original channel number includes: If the updated first coordinate offset value is equal to the number of channels split along the first direction, the second coordinate offset value is updated and the updated first coordinate offset value is set to zero; otherwise, the first coordinate offset value continues to be updated.
9. An image processing device, characterized in that: include: A first weight size acquisition unit, used to acquire a first weight size, where the first weight size is a target weight size of a convolution kernel in a convolutional neural network; The first weight size acquisition unit is also specifically used to: use the integer divisibility judgment rule to split the first weight size into second weight sizes corresponding to M*N channels, and the first weight size is M*N times the second weight size; when the first weight size cannot be divided by the second weight size, the first weight size is adjusted by the zero-padding method to obtain an updated third weight size, and the third weight size is larger than the first weight size; split the third weight size into second weight sizes corresponding to M*N channels; when the first size of the first weight size cannot be divided by the first size of the second weight size, the first size of the first weight size is adjusted by the zero-padding method, so that the value corresponding to the first size of the updated third weight size can be divided by the first value corresponding to the first size that is smaller than the fourth weight size, and the value corresponding to the first size in the second weight size is adjusted to the largest value among the first values, wherein the fourth weight size is the weight size of the maximum convolution kernel that the current hardware facilities of the electronic device can support for convolution operations. A weight size splitting unit, used to split the first weight size into a second weight size corresponding to M*N channels, where M*N is an integer greater than 1, and the second weight size is a weight size of a convolution kernel that can be supported by the current hardware facilities of the electronic device for performing a convolution operation; A convolution operation unit is used to obtain the first image data corresponding to the corresponding number of channels and perform a convolution operation with the second weight size, and accumulate the convolution results to obtain a convolution result obtained by convolving the original image data using the first weight size, where the first image data is the image data in the original image data.
10. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
11. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
