Image filling method and device in deep learning hardware

By performing filling prediction and template generation on the input image in deep learning hardware, and combining the filling template for image filling, the problem of filling operation speed and power consumption is solved, and efficient image filling processing is achieved.

CN112801864BActive Publication Date: 2024-08-23ASR SMART TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110217855.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-02-26
Publication Date
2024-08-23
Estimated Expiration
2041-02-26

AI Technical Summary

Technical Problem

In deep learning hardware, existing technology is difficult to achieve image filling of any size while increasing the processing speed of filling operations and reducing power consumption.

Method used

By predicting the filling of the input image, a filling template that meets specific conditions is generated, and the input image and the filling template are combined for actual filling processing to realize the image filling operation and reduce the number of data transfers.

Benefits of technology

Image filling of any size is implemented in deep learning hardware, which improves the processing speed of filling operations and reduces power consumption, avoids dependence on external hardware, and simplifies hardware programming.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112801864B
    Figure CN112801864B
Patent Text Reader

Abstract

The present application discloses an image filling method in deep learning hardware, comprising the following steps. Step S10: Perform filling estimation on the input image A, and calculate the size of the filling estimation image A1. Compared with the input image A, the newly added pixel points on the edge of the input image A in the filling estimation image A1 are called the first extension set. Step S20: Generate a filling template B1. This refers to the output image B1 obtained by performing a deep convolution operation on the image B, by controlling the selection of the image B, adjusting the size of the convolution kernel, the value of the convolution weight, and the value of the bias, so that the output image B1 satisfies both condition one and condition two. The output image B1 is the filling template, which is written to the memory address. Step S30: Combine the input image A with the filling template B1 to obtain the image after the actual filling processing of the input image A. The above method can realize image filling of any size in deep learning hardware.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to an image filling method in a deep learning algorithm. Background Art

[0002] Deep learning has become a hot topic in current AI (artificial intelligence) research. Deep learning algorithms need to rely on high-performance, high-computing computing platforms. The performance of general-purpose processors is poor. With the crazy growth of deep learning computing needs, general-purpose processors can no longer meet the needs of deep learning computing. Therefore, dedicated hardware is needed to accelerate to meet the high computing power requirements of deep learning. Deep learning hardware includes CPU (central processing unit), GPU (graphics processing unit), NPU (Network Processing Unit), FPGA (Field-Programmable Gate Array), etc. These AI computing hardware accelerators play their respective roles in different application scenarios and deep learning algorithms.

[0003] In deep learning algorithms, convolution and pooling operations require padding to avoid losing edge information of the input image or to keep the output and input data sizes consistent. The padding size can be adaptively adjusted according to the convolution kernel or pooling size to retain edge information or keep the input and output sizes consistent. In many neural network (NN) frameworks, such as Tensorflow, Pytorch, Caffe, etc., padding operations of any size can be performed on the input image. Implementing software algorithms in hardware itself has certain limitations for some operations. For example, directly padding the input image requires multiple data transfers, which will increase unnecessary algorithm delays and power consumption.

[0004] The prior art usually only focuses on the increase in storage space caused by the increase in data after the padding operation, but does not focus on how to perform the padding operation itself. The Chinese invention patent application "Image padding method and device in convolutional neural network FPGA acceleration" with application publication number CN109461119A and application publication date March 12, 2019 proposes a method of replacing padding around the input image by padding only in rows or columns, so that the padded data requires less storage space. Summary of the invention

[0005] The technical problem to be solved by this application is to propose a method for filling input data (input image) in deep learning hardware, which can effectively improve the processing speed of the filling operation and reduce power consumption while achieving image filling of any size.

[0006] In order to solve the above technical problems, the present application proposes an image filling method in deep learning hardware, comprising the following steps. Step S10: Perform filling estimation on the input image A and calculate the size of the filling estimation image A1; compared with the input image A, the newly added pixel points on the edge of the input image A are called the first extended set. Step S20: Generate a filling template B1; this refers to the output image B1 obtained by performing a deep convolution operation on image B, by controlling the selection of image B, adjusting the size of the convolution kernel, the value of the convolution weight, and the value of the bias, so that the output image B1 satisfies the following two conditions at the same time; Condition 1: The size of the output image B1 is greater than or equal to the size of the filling estimation image A1; Condition 2: The pixel points in the output image B1 corresponding to each pixel point in the first extended set have the same value as the pixel points at the corresponding position in the first extended set; The output image B1 is the filling template, which is written to the memory address. Step S30: Combine the input image A with the filling template B1 to obtain an image after the input image A is actually filled; this means writing the input image A into the memory address where the filling template B1 is located, and the writing method is to use the value of each pixel point of the input image A to overwrite the data of the pixel point at the corresponding position in the filling template B1. After the overwriting, the final data in the memory address is the data after the input image A is actually filled. The above method can realize image filling of any size in deep learning hardware.

