Target detection method and device, electronic equipment and storage medium
By introducing a positional encoding mechanism and improving the convolutional kernel in the transformer encoder, the problem of misalignment between features and positional information in the transformer structure is solved, thereby improving the accuracy of object detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2026-03-27
AI Technical Summary
Existing transformer-based object detectors suffer from a misalignment between feature and location information, leading to inaccurate object detection.
By introducing a position encoding mechanism into the transformer encoder, combined with dilated or deformable convolution kernels, the position vector is adjusted to align features with their positions, thereby improving detection accuracy.
This achieves alignment between features and location information, improving the accuracy of target detection.
Smart Images

Figure CN116129101B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of artificial intelligence, in particular to the computing fields of computer vision, image processing, deep learning, and the like, and more particularly to a target detection method and device, an electronic device, and a storage medium. BACKGROUND
[0002] Target detection is a basic task of computer vision and is widely applied. Most typical target detectors are based on the architecture of CNN (Convolutional Neural Networks). In recent years, CNN-based target detectors have made significant progress. In the past two years, researchers have proposed an end-to-end target detector based on transformer (DETR, DEtection TRansformer), which eliminates the need for manually designed anchors and exhibits comparable performance to anchor-based detectors (such as Faster RCNN). However, the existing DETR still has the drawback of inaccurate target detection. SUMMARY
[0003] To solve the technical problem that the features and position information learned by the transformer structure are not aligned, the present disclosure provides a target detection method, device, electronic device, and storage medium.
[0004] According to a first aspect of the present disclosure, a target detection method is provided, comprising:
[0005] obtaining a first feature map corresponding to a to-be-detected image;
[0006] inputting the first feature map into an encoder of a target detection model, and performing position encoding on the first feature map according to coordinate information of the first feature map by the encoder to obtain a first position vector corresponding to the first feature map;
[0007] inputting the first feature map and the corresponding first position vector into each level of the encoder in sequence for encoding processing to obtain a second feature map and a second position vector;
[0008] performing decoding processing on the second feature map and the second position vector to obtain a detection result of the to-be-detected image.
[0009] According to a second aspect of the present disclosure, a target detection device is provided, comprising:
[0010] an obtaining module configured to obtain a first feature map corresponding to a to-be-detected image;
[0011] An encoding module is configured to input the first feature map into an encoder of a target detection model, and obtain a corresponding first position vector through position encoding of the first feature map by the encoder;
[0012] The encoding module inputs the first feature map and the corresponding first position vector into each level of the encoder in sequence for encoding processing to obtain a second feature map and a second position vector;
[0013] A decoding module is configured to perform decoding processing on the second feature map and the second position vector to obtain a detection result of the to-be-detected image.
[0014] According to a third aspect of the present disclosure, an electronic device is provided, comprising:
[0015] at least one processor; and
[0016] a memory connected to the at least one processor in communication; wherein
[0017] The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of the above technical solutions.
[0018] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to perform the method of any one of the above technical solutions.
[0019] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the method of any one of the above technical solutions.
[0020] The present disclosure provides a target detection method and device, an electronic device and a storage medium, which aligns feature and position information and improves the accuracy of target detection.
[0021] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present disclosure, nor to limit the scope of the present disclosure. Other features of the present disclosure will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0022] The accompanying drawings are used to better understand the present scheme and do not limit the present disclosure. Among them:
[0023] Figure 1 is a step schematic diagram of the target detection method in the embodiments of the present disclosure;
[0024] Figure 2is a structural schematic diagram of a transformer structure encoder in the prior art;
[0025] Figure 3 is a structural schematic diagram of a transformer structure encoder in an embodiment of the present disclosure;
[0026] Figure 4 is a target detection flowchart of a DETR structure in the prior art;
[0027] Figure 5 is a convolution principle diagram of a standard convolution kernel in the prior art;
[0028] Figure 6 is a convolution principle diagram of a hole convolution kernel used in an embodiment of the present disclosure;
[0029] Figure 7 is a principle block diagram of a target detection apparatus in an embodiment of the present disclosure;
[0030] Figure 8 is a schematic block diagram of an example electronic device in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] Exemplary embodiments of the present disclosure are described below with reference to the accompanying drawings, which include various details of the embodiments of the present disclosure to assist in understanding, and should be considered as merely exemplary. Thus, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the present disclosure. Also, descriptions of known functions and constructions are omitted in the following description for clarity and conciseness.
[0032] Compared with anchor-based detectors, DETR regards target detection as a set prediction problem, only uses 100 queries to predict the class information and position coordinates of the target, and does not require complex post-processing such as non-maximum suppression (NMS), so DETR is a more efficient target detection method. However, DETR also has some problems, such as the problem of misalignment of position and features, which leads to inaccurate target detection results.
[0033] Currently, the DETR detector has the problem of feature misalignment: because the target detector needs to detect the position information of the target, the transformer structure loses the spatial information of the features, and the position information is also encoded by a trigonometric function in the design of DETR, so that the learned features are related to the position. However, the encoded position information is fixed, while the learned features are constantly changing, which leads to inconsistency between the learned features and the encoded position information, thereby affecting the effect of target detection.
[0034] To solve the technical problem that the learned features and position information are not aligned in the prior art transformer structure, the present disclosure provides a target detection method, as shown in Figure 1 The method comprises the following steps:
[0035] In step S101, a first feature map corresponding to a to-be-detected image is obtained. The first feature map can be obtained by feature extraction through a CNN (convolutional neural network).
[0036] In step S102, the first feature map is input into an encoder of a target detection model, and a first position vector is obtained by position encoding of the first feature map according to coordinate information of the first feature map through the encoder. The transformer structure mainly comprises a CNN, an encoder, and a decoder. A conventional transformer encoder structure is shown in Figure 2 The encoder is composed of a plurality of cascaded encoder modules. Since the feature needs to be stretched from a two-dimensional feature map with a width and a height into a one-dimensional feature vector before being input into the first-level encoder module, the spatial position information of the feature is lost. The coordinate information corresponding to the feature can be encoded into a position vector, and then the position information and the feature information are simultaneously input into each transformer encoder structure for global attention calculation, so that the position information corresponding to the feature is retained. However, the feature i+1 output by each level of the encoder is the result of global attention of other features i, and the position vector is fixed and unchanged. Since the learning of the feature by the encoder module is global rather than local, the feature point position to be focused on will change in the global attention calculation. The fixed and unchanged position vector can no longer represent the spatial position of the feature i+1. In short, if the position is unchanged, the feature i+1 (second feature map) processed by the encoder and the initial position (first position vector) cannot be aligned, which will lead to the problem that the learned features and spatial positions are not aligned, thereby affecting the accuracy of target detection.
[0037] In step S103, the first feature map and the corresponding first position vector are sequentially input into each level of the encoding module of the encoder for encoding processing to obtain a second feature map and a second position vector. The transformer encoder structure in the present embodiment is shown in Figure 3As shown, the first level encoding module encoder1 of the encoder encodes the position of the feature to obtain the position vector position, and also calculates the position offset of the attention point before and after the feature extraction. For example, the coordinate information of the feature before input into the encoder1 is (x0, y0), and the coordinate information of the feature after the encoder1 is (x1, y1). Therefore, the change of the position needs to be learned while learning the feature, so as to realize the alignment of the feature and the position, and improve the accuracy of the target detection.
[0038] In step S104, the detection result of the to-be-detected image is obtained by decoding the second feature map and the second position vector. The feature and the position output by the encoder are predicted by the decoder to obtain the detection result.
[0039] The target detection method in the embodiment can be applied to the DETR structure, which is a visual version of the Transformer and can be used for target detection and panoramic segmentation. The network structure of the DETR is simple and can be divided into three parts. The first part is a traditional CNN used for extracting high-dimensional features of the picture. The second part is a Transformer structure used for extracting the bounding box (Bounding Box) through the encoder and the decoder. Finally, a bipartite matching loss function is used to train the network. The target detection process of the DETR is as follows. Figure 4 As shown, the to-be-detected picture is first input into the backbone (backbone network) which is a CNN network to extract the picture features, and then combined with the position information to be input into the encoder and the decoder of the transformer model to obtain the detection result of the transformer. Each result is a box, and each box represents a tuple containing the category and the position of the detection frame of the object.
[0040] Compared with the traditional target detection method, the DETR effectively eliminates the need for many hand-designed components, such as the non-maximum suppression (Non-Maximum Suppression, NMS) program, anchor generation, etc. However, the DETR has the above-mentioned problem of misalignment of the position and the feature. Therefore, the target detection method in the embodiment is improved based on the DETR target detection, which can not only retain the advantages of the simple overall process of the DETR and the need for no complex post-processing, but also realize the alignment of the position and the feature in the DETR target detection.
[0041] As an optional implementation, step S101, obtaining the first feature map corresponding to the image to be detected, includes: obtaining the image to be detected; inputting the image to be detected into the convolutional neural network of the target detection model, and extracting features through the convolutional neural network to obtain the first feature map. The convolutional neural network extracts features to obtain the first feature map using dilated convolutional kernels or deformable convolutional kernels.
[0042] In traditional CNN networks, convolution operators are typically used to extract features, and the size of the convolution operator determines the size of the receptive field. The larger the convolution kernel size, the larger the receptive field. For example... Figure 5 In the diagram, the blank squares represent feature maps, and the shaded areas represent convolutional kernels. Traditional convolutional kernels include... Figure 5 As shown; dilated convolution as Figure 6 As shown, the effectiveness of features is improved by expanding the range of the convolution to increase the range of the corresponding spatial location. Essentially, while keeping the spatial location constant, increasing the receptive field enhances the feature learning effect during object detection, thereby improving the accuracy of object detection. The same principle applies to feasible variable convolution and dilated convolution. In this embodiment, the object detection effect can be further improved by modifying the convolution kernels in the CNN part and combining it with the learning of the position vector.
[0043] As an optional implementation, step S103, which involves sequentially inputting the first feature map and the corresponding first position vector into each level of the encoder for encoding processing to obtain the second feature map and the second position vector, includes:
[0044] The first feature map is encoded to obtain the second feature map, and the positional offset of the first feature map after being encoded by the current encoding module is calculated.
[0045] The second position vector is obtained by adjusting the first position vector based on the position offset.
[0046] like Figure 3As shown, in the transformer encoder, instead of keeping the predefined position position vector unchanged, the position information position and the feature information feature are simultaneously input into each level of the encoder module for global attention calculation. The position offset offset before and after the feature is input into the encoder module is output at the same time as the feature output by each level of the encoder module. The original position plus the learned position offset offset is used as the position information of the next cascaded encoder. Thus, the features and positions output by each layer of the encoder are aligned, thereby enabling the network to achieve better target detection effect. For example, the coordinate information of the feature before being extracted by the encoder 1 is (x0, y0), and the coordinate information of the feature after being extracted by the encoder 1 is changed. The encoder module can obtain the position offset offset through global attention calculation, and add the original coordinate information (x0, y0) to the offset to obtain a new position vector (x1, y1), so as to realize the change of the position vector with the change of the feature.
[0047] As an optional implementation, the position offset corresponding to the first feature map is calculated by the full connection layer of each level of the encoding module. In this embodiment, a full connection layer is added to each level of the encoder module to accurately calculate the position offset offset to a decimal place. For example, the traditional calculation of the offset can only obtain an integer 1, and the offset calculated by the full connection layer in this embodiment can be accurately calculated to 1.11. In this embodiment, the offset calculation is more accurate than the traditional offset calculation, and the adjustment accuracy of the position vector is higher.
[0048] The present disclosure also provides a target detection device 700, as shown in Figure 7 The device comprises:
[0049] The acquisition module 701 is configured to acquire a first feature map corresponding to a to-be-detected image. The target detection device can be applied to a transformer structure, mainly including a CNN, an encoder, and a decoder. The first feature map can be obtained by performing feature extraction on the to-be-detected image through a convolutional neural network.
[0050] The encoding module 702 is configured to input the first feature map into an encoder of a target detection model, and perform position encoding on the first feature map through the encoder to obtain a corresponding first position vector. The traditional transformer encoder structure is as shown in Figure 2As shown, the encoder is composed of a plurality of cascaded encoder modules. Since the feature needs to be stretched from a two-dimensional wide-by-high feature map into a one-dimensional feature vector before being fed into the first level encoder module, the spatial position information of the feature is lost. The coordinate information corresponding to the feature can be encoded into a position vector, and then each transformer encoder structure will simultaneously input the position information and the feature information for global attention calculation, so that the position information corresponding to the feature is retained. However, the feature i+1 output by each layer of encoder is the result of global attention of other features i, and the position vector is fixed after a plurality of cascaded encoders. Since the learning of the encoder module on the feature is global rather than local, the position of the feature point of interest will also change in the global attention calculation, and the fixed position vector can no longer represent the spatial position of the feature i+1, which will lead to the problem of misalignment between the learned feature and the spatial position, thereby affecting the accuracy of target detection.
[0051] The encoding module 702 inputs the first feature map and the corresponding first position vector into each level of the encoder for encoding processing to obtain the second feature map and the second position vector. The transformer encoder structure in the present embodiment is as shown in Figure 3 As shown, the first level encoder module encoder1 of the encoder encodes the position of the feature to obtain the position vector position, and also calculates the position offset of the attention point before and after the feature extraction. For example, the coordinate information of the feature before being input into the encoder1 is (x0, y0), and the actual coordinate information of the feature after being input into the encoder1 is (x1, y1). Therefore, the change of the position needs to be learned at the same time as the learning of the feature, so as to realize the alignment of the feature and the position and improve the accuracy of target detection.
[0052] The decoding module 703 is configured to decode the second feature map and the second position vector to obtain the detection result of the to-be-detected image. The feature and the position output by the encoder are predicted by the decoder module to obtain the detection result.
[0053] The target detection device in the embodiment can be applied to a DETR structure. DETR is a visual version of a Transformer and can be used for target detection and panoramic segmentation. DETR is an end-to-end framework, and the network structure of DETR is simple and can be divided into three parts. The first part is a traditional CNN used to extract high-dimensional features of a picture. The second part is a Transformer structure used to extract a bounding box by using an encoder and a decoder. Finally, a bipartite matching loss function is used to train the network. The target detection process of DETR is shown in Figure 4 As shown in the figure, first, a picture to be detected is input into a network with a CNN backbone to extract picture features, and then the position information is combined and input into an encoder and a decoder of a transformer model to obtain a detection result of the transformer. Each result is a box, and each box represents a tuple containing the category and the position of the detection frame of an object.
[0054] Compared with traditional target detection methods, DETR effectively eliminates the need for many hand-designed components, such as a non-maximum suppression (NMS) program, anchor generation, and the like. However, DETR has the problem of misalignment of position features. Therefore, the target detection method in the embodiment is improved based on DETR target detection, which can not only retain the advantages of simple overall process and no need for complex post-processing of DETR, but also realize alignment of position and features in DETR target detection.
[0055] As an optional implementation, the obtaining module 701 includes:
[0056] The image obtaining unit is configured to obtain a to-be-detected image.
[0057] The feature extraction unit is configured to input the to-be-detected image into a convolutional neural network of a target detection model to obtain a first feature map by feature extraction of the convolutional neural network. The convolutional neural network performs feature extraction on the to-be-detected image by using a dilated convolution kernel or a deformable convolution kernel to obtain the first feature map.
[0058] In a traditional CNN network, a convolution operator is generally used to extract features, and the size of the convolution operator determines the size of the receptive field. The larger the size of the convolution kernel, the larger the receptive field. As shown in Figure 5 The blank grid part is a feature map, and the shaded part is a convolution kernel. A traditional convolution kernel is shown in Figure 5 As shown in Figure 6As shown, the effectiveness of features is improved by expanding the range of the convolutional layer to increase the range of the corresponding spatial location. Simply put, this involves adding spaces (zeros) between the elements of the convolutional kernel to enlarge it. Essentially, the spatial location remains unchanged; by increasing the receptive field, the feature learning effect in the object detection process is improved, thereby increasing the accuracy of object detection. The same principle applies to feasible variable convolution and dilated convolution. In this embodiment, the object detection effect can be further improved by modifying the convolutional kernel of the CNN part and combining it with the learning of the position vector.
[0059] As an optional implementation, the encoding module 702 includes:
[0060] The feature encoding unit is configured to encode the input first feature map to obtain the second feature map.
[0061] The calculation unit is configured to calculate the position offset generated after the first feature map is encoded by the current encoding module.
[0062] The adjustment unit is configured to adjust the first position vector according to the position offset to obtain the second position vector.
[0063] like Figure 3 As shown, in the transformer encoder, we no longer keep the predefined position vector fixed. Instead, each encoder module simultaneously inputs position information and feature information for global attention calculation. Each encoder module outputs a feature and correspondingly outputs the position offset before and after the feature was learned by the encoder module. The original position plus the learned offset is used as the position information for the next cascaded encoder. This ensures that the features and positions output by each encoder layer are aligned, resulting in better object detection performance. For example, if the coordinates of the feature before extraction by encoder1 are (x0, y0), and the coordinates change after extraction, the encoder module can calculate the position offset through global attention. Adding the offset to the original coordinates (x0, y0) yields the new position vector (x1, y1), thus ensuring that the position vector changes with the feature.
[0064] As an optional implementation, each calculation unit comprises a full connection layer for calculating the position offset. By setting a full connection layer in each level of the encoding module, the position offset corresponding to the first feature map is calculated. In this embodiment, by adding a full connection layer in each level of the encoder module, the calculation of the position offset offset can be accurate to decimal places. For example, in the traditional calculation of offset, only an integer 1 can be obtained, and in this embodiment, the offset can be calculated to 1.11 by a full connection layer. In this embodiment, the calculation of the offset is more accurate than the traditional calculation, and the adjustment accuracy of the position vector is higher.
[0065] In the technical solution of the present disclosure, the acquisition, storage and application of user personal information comply with relevant laws and regulations and do not violate public order and good customs.
[0066] According to embodiments of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0067] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not meant to limit implementations of the present disclosure described and / or claimed in this document.
[0068] As Figure 8 shown, the device 800 includes a calculation unit 801 that can perform various appropriate actions and processes in accordance with a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the device 800 can also be stored. The calculation unit 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0069] A plurality of components in the device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a magnetic disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunication networks.
[0070] The computing unit 801 can be various general and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning objective function algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 801 performs various methods and processes described above, such as the object detection method. For example, in some embodiments, the object detection method can be implemented as a computer software program, which is tangibly embodied in a machine-readable medium, such as the storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed onto the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded onto the RAM 803 and executed by the computing unit 801, one or more steps of the object detection method described above can be performed. Alternatively, in other embodiments, the computing unit 801 can be configured to perform the object detection method by any other appropriate means, such as by means of firmware.
[0071] Various implementations of the systems and techniques described above herein can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0072] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. The program code can be provided to a processor or controller of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the program code, when executed by the processor or controller, produces the functions / operations specified in the flowcharts and / or block diagrams. The program code can be executed entirely on a machine, partially on a machine, partially on a machine as a standalone software package, or entirely on a remote machine or server.
[0073] In the context of the present disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0074] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0075] The systems and techniques described here can be implemented in a computing system that includes a back end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), and the Internet.
[0076] The computer system can include clients and servers. This relationship can be. The servers are typically remote from the clients with the interactions between them occurring over a communication network. The relationship between a client and a server is one of client-server. The server can be a cloud server, a server of a distributed system, or a server incorporating a blockchain.
[0077] It should be understood that the various forms of flow shown above can be re-ordered, added to, or deleted from without departing from the scope of the present disclosure. For example, the steps recited in the present disclosure can be executed in parallel, executed in sequence, or executed in a different order, as long as the desired results of the technical solutions disclosed in the present disclosure are achieved, and the present disclosure is not limited herein.
[0078] The specific implementation described above does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. A target detection method, comprising: obtaining a first feature map corresponding to a to-be-detected image; inputting the first feature map into an encoder of a target detection model, and obtaining a first position vector corresponding to the first feature map through position encoding of the encoder according to coordinate information of the first feature map; inputting the first feature map and the corresponding first position vector into each encoding module of the encoder in sequence for encoding processing to obtain a second feature map and a second position vector; performing decoding processing according to the second feature map and the second position vector to obtain a detection result of the to-be-detected image; the inputting the first feature map and the corresponding first position vector into each encoding module of the encoder in sequence for encoding processing to obtain a second feature map and a second position vector comprises: performing encoding processing on the input first feature map to obtain the second feature map, and calculating a position offset generated after the first feature map is processed by the encoding module of the current level; wherein the position offset is used to adjust the first position vector of the next level to obtain the second position vector of the next level.
2. The method of claim 1, wherein, the obtaining a first feature map corresponding to a to-be-detected image comprises: obtaining the to-be-detected image; inputting the to-be-detected image into a convolutional neural network of the target detection model, and performing feature extraction through the convolutional neural network to obtain the first feature map.
3. The method of claim 2, wherein, the performing feature extraction through the convolutional neural network to obtain the first feature map comprises: the convolutional neural network performs feature extraction through a dilated convolution kernel or a deformable convolution kernel to obtain the first feature map.
4. The method of any of claims 1-3, wherein, the inputting the first feature map and the corresponding first position vector into each encoding module of the encoder in sequence for encoding processing to obtain a second feature map and a second position vector further comprises: adjusting the first position vector of the current level according to the position offset output by the encoding module of the previous level to obtain the second position vector of the current level.
5. The method of claim 4, wherein, the performing encoding processing on the input first feature map and calculating a position offset generated after the first feature map is processed by the current encoding module comprises: performing encoding processing on the input first feature map through a global attention mechanism, and calculating the position offset generated after the first feature map is processed by the current encoding module.
6. The method of claim 4 or 5, wherein, the calculating a position offset generated after the first feature map is processed by the current encoding module comprises: calculating the position offset corresponding to the first feature map through a fully connected layer of each encoding module.
7. A target detection apparatus, comprising: an obtaining module configured to obtain a first feature map corresponding to a to-be-detected image; an encoding module configured to input the first feature map into an encoder of a target detection model, and obtain a first position vector corresponding to the first feature map through position encoding of the encoder according to coordinate information of the first feature map; the encoding module inputting the first feature map and the corresponding first position vector into each encoding module of the encoder in sequence for encoding processing to obtain a second feature map and a second position vector; The decoding module is configured to perform decoding processing on the second feature map and the second position vector to obtain a detection result of the image to be detected. The encoding module comprises: The feature encoding unit is configured to perform encoding processing on the input first feature map to obtain the second feature map. The calculation unit is configured to calculate a position offset generated after the first feature map is encoded by the encoding module of the current stage. The adjustment unit is configured to adjust the first position vector of the next stage according to the position offset to obtain the second position vector.
8. The apparatus of claim 7, wherein, The obtaining module comprises: The image obtaining unit is configured to obtain the image to be detected. The feature extraction unit is configured to input the image to be detected into a convolutional neural network of the target detection model, and perform feature extraction on the image to be detected by the convolutional neural network to obtain the first feature map.
9. The apparatus of claim 8, wherein, The convolutional neural network performs feature extraction on the first feature map by using a dilated convolution kernel or a deformable convolution kernel.
10. The apparatus of any of claims 7-9, wherein, The encoding module further comprises: The adjustment unit is configured to adjust the first position vector of the current stage according to the position offset output by the encoding module of the previous stage to obtain the second position vector of the current stage.
11. The apparatus of claim 9, wherein, The calculation unit performs encoding processing on the input first feature map by using a global attention mechanism, and calculates the position offset generated after the first feature map is processed by the current encoding module.
12. The apparatus of claim 10 or 11, wherein, Each calculation unit comprises a fully connected layer for calculating the position offset.
13. An electronic device comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method according to any one of claims 1-6.
15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-6.
15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Text translation method and device based on deep learning, equipment and storage medium
CN113420571A
Image processing method and device, electronic equipment and storage medium
CN113537350A
Target detection method and device, equipment and storage medium
CN113591840A