Object detection method, device, medium and electronic device
By generating different numbers of a priori frames according to the size of the area occupied by the object in the image, the problem of large computational load of object detection in the existing technology is solved, lightweight object detection is achieved, and hardware requirements are reduced.
Patent Information
- Application Number
- CN202111115532.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-23
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2041-09-23
AI Technical Summary
When existing object detection methods perform object detection, they do not differentiate based on the size of the area occupied by the detected object in the image, resulting in the generation of a uniform number of a priori frames, which increases the computational complexity of object detection and requires a high hardware environment.
By performing feature extraction on the input image, feature maps for detecting the first object and the second object are obtained, and different numbers of a priori frames are generated according to the size of the area they occupy in the image, respectively for the first object and the second object. Generate fewer and more prior boxes to reduce the amount of object detection operations.
It realizes lightweight object detection, reduces the requirements on the hardware environment, reduces the computational load of object detection, and achieves more efficient detection results.
Smart Images

Figure CN113869298B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present disclosure relate to the field of image processing, and more specifically, embodiments of the present disclosure relate to an object detection method, device, medium, and electronic device. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the present disclosure as recited in the claims. No description herein is admitted to be related art by inclusion in this section.
[0003] Object detection refers to the use of theories and methods in the field of image processing to detect the objects in an image, determine the semantic categories of these objects, and the positions of the objects in the image. The objects can be any type of object set according to business requirements. For example, in a human body detection scenario, the objects can be human bodies. In a face detection scenario, the objects can be faces. In a vehicle detection scenario, the objects can be vehicles.
[0004] Usually, when performing object detection, it is necessary to first use the backbone network to extract the feature map corresponding to the input image, then generate a preset number of prior frames for each pixel in the extracted feature map, and then obtain the detection frame corresponding to the detected object based on these prior frames to complete object detection. The semantic category of the image of the area surrounded by the detection frame is the detected object, and the position of the detection frame is the position of the detected object. Summary of the invention
[0005] However, when performing object detection, these methods do not distinguish the detected objects according to the size of the area occupied by the detected objects in the image, and thus uniformly generate a preset number (for example, generally 9) prior boxes for the detected objects, resulting in a relatively large amount of object detection calculations.
[0006] Therefore, in related technologies, object detection requires large amounts of computation and places high demands on the hardware environment.
[0007] Therefore, an improved object detection method is highly needed to reduce the computational complexity of object detection, achieve the purpose of lightweight object detection, and realize low requirements on the hardware environment.
[0008] In this context, embodiments of the present disclosure are intended to provide an object detection method, apparatus, medium, and electronic device.
[0009] In a first aspect of the embodiments of the present disclosure, there is provided an object detection method, comprising:
[0010] Perform feature extraction on an input image to obtain a first feature map for detecting a first object and a second feature map for detecting a second object; wherein an area occupied by the first object in the input image is smaller than an area occupied by the second object in the input image; generate a first number of first priori boxes for at least part of the pixels included in the first feature map, and detect the first object based on the generated first priori boxes; generate a second number of second priori boxes for at least part of the pixels included in the second feature map, and detect the second object based on the generated second priori boxes; wherein the first number is smaller than the second number.
[0011] In some embodiments, the feature extraction of the input image to obtain the first feature map and the second feature map includes: downsampling the input image a preset number of times and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling; and obtaining the first feature map and the second feature map based on the sampling feature map obtained after each downsampling.
[0012] In some embodiments, obtaining the first feature map and the second feature map based on the sampling feature map obtained after each downsampling includes: determining the first sampling feature map of the first resolution based on the sampling feature map obtained after each downsampling as the first feature map, and determining the second sampling feature map of the second resolution as the second feature map; or, in the sampling feature map obtained after each downsampling, fusing the third sampling feature map of the third resolution with at least one sampling feature map with a lower resolution than the third sampling feature map to obtain the first feature map, and fusing the fourth sampling feature map of the fourth resolution with at least one sampling feature map with a lower resolution than the fourth sampling feature map to obtain the second feature map; or, in the sampling feature map obtained after each downsampling, fusing the fifth sampling feature map of the fifth resolution with at least one sampling feature map with a lower resolution than the fifth sampling feature map to obtain the second feature map, and fusing the sixth sampling feature map of the sixth resolution with the second feature map to obtain the first feature map; the fifth resolution is smaller than the sixth resolution.
[0013] In some embodiments, the first resolution is greater than the second resolution, and the third resolution is greater than the fourth resolution.
[0014] In some embodiments, a target priori box of the target quantity is generated for at least part of the pixels included in the target feature map, including: obtaining a first preset value and a second preset value corresponding to the target feature map; generating a side length of each target priori box based on the first preset value and the second preset value; based on the generated side length, generating a target priori box of the target quantity for at least part of the pixels included in the target feature map; wherein the target feature map includes a first feature map or a second feature map; when the target feature map is the first feature map, the target quantity is the first quantity, and the target prior box is the first prior box; when the target feature map is the second feature map, the target quantity is the second quantity, and the target prior box is the second prior box.
[0015] In some embodiments, when the target feature map is a first feature map, the first number is four, and the first prior frame includes a first square prior frame, a second square prior frame, and a first rectangular prior frame and a second rectangular prior frame with different side lengths, the first rectangular prior frame is a vertical frame, and the second rectangle is a horizontal frame.
[0016] In some embodiments, the first preset value is less than the second preset value; the side length of each target priori box is generated based on the first preset value and the second preset value, including: setting the side length of the first square prior box to the first preset value; setting the side length of the second square prior box to a value greater than the first preset value obtained by processing the first preset value and the second preset value; setting the width of the first rectangular prior box and the height of the second rectangular prior box to a value less than the target preset value obtained by processing the target preset value; setting the height of the first rectangular prior box and the width of the second rectangular prior box to a value greater than the target preset value obtained by processing the first preset value; wherein the target preset value includes the first preset value or the second preset value.
[0017] In some embodiments, when the target feature map is a second feature map, the second number is six, and the second prior frame includes a third square prior frame, a fourth square prior frame, a third rectangular prior frame, a fourth rectangular prior frame, a fifth rectangular prior frame and a sixth rectangular prior frame with different side lengths; wherein, the third rectangular prior frame and the fifth rectangle are vertical frames, and the width of the third rectangle is greater than the width of the fifth rectangle, and the height of the third rectangle is less than the height of the fifth rectangle; the fourth rectangle is a horizontal frame; the sixth rectangular prior frame is a horizontal frame, and the width of the fourth rectangle is less than the width of the sixth rectangle, and the height of the fourth rectangle is greater than the height of the sixth rectangle, or, the sixth rectangular prior frame is a vertical frame and matches the shape of the second object.
[0018] In some embodiments, the first preset value is less than the second preset value; the generating of the side length of each target a priori box based on the first preset value and the second preset value includes: setting the side length of the third square a priori box to the first preset value; setting the side length of the fourth square a priori box to a value greater than the first preset value obtained by processing the first preset value and the second preset value; setting the width of the third rectangular a priori box and the height of the fourth rectangular a priori box to a first result value less than the target preset value obtained by processing the target preset value; setting the height of the third rectangular a priori box and the width of the fourth rectangular a priori box to a value greater than the target preset value obtained by processing the first preset value. The second result value of the value; the width of the fifth rectangular priori box is set to a third result value less than the first result value obtained by processing the target preset value, and the height is set to a fourth result value greater than the second result value obtained by processing the target preset value; the height of the sixth rectangular priori box is set to the third result value, and the width is set to the fourth result value, or the width of the sixth rectangular priori box is determined to be a value between the first result value and the third result value obtained by processing the target preset value, and the height is determined to be a value between the second result value and the fourth result value obtained by processing the target preset value; wherein the target preset value includes the first preset value or the second preset value.
[0019] In some embodiments, based on the generated target prior frame, the target object is detected, including: adjusting the target prior frame to obtain a prediction frame; based on the classification result obtained by classifying the area image enclosed by the prediction frame in the target feature map, and a preset detection frame screening method, obtaining the detection frame of the target object to complete object detection; wherein the target prior frame includes a first prior frame or a second prior frame; when the target prior frame is the first prior frame, the target feature map is the first feature map, and the target object is the first object, and when the target prior frame is the second prior frame, the target feature map is the second feature map, and the target object is the second object.
[0020] In some embodiments, the regional image enclosed by the prediction box in the target feature map is classified to obtain a classification result, including: based on the target feature map and the prediction box, using a regional image extraction unit to obtain the regional image enclosed by the prediction box in the target feature map; classifying the regional image to obtain a classification result.
[0021] In some embodiments, the preset detection frame screening method includes a non-maximum suppression method.
[0022] In some embodiments, the method further includes: displaying a detection frame of the target object in the input image.
[0023] In some embodiments, the object detection is performed using an object detection network generated based on a neural network, wherein a training method for the object detection network includes: obtaining image samples; the image samples include object type annotation information and detection box annotation information for each first object and each second object in the image; using the image samples as input, and using the object detection network to detect each first object and each second object in the image sample; wherein the detection result includes object type prediction information and detection box prediction information for each first object and each second object; and adjusting network parameters of the object detection network based on the object type prediction information and the detection box prediction information, and the object type annotation information and the detection box annotation information.
[0024] In some embodiments, feature extraction is performed on image samples to obtain a first feature map and a second feature map, including: downsampling the input image samples a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted by each downsampling is the input of the next downsampling; based on the sampling feature map obtained after each downsampling, the first feature map and the second feature map are obtained; wherein the method for extracting the sampling feature map includes: downsampling the input image samples at least once to obtain an initial sampling feature map of a target resolution; obtaining weight information corresponding to the sampling feature map of the target resolution, the weight information being obtained based on a self-attention mechanism and indicating the degree of mutual influence between pixels in the initial sampling feature map; adjusting the initial sampling feature map based on the weight information to obtain an adjusted sampling feature map; wherein the target feature map includes a first feature map and a second feature map; when the target feature map is the first feature map, the target resolution is the first resolution, and when the target feature map is the second feature map, the target resolution is the second resolution.
[0025] In some embodiments, adjusting the initial sampling feature map based on the weight information to obtain an adjusted sampling feature map includes: adjusting the initial sampling feature map based on the weight information, and fusing it with the initial sampling feature map to obtain an adjusted sampling feature map.
[0026] In some embodiments, adjusting the network parameters of the object detection network according to the object type prediction information and the detection box prediction information, the object type labeling information and the detection box labeling information includes: taking the detection box prediction information and the detection box labeling information as function inputs, and obtaining first loss information based on a preset detection box loss function; taking the object type prediction information and the object type labeling information as function inputs, and obtaining second loss information based on a preset object type loss function; and adjusting the network parameters of the object detection network based on the first loss information and the second loss information.
[0027] In some embodiments, the first object is an object occupying an area smaller than an area threshold in the input image; the second object is an object occupying an area larger than the area threshold in the input image; the method further includes: setting the side lengths of the first prior box and the second prior box according to the area threshold.
[0028] In a second aspect of the embodiments of the present disclosure, an object detection device is provided, comprising: a feature extraction module, configured to perform feature extraction on an input image to obtain a first feature map for detecting a first object and a second feature map for detecting a second object; wherein an area occupied by the first object in the input image is smaller than an area occupied by the second object in the input image; a generation and detection module, configured to generate a first number of first priori boxes for at least part of the pixels included in the first feature map, and detect the first object based on the generated first priori boxes; and generate a second number of second prior boxes for at least part of the pixels included in the second feature map, and detect the second object based on the generated second priori boxes; wherein the first number is smaller than the second number.
[0029] In a third aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, wherein the medium stores a computer program, and the computer program is used to enable a processor to execute the object detection method as shown in any of the aforementioned embodiments.
[0030] In a fourth aspect of the embodiments of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing processor executable instructions; wherein the processor implements the object detection method as shown in any of the foregoing embodiments by running the executable instructions.
[0031] In the technical solution described above, two feature maps for detecting the first object and the second object are obtained by extracting features from the input image, and then different numbers of prior frames are generated for pixels in the two feature maps for object detection. Compared with the related technology that does not distinguish between the detected objects of different occupied areas and generates a uniform number of prior frames for object detection, a smaller number of prior frames can be generated based on the characteristic that the first object occupies a smaller area in the input image, thereby reducing the amount of object detection calculations and achieving the purpose of lightweight object detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] The foregoing and other objects, features and advantages of the exemplary embodiments of the present disclosure will become readily understood by reading the detailed description below with reference to the accompanying drawings. In the accompanying drawings, several embodiments of the present disclosure are shown in an exemplary and non-limiting manner, in which:
[0033] Figure 1 A schematic diagram of an application scenario of object detection shown in an embodiment of the present disclosure;
[0034] Figure 2 A method flow chart of an object detection method shown in an embodiment of the present disclosure;
[0035] Figure 3 A schematic diagram of a feature extraction method flow chart shown in an embodiment of the present disclosure;
[0036] Figure 4 A schematic diagram of a method for generating a priori frames according to an embodiment of the present disclosure;
[0037] Figure 5 A schematic diagram of a method for generating a priori frame side length according to an embodiment of the present disclosure;
[0038] Figure 6a A second a priori block diagram is shown in an embodiment of the present disclosure;
[0039] Figure 6b A second a priori block diagram is shown in an embodiment of the present disclosure;
[0040] Figure 7 A schematic diagram of a method for generating a priori frame side length according to an embodiment of the present disclosure;
[0041] Figure 8 A schematic diagram of a method for detecting a target object based on a priori frame according to an embodiment of the present disclosure;
[0042] Fig. 9 A flowchart of an object detection network training method according to an embodiment of the present disclosure is shown;
[0043] Fig.10A schematic diagram of a flow chart of a network parameter adjustment method according to an embodiment of the present disclosure;
[0044] Fig.11 A schematic diagram of a method for extracting a sampling feature graph according to an embodiment of the present disclosure;
[0045] Fig.12 A schematic diagram of a feature extraction network structure based on self-attention shown in an embodiment of the present disclosure;
[0046] Fig.13 A schematic diagram of a human body detection network structure shown in an embodiment of the present disclosure;
[0047] Fig.14 A schematic diagram of the structure of an object detection device shown in an embodiment of the present disclosure;
[0048] Fig.15 A program product applied to an object detection method shown in an embodiment of the present disclosure;
[0049] Fig.16 The present invention is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention.
[0050] In the drawings, the same or corresponding reference numerals represent the same or corresponding parts. DETAILED DESCRIPTION
[0051] The principles and spirit of the present disclosure will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present disclosure, and are not intended to limit the scope of the present disclosure in any way. On the contrary, these embodiments are provided to make the present disclosure more thorough and complete, and to fully convey the scope of the present disclosure to those skilled in the art.
[0052] Those skilled in the art will appreciate that the embodiments of the present disclosure may be implemented as a system, device, apparatus, method or computer program product. Therefore, the present disclosure may be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software.
[0053] In addition, any number of elements in the drawings is for illustration and not limitation, and any naming is only for distinction and does not have any limiting meaning.
[0054] According to an embodiment of the present disclosure, an object detection method, medium, device and electronic device are proposed.
[0055] In this document, it is to be understood that the terms involved are as follows.
[0056] Deep learning uses deep neural networks to discover high-level and / or low-level features of data to more accurately characterize the characteristics of data distribution.
[0057] Feature extraction refers to the process of extracting image features using image processing technology. The main purpose of feature extraction is dimensionality reduction. The main idea of feature extraction is to project features in high-dimensional feature space into low-dimensional feature space to obtain low-dimensional features that are easy to distinguish. These image features can include intuitive features, grayscale statistical features, transformation coefficient features, algebraic features, etc.
[0058] A feature map is a map containing image features obtained after feature extraction of an input image. A feature map can be composed of multiple pixels.
[0059] The prior frame refers to the bounding box that is initially generated for the pixels in the feature map according to the prior frame generation strategy. In the object detection algorithm, the prediction frame can be obtained by fine-tuning the prior frame. By semantically classifying the image of the area surrounded by the prediction frame, the prediction frame that surrounds the detected object can be found. Then, the detection frame screening method can be used to determine the detection frame corresponding to the detected object from the found prediction frame.
[0060] The self-attention mechanism is a variant of the attention mechanism. It reduces dependence on external information and is better at capturing the internal correlation of data or features. In the image field, the self-attention mechanism learns the degree of mutual influence between a certain pixel and pixels at all other positions (including farther positions).
[0061] The principle and spirit of the present disclosure are explained in detail below with reference to several representative embodiments of the present disclosure. SUMMARY OF THE INVENTION
[0063] On the one hand, the inventors found that the method of implementing object detection based on the prior frame can well detect the detected object in the input image. Therefore, the present disclosure still implements object detection based on the prior frame.
[0064] On the other hand, the inventors found that if the detected objects are distinguished according to the size of the area occupied by the detected objects in the image, and a smaller number of prior frames are generated for the first object with a smaller occupied area, the amount of object detection calculation can be reduced, thereby achieving the purpose of lightweight object detection.
[0065] Therefore, the inventors considered that in the object detection stage, a first feature map for detecting the first object and a second feature map for detecting the second object can be extracted, and then a smaller number of prior frames can be generated for the pixels in the first feature map to detect the first object. Based on the characteristic that the first object occupies a smaller area in the input image, a smaller number of prior frames can be generated to reduce the amount of object detection calculations and achieve the purpose of lightweight object detection.
[0066] After introducing the basic principles of the present disclosure, various non-limiting embodiments of the present disclosure are described in detail below.
[0067] Application Scenario Overview
[0068] Please refer to Figure 1 , Figure 1 A schematic diagram of an application scenario of object detection shown in an embodiment of the present disclosure.
[0069] like Figure 1 As shown, schematically, the aforementioned application scenarios may include terminal devices such as computers 1021, mobile phones 1022, tablet computers 1023, etc., and these terminal devices may be equipped with object detection logic. The present disclosure does not limit the device type of the terminal device.
[0070] Schematically, the aforementioned terminal device can collect the input image 101 through image acquisition, image downloading, image transmission, etc., and perform object detection processing on the collected input image 101 to obtain the object detection result 103.
[0071] For example, in a live broadcast scenario, these terminal devices can capture images in real time through the onboard cameras, and perform face or body detection on the captured images to detect faces or bodies in the captured images.
[0072] These terminal devices can perform feature extraction on the input image, extract a first feature map for detecting the first object and a second feature map for detecting the second object, and then generate a smaller number of prior frames for the pixels in the first feature map to detect the first object. Based on the characteristic that the first object occupies a smaller area in the input image, a smaller number of prior frames can be generated to reduce the amount of object detection calculations and achieve the purpose of lightweight object detection.
[0073] Exemplary Methods
[0074] See also Figure 2 , Figure 2 A method flow chart of an object detection method shown in an embodiment of the present disclosure.
[0075] Figure 2The object detection method shown can be applied to an electronic device. The electronic device can execute the method by carrying software logic corresponding to the object detection method. The type of the electronic device can be a laptop, a computer, a mobile phone, a PDA (Personal Digital Assistant, PDA), etc. The type of the electronic device is not particularly limited in the present disclosure. The electronic device can also be a user-end device or a server-end device, which is not particularly limited here.
[0076] like Figure 2 As shown, the object detection method may include S202-S206. Unless otherwise specified, the present disclosure does not particularly limit the execution order of these steps.
[0077] In S202, feature extraction is performed on the input image to obtain a first feature map for detecting a first object and a second feature map for detecting a second object; wherein an area occupied by the first object in the input image is smaller than an area occupied by the second object in the input image.
[0078] The input image may be an image acquired by any collection method. For example, the input image may be an image collected by image acquisition, image downloading, image transmission, etc. These input images may include detected objects. The detected object may be set according to business requirements. For example, in a human body detection scenario, the detected object may be a human body. In a face detection scenario, the detected object may be a face. In a vehicle detection scenario, the detected object may be a vehicle.
[0079] In some embodiments, the input image may be an image obtained by scaling the acquired image, thereby controlling the computational complexity of the object detection algorithm. For example, the resolution of the image acquired by the camera may be 1080*1080. In order to control the computational complexity of the object detection algorithm, the acquired object may be scaled down to obtain a 256*256 input image.
[0080] The first object and the second object refer to the detected objects in the input image. The area occupied by the first object in the input image is smaller than the area occupied by the second object in the input image. That is, the first object is an object with a smaller area, and the second object is an object with a larger area.
[0081] In some embodiments, the first object is an object occupying an area smaller than an area threshold in the input image; and the second object is an object occupying an area larger than the area threshold in the input image.
[0082] The region threshold may be a region area threshold or a region proportion threshold. If the region threshold is a preset area threshold, the first object and the second object may be distinguished based on whether their region areas in the input image reach the area threshold. If the region threshold is a region proportion threshold, the first object and the second object may be distinguished based on whether their region proportions in the input image reach the region proportion threshold.
[0083] In some embodiments, the side lengths of the first a priori box and the second a priori box can be set according to the area threshold, so that the set first a priori box better surrounds the first object and the second a priori box better surrounds the second object, thereby improving the efficiency of subsequent object detection.
[0084] In S202, a feature extraction network generated based on a neural network may be used to extract features from the input image.
[0085] The feature extraction network may be a part of the object detection network used for object detection in the present disclosure. When training the object detection network, the training of the feature extraction network parameters may be completed at the same time. The steps for training the object detection network are described in detail in the subsequent embodiments of the present disclosure and are not described in detail here.
[0086] In some embodiments, the feature extraction network may be a network generated based on a convolutional network or a fully convolutional network. Feature extraction can be completed by performing convolution processing, pooling processing, etc. on the input image.
[0087] It should be noted that in order to further lighten the object detection algorithm in the present disclosure, a lightweight feature extraction method may be used. The lightweight feature extraction method is described in detail in the subsequent embodiments of the present disclosure and will not be described in detail here.
[0088] S204: Generate a first number of first a priori boxes for at least part of the pixels included in the first feature map, and detect the first object based on the generated first a priori boxes.
[0089] S206: Generate a second number of second prior frames for at least part of the pixels included in the second feature map, and detect the second object based on the generated second prior frames; wherein the first number is smaller than the second number.
[0090] The first number and the second number are preset numbers. The second number can be a conventional priori box number set in a conventional object detection algorithm such as FAST-RCNN (Fast Region Convolutional Neural Networks) or FASTER-RCNN (Faster Region Convolutional Neural Networks). The first number can be a number less than the conventional priori box number. Thus, different prior box numbers can be configured according to the area size of the detected object.
[0091] In S204 or S206, a target priori frame with a preset side length of the target number can be generated for each pixel in the target feature map, and a prediction frame can be obtained by fine-tuning the target priori frame. By semantically classifying the image of the area surrounded by the prediction frame, a prediction frame surrounding the target object can be found. Then, using the detection frame screening method, the detection frame corresponding to the target object can be determined from the found prediction frame to complete the detection of the target object.
[0092] Among them, the target feature map includes a first feature map or a second feature map; when the target feature map is the first feature map, the number of targets is the first number, the target prior box is the first prior box; the target object is the first object; when the target feature map is the second feature map, the number of targets is the second number, the target prior box is the second prior box, and the target object is the second object.
[0093] In the scheme recorded in S202-S206, two feature maps for detecting the first object and the second object are obtained by extracting features from the input image, and then different numbers of prior frames are generated for pixels in the two feature maps for object detection. Compared with the related technology that does not distinguish between the detected objects of different occupied areas and generates a uniform number of prior frames for object detection, a smaller number of prior frames can be generated based on the characteristic that the first object occupies a smaller area in the input image, thereby reducing the amount of object detection calculations and achieving the purpose of lightweight object detection.
[0094] The present disclosure also proposes an object detection method. The execution steps of the method can be referred to S202-S206. The steps of S202 and S206 are not described repeatedly below.
[0095] When executing S202, the complexity of the feature extraction network can be limited by limiting the number of downsampling times, thereby lightweighting the feature extraction method, further lightweighting the object detection method, and reducing the dependence of object detection on hardware.
[0096] See also Figure 3, Figure 3 A flow chart of a feature extraction method shown in an embodiment of the present disclosure. Figure 3 The illustrated method is a supplementary explanation of S202. Figure 3 As shown, executing S202 may execute S302 to S304. Unless otherwise specified, the present disclosure does not specifically limit the execution order of these steps.
[0097] In S302, the input image is downsampled a preset number of times, and a sampling feature map is obtained after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling.
[0098] The downsampling refers to the process of reducing the image and extracting features. In some embodiments, downsampling may include operations such as convolution and pooling. In some embodiments, downsampling can be performed by a downsampling layer (e.g., various types of convolution layers and pooling layers) included in the feature extraction network. The present disclosure does not limit the specific type of downsampling layer. For example, in order to improve the object detection effect, a depth-separable convolution layer, a normalization layer, etc. with slightly more complex results may be used. Of course, in order to lightweight feature extraction, the number of these complex downsampling layers may be limited.
[0099] The preset number is related to the number of downsampling layers included in the feature extraction network. Limiting the preset number to a relatively small number (e.g., 7, 8, 9, etc.) can limit the number of downsampling layers, thereby limiting the number of parameters included in the feature extraction network, reducing the amount of feature extraction operations, and further reducing the amount of object detection operations, thereby lightweighting object detection.
[0100] For example, if the input image needs to be downsampled 7 times, the feature extraction network may include 7 convolutional layers and pooling layers, thereby limiting the complexity of the feature extraction network and further lightweighting object detection.
[0101] In some embodiments, the image of the target resolution can be obtained by designing the parameters of the downsampling layer. For example, the resolution of the input image is 256*256, and the goal is to obtain sampling feature maps of seven resolution scales of 128*128, 64*64, 32*32, 16*16, 8*8, 4*4, and 2*2. The sampling feature maps of the seven resolution scales can be obtained by setting the parameters of the seven downsampling layers included in the feature extraction network so that each downsampling layer can reduce the input image by half.
[0102] S304: Obtain a first feature map and a second feature map based on the sampling feature map obtained after each downsampling.
[0103] In S304, two groups of sampling feature maps may be selected from the sampling feature maps obtained in S302 to obtain the first feature map and the second feature map.
[0104] In the feature extraction method shown in S302-S304, the number of downsampling times in the feature extraction process can be limited to limit the number of parameters of the feature extraction network, reduce the network scale, and thus reduce the amount of object detection calculations and lightweight object detection.
[0105] In some embodiments, at least three methods shown below may be used in S304.
[0106] Method 1: Determine the first sampling feature map of the first resolution among the sampling feature maps obtained after each downsampling as the first feature map, and determine the second sampling feature map of the second resolution as the second feature map.
[0107] The first resolution and the second resolution are preset resolutions according to business requirements. For example, the first resolution can be preset to 32*32 and the second resolution can be preset to 8*8. Assume that sampling feature maps with seven resolution scales of 128*128, 64*64, 32*32, 16*16, 8*8, 4*4, and 2*2 can be obtained through S302. Sampling feature maps with resolutions of 32*32 and 8*8 can be selected as the first feature map and the second feature map, respectively.
[0108] Through the first method, the sampling feature map obtained after downsampling the input image can be used as a feature map for object detection, which is beneficial for object detection.
[0109] In a second method, in the sampling feature map obtained after each downsampling, a third sampling feature map with a third resolution and at least one sampling feature map with a lower resolution than the third sampling feature map are fused to obtain the first feature map, and
[0110] The fourth sampling feature map of the fourth resolution is merged with at least one sampling feature map with a lower resolution than the fourth sampling feature map to obtain the second feature map.
[0111] The third resolution and the fourth resolution are preset resolutions according to business requirements.
[0112] In order to reduce the amount of computation, only one low-resolution sampling feature map can be selected for fusion processing.
[0113] For example, the third resolution can be pre-set to 32*32 and the fourth resolution can be pre-set to 8*8. Assume that through S302, sampling feature maps with seven resolution scales of 128*128, 64*64, 32*32, 16*16, 8*8, 4*4, and 2*2 can be obtained. From them, sampling feature maps of 32*32 and 16*16 can be selected, and then the sampling feature map of 16*16 is upsampled (for example, interpolated, or deconvolved) to a size of 32*32, and then fused with the sampling feature map of 32*32 to obtain the first feature map. You can also select sampling feature maps of 8*8 and 4*4, and then perform the aforementioned fusion step to obtain the second feature map.
[0114] The fusion refers to the process of fusing the feature maps of different sizes and resolutions obtained by downsampling the input image. Low-level features have higher resolution and contain more position and detail information, but because they have passed fewer convolutions, they have more noise. High-level features have stronger semantic information, but their resolution is very low and their perception of details is poor. Efficiently fusing the two can improve the features contained in the image, thereby improving the object detection effect.
[0115] The image fusion in the present disclosure may adopt the method described in the related art. For example, the fusion may include superimposing or splicing two images, and then performing 1*1 convolution.
[0116] Through the second method, the high-resolution and low-resolution feature maps can be fused, and more features useful for object detection can be aggregated in the first feature map and the second feature map, thereby increasing the feature information contained in the feature map and improving the object detection effect.
[0117] Mode three, in the sampling feature map obtained after each downsampling, a fifth sampling feature map with a fifth resolution and at least one sampling feature map with a lower resolution than the fifth sampling feature map are merged to obtain the second feature map, and,
[0118] The sixth sampling feature map of the sixth resolution is fused with the second feature map to obtain the first feature map; the fifth resolution is smaller than the sixth resolution.
[0119] The fifth resolution and the sixth resolution are preset resolutions according to business requirements. The fifth resolution is smaller than the sixth resolution.
[0120] In order to reduce the amount of calculation, only one low-resolution sampling feature map can be selected for fusion processing to obtain a second feature map.
[0121] For example, the fifth resolution can be pre-set to 16*16 and the sixth resolution can be pre-set to 32*32. Assume that through S302, sampling feature maps with seven resolution scales of 128*128, 64*64, 32*32, 16*16, 8*8, 4*4, and 2*2 can be obtained. From them, sampling feature maps of 16*16 and 8*8 can be selected, and then the 8*8 sampling feature map is upsampled (for example, interpolated, or deconvolved) to a size of 16*16, and then fused with the 16*16 sampling feature map to obtain a second feature map. Then the second feature map can be upsampled to a size of 32*32, and then further fused with the 32*32 sampling feature map to obtain the first feature map.
[0122] Through the method of method three, the feature information contained in the first feature map can be further expanded, thereby further improving the object detection effect.
[0123] In some embodiments, the first resolution is greater than the second resolution, and the third resolution is greater than the fourth resolution, that is, the resolution of the extracted first feature map is greater than the resolution of the second feature map.
[0124] By using a first feature map with a relatively large resolution to detect a first object occupying a small area, and using a second feature map with a relatively small resolution to detect a second object occupying a large area, the characteristic of a feature map with a relatively large resolution containing more position and detail information can be utilized to improve the detection effect of the first object.
[0125] The present disclosure also proposes an object detection method. The execution steps of the method can be referred to S202-S206. The steps of S202 and S206 are not described repeatedly below.
[0126] Among them, when executing the steps of generating a priori frames in S204 and S206, the preset numerical values can be used to generate the side length of each priori frame, and then the priori frame is generated for the pixels in the feature map based on the side length. Thus, the size of the priori frame can be adjusted by configuring the preset numerical values, so that the generated priori frame is more consistent with the detected object.
[0127] See also Figure 4 , Figure 4 The present invention is a flowchart of a method for generating a priori frames according to an embodiment of the present invention. Figure 4 The illustrated method is a supplementary explanation of the steps of generating the priori frame in S204 and S206. Figure 4 As shown, S402-S406 may be executed. Unless otherwise specified, the present disclosure does not specifically limit the execution order of these steps.
[0128] It should be noted that, in order to simplify the description of the embodiment, the first feature map or the second feature map is referred to as the target feature map. That is, the target feature map includes the first feature map or the second feature map; when the target feature map is the first feature map, the target number is the first number, and the target a priori box is the first a priori box; when the target feature map is the second feature map, the target number is the second number, and the target a priori box is the second a priori box.
[0129] S402, obtaining a first preset value and a second preset value corresponding to the target feature map.
[0130] The first preset value and the second preset value are used to generate the side length of the priori box. These two values can be set according to business requirements.
[0131] In some embodiments, the two preset values can be set according to the aforementioned area threshold for distinguishing the first object from the second object. For example, the first preset value can be less than or equal to the aforementioned area threshold, and the second preset value can be greater than the aforementioned area threshold. This can make the generated priori box more suitable for distinguishing the detected object.
[0132] It should be noted that, since the first object and the second object have different sizes, the sizes of the generated priori boxes are also different. In order to achieve this goal, the present disclosure presets different first preset values and second preset values for the first feature map and the second feature map, respectively. In S402, the corresponding first preset value and second preset value can be obtained according to the type of the feature map.
[0133] S404: Generate a side length of each target priori box based on the first preset value and the second preset value.
[0134] Each target a priori box refers to each a priori box generated for a pixel point in the feature map. For example, 9 a priori boxes are generated for a pixel point in the second feature map, and each target a priori box refers to each a priori box in the 9 a priori boxes.
[0135] In some embodiments, some side length generation rules can be set for each target a priori box to perform some mathematical operations on the first preset value and the second preset value to obtain the side length of each target a priori box. It is understandable that when the a priori box is a square, the side length can refer to any side length of the a priori box. When the a priori box is a rectangle, the side length can refer to the width and height of the a priori box. Other embodiments will be described in detail for S404 later. It will not be described in detail here.
[0136] S406: Based on the generated side length, generate a target priori box of the number of targets for at least part of the pixels included in the target feature map.
[0137] In S406, for each pixel point of the target feature map, each pixel point can be used as the center point of the priori box, and each target priori box can be generated based on the side length of each target priori box, so as to generate the target number of target prior boxes for each pixel point of the target feature map.
[0138] In the prior frame generation method recorded in S402-S404, the size of the prior frame can be adjusted by configuring a preset numerical value, so that the generated prior frame is more consistent with the detected object.
[0139] The following describes in detail the method for generating the side length of the priori box when the target feature map is the first feature map and the second feature map.
[0140] In some embodiments, when the target feature map is the first feature map, the first number is four, and the first prior frame includes a first square prior frame, a second square prior frame, and a first rectangular prior frame and a second rectangular prior frame with different side lengths. The first rectangular prior frame is a vertical frame, and the second rectangle is a horizontal frame. By setting four first prior frames with different side lengths and shapes for the pixels in the first feature map, it is possible to ensure that the amount of calculation is not small while trying to make the first prior frame cover the area shape of the first object, thereby improving the object detection effect.
[0141] See also Figure 5 , Figure 5 The present invention is a flowchart of a method for generating a priori frame side length according to an embodiment of the present invention. Figure 5 The illustrated method is a detailed description of the method for generating the side length of the first priori box in S404. Figure 5 As shown, the method may include S501-S504. Unless otherwise specified, the present disclosure does not particularly limit the execution order of these steps. In this example, the first preset value is less than the second preset value. In order to simplify the description, the first preset value is denoted as a1 and the second preset value is denoted as a2.
[0142] S501: Set the side length of the first square priori box to the first preset value.
[0143] In this step, the side length of the first square priori frame may be set to a1.
[0144] S502: Set the side length of the second square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value.
[0145] S503: Set the width of the first rectangular priori frame and the height of the second rectangular priori frame to values smaller than the target preset value obtained by processing the target preset value.
[0146] S504, setting the height of the first rectangular priori box and the width of the second rectangular priori box to values obtained by processing the first preset value and greater than the target preset value; wherein the target preset value includes the first preset value or the second preset value.
[0147] The processing in S502-S504 can be understood as mathematical operations. Any mathematical operation method that can achieve the purpose of the operation is within the scope of protection of the present disclosure. For example, in S502, the method of finding the average value of a1 and a2 or the method of finding the square root of the product of a1 and a2 can be used to obtain a value greater than the a1 as the side of the second square priori box. In S503, a1 divided by b (b is greater than 1) can be obtained to obtain a value less than a1, which is used as the width of the first rectangular priori box and the height of the second rectangular priori box. In S504, a1 multiplied by b can be obtained to obtain a value greater than a1, which is used as the height of the first rectangular priori box and the width of the second rectangular priori box. That is, the side length of the first square priori box is a1. The area of the second square priori box is greater than the area of the first square priori box, and the side length is (a1+a2) / 2 or The (width, height) of the first rectangular priori box is (a1 / b, a1*b). The (width, height) of the second rectangular priori box is (a1*b, a1 / b).
[0148] Through S501-S504, two square first a priori frames and two rectangular first a priori frames with different side lengths can be obtained, thereby ensuring that the amount of calculation is not small while making the first a priori frame cover the area shape of the first object as much as possible, thereby improving the object detection effect.
[0149] In some embodiments, when the target feature map is a second feature map, the second number is six, and the second a priori frame includes a third square a priori frame, a fourth square a priori frame, a third rectangular a priori frame, a fourth rectangular a priori frame, a fifth rectangular a priori frame, and a sixth rectangular a priori frame with different side lengths; wherein the third rectangular a priori frame and the fifth rectangle are vertical frames, and the width of the third rectangle is greater than the width of the fifth rectangle, and the height of the third rectangle is less than the height of the fifth rectangle; the fourth rectangle is a horizontal frame. The sixth rectangular a priori frame is a horizontal frame, and the width of the fourth rectangle is less than the width of the sixth rectangle, and the height of the fourth rectangle is greater than the height of the sixth rectangle, or the sixth rectangular a priori frame is a vertical frame and matches the shape of the second object.
[0150] It should be noted that the above includes at least two solutions according to different ways of determining the height and width of the sixth rectangular priori box.
[0151] First, the sixth rectangular priori frame is a horizontal frame, and the width of the fourth rectangle is smaller than the width of the sixth rectangle, and the height of the fourth rectangle is greater than the height of the sixth rectangle.
[0152] See also Figure 6a , Figure 6a A second priori block diagram is shown in an embodiment of the present disclosure. Figure 6a This is a schematic diagram of a second priori box generated by using one of the recorded schemes for any pixel point in the second feature map.
[0153] like Figure 6a As shown, the second a priori frame includes a third square a priori frame 1, a fourth square a priori frame 2, a third rectangular a priori frame 3, a fourth rectangular a priori frame 4, a fifth rectangular a priori frame 5, and a sixth rectangular a priori frame 6. Among them, the width of frame 3 is greater than the width of frame 5, and the height of frame 3 is less than the height of frame 5. The width of frame 4 is less than the width of frame 6, and the height of frame 4 is greater than the height of frame 6.
[0154] Therefore, by setting six second priori boxes with different side lengths and shapes for the pixels in the second feature map, it is possible to ensure that the amount of calculation is not small while making the second prior box cover the area shape of the second object as much as possible, thereby improving the object detection effect.
[0155] Secondly, the sixth rectangular priori frame is a vertical frame and matches the shape of the second object.
[0156] Please continue to see Figure 6a The sixth rectangular priori box 6 has a size that is too wide on the wide side and too high on the high side. Since there are usually few objects to be detected with such a long and narrow shape, the object detection operation involving the priori box 6 is usually meaningless, resulting in a waste of computing resources.
[0157] In order to solve the above problems. In the second recorded solution, the height of the sixth rectangular prior frame is made greater than its width, so that the sixth rectangle is a vertical frame, which is no longer long and narrow, and better matches the shape of the area occupied by the second object being detected in the image, avoiding meaningless calculations caused by unreasonable prior frame shapes, thereby improving object detection effects.
[0158] In some embodiments, the width of the sixth rectangular a priori frame may be greater than the width of the third rectangular a priori frame, and the height may be greater than the height of the third rectangular a priori frame. In this way, a vertical frame larger than the third rectangular a priori frame can be obtained, which is no longer narrow and long, and better matches the shape of the area occupied by the second object being detected in the image, avoiding meaningless calculations caused by unreasonable a priori frame shapes, thereby improving object detection effects.
[0159] In some embodiments, the height of the sixth rectangular priori frame may be between the widths of the third rectangular priori frame and the fifth rectangular priori frame, and the width of the sixth rectangular priori frame may be between the heights of the third rectangular priori frame and the fifth rectangular priori frame, so that the size of the sixth rectangular priori frame is between the third rectangular priori frame and the fifth rectangular priori frame, and is no longer narrow and long, and better matches the shape of the area occupied by the second object being detected in the image, avoiding meaningless calculations caused by unreasonable priori frame shapes, thereby improving object detection effects. See Figure 6b , Figure 6b A second priori block diagram is shown in an embodiment of the present disclosure. Figure 6b This is a schematic diagram of a second priori box generated by using the second recorded solution for any pixel point in the second feature map.
[0160] like Figure 6b As shown, the second a priori frame includes a third square a priori frame 1 , a fourth square a priori frame 2 , a third rectangular a priori frame 3 , a fourth rectangular a priori frame 4 , a fifth rectangular a priori frame 5 , and a sixth rectangular a priori frame 6 .
[0161] Figure 6b In the figure, the height of the sixth rectangular prior frame 6 is between the height of frame 3 and the height of frame 5, and the width is between the width of frame 3 and the width of frame 5, so that the shape of frame 6 is no longer narrow and long, and better matches the regional shape of the second object, avoiding meaningless calculations caused by unreasonable prior frame shapes, thereby improving object detection effects.
[0162] See also Figure 7 , Figure 7 The present invention is a flowchart of a method for generating a priori frame side length according to an embodiment of the present invention. Figure 7 The illustrated method is a detailed description of the method for generating the side length of the second priori frame in S404. Figure 7 As shown, the method may include S701-S706. Unless otherwise specified, the present disclosure does not particularly limit the execution order of these steps. In this example, the first preset value is less than the second preset value. In order to simplify the description, the first preset value is denoted as c1 and the second preset value is denoted as c2.
[0163] S701: Set the side length of the third square priori box to the first preset value.
[0164] In this step, the side length of the third square priori box may be set to c1.
[0165] S702: Set the side length of the fourth square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value.
[0166] S703: Set the width of the third rectangular priori frame and the height of the fourth rectangular priori frame to first result values that are smaller than the target preset value and are obtained after processing the target preset value.
[0167] S704: Set the height of the third rectangular priori frame and the width of the fourth rectangular priori frame to a second result value obtained by processing the first preset value and greater than the target preset value.
[0168] S705, setting the width of the fifth rectangular priori frame to a third result value obtained by processing the target preset value, which is smaller than the first result value, and setting the height to a fourth result value obtained by processing the target preset value, which is larger than the second result value.
[0169] S706, setting the height of the sixth rectangular prior box to the third result value, and the width to the fourth result value, or, determining the width of the sixth rectangular prior box to be a value between the first result value and the third result value obtained by processing the target preset value, and determining the height to be a value between the second result value and the fourth result value obtained by processing the target preset value; wherein the target preset value includes the first preset value or the second preset value.
[0170] The processing in S702-S706 can be understood as mathematical operations. Any mathematical operation method that can achieve the purpose of the operation is within the scope of protection of the present disclosure. For example, in S702, the method of finding the average value of c1 and c2 or the method of finding the square root of the product of c1 and c2 can be used to obtain a value greater than the c1 as the side length of the fourth square a priori box. In S703, c1 can be divided by d (d is greater than 1) to obtain a value less than c1, which is used as the width of the third rectangular a priori box and the height of the fourth rectangular a priori box. In S704, c1 can be multiplied by d to obtain a value greater than c1, which is used as the width of the third rectangular a priori box and the fourth rectangular a priori box. In S705, c1 can be divided by e (e is greater than d) to obtain a value smaller than the value obtained in S703, which is used as the width of the fifth rectangular a priori box, and c1 can be multiplied by e to obtain a value larger than the value obtained in S704, which is used as the height of the fifth rectangular a priori box.
[0171] S706 may include two solutions. In one solution of S706, the height of the sixth rectangular priori frame may be set to c1 divided by e, and the width may be set to c1 multiplied by e.
[0172] That is, the side length of the third square a priori box is c1. The area of the fourth square a priori box is larger than the area of the third square a priori box, and the side length is (c1+c2) / 2 or The (width, height) of the third rectangular priori box is (c1 / d, c1*d). The (width, height) of the fourth rectangular priori box is (c1*d, c1 / d). The (width, height) of the fifth rectangular priori box is (c1 / e, c1*e). The (width, height) of the sixth rectangular priori box is (c1*e, c1 / e).
[0173] Through S701-S706, two square second priori boxes with different side lengths and four rectangular second priori boxes can be obtained, thereby ensuring that the amount of calculation is not small while making the second priori box cover the area shape of the second object as much as possible, thereby improving the object detection effect.
[0174] In another solution included in S706, the width of the sixth rectangular priori frame may be set to c1 divided by f (f is greater than d and less than e), and the height may be set to c1 multiplied by f.
[0175] That is, the side length of the third square a priori box is c1. The area of the fourth square a priori box is larger than the area of the third square a priori box, and the side length is (c1+c2) / 2 or The (width, height) of the third rectangular priori box is (c1 / d, c1*d). The (width, height) of the fourth rectangular priori box is (c1*d, c1 / d). The (width, height) of the fifth rectangular priori box is (c1 / e, c1*e). The (width, height) of the sixth rectangular priori box is (c1 / f, c1*f).
[0176] Through S701-S706, the size of the sixth rectangular prior frame can be made between the third rectangular prior frame and the fifth rectangular prior frame, so that it is no longer long and narrow, and more closely matches the shape of the area occupied by the detected object in the image captured in the preset scene, thereby avoiding meaningless calculations due to unreasonable prior frame shapes, thereby improving object detection effects.
[0177] The present disclosure also proposes an object detection method. The execution steps of the method can be referred to S202-S206. The steps of S202 and S206 are not described repeatedly below.
[0178] When executing the steps of detecting the target object based on the prior frame in S204 and S206 , the detection frame of the target object can be obtained by using the method of semantic classification and detection frame screening, so as to complete the object detection.
[0179] See also Figure 8 , Figure 8 The present invention is a flowchart of a method for detecting a target object based on a priori boxes according to an embodiment of the present invention. Figure 8 The illustrated method is a supplementary explanation of the steps of detecting the target object based on the prior frame in S204 and S206. Figure 8As shown, S802-S804 may be executed. Unless otherwise specified, the present disclosure does not specifically limit the execution order of these steps.
[0180] It should be noted that, in order to simplify the description of the embodiment, the first a priori frame or the second a priori frame is referred to as the target a priori frame. That is, the target a priori frame includes the first a priori frame or the second a priori frame; when the target a priori frame is the first a priori frame, the target feature map is the first feature map, and the target object is the first object; when the target a priori frame is the second a priori frame, the target feature map is the second feature map, and the target object is the second object.
[0181] S802, adjusting the target priori box to obtain a predicted box.
[0182] In S802, the target prior frame may be adjusted by referring to a method for adjusting the prior frame in Faster-RCNN to obtain a predicted frame.
[0183] S804, based on the classification result obtained by classifying the area image enclosed by the prediction box in the target feature map and a preset detection box screening method, a detection box of the target object is obtained to complete object detection.
[0184] The goal of object detection is to detect the detection frame that surrounds the target object. By classifying the area image enclosed by the prediction frame in the target feature map, it can be determined whether the object enclosed by the prediction frame is the target object (i.e., the first object or the second object). That is, based on the classification result obtained by classifying the area image enclosed by the prediction frame in the target feature map, the prediction frame that surrounds the target object can be found. Then, through the preset detection frame screening method, the detection frame that surrounds the target object can be screened out from the found prediction frame.
[0185] Through S802 and S804, object detection for the target object can be completed.
[0186] In some embodiments, the regional image enclosed by the prediction box in the target feature map is classified, and the obtained classification result may include: based on the target feature map and the prediction box, using a regional image extraction unit (for example, a region of interest extraction (ROI Pooling) unit) to obtain the regional image enclosed by the prediction box in the target feature map.
[0187] Then, the region image can be classified to obtain a classification result. For example, the region image can be convolved several times, and then fully connected and softmaxed to obtain the confidence that the type of the region image is predicted to be the target object. If the confidence reaches a confidence threshold (for example, 0.5, 0.6, 0.7, etc., which are less than 1), the type of the region image can be determined to be the target object.
[0188] Therefore, the classification network can be used to classify the image in the area enclosed by the prediction box.
[0189] In some embodiments, the preset detection frame screening method includes a non-maximum suppression method, thereby improving object detection efficiency.
[0190] The method may include arranging the regional images enclosed by the prediction boxes found in S804 in descending order of confidence that they are predicted to be the target object to obtain a prediction box arrangement set, selecting a first prediction box with the highest confidence from the set, and executing:
[0191] Determine the intersection-over-union (IOU) of the first prediction box with other prediction boxes, and select a second prediction box whose IOU with the first prediction box reaches a preset ratio; delete the second prediction box, and use the first prediction box as the detection box of the target object surrounded by the first prediction box.
[0192] Afterwards, the first prediction box and the second prediction box are deleted from the set, and the above-mentioned step of determining the detection box is performed again until the set does not include any prediction box. All the determined detection boxes are output. The objects enclosed in these detection boxes are the target objects in the input image.
[0193] In some embodiments, after obtaining the detection frame of the target object, the detection frame of the target object may be displayed in the input image, so that the target object in the input image can be observed intuitively.
[0194] In this example, the second position of the detection box in the input image can be determined based on the first position of the obtained detection box in the target feature map and the mapping relationship between the pixel coordinates between the target feature map and the input image, and then the detection box is added to the input image based on a preset graphic adding scheme to display the detection box of the target object in the input image.
[0195] In some embodiments, when the non-maximum suppression method is used to filter the preset detection frames, the prediction frames found in S804 can be first filtered by a preset threshold to obtain the corresponding prediction frames whose confidence reaches the preset threshold. Then the detection frame filtering step described in the above embodiment is performed. The preset threshold is an empirical threshold. Thus, the prediction frames can be filtered by the preset threshold before filtering the detection frames, thereby reducing the number of prediction frames, improving the screening efficiency, and further improving the object detection efficiency.
[0196] The present disclosure also proposes an object detection method. The execution steps of the method can be referred to S202-S206. The steps of S202 and S206 are not described repeatedly below.
[0197] In this example, an object detection network generated based on a neural network may be used to perform the object detection, and the object detection network is pre-trained so that the object detection network can detect a detection frame of the target object.
[0198] The object detection network may include a feature extraction network and a detection frame confirmation network. The feature extraction network is used to extract features from the input image to obtain a first feature map and a second feature map. The detection frame confirmation network is used to detect a detection frame of the first object based on the first feature map and to detect a detection frame of the second object based on the second feature map.
[0199] The feature extraction network may also include a feature fusion network according to business requirements. The feature fusion network is used to fuse the high- and low-resolution sampled feature maps obtained by downsampling to increase the amount of feature information contained in the first feature map and the second feature map, thereby improving the object detection effect.
[0200] The detection frame confirmation network also includes a classification network and a detection frame recognition network. The classification network is used to classify the regional image surrounded by the prediction frame to obtain the type of object surrounded by the prediction frame. The detection frame recognition network can filter out the detection frame from the prediction frame surrounding the detected object.
[0201] It can be understood that once the object detection network is trained, the training of each sub-network included in it can be completed.
[0202] See also Fig. 9 , Fig. 9 FIG. 1 is a flow chart of an object detection network training method according to an embodiment of the present disclosure. Fig. 9 As shown, S902-S906 may be executed. Unless otherwise specified, the present disclosure does not specifically limit the execution order of these steps.
[0203] S902, obtaining an image sample; the image sample includes object type annotation information and detection box annotation information for each first object and each second object in the image.
[0204] The image samples may include positive samples and negative samples.
[0205] In some embodiments, the object type annotation information and the detection frame annotation information for the detected object can be annotated in one annotation data, that is, {annotate object type, annotate the first vertex coordinate of the detection frame, annotate the second vertex coordinate of the detection frame}. For example, the annotation data for the detected object is {1, (x1, y1), (x2, y2)}. Among them, 1 means that the annotated detection frame surrounds the detected object. (x1, y1) represents the coordinates of the upper left corner of the annotated detection frame. (x2, y2) represents the coordinates of the lower right corner of the annotated detection frame.
[0206] S904, taking the image sample as input, and using the object detection network to detect each first object and each second object in the image sample; wherein the detection result includes object type prediction information and detection box prediction information for each first object and each second object.
[0207] The specific description of this step can be referred to S202-S206, which will not be described in detail here.
[0208] The data format of the object type prediction information and the detection box prediction information for the detected object is the same as the data format of the annotation information in S902. In some embodiments, the data format of {predicted object type, predicted detection box first vertex coordinates, predicted detection box second vertex coordinates} can be used to represent the object type prediction information and the detection box prediction information for the detected object.
[0209] S906: Adjust network parameters of the object detection network according to the object type prediction information and the detection box prediction information, and the object type labeling information and the detection box labeling information.
[0210] In S906, the network parameters of the object detection network may be adjusted in a supervised manner using a preset loss function.
[0211] In practical applications, an image sample set containing positive and negative samples can be obtained, and then, based on a preset number of training times, the object detection network is supervised trained using the method of S902-S906 to indicate that the object detection network has converged. In this way, the training of the object detection network can be completed, so that the object detection network can detect the detection frame of the target object and complete the object detection task.
[0212] In some embodiments, in S906, the errors of object type prediction and detection box prediction may be calculated respectively according to two loss functions to adjust the parameters of the object detection network.
[0213] See also Fig.10 , Fig.10 A schematic diagram of a flow chart of a network parameter adjustment method shown in an embodiment of the present disclosure. Fig.10 The method shown is a detailed description of S906. Fig.10 As shown, the method shown may include S1002-S1006. Unless otherwise specified, the present disclosure does not specifically limit the execution order of these steps.
[0214] In S1002, the detection box prediction information and the detection box annotation information are used as function inputs to obtain first loss information based on a preset detection box loss function.
[0215] The detection box loss function shown may be any type of function. For example, the detection box loss function may be a Smooth L1 Loss function. The error between the detection box prediction information and the detection box annotation information, i.e., the first loss information, may be obtained through the loss function.
[0216] S1004: Use the object type prediction information and the object type labeling information as function inputs, and obtain second loss information based on a preset object type loss function.
[0217] The object type loss function shown may be any type of function. For example, the object type loss function may be a cross entropy loss function. The error between the object type prediction information and the object type labeling information, i.e., the second loss information, may be obtained through the loss function.
[0218] S1006: Adjust network parameters of the object detection network based on the first loss information and the second loss information.
[0219] In S1006, the two loss information may be combined in a variety of ways. For example, the two loss information may be combined by calculating the weighted sum of the two loss functions. Then, based on the total loss, the descent gradient may be calculated, and the network parameters of the object detection network may be adjusted by back propagation.
[0220] Through S1002-S1006, the errors of object type prediction and detection box prediction can be calculated respectively according to the two loss functions to adjust the object detection network parameters.
[0221] The present disclosure also proposes a training method for an object detection network. The execution steps of the method can be referred to S902-S906. The steps of S902-S906 are not repeated below.
[0222] In this example, during the process of executing S904 on the network training, a self-attention mechanism can be added to the link of feature extraction of the image input to the network, so that during training, irrelevant information related to the detection object can be ignored and key information can be focused on, while paying attention to the mutual connection between feature information. On the one hand, the network convergence speed is improved, and on the other hand, the performance of the network detection object is improved.
[0223] In this example, in S904, the step of extracting features from image samples to obtain the first feature map and the second feature map may include downsampling the input image samples a preset number of times and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling. Then, based on the sampling feature map obtained after each downsampling, the first feature map and the second feature map are obtained. The step of obtaining the first feature map and the second feature map based on the sampling feature map obtained after each downsampling can refer to S304 and will not be described in detail here.
[0224] See also Fig.11 , Fig.11 A schematic flow chart of a method for extracting a sampling feature graph shown in an embodiment of the present disclosure. Fig.11 The illustrated method is an explanation of the steps of extracting the sampling feature map based on the self-attention mechanism. Fig.11 As shown, executing S202 may execute S1102 to S1106. Unless otherwise specified, the present disclosure does not specifically limit the execution order of these steps.
[0225] In order to briefly describe the embodiment below, the first feature map or the second feature map is referred to as a target feature map. That is, the target feature map includes the first feature map and the second feature map; when the target feature map is the first feature map, the target resolution is the first resolution or the third resolution, and when the target feature map is the second feature map, the target resolution is the second resolution or the fourth resolution.
[0226] Wherein, S1102, down-sample the input image sample at least once to obtain an initial sampling feature map of the target resolution.
[0227] In this example, the downsampling layer included in the feature extraction network can be used to downsample the input sample image to obtain the initial sampling feature map.
[0228] S1104, obtaining weight information corresponding to the sampling feature map of the target resolution, wherein the weight information is obtained based on a self-attention mechanism and indicates the degree of mutual influence between pixels in the initial sampling feature map.
[0229] In this example, the feature extraction network includes a self-attention mechanism layer corresponding to the downsampling layer that obtains the initial feature map. The self-attention mechanism layer may include a residual network and a normalization network for predicting the degree of mutual influence between each pixel in the target feature map of the target resolution. The output of the self-attention mechanism layer may be a mask matrix of the same size as the target resolution. The elements in the matrix indicate the degree of mutual influence between corresponding pixels.
[0230] S1106: Adjust the initial sampling feature map based on the weight information to obtain an adjusted sampling feature map.
[0231] In S1106, the weight information can be matrix multiplied with the initial sampling feature map to adjust the initial sampling feature map information in combination with the degree of mutual influence between pixel points, so as to obtain a sampling feature map that can ignore irrelevant information related to the detection object and focus on key information, while paying attention to the mutual relationship between feature information, thereby improving the network convergence speed on the one hand and improving the performance of network detection objects on the other.
[0232] In some embodiments, in the process of adjusting the initial sampling feature map, the initial sampling feature map can be adjusted based on the weight information and fused with the initial sampling feature map to obtain an adjusted sampling feature map, so that the adjusted sampling feature map can not only ignore irrelevant information related to the detection object and focus on key information, while paying attention to the mutual connection between feature information, but also retain the initial feature information, thereby enriching the information contained in the feature map, thereby improving the network convergence speed on the one hand, and improving the performance of network detection objects on the other hand.
[0233] The following example explains the self-attention mechanism. Fig.12 , Fig.12 A schematic diagram of a feature extraction network structure based on self-attention is shown in an embodiment of the present disclosure. Fig.12 Only the network structure related to self-attention in the feature extraction network is illustrated, and the entire structure of the feature extraction network is illustrated.
[0234] like Fig.12 As shown, the network may include a self-attention mechanism network 1201, a feature extraction subnetwork 1202, a multiplication unit 1203, and an addition unit 1204. The input and output ends of the network may also be processed by a residual network.
[0235] The self-attention mechanism network 1201 may include a residual network, a convolution layer and a normalization layer, which are used to predict the degree of mutual influence between each pixel in the target feature map of the target resolution. The output of this layer may be a mask matrix of the same size as the target resolution. The elements in this matrix indicate the degree of mutual influence between corresponding pixels.
[0236] The feature extraction subnetwork 1202 may perform processing such as convolution and pooling to obtain an initial sampling feature map of the target resolution.
[0237] The multiplication unit 1203 can perform a matrix multiplication operation on the initial sampling feature map based on the weight information to adjust the initial sampling feature map.
[0238] The adding unit 1204 can merge the feature map adjusted by the multiplying unit 1203 with the initial sampling feature map to obtain an adjusted sampling feature map.
[0239] After being processed by units 1201-1204, it is possible to obtain a sampling feature map that can ignore irrelevant information related to the detection object and focus on key information, while focusing on the mutual connection between feature information. It can also retain the initial feature information, so that the feature map contains richer information, thereby improving the network convergence speed on the one hand, and improving the performance of network detection objects on the other.
[0240] Combine the following Figure 1 The implementation method is described in the application scenario. It should be noted that the aforementioned application scenario is only shown to facilitate understanding of the spirit and principle of the present disclosure, and the implementation method of the present disclosure is not limited in this respect. On the contrary, the implementation method of the present disclosure can be applied to any applicable scenario. The following description is given by taking the detection of human objects in a live broadcast scene as an example.
[0241] exist Figure 1 In the illustrated scenario, at the image input end, a camera carried by the mobile phone 1022 can be used to collect live video for the live broadcast personnel in real time. The live video can include multiple frames of live images. The image input end can also scale the live images in the live video to obtain an input image sequence that matches the input end of the human body detection network. In this example, the collected live images can be scaled to 256*256. Then the image input end can transmit the input image sequence to a processor (e.g., a Graphic Processing Unit (GPU) or an artificial intelligence chip) carried by the mobile phone 1022 for human body detection.
[0242] The processor carried by the mobile phone 1022 can be equipped with a human body detection network for performing human body detection.
[0243] See also Fig.13 , Fig.13 A schematic diagram of a human body detection network structure shown in an embodiment of the present disclosure.
[0244] like Fig.13 As shown, the human body detection network 1300 may include a feature extraction network 1301 and a human body detection frame confirmation network 1302.
[0245] The feature extraction network 1301 includes a feature extraction subnetwork 13011 and a feature fusion network 13012 .
[0246] The feature extraction subnetwork 13011 may include a convolution layer, a normalization layer (BatchNormalization), a ReLU activation function layer, a pooling layer (Pooling), a depthwise separable convolution layer (depthwiseseparable convolution), an upsampling layer (UpSampling) and other processing layers. These processing layers cooperate with each other to complete feature extraction. The input of the feature extraction subnetwork 13011 is 256*256. After 7 convolutions, pooling and other operations, it can output sampling feature maps of seven resolution scales of 128*128, 64*64, 32*32, 16*16, 8*8, 4*4, and 2*2 to the feature fusion network 13012. Therefore, by controlling the number of convolution and pooling processes to seven times and controlling the size of the feature map, the feature extraction subnetwork can be lightweighted, and then the human body detection network can be lightweighted, so that the network does not rely on high-performance hardware, and can efficiently complete human body detection in low-performance hardware such as mobile phones.
[0247] Among them, when training the human body detection network, a self-attention mechanism was introduced for the two sampling feature maps of 32*32 and 8*8, so that the feature maps can ignore irrelevant information about the human body and focus on key information, while paying attention to the mutual connection between human body feature information, on the one hand to improve the network convergence speed, on the other hand to improve the performance of the network in detecting human bodies.
[0248] The feature fusion network 13012 can select sampling feature maps of four resolutions: 32*32, 16*16, 8*8, and 4*4. Then, the sampling feature maps of 32*32 and 16*16 can be selected, and the sampling feature map of 16*16 can be upsampled (e.g., interpolated, or deconvolved) to a size of 32*32, and then fused with the sampling feature map of 32*32 to obtain a first feature map for detecting a human body with a relatively small proportion. The sampling feature maps of 8*8 and 4*4 can also be selected, and then the aforementioned fusion steps can be performed to obtain a second feature map for detecting a human body with a relatively large proportion.
[0249] Feature fusion can be used to fuse high-resolution and low-resolution feature maps, and aggregate more features that are beneficial to human body detection in the first feature map and the second feature map, thereby increasing the feature information contained in the feature map and improving the human body detection effect.
[0250] The feature fusion network 13012 can input the first feature map and the second feature map into the detection frame confirmation network 1302 to confirm the human body detection frame.
[0251] The detection frame confirmation network 1302 may include a classification network 13021 and a detection frame recognition network 13022. The classification network 13021 is used to classify the regional image surrounded by the prediction frame to obtain the human body surrounded by the prediction frame. The detection frame recognition network 13022 may filter out the human body detection frame from the prediction frame surrounding the human body.
[0252] In this example, the human body detection model can be trained in advance in the hardware environment using the steps illustrated in S902-S906, wherein the feature extraction of the input image sample is alleviated in S904, and a self-attention mechanism is added. It can be understood that the training of the human body detection network can be completed by completing the training of each sub-network included in it. After the training is completed, the human body detection network can be deployed in the mobile phone 1022.
[0253] When the processor of the mobile phone 1022 receives the input image sequence, it can perform the human body detection steps shown in S202-S206 for each frame of the input image to obtain a detection frame of the human body in the input image. The description of S202-S206 can refer to any of the aforementioned embodiments of the object detection method. By using S202-S206, a small number of prior frames can be generated based on the characteristic that the first object occupies a small area in the input image, thereby reducing the amount of object detection calculations and achieving the purpose of lightweight object detection.
[0254] Afterwards, the human body detection frame can be added to the input image to obtain an image including the human body detection frame, and the image can be displayed on the display screen of the mobile phone 1022. This facilitates intuitive observation of the human body detection result.
[0255] Exemplary Devices
[0256] After introducing the method of the exemplary embodiment of the present disclosure, next, refer to Fig.14 The object detection device exemplarily disclosed in the present disclosure is described. The object detection device is used to implement the object detection method shown in any of the above embodiments.
[0257] See also Fig.14 , Fig.14 The present invention is a schematic diagram of the structure of an object detection device according to an embodiment of the present invention.
[0258] like Fig.14 As shown, the object detection device 1400 may include:
[0259] A feature extraction module 1401 is used to extract features from an input image to obtain a first feature map for detecting a first object and a second feature map for detecting a second object; wherein an area occupied by the first object in the input image is smaller than an area occupied by the second object in the input image;
[0260] A generation and detection module 1402 is used to generate a first number of first a priori boxes for at least part of the pixels included in the first feature map, and detect the first object based on the generated first a priori boxes;
[0261] A second number of second priori boxes are generated for at least part of the pixels included in the second feature map, and the second object is detected based on the generated second priori boxes; wherein the first number is smaller than the second number.
[0262] In some embodiments, the feature extraction module 1401 is specifically used to:
[0263] Downsampling the input image a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling;
[0264] Based on the sampling feature map obtained after each downsampling, a first feature map and a second feature map are obtained.
[0265] In some embodiments, the feature extraction module 1401 is specifically used to:
[0266] Determine a first sampling feature map with a first resolution based on the sampling feature map obtained after each downsampling as the first feature map, and determine a second sampling feature map with a second resolution as the second feature map;
[0267] or,
[0268] In the sampling feature map obtained after each downsampling, a third sampling feature map with a third resolution is fused with at least one sampling feature map with a lower resolution than the third sampling feature map to obtain the first feature map, and,
[0269] fusing a fourth sampling feature map having a fourth resolution with at least one sampling feature map having a lower resolution than the fourth sampling feature map to obtain the second feature map;
[0270] or,
[0271] In the sampling feature maps obtained after each downsampling, a fifth sampling feature map with a fifth resolution is fused with at least one sampling feature map with a lower resolution than the fifth sampling feature map to obtain the second feature map, and,
[0272] The sixth sampling feature map of the sixth resolution is fused with the second feature map to obtain the first feature map; the fifth resolution is smaller than the sixth resolution.
[0273] In some embodiments, the first resolution is greater than the second resolution, and the third resolution is greater than the fourth resolution.
[0274] In some embodiments, the generating and detecting module 1402 is specifically used to:
[0275] Obtaining a first preset value and a second preset value corresponding to the target feature map;
[0276] Based on the first preset value and the second preset value, generating a side length of each target priori box;
[0277] Based on the generated side length, generating a target priori box of the target quantity for at least part of the pixels included in the target feature map;
[0278] Among them, the target feature map includes a first feature map or a second feature map; when the target feature map is the first feature map, the target number is the first number, and the target prior box is the first prior box; when the target feature map is the second feature map, the target number is the second number, and the target prior box is the second prior box.
[0279] In some embodiments, when the target feature map is a first feature map, the first number is four, and the first prior frame includes a first square prior frame, a second square prior frame, and a first rectangular prior frame and a second rectangular prior frame with different side lengths, the first rectangular prior frame is a vertical frame, and the second rectangle is a horizontal frame.
[0280] In some embodiments, the first preset value is less than the second preset value; the generating and detecting module 1402 is specifically used to:
[0281] Setting the side length of the first square priori frame to the first preset value;
[0282] Setting the side length of the second square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value;
[0283] Setting the width of the first rectangular priori frame and the height of the second rectangular priori frame to values obtained by processing the target preset value and smaller than the target preset value;
[0284] The height of the first rectangular priori box and the width of the second rectangular priori box are set to values obtained by processing the first preset value and greater than the target preset value; wherein the target preset value includes the first preset value or the second preset value.
[0285] In some embodiments, when the target feature map is a second feature map, the second number is six, and the second a priori frame includes a third square a priori frame, a fourth square a priori frame, a third rectangular a priori frame, a fourth rectangular a priori frame, a fifth rectangular a priori frame, and a sixth rectangular a priori frame with different side lengths; wherein the third rectangular a priori frame and the fifth rectangle are vertical frames, and the width of the third rectangle is greater than the width of the fifth rectangle, and the height of the third rectangle is less than the height of the fifth rectangle; and the fourth rectangle is a horizontal frame;
[0286] The sixth rectangular priori frame is a horizontal frame, and the width of the fourth rectangle is smaller than the width of the sixth rectangle, and the height of the fourth rectangle is greater than the height of the sixth rectangle, or the sixth rectangular priori frame is a vertical frame and matches the shape of the second object.
[0287] In some embodiments, the first preset value is less than the second preset value; the generating and detecting module 1402 is specifically used to:
[0288] Setting the side length of the third square priori frame to the first preset value;
[0289] Setting the side length of the fourth square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value;
[0290] The width of the third rectangular priori frame and the height of the fourth rectangular priori frame are set to first result values less than the target preset value obtained after processing the target preset value;
[0291] Setting the height of the third rectangular priori frame and the width of the fourth rectangular priori frame to a second result value greater than the target preset value obtained by processing the first preset value;
[0292] The width of the fifth rectangular priori frame is set to a third result value obtained by processing the target preset value and smaller than the first result value, and the height is set to a fourth result value obtained by processing the target preset value and larger than the second result value;
[0293] The height of the sixth rectangular prior box is set to the third result value, and the width is set to the fourth result value, or the width of the sixth rectangular prior box is determined to be a value between the first result value and the third result value obtained by processing the target preset value, and the height is determined to be a value between the second result value and the fourth result value obtained by processing the target preset value; wherein the target preset value includes the first preset value or the second preset value.
[0294] In some embodiments, the generating and detecting module 1402 is specifically used to:
[0295] Adjusting the target prior frame to obtain a prediction frame;
[0296] Based on the classification result obtained by classifying the area image enclosed by the prediction box in the target feature map and the preset detection box screening method, a detection box of the target object is obtained to complete object detection;
[0297] Among them, the target prior frame includes a first prior frame or a second prior frame; when the target prior frame is the first prior frame, the target feature map is the first feature map, and the target object is the first object; when the target prior frame is the second prior frame, the target feature map is the second feature map, and the target object is the second object.
[0298] In some embodiments, the generating and detecting module 1402 is specifically used to:
[0299] Based on the target feature map and the prediction frame, using a regional image extraction unit, obtaining a regional image enclosed by the prediction frame in the target feature map;
[0300] The regional image is classified to obtain a classification result.
[0301] In some embodiments, the preset detection frame screening method includes a non-maximum suppression method.
[0302] In some embodiments, the apparatus 1400 further includes:
[0303] A display module is used to display the detection frame of the target object in the input image.
[0304] In some embodiments, the object detection is performed using an object detection network generated based on a neural network, and the apparatus 1400 further includes:
[0305] The training module of the object detection network is used to:
[0306] Acquire an image sample; the image sample includes object type annotation information and detection frame annotation information for each first object and each second object in the image;
[0307] Taking the image sample as input, and using the object detection network to detect each first object and each second object in the image sample; wherein the detection result includes object type prediction information and detection box prediction information for each first object and each second object;
[0308] According to the object type prediction information and the detection box prediction information, and the object type labeling information and the detection box labeling information, the network parameters of the object detection network are adjusted.
[0309] In some embodiments, the training module of the object detection network is specifically used to:
[0310] Downsampling the input image sample a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling;
[0311] Based on the sampling feature map obtained after each downsampling, a first feature map and a second feature map are obtained;
[0312] Wherein, the method for extracting the sampling feature map includes:
[0313] Downsample the input image sample at least once to obtain an initial sampling feature map of the target resolution;
[0314] Obtaining weight information corresponding to the sampled feature map of the target resolution, wherein the weight information is obtained based on a self-attention mechanism and indicates a degree of mutual influence between pixels in the initial sampled feature map;
[0315] Adjusting the initial sampling feature map based on the weight information to obtain an adjusted sampling feature map;
[0316] Among them, the target feature map includes a first feature map and a second feature map; when the target feature map is the first feature map, the target resolution is the first resolution, and when the target feature map is the second feature map, the target resolution is the second resolution.
[0317] In some embodiments, the training module of the object detection network is specifically used to:
[0318] The initial sampling feature map is adjusted based on the weight information and merged with the initial sampling feature map to obtain an adjusted sampling feature map.
[0319] In some embodiments, the training module of the object detection network is specifically used to:
[0320] The detection box prediction information and the detection box annotation information are used as function inputs, and first loss information is obtained based on a preset detection box loss function;
[0321] The object type prediction information and the object type labeling information are used as function inputs, and second loss information is obtained based on a preset object type loss function;
[0322] Based on the first loss information and the second loss information, a network parameter of the object detection network is adjusted.
[0323] In some embodiments, the first object is an object occupying an area smaller than a region threshold in the input image; the second object is an object occupying an area larger than the region threshold in the input image;
[0324] The device 1400 further includes:
[0325] A setting module is used to set the side lengths of the first a priori box and the second a priori box according to the area threshold.
[0326] Therefore, two feature maps for detecting the first object and the second object respectively can be obtained by extracting features from the input image, and then different numbers of prior frames can be generated for pixels in the two feature maps to perform object detection. Compared with the related technology that does not distinguish between the detected objects of different occupied areas and generates a uniform number of prior frames for object detection, a smaller number of prior frames can be generated based on the characteristic that the first object occupies a smaller area in the input image, thereby reducing the amount of object detection calculations and achieving the purpose of lightweight object detection.
[0327] Exemplary Media
[0328] After introducing the method and apparatus of the exemplary embodiments of the present disclosure, next, reference is made to Fig.15 A readable storage medium exemplarily disclosed in the present disclosure is described. The storage medium stores a computer program, and the computer program is used to enable a processor to execute the object detection method shown in any of the above embodiments.
[0329] See also Fig.15 , Fig.15 A program product 1500 applied to an object detection method according to an embodiment of the present disclosure is shown.
[0330] In some embodiments shown, the aforementioned object detection method can be implemented by a program product 1500, such as a portable compact disk read-only memory (CD-ROM) and including program code, and can be run on a device, such as a personal computer. However, the program product of the present disclosure is not limited thereto, and in this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus, or a device.
[0331] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0332] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0333] The program code contained on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RE, etc., or any suitable combination of the foregoing.
[0334] Program code for performing the disclosed operations may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also conventional procedural programming languages such as C or similar programming languages. The program code may be executed entirely on the user electronic device, partially on the user electronic device, partially on the remote electronic device, or entirely on the remote electronic device or server. In the case of a remote electronic device, the remote electronic device may be connected to the user electronic device through any type of model, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external electronic device (e.g., using an Internet service provider to connect through the Internet).
[0335] Exemplary Electronic Devices
[0336] After introducing the method, apparatus and medium of the exemplary embodiments of the present disclosure, next, reference is made to Fig.16 An electronic device exemplarily disclosed in the present disclosure is described. The device comprises: a processor; a memory for storing processor executable instructions; wherein the processor implements the object detection method shown in any of the above embodiments by running the executable instructions.
[0337] See also Fig.16 , Fig.16 The present invention is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention.
[0338] Fig.16 The electronic device 1600 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0339] like Fig.16 As shown, the electronic device 1600 is in the form of a general electronic device. The components of the electronic device 1600 may include but are not limited to: the aforementioned at least one processor 1601, the aforementioned at least one storage processor 1602, and a bus 1603 connecting different system components (including the processor 1601 and the storage processor 1602).
[0340] The bus 1603 includes a data bus, a control bus, and an address bus.
[0341] The storage processor 1602 may include a readable medium in the form of a volatile memory, such as a random access memory (RAM) 16021 and / or a cache memory 16022 , and may further include a readable medium in the form of a non-volatile memory, such as a read-only memory (ROM) 16023 .
[0342] The storage processor 1602 may also include a program / utility 16025 having a set (at least one) of program modules 16024, such program modules 16024 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a model environment.
[0343] The electronic device 1600 may also communicate with one or more external devices 1604 (eg, keyboards, pointing devices, etc.).
[0344] Such communication may be performed via an input / output (I / O) interface 1605. Furthermore, the electronic device 1600 may also communicate with one or more models (e.g., a local area network (LAN), a wide area network (WAN) and / or a public model, such as the Internet) via a model adapter 1606. Fig.16 As shown, the model adapter 1606 communicates with other modules of the electronic device 1600 via the bus 1603. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 1600, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0345] It should be noted that although several units / modules or sub-units / modules of the object detection device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present disclosure, the features and functions of two or more units / modules described above may be embodied in one unit / module. Conversely, the features and functions of one unit / module described above may be further divided into multiple units / modules to be embodied.
[0346] In addition, although the operations of the disclosed method are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.
[0347] Although the spirit and principle of the present disclosure have been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the disclosed specific embodiments, and the division of various aspects does not mean that the features in these aspects cannot be combined to benefit, and such division is only for the convenience of expression. The present disclosure is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the attached claims.
Claims
1. An object detection method, characterized in that: include: Performing feature extraction on the input image to obtain a first feature map for detecting a first object and a second feature map for detecting a second object; wherein an area occupied by the first object in the input image is smaller than an area occupied by the second object in the input image; Acquire a first preset value and a second preset value corresponding to a target feature map, wherein the target feature map includes the first feature map or the second feature map; Generate a side length of each target priori box based on the first preset value and the second preset value; Based on the generated side length, a target a priori box of the target quantity is generated for at least part of the pixels included in the target feature map, wherein, when the target feature map is a first feature map, the target quantity is a first quantity, and the target a priori box is a first a priori box; when the target feature map is a second feature map, the target quantity is a second quantity, and the target a priori box is a second a priori box; Based on the generated first a priori frame, the first object is detected, and based on the generated second a priori frame, the second object is detected; wherein the first number is less than the second number; In the case where the target feature map is a first feature map, the first number is four, the first a priori box includes a first square a priori box, a second square a priori box, a first rectangular a priori box, and a second rectangular a priori box with different side lengths, the first rectangular a priori box is a vertical box, the second rectangle is a horizontal box, and the first preset value is less than the second preset value; The generating the side length of each target priori box based on the first preset value and the second preset value includes: Setting the side length of the first square priori frame to the first preset value; Setting the side length of the second square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value; Setting the width of the first rectangular priori frame and the height of the second rectangular priori frame to values obtained by processing the target preset value and smaller than the target preset value; The height of the first rectangular priori box and the width of the second rectangular priori box are set to values obtained by processing the first preset value and greater than the target preset value; wherein the target preset value includes the first preset value or the second preset value.
2. The method according to claim 1, characterized in that The step of extracting features from the input image to obtain a first feature map and a second feature map includes: Downsampling the input image a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling; Based on the sampling feature map obtained after each downsampling, a first feature map and a second feature map are obtained.
3. The method according to claim 2, characterized in that The obtaining of the first feature map and the second feature map based on the sampling feature map obtained after each downsampling includes: Determine a first sampling feature map with a first resolution based on the sampling feature map obtained after each downsampling as the first feature map, and determine a second sampling feature map with a second resolution as the second feature map; or, In the sampling feature map obtained after each downsampling, a third sampling feature map with a third resolution is fused with at least one sampling feature map with a lower resolution than the third sampling feature map to obtain the first feature map, and, fusing a fourth sampling feature map having a fourth resolution with at least one sampling feature map having a lower resolution than the fourth sampling feature map to obtain the second feature map; or, In the sampling feature maps obtained after each downsampling, a fifth sampling feature map with a fifth resolution is fused with at least one sampling feature map with a lower resolution than the fifth sampling feature map to obtain the second feature map, and, The sixth sampling feature map of the sixth resolution is fused with the second feature map to obtain the first feature map; the fifth resolution is smaller than the sixth resolution.
4. The method according to claim 3, characterized in that The first resolution is greater than the second resolution, and the third resolution is greater than the fourth resolution.
5. The method according to claim 1, characterized in that In the case where the target feature map is a second feature map, the second number is six, and the second a priori frame includes a third square a priori frame, a fourth square a priori frame, a third rectangular a priori frame, a fourth rectangular a priori frame, a fifth rectangular a priori frame and a sixth rectangular a priori frame with different side lengths; wherein the third rectangular a priori frame and the fifth rectangle are vertical frames, and the width of the third rectangle is greater than the width of the fifth rectangle, and the height of the third rectangle is less than the height of the fifth rectangle; and the fourth rectangle is a horizontal frame; The sixth rectangular priori frame is a horizontal frame, and the width of the fourth rectangle is smaller than the width of the sixth rectangle, and the height of the fourth rectangle is greater than the height of the sixth rectangle, or the sixth rectangular priori frame is a vertical frame and matches the shape of the second object.
6. The method according to claim 5, characterized in that The first preset value is less than the second preset value; and generating the side length of each target priori box based on the first preset value and the second preset value includes: Setting the side length of the third square priori frame to the first preset value; Setting the side length of the fourth square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value; The width of the third rectangular priori frame and the height of the fourth rectangular priori frame are set to first result values less than the target preset value obtained after processing the target preset value; Setting the height of the third rectangular priori frame and the width of the fourth rectangular priori frame to a second result value greater than the target preset value obtained by processing the first preset value; The width of the fifth rectangular priori frame is set to a third result value obtained by processing the target preset value and smaller than the first result value, and the height is set to a fourth result value obtained by processing the target preset value and larger than the second result value; The height of the sixth rectangular prior box is set to the third result value, and the width is set to the fourth result value, or the width of the sixth rectangular prior box is determined to be a value between the first result value and the third result value obtained by processing the target preset value, and the height is determined to be a value between the second result value and the fourth result value obtained by processing the target preset value; wherein the target preset value includes the first preset value or the second preset value.
7. The method according to claim 1, characterized in that Based on the generated target prior frame, the target object is detected, including: Adjusting the target prior frame to obtain a prediction frame; Based on the classification result obtained by classifying the area image enclosed by the prediction box in the target feature map and the preset detection box screening method, a detection box of the target object is obtained to complete object detection; Among them, the target prior frame includes a first prior frame or a second prior frame; when the target prior frame is the first prior frame, the target feature map is the first feature map, and the target object is the first object; when the target prior frame is the second prior frame, the target feature map is the second feature map, and the target object is the second object.
8. The method according to claim 7, wherein the prediction frame is characterized in that: The regional image enclosed in the marked feature map is classified, and the classification results obtained include: Based on the target feature map and the prediction frame, using a regional image extraction unit, obtaining a regional image enclosed by the prediction frame in the target feature map; The regional image is classified to obtain a classification result.
9. The method according to claim 7, characterized in that: The preset detection frame screening method includes a non-maximum suppression method.
10. The method according to any one of claims 7 to 9, characterized in that: The method further comprises: A detection box of the target object is displayed in the input image.
11. The method according to claim 1, characterized in that: The object detection is performed using an object detection network generated based on a neural network, wherein the training method of the object detection network includes: Acquire an image sample; the image sample includes object type annotation information and detection frame annotation information for each first object and each second object in the image; Taking the image sample as input, and using the object detection network to detect each first object and each second object in the image sample; wherein the detection result includes object type prediction information and detection box prediction information for each first object and each second object; According to the object type prediction information and the detection box prediction information, and the object type labeling information and the detection box labeling information, the network parameters of the object detection network are adjusted.
12. The method according to claim 11, characterized in that The step of taking the image sample as input and using the object detection network to detect each first object and each second object in the image sample includes: Extract features from the image samples to obtain a first feature map and a second feature map; detecting the first object according to the first feature map; detecting the second object according to the second feature map; The step of extracting features from the image samples to obtain a first feature map and a second feature map includes: Downsampling the input image sample a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling; Based on the sampling feature map obtained after each downsampling, a first feature map and a second feature map are obtained; Wherein, the method for extracting the sampling feature map includes: Downsample the input image sample at least once to obtain an initial sampling feature map of the target resolution; Obtaining weight information corresponding to the sampled feature map of the target resolution, wherein the weight information is obtained based on a self-attention mechanism and indicates a degree of mutual influence between pixels in the initial sampled feature map; The initial sampling feature map is adjusted based on the weight information to obtain an adjusted sampling feature map.
13. The method according to claim 12, characterized in that The adjusting the initial sampling feature map based on the weight information to obtain an adjusted sampling feature map includes: The initial sampling feature map is adjusted based on the weight information and merged with the initial sampling feature map to obtain an adjusted sampling feature map.
14. The method according to claim 11, characterized in that The adjusting the network parameters of the object detection network according to the object type prediction information and the detection box prediction information, the object type labeling information and the detection box labeling information, comprises: The detection box prediction information and the detection box annotation information are used as function inputs, and first loss information is obtained based on a preset detection box loss function; The object type prediction information and the object type labeling information are used as function inputs, and second loss information is obtained based on a preset object type loss function; Based on the first loss information and the second loss information, a network parameter of the object detection network is adjusted.
15. The method according to claim 1, characterized in that The first object is an object occupying an area smaller than a region threshold in the input image; the second object is an object occupying an area larger than the region threshold in the input image; The method further comprises: According to the area threshold, the side lengths of the first a priori box and the second a priori box are set.
16. An object detection device, characterized in that: include: a feature extraction module, configured to extract features from an input image to obtain a first feature map for detecting a first object and a second feature map for detecting a second object; wherein an area occupied by the first object in the input image is smaller than an area occupied by the second object in the input image; A generation and detection module, used to obtain a first preset value and a second preset value corresponding to a target feature map, wherein the target feature map includes a first feature map or a second feature map; based on the first preset value and the second preset value, generate a side length of each target a priori box; based on the generated side length, generate a target a priori box of a target quantity for at least part of the pixels included in the target feature map, wherein, when the target feature map is the first feature map, the target quantity is the first quantity, and the target a priori box is the first a priori box; when the target feature map is the second feature map, the target quantity is the second quantity, and the target a priori box is the second a priori box; based on the generated first a priori box, detect the first object, and based on the generated second a priori box, detect the second object; wherein the first quantity is less than the second quantity; In the case where the target feature map is a first feature map, the first number is four, the first a priori frame includes a first square a priori frame, a second square a priori frame, a first rectangular a priori frame, and a second rectangular a priori frame with different side lengths, the first rectangular a priori frame is a vertical frame, and the second rectangle is a horizontal frame; The first preset value is less than the second preset value; the generating and detecting module is specifically used for: Setting the side length of the first square priori frame to the first preset value; Setting the side length of the second square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value; Setting the width of the first rectangular priori frame and the height of the second rectangular priori frame to values obtained by processing the target preset value and smaller than the target preset value; The height of the first rectangular priori box and the width of the second rectangular priori box are set to values obtained by processing the first preset value and greater than the target preset value; wherein the target preset value includes the first preset value or the second preset value.
17. The device according to claim 16, characterized in that The feature extraction module is specifically used for: Downsampling the input image a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling; Based on the sampling feature map obtained after each downsampling, a first feature map and a second feature map are obtained.
18. The device according to claim 17, characterized in that The feature extraction module is specifically used for: Determine a first sampling feature map with a first resolution based on the sampling feature map obtained after each downsampling as the first feature map, and determine a second sampling feature map with a second resolution as the second feature map; or, In the sampling feature map obtained after each downsampling, a third sampling feature map with a third resolution is fused with at least one sampling feature map with a lower resolution than the third sampling feature map to obtain the first feature map, and, fusing a fourth sampling feature map having a fourth resolution with at least one sampling feature map having a lower resolution than the fourth sampling feature map to obtain the second feature map; or, In the sampling feature maps obtained after each downsampling, a fifth sampling feature map with a fifth resolution is fused with at least one sampling feature map with a lower resolution than the fifth sampling feature map to obtain the second feature map, and, The sixth sampling feature map of the sixth resolution is fused with the second feature map to obtain the first feature map; the fifth resolution is smaller than the sixth resolution.
19. The device according to claim 18, characterized in that The first resolution is greater than the second resolution, and the third resolution is greater than the fourth resolution.
20. The device according to claim 16, characterized in that In the case where the target feature map is a second feature map, the second number is six, and the second a priori frame includes a third square a priori frame, a fourth square a priori frame, a third rectangular a priori frame, a fourth rectangular a priori frame, a fifth rectangular a priori frame and a sixth rectangular a priori frame with different side lengths; wherein the third rectangular a priori frame and the fifth rectangle are vertical frames, and the width of the third rectangle is greater than the width of the fifth rectangle, and the height of the third rectangle is less than the height of the fifth rectangle; and the fourth rectangle is a horizontal frame; The sixth rectangular priori frame is a horizontal frame, and the width of the fourth rectangle is smaller than the width of the sixth rectangle, and the height of the fourth rectangle is greater than the height of the sixth rectangle, or the sixth rectangular priori frame is a vertical frame and matches the shape of the second object.
21. The device according to claim 20, characterized in that The first preset value is less than the second preset value; the generating and detecting module is specifically used for: Setting the side length of the third square priori frame to the first preset value; Setting the side length of the fourth square priori frame to a value greater than the first preset value obtained by processing the first preset value and the second preset value; The width of the third rectangular priori frame and the height of the fourth rectangular priori frame are set to first result values less than the target preset value obtained after processing the target preset value; Setting the height of the third rectangular priori frame and the width of the fourth rectangular priori frame to a second result value greater than the target preset value obtained by processing the first preset value; The width of the fifth rectangular priori frame is set to a third result value obtained by processing the target preset value and smaller than the first result value, and the height is set to a fourth result value obtained by processing the target preset value and larger than the second result value; The height of the sixth rectangular prior box is set to the third result value, and the width is set to the fourth result value, or the width of the sixth rectangular prior box is determined to be a value between the first result value and the third result value obtained by processing the target preset value, and the height is determined to be a value between the second result value and the fourth result value obtained by processing the target preset value; wherein the target preset value includes the first preset value or the second preset value.
22. The device according to claim 16, characterized in that The generation and detection module is specifically used for: The target a priori frame is adjusted to obtain a prediction frame; wherein the target a priori frame includes a first a priori frame or a second a priori frame; when the target a priori frame is the first a priori frame, the target feature map is the first feature map, and the target object is the first object; when the target a priori frame is the second a priori frame, the target feature map is the second feature map, and the target object is the second object; Based on the classification result obtained by classifying the area image enclosed by the prediction box in the target feature map and the preset detection box screening method, the detection box of the target object is obtained to complete the object detection.
23. The device according to claim 22, characterized in that The generation and detection module is specifically used for: Based on the target feature map and the prediction frame, using a regional image extraction unit, obtaining a regional image enclosed by the prediction frame in the target feature map; The regional image is classified to obtain a classification result.
24. The device according to claim 22, characterized in that The preset detection frame screening method includes a non-maximum suppression method.
25. The device according to any one of claims 22 to 24, characterized in that: The device also includes: A display module is used to display the detection frame of the target object in the input image.
26. The device according to claim 16, characterized in that The object detection is performed using an object detection network generated based on a neural network, and the device further comprises: The training module of the object detection network is used to: Acquire an image sample; the image sample includes object type annotation information and detection frame annotation information for each first object and each second object in the image; Taking the image sample as input, and using the object detection network to detect each first object and each second object in the image sample; wherein the detection result includes object type prediction information and detection box prediction information for each first object and each second object; According to the object type prediction information and the detection box prediction information, and the object type labeling information and the detection box labeling information, the network parameters of the object detection network are adjusted.
27. The device according to claim 26, characterized in that The training module of the object detection network is specifically used for: Downsampling the input image sample a preset number of times, and obtaining a sampling feature map after each downsampling; wherein the sampling feature map outputted from each downsampling is the input for the next downsampling; Based on the sampling feature map obtained after each downsampling, a first feature map and a second feature map are obtained; Wherein, the method for extracting the sampling feature map includes: Downsample the input image sample at least once to obtain an initial sampling feature map of the target resolution; Obtaining weight information corresponding to the sampled feature map of the target resolution, wherein the weight information is obtained based on a self-attention mechanism and indicates a degree of mutual influence between pixels in the initial sampled feature map; The initial sampling feature map is adjusted based on the weight information to obtain an adjusted sampling feature map.
28. The device according to claim 27, characterized in that The training module of the object detection network is specifically used for: The initial sampling feature map is adjusted based on the weight information and merged with the initial sampling feature map to obtain an adjusted sampling feature map.
29. The device according to claim 26, characterized in that The training module of the object detection network is specifically used for: The detection box prediction information and the detection box annotation information are used as function inputs, and first loss information is obtained based on a preset detection box loss function; The object type prediction information and the object type labeling information are used as function inputs, and second loss information is obtained based on a preset object type loss function; Based on the first loss information and the second loss information, a network parameter of the object detection network is adjusted.
30. The device according to claim 26, characterized in that The first object is an object occupying an area smaller than a region threshold in the input image; the second object is an object occupying an area larger than the region threshold in the input image; The device also includes: A setting module is used to set the side lengths of the first a priori box and the second a priori box according to the area threshold.
31. An electronic device, characterized in that: The device comprises: processor; a memory for storing processor-executable instructions; The processor implements the object detection method according to any one of claims 1 to 15 by running the executable instructions.
32. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is used to enable a processor to execute the object detection method according to any one of claims 1 to 15.
Citation Information
Patent Citations
Object detection method and device, electronic equipment and storage medium
CN112101134A
Multi-scale cascade aerial photography target detection method and system based on deep neural network
CN113052108A