[0007] Furthermore, in step S10, the input image A refers to an input image of a neural network, or an input feature map of any layer in the neural network. This is a further description of the input image A.

[0008] Furthermore, in the step S10, the method of calculating the padding estimated image A1 is as follows: let the height and width of the padding estimated image A1 be H_ and W_ respectively, H_=pad_t+pad_b+H, W_=pad_l+pad_r+W; wherein pad_t is the number of rows of pixels filled above the input image A, pad_b is the number of rows of pixels filled below the input image A, pad_l is the number of columns of pixels filled on the left side of the input image A, and pad_r is the number of columns of pixels filled on the right side of the input image A; pad_t, pad_b, pad_l, and pad_r are arbitrary values. This is a preferred implementation.

[0009] Furthermore, in step S10, each pixel in the first extended set may have the same value or different values, which are set by the user. This is to cope with various application scenarios. For example, the values ​​of each pixel in the first extended set are all 0, or all 1, or are set arbitrarily according to requirements.

[0010] Furthermore, in step S20, the newly added pixels in the output image B1 compared with the filled estimated image A1 are called the second extended set; the second extended set is either an empty set, i.e., does not contain any pixels; or is not an empty set, i.e., contains one or more pixels. This is a detailed description of the relationship between the two images.

[0011] Furthermore, in step S20, each pixel point of the filling template B1 is stored row by row in a top-down order, and each pixel point in each row is stored in a memory address in a left-to-right order. This is a preferred implementation. In other application scenarios, different storage methods may also be used.

[0012] The present application also proposes an image filling device in deep learning hardware, including a filling estimation unit, a template generation unit and a combined output unit. The filling estimation unit is used to perform filling estimation on the input image A and calculate the filling estimation image A1; compared with the input image A, the newly added pixel points on the edge of the input image A in the filling estimation image A1 are called the first extension set. The template generation unit is used to generate a filling template; this refers to the output image B1 obtained by performing a deep convolution operation on the image B, by adjusting one or more of the selection of image B, the size of the convolution kernel, the value of the convolution weight, and the value of the bias, so that the output image B1 satisfies the following two conditions at the same time; Condition 1: The size of the output image B1 is greater than or equal to the size of the filling estimation image A1; Condition 2: The pixel points at the corresponding position of each pixel point in the first extension set in the output image B1 have the same value as the pixel points at the corresponding position in the first extension set; at this time, the output image B1 is the filling template and is written to the memory address. The combined output unit is used to combine the input image A with the filling template B1 to obtain an image after the input image A is actually filled; this means that the value of each pixel point of the input image A is used to cover the data of the pixel point at the corresponding position in the filling template B1, and the final data in the memory address after the covering is the data after the input image A is actually filled. The above device can realize image filling of any size in deep learning hardware.

[0013] The technical effect achieved by the present application is to focus on the image filling operation itself in the deep learning algorithm, without relying on external hardware (such as digital signal processor DSP, CPU, etc.) for processing, and can achieve filling of any size for the input image only within the deep learning hardware; and compared to directly performing the filling operation in the memory and causing multiple data transfers, the present application is faster, simpler, and more efficient, and is not limited to the hardware programming of the acceleration platform of the deep learning algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 This is a flowchart of the image filling method in deep learning hardware proposed in this application.

[0015] Figure 2 is a schematic diagram of an embodiment of performing filling estimation in step S10.

[0016] Figure 3 is a schematic diagram of a first embodiment of generating a filling template in step S20.

[0017] Figure 4 It is a schematic diagram of an embodiment of saving the filling template in step S20.

[0018] Figure 5 is a schematic diagram of a second embodiment of generating a filling template in step S20.

