Object detection method, apparatus, computing device, and storage medium
By using a target detection method based on skeleton network feature extraction and prediction head, the problem of template matching detection being sensitive to scale and rotation is solved, achieving efficient, real-time and robust target detection, which is suitable for a variety of application scenarios.
Patent Information
- Application Number
- CN202511101361.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2045-08-07
AI Technical Summary
In existing technologies, template matching detection is sensitive to scale and rotation, has high computational cost, and deep learning object detection algorithms have high data dependence and poor interpretability.
A target detection method based on skeleton network feature extraction and prediction head is adopted. The template features are used as convolution kernels and combined with the features to be detected to output the response, predict the target confidence, bounding box and rotation angle, and achieve zero-shot generalization capability.
It improves the real-time performance and robustness of object detection, reduces dependence on data, enhances the interpretability of the model, and enables the introduction of new object types without changing the model parameters.
Smart Images

Figure CN120599237B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a target detection method, apparatus, computing device, and storage medium. Background Technology
[0002] Template matching is a commonly used algorithm in machine vision. It obtains information such as the template's position and angle on the target by analyzing the correlation between the template and the target. Its core idea is to compare pixels one by one through a sliding window, calculating the similarity between the template and local regions of the image to find the optimal matching position. It is simple to implement and requires no training data, making it widely used in industrial quality inspection, medical imaging, and traffic monitoring. However, its drawbacks include scale sensitivity; scaling the target by a certain proportion may cause matching to fail, requiring the construction of a scale pyramid for multi-scale searching. Additionally, target rotation can also lead to matching failure, necessitating the construction of multi-angle templates for one-to-one matching with the target. Detecting targets with scaling and rotation through template matching significantly increases computational costs.
[0003] Currently used deep learning object detection algorithm architectures, such as Faster-RCNN and YOLO, essentially teach the model to learn the mapping relationship from pixels to semantics. Their core processes include feature extraction, region proposal, classification, and regression. Compared to template matching, it has advantages such as strong generalization ability, strong deformation robustness, multi-target processing, high computational efficiency, and strong adaptability to the target environment. Its disadvantages include high data dependence, poor interpretability (difficult to optimize in real-time parameter tuning), and poor performance on small samples. Summary of the Invention
[0004] In view of this, embodiments of this application provide a target detection method to address the technical deficiencies existing in the prior art. Embodiments of this application also provide a target detection apparatus, a computing device, and a computer-readable storage medium.
[0005] According to a first aspect of the embodiments of this application, a target detection method is provided, comprising:
[0006] Receive template images and images to be tested;
[0007] The template image is used to extract features based on the first skeleton network to obtain template features, and the image to be detected is used to extract features based on the second skeleton network to obtain detection features.
[0008] Using the template features as the convolution kernel and the features to be detected as the convolution input, the response output of the image to be detected related to the template image is extracted;
[0009] Based on the pre-trained prediction head, the target confidence, bounding box, and rotation angle are predicted on the response output to obtain the target detection results of the template image in the image to be detected.
[0010] Optionally, the first backbone network and the second backbone network may have the same network structure or different network structures; when the first backbone network and the second backbone network have the same network structure, the first backbone network and the second backbone network share weights or train weight parameters independently.
[0011] Optionally, the prediction head employs upsampling to align the predicted results of the target confidence, the bounding box, and the rotation angle with the resolution of the image to be detected.
[0012] Optionally, the prediction of the rotation angle is divided into positive / negative sign classification and rotation value regression.
[0013] Optionally, the training process of the prediction head includes:
[0014] Construct a training image set based on the sample image set;
[0015] The training image set is used as input to the prediction head to be trained, and the prediction result is output.
[0016] Based on the training image set and the prediction results, a loss function is constructed;
[0017] The parameters of the prediction head to be trained are tuned according to the loss function until the training conditions are met, thus obtaining the pre-trained prediction head.
[0018] Optionally, constructing a training image set based on the sample image set includes:
[0019] In the sample template image of the sample image, the center point of the template is randomly selected;
[0020] Cut the template according to its center point, and then randomly scale and rotate the template to obtain the template to be pasted.
[0021] Paste the template to be pasted into the sample image to be detected in the sample image set to obtain the training sample image set. The pasting process uses Poisson fusion.
[0022] Optionally, constructing a loss function based on the training image set and the prediction results includes:
[0023] Based on the training image set, training ground truth is constructed using an adaptive Gaussian heatmap;
[0024] Based on the prediction results and the training ground truth, a first loss function is constructed corresponding to the center position of the template, wherein the first loss function adopts the cross-entropy loss function;
[0025] Based on the training results and the training image set, a second loss function corresponding to subpixel offset regression, a third loss function for scaling regression, and a fourth loss function for rotation angle regression are determined. The second loss function and the third loss function adopt Smooth L1. The loss function includes the first loss function, the second loss function, the third loss function, and the fourth loss function.
[0026] According to a second aspect of the embodiments of this application, a target detection device is provided, comprising:
[0027] The receiving module is configured to receive template images and images to be detected.
[0028] The extraction module is configured to extract features from the template image based on a first skeleton network to obtain template features, and to extract features from the image to be detected based on a second skeleton network to obtain the features to be detected.
[0029] The convolution module is configured to use the template features as the convolution kernel, the features to be detected as the convolution input, and extract the response output of the image to be detected related to the template image.
[0030] The prediction module is configured to predict the target confidence, bounding box, and rotation angle of the response output based on a pre-trained prediction head, so as to obtain the target detection result of the template image in the image to be detected.
[0031] According to a third aspect of the embodiments of this application, a computing device is provided, comprising:
[0032] Memory and processor;
[0033] The memory is used to store computer-executable instructions, and the processor executes the computer-executable instructions to implement the steps of the target detection method.
[0034] According to a fourth aspect of the embodiments of this application, a computer-readable storage medium is provided that stores computer-executable instructions, which, when executed by a processor, implement the steps of the target detection method.
[0035] According to a fifth aspect of the present application, a chip is provided that stores a computer program, which, when executed by the chip, implements the steps of the target detection method.
[0036] The object detection method provided in this application receives a template image and an image to be detected; extracts features from the template image based on a first skeleton network to obtain template features, and extracts features from the image to be detected based on a second skeleton network to obtain detection features; uses the template features as a convolution kernel and the detection features as the convolution input to extract the response output of the image to be detected related to the template image; based on a pre-trained prediction head, predicts the target confidence, bounding box, and rotation angle of the response output to obtain the target detection result of the image to be detected related to the template image. This method provides a way to achieve near-supervised learning detection results with a small number of templates. Specifically, by extracting the template and the image's depth features, and then performing mutual attention between the two, the method predicts the position, size, and angle of the template target in the image, improving the model's interpretability. Furthermore, it greatly improves the practicality of object detection in real-world applications; when a new type of target to be detected is introduced, only the new target type needs to be provided as input to the object detection model, without needing to change the model parameters. Simultaneously, it ensures the real-time performance and robustness of object detection. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 This is a flowchart of a target detection method provided in an embodiment of this application;
[0039] Figure 2 This is a network structure diagram of a target detection method provided in an embodiment of this application;
[0040] Figure 3 This is a schematic diagram of the structure of a target detection device provided in an embodiment of this application;
[0041] Figure 4 This is a structural block diagram of a computing device provided in one embodiment of this application. Detailed Implementation
[0042] Many specific details are set forth in the following description to provide a full understanding of this application. However, this application can be implemented in many other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this application; therefore, this application is not limited to the specific embodiments disclosed below.
[0043] The terminology used in one or more embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the scope of one or more embodiments of this application. The singular forms “a,” “the,” and “the” used in one or more embodiments of this application and in the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” used in one or more embodiments of this application refers to and includes any or all possible combinations of one or more associated listed items.
[0044] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this application, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this application, and similarly, second may also be referred to as first.
[0045] This application provides a target detection method. This application also relates to a target detection apparatus, a computing device, and a computer-readable storage medium, which will be described in detail in the following embodiments.
[0046] Figure 1 A flowchart of a target detection method according to an embodiment of this application is shown, which specifically includes the following steps:
[0047] Step S102: Receive template image and image to be detected;
[0048] Step S104: Extract features from the template image based on the first skeleton network to obtain template features, and extract features from the image to be detected based on the second skeleton network to obtain the detection features;
[0049] Step S106: Using the template features as the convolution kernel and the features to be detected as the convolution input, extract the response output of the image to be detected related to the template image;
[0050] Step S108: Based on the pre-trained prediction head, predict the target confidence, bounding box, and rotation angle of the response output to obtain the target detection result of the template image in the image to be detected.
[0051] In this context, the image to be detected is the image for which target recognition is required, and the template image is the image of the target to be recognized. The first backbone network and the second backbone network are BackboneT and BackboneS, respectively. BackboneT extracts the depth features of the template image, i.e., the template features, and BackboneS extracts the depth features of the image to be detected, i.e., the features to be detected.
[0052] Based on this, template features are used as convolution kernels and the features to be detected are used as convolution inputs. The template features and the features to be detected are fused to achieve target detection. This can train a zero-shot generalization model. The template features are transformed into convolution kernels to participate in inference, so that the model only learns "how to match" rather than "memorizing the template", giving the model zero-shot generalization ability across templates and scenarios.
[0053] Subsequently, the prediction head is used to predict the target confidence, bounding box, and rotation angle. For target detection applications in different application scenarios, only a small number of target templates need to be provided to complete the target detection in the image, i.e., small sample target detection.
[0054] Furthermore, in step S104, the first backbone network and the second backbone network have the same network structure or different network structures; when the first network backbone and the second network backbone have the same network structure, the first network backbone and the second network backbone share weights or train weight parameters independently.
[0055] Furthermore, in step S108, the prediction head uses upsampling to align the prediction results of the target confidence, the bounding box, and the rotation angle with the resolution of the image to be detected.
[0056] Furthermore, in step S108, the prediction of the rotation angle is divided into positive and negative sign classification and rotation value regression.
[0057] Furthermore, in step S108, the training process of the prediction head is specifically implemented as follows in this embodiment:
[0058] Based on the sample image set, a training image set is constructed; the training image set is used as the input to the prediction head to be trained, and the prediction result is output; a loss function is constructed according to the training image set and the prediction result; the parameters of the prediction head to be trained are tuned according to the loss function until the training conditions are met, and the pre-trained prediction head is obtained.
[0059] Furthermore, the process of constructing a training image set based on the sample image set described above is implemented in this embodiment as follows:
[0060] In the sample template images in the sample images, a template center point is randomly selected; the template is cropped according to the template center point, and the template is randomly scaled and rotated to obtain the template to be pasted; the template to be pasted is pasted to the sample images to be detected in the sample image set to obtain the training sample image set, wherein the pasting process adopts Poisson fusion.
[0061] Furthermore, the process of constructing the loss function based on the training image set and prediction results is specifically implemented in this embodiment as follows:
[0062] Based on the training image set, a training ground truth is constructed using an adaptive Gaussian heatmap. According to the prediction results and the training ground truth, a first loss function corresponding to the template center position is constructed, wherein the first loss function employs a cross-entropy loss function. Based on the training results and the training image set, a second loss function corresponding to sub-pixel offset regression, a third loss function for scaling regression, and a fourth loss function for rotation angle regression are determined, wherein the second and third loss functions employ Smooth L1, and the loss functions include the first, second, third, and fourth loss functions.
[0063] Among them, such as Figure 2 The network structure diagram of the proposed object detection method is shown. The template and the image to be detected are feature extracted using BackboneT and BackboneS, respectively. Then, DW_Conv (Depthally Separable Convolution) is used, where the template features are used as the convolution kernel and the features to be detected are used as the input to the convolution. This is used to obtain the response of the image to be detected regarding the template, achieving mutual attention between the template features and the features to be detected, fully utilizing the operational advantages of channel-wise convolution to extract spatial features, and achieving efficient matching between features. Subsequently, the Head (prediction head of the network structure) is used to predict the target confidence, bounding box, and rotation angle based on the response of DW_Conv.
[0064] It should be noted that the aforementioned steps result in a reduced resolution of the feature map compared to the original image. The head not only needs to learn information such as the target's position, size, and angle, but also needs to upsample the feature map to ensure that the prediction head's result is aligned with the resolution of the image to be detected. Upsampling can be performed through methods such as PixelShuffle, deconvolution, and interpolation. The specific upsampling method used depends on the actual use case, and this embodiment does not impose any limitations. Finally, based on the upsampling results, the prediction results are output through the classification head and regression head, namely, the prediction of the target confidence, bounding box, and rotation angle. In addition, this embodiment divides the rotation angle prediction into two parts: positive / negative sign classification and rotation value regression, effectively solving the problems of angle periodicity (-180° to +180°) and the influence of value range scale.
[0065] Furthermore, a self-supervised training method is employed during training. Target bounding boxes labeled in open-source datasets such as CoCo and CUB-200 are used as templates. Pixel weight recombining is used to randomly paste these templates onto the dataset images. Specifically, the templates are scaled and rotated to a certain extent before pasting. Poisson fusion is introduced to avoid unnatural boundary artifacts in the pasted images. For each batch, random data generation and processing are performed before training. The basic principle is to randomly select the center point of the template from the first image, crop the template, and then paste it onto the images in this batch. During the pasting process, the template needs to be randomly scaled and rotated. The upsampling process uses pixel recombining to upsample features, effectively avoiding the checkerboard artifact phenomenon in traditional upsampling methods, preserving the original positional information, and upsampling to the original image size.
[0066] Furthermore, an adaptive Gaussian heatmap is used as the ground truth for training. Each pixel in the output feature is classified based on the confidence of the template center. Only regions with a ground truth confidence greater than a confidence threshold are calculated to reduce computational cost. The first loss function used is the cross-entropy loss function. This branch yields the position of the template center. The first loss function, constructed by estimating the center point position based on template-based object detection, avoids problems such as uneven positive and negative sample distribution and difficulty in setting anchor box hyperparameters. It should be noted that the confidence threshold ranges from [0.3, 0.7], with a preferred value of 0.5. Sub-pixel localization technology, utilizing the floating-point precision of the Gaussian heatmap, calculates the weighted center of all pixels around the predicted hotspot that exceed a set threshold, achieving more accurate target localization than single integer coordinates.
[0067] The prediction of rotation angle is divided into two parts: positive and negative classification and rotation angle cosine value regression. Specifically, the loss function of rotation angle, namely the fourth loss function, is divided into positive and negative loss and angle value loss. Since the template target may have a rotation angle of (-180, 180) in the image to be detected, the angle value predicted by the model is defined as the cosine value of the actual rotation angle. The model can fully express the rotation angle of the template target in the image to be detected by adding the positive and negative prediction of the angle value, which effectively solves the problems of angle periodicity (-180°, 180°) and value range scale mismatch.
[0068] In addition, to avoid the problem of imbalance between positive and negative samples, that is, the problem of severe imbalance between positive and negative samples in the prediction of the target center point of the template, logistic regression with penalized focus loss is used to effectively balance the training samples.
[0069] Corresponding to the above method embodiments, this application also provides embodiments of a target detection device. Figure 3A schematic diagram of the structure of a target detection device according to an embodiment of this application is shown. Figure 3 As shown, the device includes:
[0070] The receiving module 302 is configured to receive the template image and the image to be detected;
[0071] The extraction module 304 is configured to extract features from the template image based on a first skeleton network to obtain template features, and to extract features from the image to be detected based on a second skeleton network to obtain the features to be detected.
[0072] The convolution module 306 is configured to use the template features as the convolution kernel, use the features to be detected as the convolution input, and extract the response output of the image to be detected related to the template image.
[0073] The prediction module 308 is configured to predict the target confidence, bounding box, and rotation angle of the response output based on a pre-trained prediction head, so as to obtain the target detection result of the template image in the image to be detected.
[0074] In an optional embodiment, the receiving module 302 is further configured such that the first backbone network and the second backbone network have the same network structure or different network structures; when the first network backbone and the second network backbone have the same network structure, the first network backbone and the second network backbone share weights or train weight parameters independently.
[0075] In an optional embodiment, the prediction module 308 is further configured such that the prediction head uses upsampling to align the prediction results of the target confidence, the bounding box, and the rotation angle with the resolution of the image to be detected.
[0076] In an optional embodiment, the prediction module 308 is further configured to predict the rotation angle by dividing it into positive / negative sign classification and rotation value regression.
[0077] In an optional embodiment, the target detection device further includes:
[0078] The training module is configured to construct a training image set based on the sample image set; use the training image set as input to the prediction head to be trained and output the prediction result; construct a loss function based on the training image set and the prediction result; and tune the parameters of the prediction head to be trained according to the loss function until the training conditions are met, thereby obtaining the pre-trained prediction head.
[0079] In an optional embodiment, the training module is further configured to:
[0080] In the sample template images in the sample images, a template center point is randomly selected; the template is cropped according to the template center point, and the template is randomly scaled and rotated to obtain the template to be pasted; the template to be pasted is pasted to the sample images to be detected in the sample image set to obtain the training sample image set, wherein the pasting process adopts Poisson fusion.
[0081] In an optional embodiment, the training module is further configured to:
[0082] Based on the training image set, a training ground truth is constructed using an adaptive Gaussian heatmap. According to the prediction results and the training ground truth, a first loss function corresponding to the template center position is constructed, wherein the first loss function employs a cross-entropy loss function. Based on the training results and the training image set, a second loss function corresponding to sub-pixel offset regression, a third loss function for scaling regression, and a fourth loss function for rotation angle regression are determined, wherein the second and third loss functions employ Smooth L1, and the loss functions include the first, second, third, and fourth loss functions.
[0083] The target detection device provided in this application receives a template image and a target image; extracts features from the template image based on a first skeleton network to obtain template features, and extracts features from the target image based on a second skeleton network to obtain target features; uses the template features as a convolution kernel and the target features as the convolution input to extract the response output of the target image related to the template image; and predicts the target confidence, bounding box, and rotation angle of the response output based on a pre-trained prediction head to obtain the target detection result of the target image related to the template image in the target image. This provides a method to achieve near-supervised learning detection results with a small number of templates. Specifically, by extracting the template and the image's depth features, and then performing mutual attention between the two, the device predicts the position, size, and angle of the template target in the image, improving the model's interpretability. Furthermore, it greatly improves the practicality of target detection in real-world applications; when a new target type is introduced, only the new target type needs to be provided as input to the target detection model, without needing to change the model parameters. Simultaneously, it ensures the real-time performance and robustness of target detection.
[0084] The above is an illustrative scheme of a target detection device according to this embodiment. It should be noted that the technical solution of this target detection device and the technical solution of the target detection method described above belong to the same concept. Details not described in detail in the technical solution of the target detection device can be found in the description of the technical solution of the target detection method described above. Furthermore, the components in the device embodiment should be understood as functional modules necessary to implement each step of the program flow or each step of the method; these functional modules are not actual functional divisions or separations. A device claim defined by such a set of functional modules should be understood as a functional module architecture that primarily implements the solution through the computer program described in the specification, and not as a physical device that primarily implements the solution through hardware.
[0085] Figure 4 A structural block diagram of a computing device 400 according to an embodiment of this application is shown. The components of the computing device 400 include, but are not limited to, a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and a database 450 is used to store data.
[0086] The computing device 400 also includes an access device 440, which enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of wired or wireless network interface (e.g., a Network Interface Card (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) interface, a Wi-MAX interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, a Near Field Communication (NFC) interface, and so on.
[0087] In one embodiment of this application, the aforementioned components of the computing device 400 and Figure 4 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 4 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this application. Those skilled in the art can add or replace other components as needed.
[0088] The computing device 400 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or PCs. The computing device 400 can also be a mobile or stationary server.
[0089] The processor 420 is used to execute computer-executable instructions for each step of the target detection method.
[0090] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device and the technical solution of the target detection method described above belong to the same concept. For details not described in detail in the technical solution of the computing device, please refer to the description of the technical solution of the target detection method described above.
[0091] An embodiment of this application also provides a computer-readable storage medium storing computer instructions that, when executed by a processor, are used to implement the steps of the target detection method.
[0092] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium and the technical solution of the target detection method described above belong to the same concept. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the target detection method described above.
[0093] An embodiment of this application also provides a chip that stores a computer program, which, when executed by the chip, implements the steps of the target detection method.
[0094] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0095] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0096] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0097] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0098] The preferred embodiments disclosed above are merely illustrative of this application. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this application. These embodiments are selected and specifically described in this application to better explain the principles and practical applications of this application, thereby enabling those skilled in the art to better understand and utilize this application. This application is limited only by the claims and their full scope and equivalents.
Claims
1. A target detection method characterized by, The method comprises the following steps: receiving a template picture and a to-be-detected picture; performing feature extraction on the template picture based on a first skeleton network to obtain a template feature, and performing feature extraction on the to-be-detected picture based on a second skeleton network to obtain a to-be-detected feature, wherein the first skeleton network and the second skeleton network are the same network structure or different network structures; when the first skeleton network and the second skeleton network are the same network structure, the first skeleton network and the second skeleton network share weights or independently train weight parameters; taking the template feature as a convolution kernel and taking the to-be-detected feature as a convolution input to extract a response output of the template picture in the to-be-detected picture, wherein the convolution is a depth separable convolution; performing target confidence, bounding box and rotation angle prediction on the response output based on a pre-trained prediction head to obtain a target detection result of the template picture in the to-be-detected picture, wherein the training process of the prediction head comprises the following steps: constructing a training picture set based on a sample picture set, taking the training picture set as an input of a to-be-trained prediction head to output a prediction result, constructing a loss function according to the training picture set and the prediction result, and adjusting the to-be-trained prediction head according to the loss function until a training condition is met to obtain the pre-trained prediction head; specifically, the construction process of the training picture set comprises the following steps: randomly selecting a template center point in a sample template picture in the sample picture set, cropping a template according to the template center point, and randomly scaling and rotating the template to obtain a to-be-pasted template, pasting the to-be-pasted template to a sample to-be-detected picture in the sample picture set to obtain a training sample picture set, wherein the pasting process adopts Poisson fusion; the construction process of the loss function comprises the following steps: constructing a training true value based on the training picture set by using an adaptive Gaussian heat map, constructing a first loss function of a corresponding template center position according to the prediction result and the training true value, wherein the first loss function adopts a cross-entropy loss function, determining a second loss function of sub-pixel offset regression, a third loss function of scaling size regression, and a fourth loss function of rotation angle regression according to the prediction result and the training picture set, wherein the second loss function and the third loss function adopt Smooth L1, and the loss function comprises the first loss function, the second loss function, the third loss function and the fourth loss function.
2. The object detection method according to claim 1, characterized in that, The prediction head adopts up-sampling to align the prediction results of the target confidence, the bounding box and the rotation angle with the resolution of the to-be-detected picture.
3. The object detection method of claim 1, wherein The prediction of the rotation angle is classified into positive and negative sign classification and rotation value regression.
4. A target detection apparatus characterized by comprising: The method comprises the following steps: a receiving module configured to receive a template picture and a to-be-detected picture; The extraction module is configured to perform feature extraction on the template picture based on a first skeleton network to obtain template features, and perform feature extraction on the to-be-detected picture based on a second skeleton network to obtain to-be-detected features, wherein the first skeleton network and the second skeleton network are the same network structure or different network structures; when the first skeleton network and the second skeleton network are the same network structure, the first skeleton network and the second skeleton network share weights or independently train weight parameters. The convolution module is configured to take the template features as a convolution kernel and the to-be-detected features as a convolution input to extract a response output about the template picture in the to-be-detected picture, wherein the convolution is a depth separable convolution. The prediction module is configured to perform target confidence, bounding box, and rotation angle prediction on the response output based on a pre-trained prediction head to obtain a target detection result about the template picture in the to-be-detected picture, wherein the training process of the prediction head includes the following steps: constructing a training picture set based on a sample picture set, taking the training picture set as an input of a to-be-trained prediction head to output a prediction result, constructing a loss function according to the training picture set and the prediction result, and adjusting the to-be-trained prediction head according to the loss function until a training condition is met to obtain the pre-trained prediction head. Specifically, the training picture set construction process includes the following steps: randomly selecting a template center point in a sample template picture in the sample picture, cropping a template according to the template center point, and performing random scaling and random rotation on the template to obtain a to-be-pasted template, pasting the to-be-pasted template to a sample to-be-detected picture in the sample picture set to obtain a training sample picture set, wherein the pasting process adopts Poisson fusion. The loss function construction process includes the following steps: constructing a training true value based on the training picture set by using an adaptive Gaussian heat map, constructing a first loss function of a corresponding template center position according to the prediction result and the training true value, wherein the first loss function adopts a cross-entropy loss function, determining a second loss function of sub-pixel offset regression, a third loss function of scaling size regression, and a fourth loss function of rotation angle regression according to the prediction result and the training picture set, wherein the second loss function and the third loss function adopt Smooth L1, and the loss function includes the first loss function, the second loss function, the third loss function, and the fourth loss function.
5. A computing device, comprising: Comprise: a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions to realize the steps of the target detection method in any one of claims 1 to 3.
6. A computer-readable storage medium storing computer instructions, wherein, The instructions are executed by the processor to realize the steps of the target detection method in any one of claims 1 to 3.
Citation Information
Patent Citations
Target template graph matching and positioning method based on twin network and central position estimation
CN115330876A
Fast food rotating target detection method based on LR-Center Net
CN115713760A
Target following model training method and device, equipment and storage medium
CN117274296A
Object detection method and device, intelligent equipment and storage medium
CN117994551A