Object detection method, machine learning method, and electronic device
An object detection method includes the following steps: detecting an environment signal, determining a task mode based on the environment signal, capturing an input image, performing feature extraction on the input image through a sub-model of a neural network model according to the task mode, where the sub-model of the neural network model includes a task-specific layer corresponding to the task mode, where a polarization mask of the task-specific layer determines the sub-model of the neural network model, and outputting an object detection result corresponding to the task mode.
1 . An object detection method, comprising:
detecting an environment signal;
determining a task mode according to the environment signal;
capturing an input image;
performing feature extraction on the input image according to the task mode through a sub-model of a neural network model, wherein the sub-model of the neural network model comprising a task-specific layer corresponding to the task mode, and a polarization mask of the task-specific layer determines the sub-model of the neural network model, wherein the neural network model comprising a feature extraction network, wherein the polarization mask of the task-specific layer comprising a plurality of scaling factors of a batch normalization layer of the feature extraction network, and the plurality of scaling factors are associated with a plurality of convolutional kernels of a convolutional layer of the feature extraction network, wherein the step of performing feature extraction on the input image according to the task mode through the sub-model of the neural network model comprising:
passing the input image through the feature extraction network to obtain an input feature map, further comprising:
passing the input image through the convolutional layer and obtaining the input feature map by performing normalization calculation based on the plurality of scaling factors of the batch normalization layer; and
outputting an object detection result corresponding to the task mode.
2 . The object detection method of claim 1 , wherein the feature extraction network comprising a backbone network and a neck network, wherein the step of passing the input image through the feature extraction network to obtain the input feature map comprising:
passing the input image through the backbone network to obtain a first feature map; and
passing the first feature map through the neck network to obtain the input feature map.
3 . The object detection of claim 2 , wherein the polarization mask of the task-specific layer comprising a plurality of first scaling factors of a first batch normalization layer of the backbone network and a plurality of second scaling factors of a second batch normalization layer of the neck network, wherein the plurality of first scaling factors are associated with a plurality of first convolutional kernels in a first convolutional layer of the backbone network, wherein the plurality of second scaling factors are associated with a plurality of second convolutional kernels in a second convolutional layer of the neck network, wherein the step of passing the input image through the feature extraction network to obtain the input feature map comprising:
passing the input image through the first convolutional layer and obtaining the first feature map by performing normalization calculation based on the plurality of first scaling factors of the first batch normalization layer; and
passing the first feature map through the second convolutional layer and obtaining the input feature map by performing normalization calculation based on the plurality of second scaling factors of the second batch normalization layer.
4 . The object detection method of claim 1 , wherein the neural network model further comprising a head network, wherein the step of outputting the object detection result corresponding to the task mode comprising:
passing the input feature map through the head network to obtain a prediction class and a bounding box of the input image.
5 . The object detection method of claim 4 , wherein the head network comprising a third batch normalization layer and a plurality of output layers, wherein the polarization mask of the task-specific layer comprising a plurality of third scaling factors of the third batch normalization layer, wherein the plurality of third scaling factors are associated with a plurality of third convolutional kernels in a third convolutional layer of the third batch normalization layer, wherein the step of passing the input feature map through the head network to obtain the prediction class and the bounding box of the input image comprising:
passing the input feature map through the third convolutional layer and obtaining an output feature map by performing normalization calculation based on the plurality of third scaling factors of the third batch normalization layer; and
passing the output feature map through the plurality of output layers to obtain the prediction class and the bounding box.
6 . The object detection method of claim 1 , wherein the neural network model is a YOLOR model.
7 . The object detection method of claim 1 , further comprising:
receiving a training data associated with the task mode, wherein the training data comprising a training image, a class label corresponding to the training image and a bounding box corresponding to the training image;
configuring the task-specific layer of the neural network model according to the task mode;
determining a loss function according to the class label, the bounding box label and the polarization mask of the task-specific layer;
determining a backpropagation gradient according to the loss function; and
updating the neural network model and the polarization mask of the task-specific layer according to the backpropagation gradient.
8 . The object detection method of claim 7 , wherein the loss function comprising:
a cross entropy loss; and
a layer-wise polarization regularization term.
9 . The object detection method of claim 8 , wherein the polarization mask of the task-specific layer comprising a plurality of scaling factors of a batch normalization layer of the neural network model, and the plurality of scaling factors are associated with a plurality of convolutional kernels in a convolutional layer of the neural network model, wherein the layer-wise polarization regularization term is calculated by the following formula:
R
s
(
r
)
=
∑
l
=
1
L
∑
c
=
1
C
l
k
❘
"\[LeftBracketingBar]"
r
l
,
c
t
❘
"\[RightBracketingBar]"
-
❘
"\[LeftBracketingBar]"
r
l
,
c
t
-
r
l
_
❘
"\[RightBracketingBar]"
,
r
l
_
=
∑
c
=
1
C
l
r
l
,
c
t
/
C
l
,
wherein R s (r) represents the layer-wise polarization regularization term,
r
l
,
c
t
represents the plurality of scaling factors, L represents a number of layers of the batch normalization layer and the convolutional layer, C l represents a number of channels of the convolutional kernels, and k is a parameter.
10 . The object detection method of claim 7 , wherein the step of updating the neural network model and the polarization mask of the task-specific layer according to the backpropagation gradient comprising:
determining activation parameters based on the polarization mask of the task-specific layer;
adjusting the backpropagation gradient according to the activation parameters; and
updating the neural network model and the polarization mask of the task-specific layer according to the backpropagation gradient.
11 . The object detection method of claim 7 , further comprising:
determining a second task mode according to the environment signal and receiving a second training data associated with the second task mode;
configuring a second task-specific layer of the neural network model according to the second task mode, wherein a second polarization mask of the second task-specific layer determines a second sub-model of the neural network model; and
updating the neural network model and the second polarization mask of the second task-specific layer according to the second training data.
12 . An electronic device, comprising:
a storage medium, storing a plurality of modules; and
a processor, coupled to the storage medium, configured to execute the plurality of modules, wherein the plurality of modules comprising:
an environment perception module, detecting an environment signal;
an image capturing module, capturing an input image; and
an inference module,
determining a task mode according to the environment signal,
performing feature extraction on the input image according to the task mode through a sub-model of a neural network model, wherein the sub-model of the neural network model comprising a task-specific layer corresponding to the task mode, and a polarization mask of the task-specific layer determines the sub-model of the neural network model, wherein the neural network model comprising a feature extraction network, wherein the polarization mask of the task-specific layer comprising a plurality of scaling factors of a batch normalization layer of the feature extraction network, and the plurality of scaling factors are associated with a plurality of convolutional kernels of a convolutional layer of the feature extraction network;
passing the input image through the feature extraction network to obtain an input feature map;
passing the input image through the convolutional layer and obtaining the input feature map by performing normalization calculation based on the plurality of scaling factors of the batch normalization layer; and
outputting an object detection result corresponding to the task mode.