[0019] Figure 6 FIG. 1 is a schematic diagram of an embodiment of writing the filling template with the input image A in step S30 .

[0020] Figure 7 It is a structural schematic diagram of the image filling device in deep learning hardware proposed in this application.

[0021] Explanation of the reference numerals in the figure: 10 is a filling estimation unit; 20 is a template generation unit; 30 is a combined output unit. DETAILED DESCRIPTION

[0022] See also Figure 1 , the image filling method in deep learning hardware proposed in this application includes the following steps.

[0023] Step S10: padding estimation is performed on the input image A, and the size of the image A1 after padding estimation (referred to as the padding estimation image) is calculated. The input image A refers to the input image of the neural network, or the input feature map of any layer in the neural network. The method of calculating the padding estimation is as follows: let the height and width of the padding estimation image A1 be H_ and W_ respectively, H_=pad_t+pad_b+H, W_=pad_l+pad_r+W. Among them, pad_t is the number of rows of pixels filled above the input image A, pad_b is the number of rows of pixels filled below the input image A, pad_l is the number of columns of pixels filled on the left side of the input image A, and pad_r is the number of columns of pixels filled on the right side of the input image A. pad_t, pad_b, pad_l, and pad_r can take any value. Compared with the input image A, the pixel points added to the edge of the padding estimation image A1 at the edge of the input image A are called the first extended set. The pixel points in the first extended set can take the same value or different values, which are set by the user.

[0024] Step S20: Generate a filling template B1. This refers to the output image B1 obtained by performing a depthwise convolution operation on image B. By controlling the selection of image B, adjusting the size of the convolution kernel, the value of the convolution weight, and one or more of the bias values, the output image B1 satisfies the following two conditions at the same time. Condition 1: The size of the output image B1 is greater than or equal to the size of the filled estimated image A1, and is preferably equal to. Compared with the filled estimated image A1, the newly added pixel points in the output image B1 are called the second extended set. The second extended set can be an empty set, that is, it does not contain any pixel points; it can also be a non-empty set, that is, it contains one or more pixel points. Condition 2: The pixel points in the output image B1 corresponding to each pixel point in the first extended set have the same value as the pixel points at the corresponding position in the first extended set, and there is no requirement for the values ​​of the remaining pixel points in the output image B1. At this time, the output image B1 is a filling template and is written to the memory address. The size of the memory address is the size of the filling template B1. For example, each pixel of the filling template B1 is saved row by row from top to bottom, and each pixel in each row is saved row by row from left to right.

[0025] Step S30: Combining the input image A with the filling template B1, obtaining an image after the input image A is actually filled. This means writing the input image A into the memory address where the filling template B1 is located, and the writing method is to use the value of each pixel point of the input image A to overwrite the data of the pixel point at the corresponding position in the filling template B1. After the overwriting, the final data in the memory address is the data after the input image A is actually filled.

[0026] The method described in the present application will be described in detail below with reference to a specific embodiment.

[0027] See also Figure 2 In step S10, the input image A is, for example, an image of size 3×3×1 (height×width×number of pixels in the depth direction, the same below), and the values ​​of pad_t, pad_b, pad_l, and pad_r are, for example, all 1, and the size of the padded estimated image A1 becomes 5×5×1. Among them, a, b, c, d, e, f, g, h, and i are the values ​​of each pixel in the input image A, respectively, and are also the values ​​of the pixels in the padded estimated image A1 at the corresponding positions of the input image A. Compared with the input image A, the pixels newly added to the edge of the padded estimated image A1 are called the first extended set. The values ​​of each pixel in the first extended set are, for example, all 0. In other embodiments, the values ​​of each pixel in the first extended set may all be other values, or may be different.

[0028] See also Figure 3 In step S20, the image B is, for example, 5×5×1 in size. The convolution kernel is 1×1×1 in size, and the value of each pixel in the convolution kernel (i.e., the convolution weight) is 0. The value of the bias is 0. It can be found that the convolution result is the output image B1, which is 5×5×1 in size, which is equal to the size of the padded estimated image A1, and thus meets condition 1. Figure 3 The calculation process of the deep convolution in is as follows: p1 = b1 × 0 + 0 = 0, p2 = b2 × 0 + 0 = 0, and so on. It can be obtained that the values ​​of p3, p4, etc. are all 0. Then the pixel points p1, p2, p3, p4, p5, p6, p10, p11, p15, p16, p20, p21, p22, p23, p24, p25 in the output image B1 corresponding to each pixel point in the first extended set have the same value as the pixel points at the corresponding position in the first extended set, which are all 0, thus satisfying condition 2. At this time, the output image B1 is the filling template B1. In different application scenarios, the output image B1 can satisfy both conditions 1 and 2 by controlling the selection of image B, adjusting the size of the convolution kernel, the value of the convolution weight, and the value of the bias.

