Image processing method, image processing apparatus, electronic device, and computer-readable storage medium
The present application provides an image processing method, an image processing apparatus, an electronic device, and a computer-readable storage medium. The image processing method includes: pre-processing an image to be detected to obtain an input feature map; performing multi-channel processing on the input feature map to obtain a channel attention feature map; processing spatial domain information in the channel attention feature map to obtain a spatial attention weight; and determining an output feature map according to the spatial attention weight and the channel attention feature map.
1 . An image processing method, comprising:
pre-processing an image to be detected to obtain an input feature map;
performing multi-channel processing on the input feature map to obtain a channel attention feature map;
processing spatial domain information in the channel attention feature map to obtain a spatial attention weight; and
determining an output feature map according to the spatial attention weight and the channel attention feature map,
wherein the performing multi-channel processing on the input feature map to obtain the channel attention feature map comprises:
performing global average pooling on the input feature map to obtain a feature map to be detected; and
determining the channel attention feature map according to N channel convolution kernels and the feature map to be detected, wherein the N channel convolution kernels are different in scale, and N is an integer greater than or equal to 1,
wherein the determining the channel attention feature map according to the N channel convolution kernels and the feature map to be detected comprises:
performing operation on the N channel convolution kernels and the feature map to be detected respectively to obtain N channel feature maps;
performing image equalization on the N channel feature maps, and determining an equalized channel feature map comprising a one-dimensional feature vector; and
determining the channel attention feature map according to the equalized channel feature map and the input feature map.
2 . The method according to claim 1 , wherein the determining the channel attention feature map according to the equalized channel feature map and the input feature map comprises:
performing dot product operation on the equalized channel feature map and the feature map to be detected to obtain the channel attention feature map.
3 . The method according to claim 2 , wherein the image to be detected comprises a face image, and the pre-processing the image to be detected to obtain the input feature map comprises:
detecting and aligning images to be detected in an input face image set to obtain a face feature map set, wherein the face image set comprises a first image to be detected and a second image to be detected, and the face feature map set comprises a first face feature map and a second face feature map.
4 . The method according to claim 3 , wherein after determining the output feature map according to the spatial attention weight and the channel attention feature map, the method further comprises:
calculating a matching similarity between a first output feature map corresponding to the first face feature map and a second output feature map corresponding to the second face feature map; and
determining, according to the matching similarity and a preset similarity threshold, whether the first image to be detected and the second image to be detected are the same or not.
5 . The method according to claim 1 , wherein the processing spatial domain information in the channel attention feature map to obtain the spatial attention weight comprises:
performing maximum pooling on the spatial domain information in the channel attention feature map by taking each channel as a unit, to obtain a pooled feature map comprising a two-dimensional feature vector; and
performing convolution operation on the pooled feature map corresponding to each channel to determine the spatial attention weight.
6 . The method according to claim 5 , wherein the image to be detected comprises a face image, and the pre-processing the image to be detected to obtain the input feature map comprises:
detecting and aligning images to be detected in an input face image set to obtain a face feature map set, wherein the face image set comprises a first image to be detected and a second image to be detected, and the face feature map set comprises a first face feature map and a second face feature map.
7 . The method according to claim 1 , wherein the determining the output feature map according to the spatial attention weight and the channel attention feature map comprises:
performing dot product operation on the spatial attention weight and the channel attention feature map, to obtain the output feature map.
8 . The method according to claim 7 , wherein the image to be detected comprises a face image, and the pre-processing the image to be detected to obtain the input feature map comprises:
detecting and aligning images to be detected in an input face image set to obtain a face feature map set, wherein the face image set comprises a first image to be detected and a second image to be detected, and the face feature map set comprises a first face feature map and a second face feature map.
9 . The method according to claim 1 , wherein the image to be detected comprises a face image, and the pre-processing the image to be detected to obtain the input feature map comprises:
detecting and aligning images to be detected in an input face image set to obtain a face feature map set, wherein the face image set comprises a first image to be detected and a second image to be detected, and the face feature map set comprises a first face feature map and a second face feature map.
10 . The method according to claim 9 , wherein after determining the output feature map according to the spatial attention weight and the channel attention feature map, the method further comprises:
calculating a matching similarity between a first output feature map corresponding to the first face feature map and a second output feature map corresponding to the second face feature map; and
determining, according to the matching similarity and a preset similarity threshold, whether the first image to be detected and the second image to be detected are the same or not.
11 . The method according to claim 10 , wherein the calculating the matching similarity between the first output feature map corresponding to the first face feature map and the second output feature map corresponding to the second face feature map comprises:
calculating, according to n feature vectors in the first output feature map and n feature vectors in the second output feature map, a cosine similarity between the first output feature map and the second output feature map, wherein n is an integer greater than or equal to 1.
12 . An electronic device, comprising:
at least one processor; and
a memory having at least one computer program stored thereon, at least one computer program, executed by the at least one processor, causes the at least one processor to implement the image processing method according to claim 1 .
13 . A non-transitory computer-readable storage medium having a computer program stored thereon, the at least one computer program, executed by a processor, causes the processor to implement the image processing method according to claim 1 .
14 . An image processing apparatus, comprising:
a pre-processing module configured to pre-process an image to be detected to obtain an input feature map;
a channel attention processing module configured to perform multi-channel processing on the input feature map to obtain a channel attention feature map;
a spatial weight determination module configured to process spatial domain information in the channel attention feature map to obtain a spatial attention weight; and
a spatial attention processing module configured to determine an output feature map according to the spatial attention weight and the channel attention feature map,
wherein the channel attention processing module is configured to perform multi-channel processing on the input feature map to obtain the channel attention feature map by:
performing global average pooling on the input feature map to obtain a feature map to be detected; and
determining the channel attention feature map according to N channel convolution kernels and the feature map to be detected, wherein the N channel convolution kernels are different in scale, and N is an integer greater than or equal to 1,
wherein the channel attention processing module is configured to determine the channel attention feature map according to the N channel convolution kernels and the feature map to be detected by:
performing operation on the N channel convolution kernels and the feature map to be detected respectively to obtain N channel feature maps;
performing image equalization on the N channel feature maps, and determining an equalized channel feature map comprising a one-dimensional feature vector; and
determining the channel attention feature map according to the equalized channel feature map and the input feature map.
15 . An image processing method, comprising:
pre-processing an image to be detected to obtain an input feature map;
performing multi-channel processing on the input feature map to obtain a channel attention feature map;
processing spatial domain information in the channel attention feature map to obtain a spatial attention weight; and
determining an output feature map according to the spatial attention weight and the channel attention feature map,
wherein the processing spatial domain information in the channel attention feature map to obtain the spatial attention weight comprises:
performing maximum pooling on the spatial domain information in the channel attention feature map by taking each channel as a unit, to obtain a pooled feature map comprising a two-dimensional feature vector; and
performing convolution operation on the pooled feature map corresponding to each channel to determine the spatial attention weight.