MODEL GENERATION METHOD, OBJECT DETECTION METHOD, APPARATUS, DEVICE, AND STORAGE MEDIUM
By pruning batch normalization layers in deep learning models for object detection, the method enhances detection speed and efficiency, addressing the computational limitations of resource-constrained systems like unmanned delivery vehicles.
Patent Information
- Application Number
- JP2022544673
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-03-17
- Filing Date
- 2021-03-09
- Publication Date
- 2024-09-19
- Estimated Expiration
- 2041-03-09
AI Technical Summary
Deep learning models for object detection are slow due to their large size, which is particularly problematic for equipment with limited computational resources, such as unmanned delivery vehicles, affecting their environment sensing ability and delivery efficiency.
A model generation method involving channel pruning of batch normalization layers in intermediate detection models, specifically selecting and removing scaling coefficients and corresponding channels to compress the model while maintaining detection performance.
The method improves detection speed and reduces computational requirements, allowing the model to be efficiently applied in resource-constrained environments like unmanned delivery vehicles without compromising detection accuracy.
Smart Images

Figure 0007554273000017 
Figure 0007554273000012 
Figure 0007554273000010
Abstract
Description
[Technical field]
[0001] This application claims priority to a Chinese patent application bearing application number 202010188303.6, filed with the China Patent Office on March 17, 2020, the entire contents of which are incorporated herein by reference.
[0002] The embodiments of the present application relate to the technical field of computer applications, for example, to a model generation method, an object detection method, an apparatus, a device, and a storage medium. [Background technology]
[0003] Object detection technology is the basis of many computer vision tasks and can be used to determine whether an object of interest is present in an image and to accurately locate the object. Furthermore, object detection technology can be combined with techniques such as object tracking and object recognition to be used in fields such as artificial intelligence systems, autonomous vehicle driving systems, intelligent robots, and intelligent logistics.
[0004] In the process of realizing the present application, the inventors have found that the following problems exist in the related art: Many of the object detection technologies in the related art are realized based on deep learning models, but deep learning models tend to suffer from the problem of slow detection speed due to their large size, which is particularly noticeable in devices with limited computing resources, making it difficult to directly apply object detection technologies to real projects.
[0005] For example, in the field of intelligent logistics, the mass application of unmanned delivery vehicles can reduce delivery costs and improve delivery efficiency, and vision-based object detection technology is an extremely important technical means required for unmanned delivery vehicles to sense the surrounding environment. However, due to considerations of mass production and cost, most of the on-board processors in unmanned delivery vehicles are made of Xvaier platforms with relatively limited computing resources. As a result, the relatively slow detection speed of the deep learning model applied to the on-board processor directly affects the environmental sensing ability of the unmanned delivery vehicle, and further affects the delivery efficiency of the unmanned delivery vehicle. Therefore, how to improve the detection speed of the deep learning model is extremely important for the development of the field of intelligent logistics. Summary of the Invention
[0006] The embodiments of the present application provide a model generation method, an object detection method, an apparatus, a device, and a storage medium, thereby achieving the effect of improving the detection speed of a model by compressing the model.
[0007] In a first aspect, an embodiment of the present application is a method of generating a model, comprising: Obtaining multiple scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on multiple training samples, each training sample including a sample image and a sample labeling result of a known object in the sample image; Selecting a to-be-pruned coefficient from the plurality of scaling coefficients based on the numerical magnitudes of the plurality of scaling coefficients; The present invention provides a model generation method that may include selecting pruning target channels corresponding to pruning target coefficients from a plurality of channels of an intermediate detection model, and performing channel pruning on the pruning target channels to generate an object detection model.
[0008] In a second aspect, an embodiment of the present application provides an object detection method, comprising: Obtaining an image of a detection target and an object detection model generated according to any one of the methods described above; The present invention further provides an object detection method which may include inputting an image of a detection target into an object detection model, and obtaining an object detection result for the object to be detected in the image of the detection target based on an output result of the object detection model.
[0009] In a third aspect, an embodiment of the present application provides a model generating apparatus, comprising: a first acquisition module configured to acquire a plurality of scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on a plurality of training samples, each training sample including a sample image and a sample labeling result of a known object in the sample image; a first selection module configured to select a coefficient to be pruned from the plurality of scaling coefficients according to numerical magnitudes of the plurality of scaling coefficients; The present invention further provides a model generation apparatus that may include: a model generation module configured to select pruning target channels corresponding to pruning target coefficients from a plurality of channels of the intermediate detection model, and to channel prune the pruning target channels to generate an object detection model.
[0010] In a fourth aspect, an embodiment of the present application provides an object detection apparatus, comprising: A second acquisition module configured to acquire an image of a detection target and an object detection model generated according to any one of the methods described above; The present invention further provides an object detection apparatus that may include an object detection module configured to input the image to be detected to an object detection model, and obtain an object detection result for the object to be detected in the image to be detected based on an output result of the object detection model.
[0011] In a fifth aspect, an embodiment of the present application is an apparatus comprising: At least one processor; and a memory configured to store at least one program, There is further provided an apparatus, which when the at least one program is executed by the at least one processor, causes the at least one processor to implement the model generation method or the object detection method according to any embodiment of the present application.
[0012] In a sixth aspect, embodiments of the present application further provide a computer readable storage medium having a computer program stored thereon, the computer program being adapted to implement the model generation method or object detection method according to any embodiment of the present application when executed by a processor. [Brief description of the drawings]
[0013] [Figure 1] 1 is a flowchart of a model generating method according to a first embodiment of the present application. [Diagram 2] 11 is a flowchart of a model generating method according to a second embodiment of the present application. [Diagram 3] 11 is a flowchart of an object detection method according to a third embodiment of the present application. [Figure 4a] 13 is a flowchart of model compression in an object detection method according to a third embodiment of the present application. [Figure 4b] 13 is a flowchart of model pruning in the object detection method according to the third embodiment of the present application. [Diagram 5] FIG. 11 is a configuration block diagram of a model generating device according to a fourth embodiment of the present invention. [Figure 6] FIG. 11 is a configuration block diagram of an object detection device according to a fifth embodiment of the present invention. [Figure 7] FIG. 13 is a schematic diagram showing the configuration of an apparatus according to a sixth embodiment of the present invention. [Figure 8] FIG. 13 is a schematic diagram illustrating the configuration of an object detection system according to a ninth embodiment of the present invention. [Figure 9] FIG. 15 is a schematic diagram showing the configuration of an unmanned vehicle according to a tenth embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0014] Example 1 1 is a flow chart of a model generation method according to a first embodiment of the present application. This embodiment can be applied to compressing a deep learning model in an object detection technology. The method can be performed by a model generation device according to an embodiment of the present application, and the device can be realized in at least one of software and hardware, and the device can be integrated into various electronic devices.
[0015] Referring to FIG. 1, the method of the embodiment of the present application includes steps S110 to S130.
[0016] Step S110: Obtain multiple scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on multiple training samples, where each training sample includes a sample image and a sample marking result of a known object in the sample image.
[0017] Here, an untrained original detection model is obtained, which is a model used for vision detection in deep learning model, and can be divided into anchor-based, anchor-free, and both fusion types, and the difference between them is whether to use anchor to extract bounding box. An anchor can also be called an anchor box, which is a set of rectangular frames obtained based on a clustering algorithm on training samples before model training.
[0018] The original detection models in anchor-based include fasterRCNN, SSD (Single Shot MultiBox Detector), YoloV2, YoloV3, etc., the original detection models in anchor-free include CornerNet, ExtremeNet, CenterNet, FCOS, etc., and the original detection models that combine anchor-based and anchor-free branches include FSAF, SFace, GA-RPN, etc. SSD is a one-stage detection model that does not have a candidate region generation stage, and directly generates the class probability and position coordinates of the object to be detected, which has a great advantage in detection speed and can be better performed in unmanned delivery vehicles and mobile terminals. Therefore, as a preferred example, the original detection model may be SSD, and the main network of SSD may be an inception_v3 structure.
[0019] Thus, after training the original detection model based on multiple training samples, a initially trained intermediate detection model can be obtained, where each training sample may include a sample image and a sample marking result of a known object in the sample image, the sample image may be a frame image or a video sequence, etc., and the sample marking result may be a class estimate and location coordinates.
[0020] In addition, each convolution layer of the original detection model is followed by a batch normalization (BN) layer, which can normalize the scale of the output result of each convolution layer, which can avoid gradient loss and gradient overflow during training. The BN layer includes a scaling factor (gamma coefficient) and an offset factor (beta coefficient), where the number of scaling factors in each BN layer is consistent with the number of channels in the convolution layer adjacent to the BN layer, that is, each scaling factor corresponds to one of the channels in the convolution layer. For example, if a BN layer has 32 scaling factors, the convolution layer adjacent to the BN layer will have 32 channels, and the BN layer will also have 32 channels. Furthermore, in the training and application stages of the original detection model, each scaling factor is multiplied with a corresponding channel in the convolution layer, that is, whether a certain scaling factor exists directly affects whether the corresponding channel in the convolution layer works. Therefore, multiple scaling factors of the batch normalization layer in the intermediate detection model can be obtained, and which models in the intermediate detection model are to be pruned based on the multiple scaling factors.
[0021] Step S120: Coefficients to be pruned are selected from the multiple scaling coefficients based on the magnitudes of the numerical values of the multiple scaling coefficients.
[0022] Here, there are various ways in which the selection of coefficients to be pruned from the multiple scaling coefficients based on the numerical magnitudes of the multiple scaling coefficients can be realized. For example, the numerical magnitudes of the multiple scaling coefficients can be ranked, a median of the multiple scaling coefficients can be obtained from the ranking result, and a coefficient to be pruned can be selected from the multiple scaling coefficients based on the median value. For example, an average value of the numerical magnitudes of the multiple scaling coefficients can be calculated, and a coefficient to be pruned can be selected from the multiple scaling coefficients based on the average value. Also, for example, a pruning threshold for the multiple scaling coefficients can be obtained based on the numerical magnitudes of the multiple scaling coefficients and a predetermined pruning rate, and a coefficient to be pruned, which may be a scaling coefficient equal to or greater than the pruning threshold, can be selected from the multiple scaling coefficients based on the pruning threshold.
[0023] Step S130: Select a pruning target channel corresponding to a pruning target coefficient from the multiple channels of the intermediate detection model, and perform channel pruning on the pruning target channel to generate an object detection model.
[0024] Here, the multiple scaling coefficients have a one-to-one correspondence with the multiple channels in a certain convolutional layer, and the multiple channels in a certain convolutional layer also have a one-to-one correspondence with the multiple channels in a BN layer adjacent to the convolutional layer. This makes it possible to select channels to be pruned from the multiple channels in the intermediate detection model based on the coefficients to be pruned. The channels to be pruned are channels with low importance, which may be channels in a certain convolutional layer or may be channels in a certain BN layer.
[0025] The pruning target channels can be pruned to generate an object detection model, thereby achieving the effect of model compression. Here, channel pruning is a structural form of compression, which is a method of simplifying a model by removing redundant channels in the model. Furthermore, after pruning the pruning target channels, the convolution kernels corresponding to these pruning target channels are also correspondingly removed, so that the channel pruning also reduces the amount of convolution calculation. For example, if a convolution layer has 32 channels, the adjacent BN layer also has 32 channels, and each channel in the BN layer includes a scaling factor and an offset factor, and the coefficients to be pruned are selected from the scaling factor, so that according to the coefficients to be pruned, it can be determined which channels in the BN layer are the channels to be pruned, and accordingly it can be determined which channels in the convolution layer are the channels to be pruned.
[0026] Preferably, the above-mentioned channel pruning implementation process may be as follows: from the multiple channels of the multiple convolution layers of the intermediate detection model, select the output channel of the current convolution layer corresponding to the current pruning coefficient in the multiple pruning target coefficients and the input channel of the next convolution layer of the current convolution layer, and take the output channel of the current convolution layer and the input channel of the next convolution layer of the current convolution layer as the pruning target channels. This is because the output channel of the current convolution layer is the input channel of the next convolution layer of the current convolution layer. For example, if the output channel of the current convolution layer is 1-32, the input channel of the next convolution layer of the current convolution layer is also 1-32. At this time, if the output channel 17 of the current convolution layer corresponding to the current pruning coefficient is the pruning target channel, the input channel 17 of the next convolution layer of the current convolution layer is also the pruning target channel.
[0027] In the technical solution of the embodiment of the present application, by obtaining a plurality of scaling coefficients of the batch normalization layer in the initially trained intermediate detection model, a coefficient to be pruned can be selected from the plurality of scaling coefficients according to the numerical magnitude of the plurality of scaling coefficients, and the coefficient to be pruned and the channel to be pruned have a corresponding relationship, so that a channel to be pruned corresponding to the coefficient to be pruned can be selected from the plurality of channels of the intermediate detection model, and the channel to be pruned can be channel pruned to generate an object detection model. In the above technical solution, the channel pruning and the intermediate detection model can be combined to perform channel pruning of the intermediate detection model according to the scaling coefficients in the initially trained intermediate detection model, thereby achieving the effect of compressing the model to improve the detection speed of the model.
[0028] As a preferred technical solution, the above model generation method may further include: selecting a convolutional layer that can be pruned from a plurality of convolutional layers of the intermediate detection model, where the convolutional layer that can be pruned includes a 1*1 convolutional layer and / or a convolutional layer other than a convolutional layer in a classification / regression branch; selecting a scaling coefficient corresponding to the convolutional layer that can be pruned from a plurality of scaling coefficients, where the scaling coefficient corresponding to the convolutional layer that can be pruned is an object scaling coefficient; accordingly, selecting a coefficient to be pruned from the plurality of scaling coefficients based on the numerical magnitudes of the plurality of scaling coefficients may include selecting a coefficient to be pruned from the plurality of object scaling coefficients based on the numerical magnitudes of the plurality of object scaling coefficients.
[0029] Here, in a normal case, the original detection model usually includes two parts: a main network and a classification regression branch, the main network can be used to extract a feature map, and the classification regression branch is a classification branch and a regression branch branched from the main network, which can be used to classify or regress the extracted feature map. Since the classification and regression class is usually constant, the convolution layer in the classification regression branch can be made constant as much as possible, thus ensuring that the output dimension is constant and simplifying the execution code. Thus, the convolution layer other than at least one of the 1*1 convolution layer and the convolution layer in the classification regression branch can be made a prunable convolution layer, and the coefficient to be pruned can be selected from the multiple object scaling coefficients in the prunable convolution layer.
[0030] As a preferred technical solution, after the pruning of the channel to be pruned, a pruned detection model is first generated, and then the pruned detection model is trimmed and trained to generate an object detection model. That is, by trimming and training the simple pruned detection model after channel pruning, the detection effect can be restored, that is, the model can be compressed while maintaining the original performance of the model as much as possible. Here, the trimming training process can be as follows: Obtain a historical image and a historical marking result of a known object in the historical image, take the historical image and the historical marking result as a set of historical samples, and train a pruned detection model based on the multiple historical samples to obtain an object detection model. Note that, in a normal case, the historical sample and the training sample are similar sample data, that is, when trimming training, the historical image and the sample image can be similar images, and the historical marking result and the sample marking result can be similar marking results.
[0031] Example 2 FIG. 2 is a flow chart of a model generation method according to the second embodiment of the present application. This embodiment is sub-divided based on the above technical solutions. In this embodiment, preferably, the model generation method further includes obtaining a plurality of training samples, and performing sparse training based on a batch normalization layer on the original detection model based on the plurality of training samples to obtain an intermediate detection model. However, the description of the same or corresponding terms as those in the above embodiments is omitted here.
[0032] Referring to FIG. 2, the method of this embodiment may include steps S210 to S230. Step S210: obtain a plurality of training samples, and perform sparse training based on a batch normalization layer on the original detection model based on the plurality of training samples to obtain an intermediate detection model, where each training sample includes a sample image and a sample marking result of a known object in the sample image.
[0033] Here, when the sparse training based on the BN layer is performed on the original detection model, an intermediate detection model in which the BN layer is sparsified can be obtained, that is, sparsification is introduced into the dense connection of the original detection model. Illustratively, a preferred embodiment of the sparse training based on the BN layer is to add an L1 regularity constraint to each scaling coefficient in the original detection model, so that the original detection model adjusts the parameters toward structural sparsity, and at this time, the role of the scaling coefficient (gamma coefficient) in the BN layer corresponds to the switch coefficient of the information stream channel, and controls the switch of the information stream channel to be closed.
[0034] The reason for this is that during model training, an L1 regularity constraint is applied to the scaling coefficients, so that more scaling coefficients can be adjusted to 0. Thus, during the model training and application stages, the scaling coefficients are multiplied with the corresponding channels in the convolution layer, so that when more scaling coefficients become 0, the channels in the convolution layer corresponding to them have no effect, that is, the role of channel pruning is also played by greatly compressing the scaling coefficients. Moreover, when selecting channels to be pruned based on a preset pruning rate, the more scaling coefficients in the intermediate detection model that have a numerical value of 0, the less likely the channels corresponding to the scaling coefficients that have a numerical value other than 0 are to be pruned, so that the network structure of the generated object detection model and the network structure of the intermediate detection model are consistent, and thus the detection performances of both are consistent, that is, the detection performance is maintained while the effect of model compression is realized.
[0035] Moreover, the object loss function in the original detection model may be composed of an original loss function and an L1 regularity constraint function, and the L1 regularity constraint function may include a loss function that performs an L1 regularity constraint on the scaling factor. That is, an L1 regularity constraint term of the scaling factor of the BN layer is introduced on the original loss function. In this way, during training, a local minimum is obtained based on the object loss function, and multiple parameter values in the model can be adjusted based on the obtained result.
[0036] Preferably, the object loss function L can be expressed as the following formula:
[0037]
number
[0038] Here, x is a sample image, y is a sample labeling result of the sample image, W is a parameter value in the original detection model, f(x, W) is a sample prediction result of a known object in the sample image, γ is a scaling factor, λ is a penalty factor, l() is the original loss function, g() is an L1 regularity constraint function, and Γ represents the set of all scaling factors in the original detection model. Furthermore, since the L1 regularity constraint function is only applied to the scaling factor of the BN layer, when updating the gradient by propagating backwards, the gradient of the scaling factor γ grad It is necessary to add a product term of the sign (γ) of the scaling coefficient and the penalty coefficient λ to the above, and the formula is shown below.
[0039]
number
[0040] Step S220: Obtain a plurality of scaling coefficients of a batch normalization layer in the intermediate detection model, and select a coefficient to be pruned from the plurality of scaling coefficients according to the numerical magnitudes of the plurality of scaling coefficients.
[0041] Step S230: Select a pruning target channel corresponding to a pruning target coefficient from the multiple channels of the intermediate detection model, and perform channel pruning on the pruning target channel to generate an object detection model.
[0042] In the technical solution of the embodiments of the present application, based on multiple training samples, sparse training based on a BN layer is performed on the original detection model, and an intermediate detection model with a sparsified BN layer can be obtained. After channel pruning of the intermediate detection model, an object detection model can be generated, and the detection performance of both is consistent, that is, the detection performance is maintained while the effect of model compression is realized.
[0043] Example 3 3 is a flowchart of an object detection method according to a third embodiment of the present application. In this embodiment, an object detection model generated based on the method described in any of the above embodiments can be applied to object detection in an image to be detected. The method may be executed by an object detection device according to the embodiment of the present application, and the device may be realized in at least one form of software and hardware, and the device may be integrated into various electronic devices.
[0044] Referring to FIG. 3, the method of the embodiment of the present application includes steps S310 to S320.
[0045] Step S310: Obtain an image of a detection target and an object detection model generated according to the method of any embodiment above.
[0046] Here, the image to be detected may be a frame image or a video sequence, etc., and the object detection model may be a vision detection model generated according to the method described in any of the above embodiments. Exemplarily, one of the methods for generating the object detection model may be that shown in FIG. 4a.
[0047] First, based on the original SSD detection model, the inception_v3 structure is used as the main network. During model training, if the original parameter settings are kept, an L1 regularity constraint is added to the gamma coefficient in the BN layer adjacent to the convolution layer, so that the model adjusts the parameters toward structural sparsity, thereby realizing the sparsification of the BN layer. Secondly, after the sparse training based on the BN layer is completed, the channels of the corresponding convolution layer and BN layer can be pruned for the intermediate detection model trained initially according to the scaling factor of the BN layer according to the preset pruning rate, so that the model can be simplified to improve a certain detection speed. Finally, the channel-pruned simple model is trimmed and trained to restore the detection effect.
[0048] The above channel pruning process may be as shown in FIG. 4b. First, it is necessary to determine which convolution layer is to be pruned, and in the embodiment of the present application, there are two restrictions: neither the 1*1 convolution layer nor the convolution layer in the classification / regression branch is pruned, which can ensure that the output dimension is not changed. Then, the gamma coefficients in the BN layer corresponding to the remaining prunable convolution layers are statistically calculated, and all the statistical gamma coefficients are ranked, and the pruning threshold of the gamma coefficient is calculated according to a preset pruning rate. Furthermore, based on the pruning threshold, each channel in the convolution layer and the BN layer is selected, and those channels corresponding to the gamma coefficient whose value exceeds the pruning threshold are reserved, thereby determining a mask (MASK) of the channels that can be reserved in the BN layer and the convolution layer adjacent to the BN layer. Finally, based on the MASK, the corresponding channels in the convolution layer and the BN layer are reserved, and the channels that are not reserved are pruned.
[0049] Step S320: The image of the detection target is input to an object detection model, and an object detection result of the object to be detected in the image of the detection target is obtained based on the output result of the object detection model.
[0050] As a preferred example, the above object detection method can be applied to vision object detection in unmanned delivery vehicles in the field of intelligent logistics, taking the example in the background art as a preferred example. Most of the on-board processors in unmanned delivery vehicles are made of the Xvaier platform, which has relatively limited computing resources, but the object detection model according to the above object detection method has a small scale and a fast detection speed, and can still meet the full-scale unmanned operation of unmanned delivery vehicles even if it is limited by the constraints of computing resources. Furthermore, by performing a structural pruning operation on the channel level, the generated simple model can be directly executed on mature frameworks such as Pytorch, MXnet, TensorFlow, or hardware platforms such as graphics processors (Graphics Processing Units, GPUs) and field programmable gate arrays (Field Programmable Gate Arrays, FPGAs), which does not require the support of special algorithm libraries, making it more convenient to apply.
[0051] In order to verify the detection accuracy of the above object detection method, the method is used to test the detection accuracy on five subsets (car, pedestrian, truck, bus, rider) of the University of California Berkeley DeepDrive Deep Learning Autonomous Driving Industry Union (Berkeley DeepDrive, BDD) dataset, and the quantified results are shown in the following two tables. From the data in the tables, it can be seen that the structural pruning object detection method of the embodiment of the present application can achieve obvious compression effect when some convolutional layers and BN layers are left unchanged, and at the same time, the detection result mAP (average value of five subsets) is slightly reduced.
[0052] [Table 1]
[0053] [Table 2]
[0054] In the technical solution of the embodiments of the present application, an object can be detected in the target image based on the generated object detection model. Since the object detection model is a simplified model that has been compressed, it can effectively improve the detection speed of the target object in the target image, and can maintain the original performance of the model as much as possible.
[0055] Example 4 5 is a block diagram of a model generating device according to a fourth embodiment of the present application, which is configured to execute the model generating method according to any of the above embodiments. The device belongs to the same inventive concept as the model generating method of each of the above embodiments, and the details not described in detail in the embodiment of the model generating device can be referred to the embodiment of the model generating method. Referring to FIG. 5, the device may include a first acquisition module 410, a first selection module 420, and a model generating module 430.
[0056] Wherein, the first acquisition module 410 is configured to acquire a plurality of scaling coefficients of a batch normalization layer in an initially trained intermediate detection model, the intermediate detection model being trained on an original detection model based on a plurality of training samples, each training sample including: a sample image; and a sample labeling result of a known object in the sample image; The first selection module 420 is configured to select coefficients to be pruned from the plurality of scaling coefficients based on numerical magnitudes of the plurality of scaling coefficients; The model generation module 430 is configured to select pruning channels corresponding to the pruning coefficients from the multiple channels of the intermediate detection model, and perform channel pruning on the pruning channels to generate an object detection model.
[0057] Preferably, the first screening module 420 comprises: The method may be configured to obtain a pruning threshold for the multiple scaling coefficients based on the numerical magnitudes of the multiple scaling coefficients and a predetermined pruning rate, and to select coefficients to be pruned from the multiple scaling coefficients based on the pruning threshold.
[0058] Preferably, in accordance with the above device, the device comprises: A second selection module configured to select prunable convolutional layers from a plurality of convolutional layers of the intermediate detection model, the prunable convolutional layers including convolutional layers other than at least one of a 1*1 convolutional layer and a convolutional layer in a classification / regression branch; The method may further include a third sorting module configured to sort a scaling coefficient corresponding to a prunable convolutional layer from the plurality of scaling coefficients, where the scaling coefficient corresponding to the prunable convolutional layer is an object scaling coefficient; The first screening module 420 is The method may be configured to select coefficients to be pruned from the plurality of object scaling coefficients based on the magnitudes of the numerical values of the plurality of object scaling coefficients.
[0059] Preferably, the model generation module 430 comprises: The intermediate detection model may include a pruning channel selection unit configured to select an output channel of a current convolutional layer corresponding to a current pruning coefficient in the multiple pruning coefficients and an input channel of a next convolutional layer of the current convolutional layer from the multiple channels of the multiple convolutional layers of the intermediate detection model, and to set the output channel and the input channel as pruning channels.
[0060] Preferably, in accordance with the above device, the device comprises: The method may further include a third acquisition module configured to acquire a plurality of training samples; and perform sparse training based on a batch normalization layer on the original detection model based on the plurality of training samples to obtain an intermediate detection model.
[0061] Preferably, the object loss function in the original detection model is composed of an original loss function and an L1 regularity constraint function, and the L1 regularity constraint function includes a loss function that performs an L1 regularity constraint on a plurality of scaling factors.
[0062] Preferably, the object loss function L is expressed as the following formula:
[0063]
number
[0064] where x is a sample image, y is a sample labeling result of the sample image, W is a parameter value in the original detection model, f(x, W) is a sample prediction result of a known object in the sample image, γ is a scaling coefficient, λ is a penalty coefficient, l() is the original loss function, g() is the L1 regularity constraint function, and Γ represents the set of all scaling coefficients in the original detection model.
[0065] Preferably, the model generation module 430 comprises: a channel pruning unit configured to channel prune a channel to be pruned and obtain a pruned detection model; and a trimming training unit configured to trim and train the pruned detection model to generate an object detection model.
[0066] In the model generating device according to the fourth embodiment of the present application, a first acquisition module acquires a plurality of scaling coefficients of a batch normalization layer in a rudimentarily trained intermediate detection model, a first selection module can select a coefficient to be pruned from the plurality of scaling coefficients according to the magnitude of the numerical values of the plurality of scaling coefficients, and a model generating module can select a channel to be pruned corresponding to the coefficient to be pruned from the plurality of channels of the intermediate detection model, since the coefficient to be pruned and the channel to be pruned have a corresponding relationship, and can perform channel pruning on the channel to be pruned to generate an object detection model. In the above device, the channel pruning and the intermediate detection model can be combined to perform channel pruning on the intermediate detection model according to the scaling coefficients in the rudimentarily trained intermediate detection model, thereby realizing the effect of improving the detection speed of the model by compressing the model.
[0067] A model generating device according to an embodiment of the present application can execute the model generating method according to any embodiment of the present application, and includes functional modules corresponding to executing the method.
[0068] In the above embodiment of the model generation device, each unit and module included is merely divided according to functional logic, but is not limited to the above division as long as it can realize the corresponding function. Furthermore, the names of each functional unit are merely for the convenience of distinction and are not used to limit the scope of the claims of this application.
[0069] Example 5 6 is a block diagram of an object detection device according to a fifth embodiment of the present application, which is configured to execute the object detection method according to any of the above embodiments. The device belongs to the same inventive concept as the object detection method of each of the above embodiments, and the details not described in detail in the object detection device embodiment can be referred to the object detection method embodiment. Referring to FIG. 6, the device may include a second acquisition module 510 and an object detection module 520.
[0070] Wherein, the second acquisition module 510 is configured to acquire an image of a detection target and an object detection model generated according to the method of any one of the first and second embodiments; The object detection module 520 is configured to input the target image to an object detection model, and obtain an object detection result for the target object in the target image based on an output result of the object detection model.
[0071] In the object detection device of Example 5 of the present application, the second acquisition module and the object detection module are combined with each other, so that an object can be detected in the image to be detected based on the generated object detection model. Since the object detection model is a simplified model in which the model is compressed, this can effectively improve the detection speed of the object to be detected in the image to be detected, and can maintain the original performance of the model as much as possible.
[0072] The object detection apparatus according to the embodiments of the present application can execute the object detection method according to any embodiment of the present application, and includes functional modules corresponding to executing the method.
[0073] In the above embodiment of the object detection device, each unit and module included is merely divided according to functional logic, but is not limited to the above division as long as it can realize the corresponding function. Furthermore, the names of each functional unit are merely for the convenience of distinction and are not used to limit the scope of the claims of this application.
[0074] Example 6 Fig. 7 is a schematic diagram of a configuration of a device according to a sixth embodiment of the present application, and as shown in Fig. 7, the device includes a memory 610, a processor 620, an input device 630, and an output device 640. The number of processors 620 in the device may be at least one, and Fig. 7 shows an example in which there is one processor 620. The memory 610, the processor 620, the input device 630, and the output device 640 in the device may be connected by a bus or other form, and Fig. 7 shows an example in which they are connected by a bus 650.
[0075] The memory 610 may be configured as a computer-readable storage medium to store software programs, computer-executable programs, and modules, such as program instructions / modules corresponding to the model generation method according to the embodiment of the present application (e.g., the first acquisition module 410, the first selection module 420, and the model generation module 430 in the model generation device), or program instructions / modules corresponding to the object detection method according to the embodiment of the present application (e.g., the second acquisition module 510 and the object detection module 520 in the object detection device). The processor 620 executes the software programs, instructions, and modules stored in the memory 610 to perform various functional applications and data processing of the device, i.e., to realize the above-mentioned model generation method or object detection method.
[0076] The memory 610 may mainly include a program storage area and a data storage area, where the program storage area can store an operating system and an application program required for at least one function, and the data storage area can store data generated according to the use of the device, etc. The memory 610 may also include a high-speed random access memory (RAM) or a non-volatile memory, such as at least one magnetic disk memory member, a flash memory member, or other non-volatile solid-state memory member. In some examples, the memory 610 may include memories located remotely to the processor 620, and these remote memories may be connected to the device via a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0077] The input device 630 is configured to accept entered numeric or textual information and to generate key signal inputs related to user settings and function control of the device. The output device 640 may include a display device such as a display.
[0078] Example 7 Example 7 of the present application provides a storage medium including computer-executable instructions, the computer-executable instructions being used, when executed by a computer processor, to perform a model generation method, the method including: Obtaining multiple scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on multiple training samples, each training sample including a sample image and a sample labeling result of a known object in the sample image; selecting a coefficient to be pruned from the plurality of scaling coefficients based on the magnitudes of the numerical values of the plurality of scaling coefficients; Selecting pruning target channels corresponding to the pruning target coefficients from a plurality of channels of the intermediate detection model, and channel pruning the pruning target channels to generate an object detection model.
[0079] It will be appreciated that a storage medium containing computer-executable instructions according to embodiments of the present application may include computer-executable instructions for performing operations related to the model generation method according to any embodiment of the present application, including but not limited to the operations of the methods described above.
[0080] Example 8 An eighth embodiment of the present application provides a storage medium including computer-executable instructions, the computer-executable instructions being used to perform an object detection method when executed by a computer processor, the method including: Obtaining an image of a detection target and an object detection model generated according to the method described in any one of the above embodiments 1 and 2; The method includes inputting an image of a detection target into an object detection model, and obtaining an object detection result for the object to be detected in the image of the detection target based on an output result of the object detection model.
[0081] Example 9 An embodiment of the present application further provides an object detection system, referring to FIG. 8 , the system includes a collection device 710, a calculation device 720, and a storage device 730, in which the object detection model generated in embodiment 1 or embodiment 2 is stored, the collection device 710 is configured to collect an image of a detection target, and the calculation device 720 is configured to load the image of the detection target and the object detection model, and input the image of the detection target into the object detection model, and obtain an object detection result of the object to be detected in the image of the detection target based on an output result of the object detection model.
[0082] Example 10 An embodiment of the present application further provides an unmanned vehicle, and referring to FIG. 9 , the unmanned vehicle includes a driving device 810, a path planning device 820, and the device 830 described in Example 7, where the driving device 810 drives the unmanned vehicle to run according to a path planned by the path planning device 820, the device 830 described in Example 6 is configured to realize detection of a detection target object in an image of a detection target, and the path planning device 820 is configured to plan a path of the unmanned vehicle based on the detection result of the device described in Example 6 for the detection target object in the detection target image.
[0083] Through the description of the above embodiments, it is obvious to those skilled in the art that the present application can be realized by relying on software and necessary general-purpose hardware, and can also be realized by hardware. Based on this understanding, the technical solution of the present application can be essentially embodied as a software product, and the computer software product can be stored in a computer-readable storage medium such as a computer flexible disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (FLASH (registered trademark)), a hard disk, or an optical disk, and can include some instructions and be used by a computer device (which may be a personal computer (PC), a server, or a network device, etc.) to execute the methods according to the embodiments of the present application. [Aspect 1] 1. A model generation method, comprising: Obtaining multiple scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on multiple training samples, each training sample including a sample image and a sample labeling result of a known object in the sample image; selecting a coefficient to be pruned from the plurality of scaling coefficients based on the magnitudes of the numerical values of the plurality of scaling coefficients; Selecting a pruning target channel corresponding to the pruning target coefficient from a plurality of channels of the intermediate detection model, and channel pruning the pruning target channel to generate an object detection model. Model generation method. [Aspect 2] Selecting a coefficient to be pruned from the plurality of scaling coefficients based on the magnitude of the numerical values of the plurality of scaling coefficients includes: obtaining a pruning threshold for the plurality of scaling coefficients based on the numerical magnitudes of the plurality of scaling coefficients and a reserved pruning rate; and selecting a coefficient to be pruned from the plurality of scaling coefficients based on the pruning threshold. The method according to embodiment 1. [Aspect 3] Selecting prunable convolutional layers from the plurality of convolutional layers of the intermediate detection model, where the prunable convolutional layers include convolutional layers other than at least one of a 1*1 convolutional layer and a convolutional layer in a classification / regression branch; selecting a scaling coefficient corresponding to the convolutional layer that can be pruned from the plurality of scaling coefficients, the scaling coefficient corresponding to the convolutional layer that can be pruned being an object scaling coefficient; selecting coefficients to be pruned from the plurality of scaling coefficients based on the magnitudes of the numerical values of the plurality of scaling coefficients includes selecting coefficients to be pruned from the plurality of object scaling coefficients based on the magnitudes of the numerical values of the plurality of object scaling coefficients. The method according to embodiment 1. [Aspect 4] The pruning target coefficients are a plurality of coefficients, and selecting pruning target channels corresponding to the pruning target coefficients from a plurality of channels of the intermediate detection model includes: Select an output channel of a current convolution layer corresponding to a current pruning coefficient among the multiple pruning target coefficients from the multiple channels of the multiple convolution layers of the intermediate detection model, and an input channel of a convolution layer next to the current convolution layer, and set the output channel and the input channel as pruning target channels; The method according to embodiment 1. [Aspect 5] obtaining a plurality of the training samples; and performing sparse training based on the batch normalization layer on the original detection model based on the plurality of the training samples to obtain the intermediate detection model. The method according to embodiment 1. [Aspect 6] The object loss function in the original detection model is composed of an original loss function and an L1 regularity constraint function, and the L1 regularity constraint function includes a loss function that performs an L1 regularity constraint on a plurality of the scaling factors. The method according to embodiment 5. [Aspect 7] The object loss function L is expressed as the following formula:
number
Claims
1. 1. A model generation method, comprising: Obtaining multiple scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on multiple training samples, each training sample including a sample image and a sample labeling result of a known object in the sample image; selecting a coefficient to be pruned from the plurality of scaling coefficients based on the magnitudes of the numerical values of the plurality of scaling coefficients; Selecting a pruning target channel corresponding to the pruning target coefficient from a plurality of channels of the intermediate detection model, and channel pruning the pruning target channel to generate an object detection model; The pruning target coefficients are a plurality of coefficients, and selecting pruning target channels corresponding to the pruning target coefficients from a plurality of channels of the intermediate detection model includes: Selecting an output channel of a current convolutional layer corresponding to a current pruning coefficient among the multiple pruning target coefficients from a plurality of channels of a plurality of convolutional layers of the intermediate detection model and an input channel of a convolutional layer next to the current convolutional layer, and setting the output channel and the input channel as pruning target channels; The model generation method includes: Selecting prunable convolutional layers from the plurality of convolutional layers of the intermediate detection model, where the prunable convolutional layers include convolutional layers other than at least one of a 1*1 convolutional layer and a convolutional layer in a classification / regression branch; selecting a scaling coefficient corresponding to the convolutional layer that can be pruned from the plurality of scaling coefficients, the scaling coefficient corresponding to the convolutional layer that can be pruned being an object scaling coefficient; selecting coefficients to be pruned from the plurality of scaling coefficients based on the magnitudes of the numerical values of the plurality of scaling coefficients includes selecting coefficients to be pruned from the plurality of object scaling coefficients based on the magnitudes of the numerical values of the plurality of object scaling coefficients. Model generation method.
2. Selecting a coefficient to be pruned from the plurality of scaling coefficients based on the magnitude of the numerical values of the plurality of scaling coefficients includes: obtaining a pruning threshold for the plurality of scaling coefficients based on the numerical magnitudes of the plurality of scaling coefficients and a reserved pruning rate; and selecting a coefficient to be pruned from the plurality of scaling coefficients based on the pruning threshold. The method of claim 1.
3. The method further includes obtaining a plurality of the training samples, and performing sparse training based on the batch normalization layer on the original detection model based on the plurality of the training samples to obtain the intermediate detection model; The object loss function in the original detection model is composed of an original loss function and an L1 regularity constraint function, and the L1 regularity constraint function includes a loss function that performs an L1 regularity constraint on a plurality of the scaling factors. The method of claim 1.
4. The object loss function L is expressed as the following formula: [0010] where x is a sample image, y is a sample labeling result in the sample image, W is a parameter value in the original detection model, f(x, W) is a sample prediction result of a known object in the sample image, γ is a scaling factor, λ is a penalty factor, l() is the original loss function, g() is the L1 regularity constraint function, and Γ represents the set of all scaling factors in the original detection model. The method according to claim 3.
5. The channel pruning of the pruning target channel and generating an object detection model includes: pruning the pruning target channel to obtain a pruned detection model; and training the pruned detection model to generate an object detection model. The method of claim 1.
6. The original detection model includes a single-shot multi-box detector SSD; The SSD backbone network includes an inception_v3 structure; The method of claim 1.
7. 1. A method for object detection, comprising: Obtaining an image of a detection target and an object detection model generated according to the method of any one of claims 1 to 6; inputting the image of the detection target into the object detection model, and obtaining an object detection result of the object to be detected in the image of the detection target based on an output result of the object detection model. Object detection methods.
8. A model generating device, a first acquisition module configured to acquire a plurality of scaling factors of a batch normalization layer in an initially trained intermediate detection model, where the intermediate detection model is trained on an original detection model based on a plurality of training samples, each training sample including a sample image and a sample labeling result of a known object in the sample image; and a first selection module configured to select coefficients to be pruned from the plurality of scaling coefficients based on numerical magnitudes of the plurality of scaling coefficients; a model generation module configured to select pruning channels corresponding to the pruning coefficients from a plurality of channels of the intermediate detection model, and to perform channel pruning on the pruning channels to generate an object detection model; The coefficients to be pruned are multiple, and the model generation module a pruning target channel selection unit configured to select an output channel of a current convolutional layer corresponding to a current pruning coefficient in the plurality of pruning target coefficients and an input channel of a convolutional layer next to the current convolutional layer from a plurality of channels of a plurality of convolutional layers of the intermediate detection model, and to set the output channel and the input channel as pruning target channels; The model generating device comprises: A second selection module configured to select prunable convolutional layers from the plurality of convolutional layers of the intermediate detection model, where the prunable convolutional layers include convolutional layers other than at least one of a 1*1 convolutional layer and a convolutional layer in a classification / regression branch; a third sorting module configured to sort a scaling coefficient corresponding to the prunable convolutional layer from the plurality of scaling coefficients, the scaling coefficient corresponding to the prunable convolutional layer being an object scaling coefficient; wherein the first selection module is configured to select coefficients to be pruned from the plurality of object scaling coefficients based on numerical magnitudes of the plurality of object scaling coefficients; Model generation device.
9. 1. An object detection device, comprising: - a second acquisition module configured to acquire an image of the detection target and an object detection model generated according to the method of any one of claims 1 to 6; an object detection module configured to input the image of the detection target to the object detection model and obtain an object detection result of the object to be detected in the image of the detection target based on an output result of the object detection model; Object detection device.
10. An apparatus comprising: At least one processor; a memory configured to store at least one program; The at least one program, when executed by the at least one processor, causes the at least one processor to implement the model generating method according to any one of claims 1 to 6. device.
11. An apparatus comprising: At least one processor; a memory configured to store at least one program; The at least one program, when executed by the at least one processor, causes the at least one processor to implement the object detection method according to claim 7. device.
12. 1. A computer-readable storage medium, comprising: A computer program is stored in the computer-readable storage medium, and the computer program, when executed by a processor, realizes the model generation method according to any one of claims 1 to 6 or the object detection method according to claim 7. A computer readable storage medium.
13. It is an unmanned vehicle, A driving device, a path planning device, and the device according to claim 11, The driving device drives the unmanned vehicle to travel according to the path planned by the path planning device, and the device according to claim 11 is configured to realize detection of a detection target object in an image of a detection target, and the path planning device is configured to plan a path for the unmanned vehicle based on a detection result of the device according to claim 11 for the detection target object in the image of the detection target. Unmanned car.
Citation Information
Patent Citations
Compression method and device of target detector, medium and electronic equipment
CN110633747A
Vehicle detection method based on improved YOLOv3
CN110796168A
Information processing device, information processing method, and program
JP2019159694A
Neural network pruning device, information processor, neural network pruning method and program
JP2019212206A