[0029] See also Figure 4 In step S20, for example, each pixel point of the filling template B1 is saved row by row in a top-down order, and each pixel point in each row is saved in a memory address in a left-to-right order; that is, they are saved in the memory address in sequence from p1 to p25.

[0030] See also Figure 5In step S20, the image B is, for example, 7×7×1 in size. The convolution kernel is 3×3×1 in size, and the value of each pixel in the convolution kernel (i.e., the convolution weight) is 0. The value of the bias is 0. It can be found that the convolution result is the output image B1, which has a size of 5×5×1, which is equal to the size of the padded estimated image A1, and thus meets condition 1. Figure 5 The calculation process of the depth convolution in is as follows: p1 = b1 × 0 + b2 × 0 + b3 × 0 + b8 × 0 + b9 × 0 + b10 × 0 + b15 × 0 + b16 × 0 + b17 × 0 + 0 = 0, p2 = b2 × 0 + b3 × 0 + b4 × 0 + b9 × 0 + b10 × 0 + b11 × 0 + b16 × 0 + b17 × 0 + b18 × 0 + 0 = 0, and so on, it can be obtained that the values ​​of p3, p4, etc. are all 0. Then the pixel points p1, p2, p3, p4, p5, p6, p10, p11, p15, p16, p20, p21, p22, p23, p24, and p25 corresponding to each pixel point in the first extended set in the output image B1 have the same values ​​as the corresponding pixel points in the first extended set, which are all 0, thus satisfying condition 2. At this time, the output image B1 is the filling template B1. In different application scenarios, the output image B1 can satisfy both condition 1 and condition 2 by controlling the selection of image B, adjusting the size of the convolution kernel, the value of the convolution weight, and one or more of the bias values.

[0031] See also Figure 6 In step S30, the input image A is written into the memory address where the filling template B1 is located. The writing method is to use the value of each pixel of the input image A to overwrite the data of the pixel at the corresponding position in the filling template B1, that is, to use the values ​​of a, b, c, d, e, f, g, h, i to overwrite the values ​​of p7, p8, p9, p12, p13, p14, p17, p18, and p19 respectively. After overwriting, the final data in the memory address is the image after the actual filling processing of the input image A. It can be found that the method described in the present application has only one data transfer process in the memory.

[0032] See also Figure 7 The image filling device in deep learning hardware proposed in this application includes a filling estimation unit 10, a template generation unit 20 and a combined output unit 30.

[0033] The padding estimation unit 10 is used to perform padding estimation on the input image A and calculate the size of the image A1 (called the padding estimation image) after padding estimation. Compared with the input image A, the padding estimation image A1 has newly added pixel points at the edge of the input image A, which is called the first extended set.

[0034] The template generation unit 20 is used to generate a filling template B1. This refers to the output image B1 obtained by performing a deep convolution operation on the image B, by adjusting one or more of the selection of image B, the size of the convolution kernel, the value of the convolution weight, and the value of the bias, so that the output image B1 satisfies the following two conditions at the same time. Condition 1: The size of the output image B1 is greater than or equal to the size of the filled estimated image A1. Compared with the filled estimated image A1, the newly added pixel points in the output image B1 are called the second extended set. Condition 2: The pixel points in the output image B1 that correspond to each pixel point in the first extended set have the same value as the pixel points at the corresponding position in the first extended set, and there is no requirement for the values ​​of the remaining pixel points in the output image B1. At this time, the output image B1 is the filling template and is written to the memory address.

[0035] The combined output unit 30 is used to combine the input image A with the filling template B1 to obtain an image after the input image A is actually filled. This means that the value of each pixel point of the input image A is used to cover the data of the pixel point at the corresponding position in the filling template B1. After the covering, the final data in the memory address is the data after the input image A is actually filled.

