A target detection method using convolution operation for image scaling acceleration
By combining convolutional downsampling and upsampling units with edge-padding operations before the target detector, the low efficiency of traditional image scaling algorithms on mobile devices is solved, achieving efficient image scaling and target detection.
Patent Information
- Application Number
- CN202211064866.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-01
- Publication Date
- 2026-02-10
- Estimated Expiration
- 2042-09-01
AI Technical Summary
Traditional image scaling algorithms are inefficient and time-consuming on mobile devices, and deep learning-based image preprocessing methods are complex and inconvenient to apply.
Image scaling is achieved by using convolution operations. By combining convolution downsampling units and convolution upsampling units with edge-padding operations, basic operators are directly added in front of the target detector to achieve stretch-free image scaling.
It improves the efficiency of object detection, is applicable to NPU, GPU or TPU platforms, eliminates the tedious model training process, and improves the speed and efficiency of image scaling.
Smart Images

Figure CN115423886B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology and relates to a target detection method that uses convolution operations to accelerate image scaling. Background Technology
[0002] With the development of artificial intelligence technology, deep learning has achieved high-precision target detection and recognition results in multiple scenarios. At the same time, the intelligent development of cities and society has led to an increasing demand for video stream analysis, and more and more artificial intelligence applications are being implemented, requiring more and more deep learning models to be deployed on mobile devices. Image scaling is an essential data preprocessing step for deep learning algorithms; specifically, it involves scaling the original image size to the input size of the neural network.
[0003] Traditional image scaling algorithms mostly rely on different interpolation algorithms.
[0004] (1) Nearest neighbor interpolation method and bilinear interpolation method:
[0005] The nearest neighbor interpolation method calculates the point (X) in the target image using a scaling formula. dst ,Y dst The point (X) in the corresponding source image src ,Y src The source image coordinates are obtained by rounding, and the pixel values from the source image are used to fill the target image. This is a very basic and simple image scaling algorithm. However, the results are not good; the enlarged image has severe pixelation, and the reduced image has severe distortion.
[0006]
[0007] Bilinear interpolation is the most commonly used algorithm for image magnification. It is more efficient than other algorithms and produces acceptable image quality. Bilinear interpolation performs linear interpolation once in each of the two directions, such as... Figure 1 As shown, X is known. i,j ,X i,j+1 ,X i+1,j ,X i+1,j+1 The pixel value at point Y m,n Interpolate the points.
[0008] Y m,n =abX i,j +a(1-b)X i+1,j +(1-a)bX i,j+1 +(1-a)(1-b)X i+1,j+1 (2)
[0009] 'a' represents the distance from the interpolation point to the bottom right corner. i+1j+1 The distance in the x-direction, where b is the distance from the interpolation point to the lower right corner.i+1j+1 The distance in the y-direction.
[0010] (2) Edge-based image interpolation algorithm:
[0011] To overcome the shortcomings of traditional methods, many edge-preserving interpolation methods have been proposed, which enhance the edges of the interpolated image to a certain extent, making the image visually better. The disadvantage is that the running efficiency is very low.
[0012] (3) Region-based image interpolation algorithm:
[0013] When reducing image size, region interpolation yields the best results. This algorithm samples the current pixel based on pixels in the surrounding region; the key is determining the size of the sampling region. This method is simple and effective to implement.
[0014] Traditional digital image processing algorithms are inefficient and time-consuming on mobile CPUs (Central Processing Units). Besides traditional image processing algorithms, there are also methods that use deep learning networks to reconstruct images. Deep learning models for image super-resolution (image SR) can be used to predict high-quality, high-resolution images with varying details from low-resolution images. There are also deep learning algorithms that downsample high-resolution images to create visually appealing low-resolution images. The drawbacks of these deep learning-based approaches are that the models can be overly complex and require training on specific datasets, making them less suitable for image preprocessing within deep learning systems. Summary of the Invention
[0015] To address the aforementioned problems in the existing technology, this invention provides a target detection method that utilizes convolution operations for image scaling acceleration. The technical problem to be solved by this invention is achieved through the following technical solution:
[0016] This invention provides a target detection method that utilizes convolution operations to accelerate image scaling. The target detection method includes:
[0017] Step 1: Obtain the source image to be processed;
[0018] Step 2: Determine the processing method of the source image to be processed based on the target size, so as to determine the unstretched scaling factor of the source image to be processed, wherein the processing method includes enlarging or reducing;
[0019] Step 3: When the source image to be processed is reduced in size, the source image to be processed enters the convolution downsampling unit to obtain a proportionally scaled image; or, when the source image to be processed is enlarged in size, the source image to be processed enters the convolution upsampling unit to obtain a proportionally scaled image.
[0020] Step 4: Perform edge-padding operation on the proportionally scaled image according to the edge-padding length calculation formula to obtain a final scaled image with the target size;
[0021] Step 5: Input the final scaled image into the target detector for target detection and obtain the detection result.
[0022] In one embodiment of the invention, step 2 includes:
[0023] Step 2.1: Determine whether the source image to be processed should be reduced or enlarged based on the target size;
[0024] Step 2.2: When the source image to be processed is reduced in size, the scaling factor without stretching is calculated using the reduction calculation formula; or, when the source image to be processed is enlarged in size, the scaling factor without stretching is calculated using the enlargement calculation formula.
[0025] In one embodiment of the invention, the reduction calculation formula is:
[0026]
[0027] The amplification calculation formula is as follows:
[0028]
[0029] Where scale is the scaling factor without stretching, and net w For the width in the target size, net h The height of the target size, img w The width of the source image to be processed, img h The height of the source image to be processed.
[0030] In one embodiment of the invention, the size of the proportionally scaled image obtained by the source image to be processed entering the convolutional downsampling unit is represented as follows:
[0031]
[0032]
[0033] Among them, net w 'To scale the image width proportionally, net h ' represents the height of the image scaled proportionally, p is the number of zero-padding layers, k is the kernel size, s1 is the first step size, s1 = [scale], and [·] is for rounding down.
[0034] In one embodiment of the invention, when the source image to be processed is magnified, the source image to be processed enters a convolutional upsampling unit to obtain a proportionally scaled image, including:
[0035] S1. Fill the surrounding area of the source image to be processed with kp-1 rows and 0 columns of pixels, and fill the effective pixels in the source image to be processed with s-1 rows and 0 columns of pixels, where k is the convolution kernel size, s is the stride, and p is the number of zero-padding layers.
[0036] S2. First, symmetrically flip the convolution kernel along the vertical center line, and then flip it along the horizontal center line to obtain the flipped convolution kernel. Perform convolution operation based on the flipped convolution kernel to obtain the proportionally scaled image.
[0037] In one embodiment of the invention, the size of the proportionally scaled image obtained by the source image to be processed entering the convolutional upsampling unit is represented as follows:
[0038] net w '=(img w -1)×s2-2×p+k
[0039] net h '=(img h -1)×s2-2×p+k
[0040] Among them, net w 'To scale the image width proportionally, net h ' represents the height of the image scaled proportionally, p is the number of zero-padding layers, k is the kernel size, s2 is the second stride, s2 = 2·[scale] - [scale] mod 2, and [·] is rounded down.
[0041] In one embodiment of the invention, prior to step S2, the method further includes:
[0042] When calculating the current convolution kernel parameters, based on the interpolation formula, according to 'a' within the transposed convolution window... 2 The current convolution kernel parameters are obtained from the number of valid pixels and interpolation points;
[0043] The transposed convolution window is moved in a preset direction, and the kernel parameters corresponding to the moved transposed convolution window are calculated until all kernel parameters are obtained.
[0044] In one embodiment of the invention, the interpolation formula is:
[0045]
[0046] Among them, y m,n The result is the interpolation result, and (m,n) are the interpolation points. This refers to the valid pixel point with coordinates (x0+i, y0+j). It is the coefficient related to the distance between the effective pixel (x0+i,y0+j) and the interpolation point (m,n), where (x0,y0) is the pixel coordinate point of the upper left corner of the transposed convolution window, and i and j are the two-dimensional indices of the effective pixels within the transposed convolution window.
[0047] In one embodiment of the invention, the formula for calculating the side-addition length is:
[0048]
[0049] Among them, pad w pad is the required padding length in the x-direction. h The required side length in the y-direction, scale is the unstretched scaling factor, and net w For the width in the target size, net h The height of the target size, img w The width of the source image to be processed, img h The height of the source image to be processed.
[0050] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0051] The method of this invention uses convolutional downsampling units, convolutional upsampling units, and edge-padding operations that do not require a cumbersome model training process. They only use basic operators in the deep learning framework and can be directly added before the object detector to scale and merge the image into the deep learning model to form a unified model, thereby improving the efficiency of object detection.
[0052] Traditional image scaling operates on the CPU, which is time-consuming and inefficient on embedded development boards. However, the object detection method provided by this invention can be used on multiple platforms such as NPU, GPU, or TPU.
[0053] The embodiments of the present invention utilize convolutional downsampling units / convolutional upsampling units to achieve image scaling without stretching.
[0054] Other aspects and features of the invention will become apparent from the following detailed description with reference to the accompanying drawings. However, it should be understood that the drawings are for illustrative purposes only and not as a limitation of the scope of the invention, as reference should be made to the appended claims. It should also be understood that, unless otherwise indicated, the drawings are not necessarily drawn to scale; they are merely intended to conceptually illustrate the structures and processes described herein. Attached Figure Description
[0055] Figure 1This is a flowchart illustrating a target detection method that uses convolution operations to accelerate image scaling, as provided in an embodiment of the present invention.
[0056] Figure 2 This is a flowchart illustrating another target detection method that uses convolution operations to accelerate image scaling, provided by an embodiment of the present invention.
[0057] Figure 3 This is a schematic diagram of a filled image provided in an embodiment of the present invention;
[0058] Figure 4 This is a schematic diagram of a convolution kernel flipping process provided in an embodiment of the present invention;
[0059] Figure 5 This is a schematic diagram of interpolation using bilinear interpolation provided in an embodiment of the present invention;
[0060] Figure 6 This is a schematic diagram of a transposed convolution window without boundary padding points provided in an embodiment of the present invention;
[0061] Figure 7 This is a schematic diagram illustrating the calculation of transposed convolution kernel parameters according to an embodiment of the present invention;
[0062] Figure 8 This is a schematic diagram of the structure of an image scaling module and a target detector provided in an embodiment of the present invention. Detailed Implementation
[0063] The present invention will be further described in detail below with reference to specific embodiments, but the implementation of the present invention is not limited thereto.
[0064] Example 1
[0065] When deploying deep learning models, it's typically necessary to scale the source image to the network input size, which falls under the image preprocessing section. Traditional image scaling algorithms perform poorly on lightweight mobile devices, hindering model inference and severely impacting the application of AI-related achievements on mobile devices. AI platforms inevitably include a module for neural network inference, whether it's a GPU (Graphics Processing Unit), NPU (Neural Processing Unit), or TPU (Tensor Processing Unit), all capable of parallel convolutional computation. This paper leverages convolutional operations from deep learning to efficiently implement image scaling, addressing the slow image scaling issue on mobile devices.
[0066] Based on this, please see Figure 1 and Figure 2 , Figure 1 This is a flowchart illustrating a target detection method that utilizes convolution operations to accelerate image scaling, as provided in an embodiment of the present invention. Figure 2 This is a flowchart illustrating another target detection method for accelerating image scaling using convolution operations, provided by an embodiment of the present invention. The present invention provides a target detection method for accelerating image scaling using convolution operations, comprising steps 1-5, wherein:
[0067] Step 1: Obtain the source image to be processed.
[0068] The source image to be processed is the image used for target detection, and the target can be, for example, a person, a vehicle, an animal, etc.
[0069] Step 2: Determine the processing method for the source image to be processed based on the target size, thereby determining the unstretched scaling factor of the source image to be processed. The processing method includes enlarging or reducing the image. The target size is the size that needs to be input into the target detector for target detection, and the unstretched scaling factor is the coefficient corresponding to enlarging or reducing the source image to be processed.
[0070] In one specific embodiment, step 2 may include:
[0071] Step 2.1: Determine whether the source image to be processed should be reduced or enlarged based on the target size.
[0072] In other words, when the target size is larger than the size of the source image to be processed, the source image to be processed is enlarged; when the target size is smaller than the size of the source image to be processed, the source image to be processed is reduced.
[0073] Step 2.2: When the source image to be processed is reduced in size, calculate the scaling factor without stretching using the reduction calculation formula; or, when the source image to be processed is enlarged in size, calculate the scaling factor without stretching using the enlargement calculation formula.
[0074] In other words, based on the target size, first determine whether the source image to be processed needs to be reduced or enlarged, and then select the reduction calculation formula or the enlargement calculation formula to calculate the unstretched scaling factor.
[0075] The formula for shrinkage is as follows:
[0076]
[0077] The formula for magnification calculation is:
[0078]
[0079] Where scale is the scaling factor without stretching, and net w For the width in the target size, net h The height of the target size, imgw The width of the source image to be processed, img h The height of the source image to be processed.
[0080] Step 3: When the source image to be processed is reduced in size, the source image to be processed enters the convolution downsampling unit to obtain a proportionally scaled image; or, when the source image to be processed is enlarged in size, the source image to be processed enters the convolution upsampling unit to obtain a proportionally scaled image.
[0081] In one specific embodiment, when the source image to be processed needs to be reduced in size, convolution is used instead of downsampling when the source image enters the convolutional downsampling unit. The key is to determine the size of the convolution kernel, stride, number of zero-padding layers, and weights. Typically, the input source image to be processed is .img in size. w ×img h If the kernel size is k, the first step amplitude is s1, and the number of zero-padding layers is p, then the size of the feature map (i.e., the proportionally scaled image) after convolution by the convolution downsampling unit is net. w '×net h The formula for calculating ' is:
[0082]
[0083]
[0084] Among them, net w 'To scale the image width proportionally, net h ' represents the height of the image scaled proportionally, p is the number of zero-padding layers, k is the kernel size, s1 is the first step size, s1 = [scale], and [·] is for rounding down.
[0085] Based on the scaling algorithm based on area interpolation, in a specific embodiment of implementing the convolutional downsampling unit, let the convolutional kernel k=3 and the number of zero-padding layers p=0. Combining this with the convolutional feature map calculation formula, the downsampling factor at this point depends entirely on s1. Assuming the required scaling factor is scale, then s = [scale]. In the design of the convolutional weights, the idea of mean filtering is adopted, fixing the weights of the convolutional layer to 1 / k. 2 .
[0086] In another specific embodiment, when the source image to be processed is magnified, the source image to be processed enters the convolutional upsampling unit to obtain a proportionally scaled image, including:
[0087] S1. Fill the surrounding area of the source image to be processed with kp-1 rows and 0 columns of pixels, and fill the effective pixels in the source image to be processed with s-1 rows and 0 columns of pixels, where k is the convolution kernel size, s is the stride, and p is the number of zero-padding layers.
[0088] In other words, upsampling is performed using transposed convolution. Before calculating the transposed convolution, padding is applied around the edges of the source image and between the effective pixels, with the padded pixels having a value of 0. The padding effect is as follows: Figure 3 As shown, if the source image to be processed enters the convolutional downsampling unit, the stride s is the first stride s1, and if the source image to be processed enters the convolutional downsampling unit, the stride s is the second stride s2.
[0089] S2. First, symmetrically flip the convolution kernel along the vertical center line, then flip it along the horizontal center line to obtain the flipped convolution kernel. Perform convolution operations based on the flipped convolution kernel to obtain a proportionally scaled image. See also... Figure 4 , Figure 4 In the diagram, (a) represents the unflipped convolution kernel. Figure 4 (b) in the diagram represents the convolution kernel after symmetrical flipping along the vertical centerline. Figure 4 (c) in the diagram represents the convolution kernel after symmetrical flipping along the horizontal center line.
[0090] Specifically, after flipping the convolution kernel parameters horizontally and vertically, the flipped convolution kernel is used to perform normal convolution operations on the padded image, resulting in a feature map after convolution by the convolution upsampling unit (i.e., a proportionally scaled image). The size of this proportionally scaled image is net. w '×net h The formula for calculating ' is:
[0091] net w '=(img w -1)×s2-2×p+k
[0092] net h '=(img h -1)×s2-2×p+k
[0093] Among them, net w 'To scale the image width proportionally, net h ' represents the height of the image scaled proportionally, p is the number of zero-padding layers, k is the kernel size, s2 is the second stride, s2 = 2·[scale] - [scale] mod 2, and [·] is rounded down.
[0094] When constructing the convolutional upsampling unit, the second stride s2 is first determined based on the unstretched scaling factor, s2 = 2·[scale] - [scale] mod 2. Regarding the choice of k, to ensure that a certain number of valid pixels always fall within the sliding convolution window, k = as2, a = 2, 3..., where a is the number of valid pixels in each row or column in the x or y direction within the sliding convolution window. The value of p can be determined by s2, k, and img. w ,img h net w 'and net h 'The only certainty.'
[0095] Furthermore, since the parameters of the convolution kernel in the convolution upsampling unit are undetermined, the parameters of the convolution kernel need to be determined before proceeding to step S2. Therefore, this embodiment also provides a method for obtaining the parameters of the convolution kernel, including:
[0096] When calculating the current convolution kernel parameters, based on the interpolation formula, according to 'a' within the transposed convolution window... 2 The positional relationship between the effective pixels and the interpolation points yields the value of a at the same position as the effective pixel. 2 One convolution kernel parameter; move the transposed convolution window according to a preset direction, and continue to calculate the 'a' corresponding to the moved transposed convolution window according to the above steps. 2 The process iterates through the convolution kernel parameters until all kernel parameters are obtained. The transposed convolution window is the window formed by the convolution kernels; that is, the area of the image filled by the current convolution kernel is the area corresponding to the transposed convolution window. The default direction is from left to right and from top to bottom.
[0097] Specifically, we first need to know that the transposed convolution window contains 'a'. 2 There are 100 valid pixels, and then it is necessary to determine the value of a. 2 An interpolation formula is constructed from the effective pixels, and this interpolation formula is expressed as:
[0098]
[0099] Where (m,n) are the interpolation points (i.e., sampling points), y m,n This is the interpolation result, i.e., the pixel value at the sampling point (m,n). Let (x0, y0) be the effective pixel with coordinates (x0+i, y0+j), (x0, y0) be the pixel coordinates of the top left corner of the transposed convolution window, and i and j be the two-dimensional indices of the effective pixels within the transposed convolution window.
[0100] This is a coefficient related to the distance between the effective pixel (x0+i, y0+j) and the sampling point (m, n), and its specific value can be calculated according to the interpolation algorithm. This embodiment derives the convolution kernel parameters through convolution operations. At the current position of the transposed convolution window, it can be obtained from a... 2 An interpolation point is derived from each valid pixel, and the parameters of the convolution kernel are set to... After one iteration, the convolution kernel is moved (i.e., the transposed convolution window) to calculate the parameters of the convolution kernel for the next iteration. This allows the parameter values of other positions in the convolution kernel to be calculated until all convolution kernel parameters have been calculated.
[0101] Preferably, this embodiment uses bilinear interpolation, setting a=2, meaning that the current transposed convolution window contains a... 2 = 4 valid pixels, the coordinates of the interpolation point and the valid pixels are as follows Figure 5 As shown, where a 2 The pixel value of each valid pixel is (x) ij ,x ij+1 ,x i+1j ,x i+1j+1 Then, the interpolation calculation formula for any point inside the transposed convolution window is:
[0102] y m,n =ABx i,j +A(1-B)x i+1,j +(1-A)Bx i,j+1 +(1-A)(1-B)x i+1,j+1
[0103] Among them, y m,n This is the interpolation result, where A is the effective pixel value from the interpolation point to the bottom right corner. i+1j+1 The x-direction distance, B is the effective pixel point from the interpolation point to the lower right corner. i+1j+1 The y-direction distance. When using transposed convolution, image boundaries are padded with 0s. If the transposed convolution window includes the boundary padding points, then the condition a cannot be satisfied within the transposed convolution window. 2 The number of valid pixels is considered when calculating the convolution kernel parameters, taking into account the case without boundary padding points. The first transposed convolution window is as follows: Figure 6 As shown. Therefore, the convolution kernel parameters are deduced by reverse engineering the convolution operation, and the specific values are calculated as follows. Figure 7 As shown. First, the values of interpolation points m and n need to be calculated:
[0104] m = n = scale - 0.5
[0105] After determining the interpolation points m and n using the above formula, the pixel interpolation point y can be determined. m,n Then calculate the interpolation point to x. i+1j+1 Find the distances A and B, then calculate y. m,nThe four corresponding coefficients in the bilinear interpolation formula are used as convolution kernel parameters (AB, A(1-B), (1-A)B, (1-A)(1-B)). After one iteration, the convolution kernel is moved to calculate the parameters for the next iteration, and the parameter values at other positions in the convolution kernel can be calculated until all convolution kernel parameters have been calculated.
[0106] Step 4: Perform edge-padding operation on the proportionally scaled image according to the edge-padding length calculation formula to obtain the final scaled image with the target size.
[0107] Specifically, after obtaining the proportionally scaled image, other proportionally scaled images obtained in step 3 and processed by the convolutional upsampling unit or convolutional downsampling unit can be padded with edges using the edge padding length calculation formula:
[0108]
[0109] Among them, pad w pad is the required padding length in the x-direction. h The required side length in the y-direction, scale is the unstretched scaling factor, and net w For the width in the target size, net h The height of the target size, img w The width of the source image to be processed, img h Let pad be the height of the source image to be processed. w or pad h If the value is not 0, then fill the target size with 0 in the corresponding direction.
[0110] It should be noted that the image is three-channel. The proportionally scaled image processed by the convolutional upsampling unit or convolutional downsampling unit is then stitched together with the other two channels before the edge patching operation is performed.
[0111] Step 5: Input the final scaled image into the target detector for target detection and obtain the detection results.
[0112] Specifically, the network input size of the object detector is used as the target size of the image scaling module (including upsampling / downsampling and edge alignment operations). For example, the image from the video stream is used as the input to the image scaling module. Steps 1 to 4 obtain an image of the target size input to the object detector, thereby enabling the object detector to detect the target in the source image. Figure 8 As shown, this embodiment uses an image scaling module and an object detector to enable the object detector to accept input of arbitrary size, forming an end-to-end deep learning deployment model from image source file to inference result, thereby enabling the detection of objects.
[0113] For example, the target detector is Yolov5-s.
[0114] The object detection method provided in this invention can be applied to various platforms such as NPU, GPU, or TPU. This invention utilizes convolutional downsampling units / convolutional upsampling units to achieve image scaling without stretching. The convolutional downsampling units, convolutional upsampling units, and edge-padding operations used in this invention do not require a cumbersome model training process. They only use basic operators in the deep learning framework and can be directly added before the object detector, thereby eliminating the training process and improving the efficiency of object detection.
[0115] The image scaling method in the object detection method of this invention is based on convolution operations, which can fully utilize the high efficiency of convolution operations on artificial intelligence hardware platforms. Furthermore, this invention has strong versatility and can be added before most deep learning models (object detectors), eliminating the need for image preprocessing and thus greatly improving the efficiency of object detection.
[0116] In the description of the invention, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0117] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or feature data point described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or feature data points described may be combined in any suitable manner in one or more embodiments or examples. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.
[0118] The above description, in conjunction with specific preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various simple deductions or substitutions can be made without departing from the concept of the present invention, and all such modifications and substitutions should be considered within the scope of protection of the present invention.
Claims
1. A target detection method that utilizes convolution operations to accelerate image scaling, characterized in that, The target detection method includes: Step 1: Obtain the source image to be processed; Step 2: Determine the processing method of the source image to be processed based on the target size, so as to determine the unstretched scaling factor of the source image to be processed, wherein the processing method includes enlarging or reducing; Step 3: When the source image to be processed is reduced in size, the source image to be processed enters the convolution downsampling unit to obtain a proportionally scaled image; or, when the source image to be processed is enlarged in size, the source image to be processed enters the convolution upsampling unit to obtain a proportionally scaled image. Step 4: Perform edge-padding operation on the proportionally scaled image according to the edge-padding length calculation formula to obtain a final scaled image of the target size; the edge-padding length calculation formula is: Among them, pad w pad is the required padding length in the x-direction. h The required side length in the y-direction, scale is the unstretched scaling factor, and net w For the width in the target size, net h The height of the target size, img w The width of the source image to be processed, img h The height of the source image to be processed; Step 5: Input the final scaled image into the target detector for target detection and obtain the detection result.
2. The target detection method using convolution operations to accelerate image scaling according to claim 1, characterized in that, Step 2 includes: Step 2.1: Determine whether the source image to be processed should be reduced or enlarged based on the target size; Step 2.2: When the source image to be processed is reduced in size, the scaling factor without stretching is calculated using the reduction calculation formula; or, when the source image to be processed is enlarged in size, the scaling factor without stretching is calculated using the enlargement calculation formula.
3. The target detection method using convolution operations to accelerate image scaling according to claim 2, characterized in that, The shrinkage calculation formula is as follows: The amplification calculation formula is as follows: Where scale is the scaling factor without stretching, and net w For the width in the target size, net h The height of the target size, img w The width of the source image to be processed, img h The height of the source image to be processed.
4. The target detection method using convolution operations to accelerate image scaling according to claim 3, characterized in that, The size of the proportionally scaled image obtained by the source image to be processed entering the convolutional downsampling unit is expressed as: Among them, net w 'To scale the image width proportionally, net h ' represents the height of the image scaled proportionally, p is the number of zero-padding layers, k is the kernel size, s1 is the first step size, s1 = [scale], and [·] is for rounding down.
5. The target detection method using convolution operations to accelerate image scaling according to claim 3, characterized in that, When the source image to be processed is magnified, the source image to be processed enters the convolutional upsampling unit to obtain a proportionally scaled image, including: S1. Fill the surrounding area of the source image to be processed with kp-1 rows and 0 columns of pixels, and fill the effective pixels in the source image to be processed with s-1 rows and 0 columns of pixels, where k is the convolution kernel size, s is the stride, and p is the number of zero-padding layers. S2. First, symmetrically flip the convolution kernel along the vertical center line, and then flip it along the horizontal center line to obtain the flipped convolution kernel. Perform convolution operation based on the flipped convolution kernel to obtain the proportionally scaled image.
6. The target detection method using convolution operations to accelerate image scaling according to claim 5, characterized in that, The size of the proportionally scaled image obtained by the source image to be processed entering the convolutional upsampling unit is expressed as: net w '=(img w -1)×s2-2×p+k net h '=(img h -1)×s2-2×p+k Among them, net w 'To scale the image width proportionally, net h ' represents the height of the image scaled proportionally, p is the number of zero-padding layers, k is the kernel size, s2 is the second stride, s2 = 2·[scale] - [scale] mod 2, and [·] is rounded down.
7. The target detection method using convolution operations to accelerate image scaling according to claim 5, characterized in that, Before step S2, the following is also included: When calculating the current convolution kernel parameters, based on the interpolation formula, according to 'a' within the transposed convolution window... 2 The current convolution kernel parameters are obtained from the number of valid pixels and interpolation points; The transposed convolution window is moved in a preset direction, and the kernel parameters corresponding to the moved transposed convolution window are calculated until all kernel parameters are obtained.
8. The target detection method using convolution operations to accelerate image scaling according to claim 7, characterized in that, The interpolation formula is: Among them, y m,n The result is the interpolation result, and (m,n) are the interpolation points. This refers to the valid pixel point with coordinates (x0+i, y0+j). It is the coefficient related to the distance between the effective pixel (x0+i,y0+j) and the interpolation point (m,n), where (x0,y0) is the pixel coordinate point of the upper left corner of the transposed convolution window, and i and j are the two-dimensional indices of the effective pixels within the transposed convolution window.
Citation Information
Patent Citations
Large-scale image clustering method based on anchor twin graph automatic encoder
CN113920346A
Method and system for detecting position of a target area in a target subject
WO2020141468A1