[0036] The image filling processing method in deep learning hardware proposed in this application does not need to rely on external processing. The input image can be filled with any size only within the deep learning hardware. Compared with the prior art that directly performs filling operations in the memory and causes multiple data transfers, this application is faster and simpler, and is not limited to the hardware programming of the acceleration platform of the deep learning algorithm.

[0037] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should all be included in the protection scope of the present application.

Claims

1. An image filling method in deep learning hardware, characterized in that: The steps include: Step S10: performing filling estimation on the input image A, and calculating the size of the filled estimated image A1; compared with the input image A, the pixel points newly added on the edge of the input image A in the filled estimated image A1 are called the first extended set; Step S20: Generate a filling template B1; this refers to the output image B1 obtained by performing a deep convolution operation on the image B, by controlling the selection of the image B, adjusting the size of the convolution kernel, the value of the convolution weight, and one or more of the bias values, so that the output image B1 satisfies the following two conditions at the same time: Condition 1: The size of the output image B1 is greater than or equal to the size of the filling estimated image A1; Condition 2: The pixel points at the positions corresponding to each pixel point in the first extended set in the output image B1 have the same values ​​as the pixel points at the corresponding positions in the first extended set; the output image B1 is the filling template, which is written to the memory address; Step S30: Combine the input image A with the filling template B1 to obtain an image after the input image A is actually filled; this means writing the input image A into the memory address where the filling template B1 is located, and the writing method is to use the value of each pixel point of the input image A to overwrite the data of the pixel point at the corresponding position in the filling template B1. After the overwriting, the final data in the memory address is the data after the input image A is actually filled.

2. The image filling method in deep learning hardware according to claim 1, characterized in that: In step S10, the input image A refers to the input image of the neural network, or the input feature map of any layer in the neural network.

3. The image filling method in deep learning hardware according to claim 1, characterized in that: In the step S10, the method of calculating the filled estimated image A1 is as follows: suppose the height and width of the filled estimated image A1 are H_ and W_ respectively, H_=pad_t+pad_b+H, W_=pad_l+pad_r+W; wherein, pad_t is the number of rows of pixels filled above the input image A, pad_b is the number of rows of pixels filled below the input image A, pad_l is the number of columns of pixels filled on the left side of the input image A, and pad_r is the number of columns of pixels filled on the right side of the input image A; pad_t, pad_b, pad_l, and pad_r are arbitrary values.

4. The image filling method in deep learning hardware according to claim 1, characterized in that: In step S10, each pixel point in the first extended set may adopt the same value or different values, which are set by the user.

5. The image filling method in deep learning hardware according to claim 1, characterized in that: In step S20, the newly added pixels in the output image B1 compared with the filled estimated image A1 are called the second extended set; the second extended set is either an empty set, that is, it does not contain any pixels; or it is not an empty set, that is, it contains one or more pixels.

6. The image filling method in deep learning hardware according to claim 1, characterized in that: In the step S20, each pixel point of the filling template B1 is saved row by row in a top-down order, and each pixel point in each row is saved in a memory address in a left-to-right order.

7. An image filling device in deep learning hardware, characterized in that: It includes a filling estimation unit, a template generation unit and a combined output unit; The filling estimation unit is used to perform filling estimation on the input image A and calculate the filling estimation image A1; Compared with the input image A, the pixel points newly added on the edge of the input image A in the filled estimated image A1 are called the first extended set; The template generation unit is used to generate a filling template; this refers to an output image B1 obtained by performing a deep convolution operation on image B, by adjusting one or more of the selection of image B, the size of the convolution kernel, the value of the convolution weight, and the value of the bias, so that the output image B1 satisfies the following two conditions at the same time: condition one: the size of the output image B1 is greater than or equal to the size of the filling estimated image A1; condition two: the pixel points at the corresponding position of each pixel point in the first extended set in the output image B1 have the same value as the pixel points at the corresponding position in the first extended set; at this time, the output image B1 is the filling template and is written to the memory address; The combined output unit is used to combine the input image A with the filling template B1 to obtain an image after the input image A is actually filled; this means that the value of each pixel point of the input image A is used to cover the data of the pixel point at the corresponding position in the filling template B1. After the covering, the final data in the memory address is the data after the input image A is actually filled.