Target detection method, electronic equipment and storage medium
By weighted fusion of the initial features after multi-scale feature extraction in the target detection method and combining feature information of different scales, the problem of low detection accuracy in the existing technology is solved and higher target detection accuracy is achieved.
Patent Information
- Application Number
- CN202411166389.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-23
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-08-23
AI Technical Summary
After existing target detection methods use multi-scale feature extraction, the target detection results corresponding to features of different scales are different, resulting in low detection accuracy.
By obtaining the initial feature set after multi-scale feature extraction, multiple sets of weight groups are determined, and each initial feature is weighted and fused to generate advanced features to combine feature information at different scales.
The accuracy of target detection results is improved, the advanced features contain richer information, and the detection results are unified.
Smart Images

Figure CN118675005A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to a target detection method, an electronic device, and a storage medium. Background Art
[0002] In recent years, with the development of neural network technology and the rapid improvement of computer computing power, more and more visual tasks such as garbage detection, license plate detection, commodity detection, remote sensing target detection, etc. can be intelligently processed by computers. The target detection task has a wide range of application values in many fields such as life, industrial production, urban construction, and environmental protection by accurately locating the target position and identifying the target category. In the prior art, multi-scale feature extraction is first performed on the image to be detected, and the extracted features are directly used for target detection to obtain the target detection result. However, using multi-scale extracted features for target detection may cause differences between the target detection results corresponding to features of different scales, resulting in low accuracy of the target detection results obtained by combining the multi-scale extracted features.
[0003] In view of the existing technical defects, how to provide an effective target detection solution is a technical problem that needs to be solved urgently by technical personnel in this field. Summary of the invention
[0004] The present application at least provides a target detection method, an electronic device and a storage medium.
[0005] The present application provides a target detection method, comprising: using a target detection model to obtain an initial feature set obtained by performing multi-scale feature extraction on an image to be detected, wherein the initial feature set contains at least two initial features and the scales of the initial features are different; based on the initial features in the initial feature set, multiple weight groups are determined, the initial features corresponding to different weight groups are different, and the number of weights carried in each weight group is the same as the number of initial features contained in the initial feature set; for each initial feature, using a target weight group to perform weighted fusion on the initial features in the initial feature set to obtain an advanced feature after the initial feature is updated, and the target weight group is a weight group corresponding to the initial feature in the multiple weight groups; using the advanced features corresponding to the initial features to obtain a target detection result of the image to be detected.
[0006] The present application provides a target detection device, comprising: an acquisition module, a weight determination module, a weighted fusion module and a target detection module; the acquisition module is used to use a target detection model to obtain an initial feature set obtained by performing multi-scale feature extraction on a to-be-detected image, wherein the initial feature set contains at least two initial features and the scales of the initial features are different; the weight determination module is used to determine multiple weight groups based on the initial features in the initial feature set, different weight groups correspond to different initial features, and the number of weights carried in each weight group is the same as the number of initial features contained in the initial feature set; the weighted fusion module is used to use a target weight group to perform weighted fusion on each initial feature in the initial feature set for each initial feature, to obtain an advanced feature after the initial feature is updated, and the target weight group is a weight group corresponding to the initial feature in the multiple weight groups; the target detection module is used to use the advanced features corresponding to each initial feature to obtain a target detection result of the to-be-detected image.
[0007] The present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned target detection method.
[0008] The present application provides a computer-readable storage medium on which program instructions are stored. When the program instructions are executed by a processor, the above-mentioned target detection method is implemented.
[0009] The above scheme uses the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, and based on the initial features of different scales in the initial feature set, multiple weight groups that can combine the feature information of each scale are determined. Then, for each initial feature, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain the advanced features after the initial features are updated. Each advanced feature can combine feature information of different scales to make the feature information contained in the advanced feature richer, so that the results obtained by subsequent target detection using each advanced feature are more unified, thereby improving the accuracy of the target detection results.
[0010] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0012] Figure 1 This is a flow chart of an embodiment of the target detection method of the present application. Figure 1 ; Figure 2This is a flow chart of an embodiment of the target detection method of the present application. Figure 2 ; Figure 3 It is a schematic diagram of the correspondence between each initial feature and each advanced feature in an embodiment of the target detection method of the present application; Figure 4 This is a flow chart of an embodiment of the target detection method of the present application. Figure 3 ; Figure 5 A schematic diagram of the structure of an embodiment of a target detection device of the present application; Figure 6 It is a structural schematic diagram of an embodiment of the electronic device of the present application; Figure 7 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION
[0013] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0014] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0015] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0016] The present application provides some target detection methods and target detection devices. The application scenarios of the target detection method include but are not limited to target detection related to target detection tasks for images to be detected. For example, the target detection task may be a target detection task related to object positioning and a target detection task related to object classification. The execution subject of the target detection method may be any device with a target detection function, for example, a target detection device or a target detection model. The target detection device may be arranged in a terminal device or a server or other processing device, wherein the terminal device may be a device for target detection, a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device, etc. In some possible implementations, the target detection method may be implemented by a processor calling computer-readable instructions stored in a memory.
[0017] See also Figure 1 , Figure 1 This is a flow chart of an embodiment of the target detection method of the present application. Figure 1 Specifically, the target detection method may include the following steps: Step S11: using the target detection model to obtain an initial feature set obtained by performing multi-scale feature extraction on the image to be detected.
[0018] The initial feature set includes at least two initial features and the scales of the initial features are different.
[0019] The target detection model can be used to perform target detection on the image to be detected and obtain the target detection result of the image to be detected. The image to be detected is input into the target detection model, and the target detection result of the image to be detected can be obtained. In some application scenarios, the target detection model can correspond to different target detection tasks. Different target detection tasks can correspond to different types of target detection models and different types of target detection results. It can be understood that an object in the image to be detected can be a target, which will not be repeated below. Specifically, the target detection task can be a task related to object detection, a task related to object classification, a task related to object positioning, a task related to target tracking, and a task related to target counting. Exemplarily, the task related to object detection can be to detect the existence of an object in multiple frames of the image to be detected in the image to be detected or video, and accurately identify the position of the object through a bounding box or a pixel-level mask. At this time, the target detection result can be whether the object exists. If it exists, the target detection model outputs the bounding box or the position of the object. The task related to object classification can be to identify the category of the object detected in the image to be detected. At this time, the target detection result is that the object or target in the image to be detected belongs to a preset category. The preset category can be a vehicle or an animal. For example, the object in the image to be detected belongs to a vehicle or the object in the image to be detected belongs to an animal, etc. Exemplarily, the task related to object positioning can be to determine the position and size of the object in the image to be detected, usually represented by a bounding box. At this time, the target detection result can be a bounding box. The bounding box can represent the position and size of the object in the image to be detected. Exemplarily, the task related to target tracking can be to continuously track the movement and position change of the object in multiple frames of images to be detected in a video stream. At this time, the target detection result can be the movement and position change of the object. Exemplarily, the task related to target counting can be to count the number of objects of a specific category in multiple frames of images to be detected in a statistical image or video, such as animal number counting, vehicle counting, etc. At this time, the target detection result can be a numerical value corresponding to the number of objects. It can be understood that the target detection task corresponding to the target detection model here is only for example, and does not limit the target detection task corresponding to the target detection model.
[0020] The image to be detected may be an image with target detection requirements. The image to be detected may be a static image or a video frame that may contain an object or target of interest. Exemplarily, the image to be detected may be a real-time scene acquired from an image acquisition device, a medical image, an image corresponding to a natural scene, or any other image in which object information or target information needs to be analyzed and understood. Specifically, different images to be detected may correspond to different target detection tasks. Exemplarily, the target detection task may be a task related to object classification. The image to be detected may be an image containing multiple animals. The target detection result of the image to be detected may be the animal type of each target in the image to be detected. Exemplarily, the target detection task may be a task related to object positioning. The image to be detected may be an image containing multiple vehicles in a traffic scene. The target detection result of the image to be detected may be the position information between the vehicles.
[0021] In some application scenarios, the target detection model may include multiple modules or networks. The target detection model includes a feature extraction module.
[0022] The feature extraction module is used to perform multi-scale feature extraction on the image to be detected to obtain an initial feature set. The initial feature set contains at least two initial features and the scales of each initial feature are different. This application takes the number of initial features in the initial feature set as 3 as an example. The initial features in the initial feature set are the first initial feature, the second initial feature and the third initial feature, which will not be repeated below. It can be understood that this application does not limit the number of initial features in the initial feature set, and the number can also be 2, 4, etc.
[0023] Multi-scale feature extraction is used to obtain features of the image to be detected from different scales and resolutions. Specifically, multi-scale feature extraction can be directly inputting the image to be detected into the feature extraction module to obtain at least two initial features of different scales output by the feature extraction module. In some application scenarios, inputting the image to be detected into the feature extraction module to obtain at least two initial features of different scales output by the feature extraction module can be: the feature extraction module includes a plurality of feature extraction submodules with different preset feature scales, and the image to be detected is respectively input into the feature extraction submodule, and the features output by each feature extraction submodule can be obtained, and the features output by each feature extraction submodule are used as each initial feature. Among them, the number of feature extraction submodules is the same as the number of each initial feature in the initial feature set. In other application scenarios, inputting the image to be detected into the feature extraction module to obtain at least two initial features of different scales output by the feature extraction module can be: inputting the image to be detected into the feature extraction module, and the feature extraction module can continuously perform multiple downsampling of the image to be detected at a preset scale to obtain each initial feature obtained after each downsampling. Among them, the number of downsampling is the same as the number of each initial feature. For example, the number of downsampling is 3 times. Specifically, the multiple downsampling of the preset scale may be a pooling operation or a convolution operation performed on the image to be detected. Exemplarily, the multiple downsampling of the preset scale may be that the image to be detected undergoes three pooling operations, and the features output by each pooling operation are the initial features. Exemplarily, the multiple downsampling of the preset scale may be that the image to be detected undergoes a preset step increase in three convolution operations. The image to be detected undergoes a convolution operation of a first preset step to obtain a first extracted feature. The first extracted feature undergoes a convolution operation of a second preset step to obtain a second extracted feature. The second extracted feature undergoes a convolution operation of a third preset step to obtain a third extracted feature. The first extracted feature, the second extracted feature, and the third extracted feature are used as initial features in the initial feature set. Specifically, the first extracted feature is used as the first initial feature in the initial feature set. The second extracted feature is used as the second initial feature in the initial feature set. The third extracted feature is used as the third initial feature in the initial feature set.
[0024] The first preset stride, the second preset stride and the third preset stride are arranged in increasing order. Exemplarily, the first preset stride, the second preset stride and the third preset stride are stride 8, stride 16 and stride 32, respectively. In some application scenarios, the feature extraction module is a feature pyramid structure. The step of inputting the image to be detected into the feature extraction module to obtain at least two initial features of different scales output by the feature extraction module may be inputting the image to be detected into the feature pyramid structure to obtain features of each level in the feature pyramid structure. The feature scales of the features of each level in the feature pyramid are not the same, and each level in the feature pyramid can perform a convolution operation of the preset stride corresponding to the level on the features output by the previous level or the image to be detected, thereby obtaining the features output by each level. Exemplarily, if the feature pyramid contains three levels, each level in the feature pyramid includes a first level, a second level and a third level. The preset stride corresponding to the first level may be the first preset stride. The preset stride corresponding to the second level may be the second preset stride. The preset stride corresponding to the third level may be the third preset stride. The feature output by the first level may be the first extracted feature. Exemplarily, the first extracted feature may be represented as P1. Specifically, the first extracted feature may be represented as ,in, It can represent the first extracted feature. The first extracted feature can be a graph feature. It can represent the channel information corresponding to the first extracted feature, the height information of the graph feature, and the width information of the graph feature. C1 can represent the channel information corresponding to the first extracted feature. H1 can represent the height information of the graph feature in the first extracted feature. W1 can represent the width information of the graph feature in the first extracted feature. The feature output by the second level can be the above-mentioned second extracted feature. Exemplarily, the second extracted feature can be represented as P2. Specifically, the second extracted feature can be represented as ,in, The second extracted feature may be a graph feature. It can represent the channel information corresponding to the second extracted feature, the height information of the graph feature, and the width information of the graph feature. C2 can represent the channel information corresponding to the second extracted feature. H2 can represent the height information of the graph feature in the second extracted feature. W2 can represent the width information of the graph feature in the second extracted feature. The feature outputted by the third level can be the third extracted feature mentioned above. Exemplarily, the third extracted feature can be represented as P3. Specifically, the third extracted feature can be represented as ,in, The third extracted feature may be a graph feature. It can represent the channel information corresponding to the third extracted feature, the height information of the graph feature, and the width information of the graph feature. C3 can represent the channel information corresponding to the third extracted feature. H3 can represent the height information of the graph feature in the third extracted feature. W3 can represent the width information of the graph feature in the third extracted feature. It can be understood that the channel information corresponding to the first extracted feature, the second extracted feature, and the third extracted feature can be the same or different. The height information and width information of the graph feature in the first extracted feature, the second extracted feature, and the third extracted feature are not the same, and the height information and width information are sorted in descending order. For example, the height information of the graph feature in the first extracted feature is greater than that of the second extracted feature. The height information of the graph feature in the second extracted feature is greater than that of the third extracted feature. The width information of the graph feature in the first extracted feature is greater than that of the second extracted feature. The width information of the graph feature in the second extracted feature is greater than that of the third extracted feature.
[0025] Step S12: Determine multiple weight groups based on each initial feature in the initial feature set.
[0026] Different weight groups correspond to different initial features, and the number of weights carried in each weight group is the same as the number of initial features contained in the initial feature set. Each initial feature can correspond to a weight group, and different weight groups correspond to different initial features. Each weight group can include multiple weights. Exemplarily, the multiple weight groups are divided into three groups. The multiple weight groups include a first weight group, a second weight group, and a third weight group. The first initial feature can correspond to the first weight group. The second initial feature can correspond to the second weight group. The third initial feature can correspond to the third weight group.
[0027] Each weight in each weight group may correspond to an initial feature in the initial feature set. The initial feature corresponding to the weight group in the initial feature set is the target feature, the features other than the target feature in the initial feature set are the reference features, and the weight group corresponding to the target feature is the target weight group. It can be immediately understood that for each target weight group, the initial feature set includes the target feature and the reference feature. Each target weight group includes the weight corresponding to the target feature and the weight corresponding to the reference feature. Exemplarily, the first weight group is the weight group corresponding to the first initial feature. When the weight group is the first weight group, that is, when the target feature is the first initial feature, the target weight group is the first weight group, and the reference feature is the second initial feature and the third initial feature, the first weight group includes the weight corresponding to the target feature and the weight corresponding to the reference feature. Among them, the weight corresponding to the target feature may be the weight corresponding to the first initial feature. The weight corresponding to the reference feature may be the weight corresponding to the second initial feature and the weight corresponding to the third initial feature. Exemplarily, the second weight group is the weight group corresponding to the second initial feature. In the case where the weight group is the second weight group, that is, when the target feature is the second initial feature, the target weight group is the second weight group, and the reference features are the first initial feature and the third initial feature, the second weight group includes the weight corresponding to the target feature and the weight corresponding to the reference feature. Among them, the weight corresponding to the target feature can be the weight corresponding to the second initial feature. The weight corresponding to the reference feature can be the weight corresponding to the first initial feature and the weight corresponding to the third initial feature. Exemplarily, the third weight group is the weight group corresponding to the third initial feature. In the case where the weight group is the third weight group, that is, when the target feature is the third initial feature, the target weight group is the third weight group, and the reference features are the second initial feature and the first initial feature, the third weight group includes the weight corresponding to the target feature and the weight corresponding to the reference feature. Among them, the weight corresponding to the target feature can be the weight corresponding to the third initial feature. The weight corresponding to the reference feature can be the weight corresponding to the second initial feature and the weight corresponding to the first initial feature.
[0028] Specifically, each weight in each weight group may indicate the importance of the initial feature corresponding to the weight in the initial feature set among all the initial features. The weights corresponding to the initial features in each weight group may be the same or different. In some application scenarios, when the weights corresponding to the initial features in each weight group are the same, the weights corresponding to the initial features in different weight groups may be the same or different. In other application scenarios, when the weights corresponding to the initial features in each weight group are different, the weights corresponding to the initial features in different weight groups may be the same or different. In other application scenarios, when the weights corresponding to the initial features in each weight group are different, the weight corresponding to the target feature in each weight group is different from the weight corresponding to the reference feature. If there are multiple reference features, the weights corresponding to the reference features may be the same or different. Specifically, the weight corresponding to the target feature in the target weight group may indicate the importance of the target feature in the initial feature set among all the initial features. The weight corresponding to the reference feature in the target weight group may indicate the importance of the reference feature in the initial feature set among all the initial features. In some application scenarios, for a target weight group, the value of the weight corresponding to the target feature is greater than the value of the weight corresponding to the reference feature. In other application scenarios, for a target weight group, the value of the weight corresponding to the target feature is smaller than the value of the weight corresponding to the reference feature. It is understandable that when the weights corresponding to the initial features in each weight group are different, and the weights corresponding to the target features and the weights corresponding to the reference features in each weight group are different, the value of the weight corresponding to the target feature and the value of the weight corresponding to the reference feature depend on the degree of attention paid to the target feature and the reference feature in the initial feature set in units of the target weight group. It can be considered that each weight in each target weight group can combine the feature information of all the initial features in the initial feature set.
[0029] In some application scenarios, for each target weight group, the method for determining each weight in the target weight group may be to directly use a preset value and use the preset value as the weight corresponding to each initial feature. In some application scenarios, for each target weight group, the method for determining each weight in the target weight group may be to directly normalize the initial features to obtain the weight corresponding to each initial feature. In other application scenarios, for each target weight group, the method for determining each weight in the target weight group may be to subject each initial feature in the initial feature set to a preset process to obtain each preset processed initial feature. Each preset processed initial feature is normalized, and the normalized value is determined as the weight corresponding to each initial feature.
[0030] Step S13: For each initial feature, use the target weight group to perform weighted fusion on the initial features in the initial feature set to obtain an advanced feature after the initial feature is updated.
[0031] The target weight group is a weight group corresponding to the initial features in the multiple weight groups.
[0032] For each initial feature, the target weight group is used to perform weighted fusion on each initial feature in the initial feature set to obtain the advanced feature after the initial feature is updated. For each target feature, the target weight group corresponding to the target feature is used to perform weighted fusion on each initial feature in the initial feature set to obtain the advanced feature after the target feature is updated. Specifically, the weight corresponding to each initial feature in the initial feature set is selected from the target weight group as the weight to be fused. In some application scenarios, for each weight to be fused, the weight to be fused is directly fused with the initial feature corresponding to the weight to be fused to obtain the feature to be fused corresponding to each initial feature. In other application scenarios, for each weight to be fused, the weight to be fused is weighted averaged among the weights in the target weight group. Specifically, the weight to be fused is divided by the sum of the weights in the target weight group to obtain the updated value of the weight to be fused. The updated value of the weight to be fused is fused with the initial feature corresponding to the weight to be fused to obtain the feature to be fused corresponding to each initial feature. The features to be fused are fused to obtain the advanced feature after the target feature is updated. For a target weight group, fusing the features to be fused to obtain the advanced features after the target features are updated may be concatenating the features to be fused to obtain the advanced features after the target features are updated.
[0033] Exemplarily, when the target weight group is the above-mentioned second weight group, the target feature is the second initial feature. For each initial feature, the target weight group is used to perform weighted fusion on each initial feature in the initial feature set to obtain the advanced feature after the initial feature is updated. For the second initial feature, the second weight group is used to perform weighted fusion on each initial feature in the initial feature set to obtain the advanced feature after the second initial feature is updated. Among them, the weight corresponding to each initial feature in the second weight group is fused with each initial feature to obtain the feature to be fused corresponding to each initial feature. The features to be fused corresponding to each initial feature are spliced to obtain the advanced feature after the second initial feature is also updated. Specifically, the weight corresponding to the target feature in the second weight group is fused with the target feature to obtain the feature to be fused corresponding to the target feature. The weight corresponding to the reference feature in the second weight group is fused with the target feature to obtain the feature to be fused corresponding to the reference feature. The feature to be fused corresponding to the target feature is spliced with the feature to be fused corresponding to the reference feature to obtain the advanced feature after the target feature corresponding to the target weight group is updated.
[0034] It can be understood that weighted fusion can be to directly multiply each weight to be fused in the target weight group with each initial feature to obtain each feature to be fused, and to splice each feature to be fused to obtain the advanced feature after the target feature is updated. Weighted fusion can also be to weighted average each weight to be fused in the target weight group to obtain the updated value of the weight to be fused, multiply each initial feature with the updated value of the weight to be fused, and to splice each feature to be fused to obtain the advanced feature after the target feature is updated. Weighted fusion can also be to input each initial feature into the self-attention mechanism, and use each weight to be fused in the target weight group as an auxiliary weight to fuse and update the attention weight, obtain the feature representation output by the self-attention mechanism, and use the feature representation output by the self-attention mechanism as the advanced feature after the target feature is updated.
[0035] The advanced feature is used to represent the updated feature of each target feature. Each target weight group corresponds to an advanced feature. It can be considered that the advanced feature after the target feature is updated has the feature information of the target feature and the reference feature, and has richer feature information than a single target feature. Exemplarily, the advanced feature may include a first advanced feature, a second advanced feature, and a third advanced feature. The first advanced feature may be an advanced feature updated from the first initial feature obtained by the first weight group when the first initial feature is used as the target feature. The second advanced feature may be an advanced feature updated from the second initial feature obtained by the second weight group when the second initial feature is used as the target feature. The third advanced feature may be an advanced feature updated from the third initial feature obtained by the third weight group when the third initial feature is used as the target feature.
[0036] Step S14: using the advanced features corresponding to the initial features to obtain the target detection result of the image to be detected.
[0037] The target detection result of the image to be detected can be the result output related to the target detection task. Different target detection tasks will result in different target detection results for the same image to be detected. The target detection result can be an object bounding box, which is used to indicate the position and size of the detected target in the image. The target detection result can be an object category, which is used to indicate the type of object detected in the image to be detected. The target detection result can be a confidence score. The target detection result can be other attributes, which can be the posture, orientation or other key information of the object, depending on the requirements of the target detection task.
[0038] The advanced features corresponding to each initial feature are input into a preset target prediction module to obtain the target detection result of the image to be detected. Among them, the preset target prediction module can be a positioning prediction head or a classification prediction head. In some application scenarios, the advanced features corresponding to each initial feature are input into the positioning prediction head to obtain the target detection result of the image to be detected. The positioning prediction head is used to implement the above-mentioned object positioning-related tasks for the image to be detected, and the output target detection result can be a bounding box. The bounding box can represent the position and size of the object in the image to be detected. In other application scenarios, the advanced features corresponding to each initial feature are input into the classification prediction head to obtain the target detection result of the image to be detected. The classification prediction head is used to implement the above-mentioned tasks related to object classification for the image to be detected. Exemplarily, the image to be detected can be an image containing multiple animals. The target detection result of the image to be detected can be the animal type of each target in the image to be detected.
[0039] Specifically, the advanced features corresponding to the first initial features, the advanced features corresponding to the second initial features, and the advanced features corresponding to the third initial features are simultaneously input into a preset target prediction module to obtain a target detection result of the image to be detected.
[0040] It can be considered that the advanced features corresponding to the initial features of different scales are obtained by using the initial features of different scales. The initial features of different scales are different levels of feature information, for example, shallow feature information, middle layer feature information and top layer feature information. Exemplarily, the first initial feature is the bottom layer feature, the second initial feature is the middle layer feature, and the third initial feature is the top layer feature. The advanced features of different scales are different levels of feature information, and each advanced feature is weightedly fused by the target weight group to obtain feature information of all layers, so that the advanced features have rich feature information.
[0041] The above scheme uses the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, and based on the initial features of different scales in the initial feature set, multiple weight groups that can combine the feature information of each scale are determined. Then, for each initial feature, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain the advanced features after the initial features are updated. Each advanced feature can combine feature information of different scales to make the feature information contained in the advanced feature richer, so that the results obtained by subsequent target detection using each advanced feature are more unified, thereby improving the accuracy of the target detection results.
[0042] See also Figure 2 , Figure 2 This is a flow chart of an embodiment of the target detection method of the present application. Figure 2 .
[0043] In some embodiments, based on each initial feature in the initial feature set, multiple groups of weight groups are determined, including: performing the following steps on each weight group respectively: taking the initial feature corresponding to the weight group in the initial feature set as the target feature, taking other features in the initial feature set except the target feature as reference features, and taking the weight group corresponding to the target feature as the target weight group.
[0044] Step S121: According to the size of the target feature, the reference features are scaled so that the size of each reference feature after the scale transformation is the same as the size of the target feature.
[0045] For the target weight group, the size of the target feature can be the size of the target feature itself, or the size of the target feature expected to be transformed. The size of the target feature expected to be transformed is different from the size of the target feature itself. The size of the target feature expected to be transformed can be a preset size, which transforms the size of the target feature itself into the size of the target feature expected to be transformed.
[0046] In the case where the size of the target feature is the size of the target feature itself, the above step S121 may be: for each reference feature, scale the reference feature so that the size of the reference feature after the scale transformation is the same as the size of the target feature.
[0047] In the case where the size of the target feature is the size of the target feature itself, the above step S121 may be: for each reference feature, the reference feature is scaled to obtain a reference feature after the scale transformation, and the size of the reference feature after the scale transformation is the same as the size of the target feature. For the target feature, the target feature is scaled to obtain a target feature after the scale transformation that has the same size as the size of the target feature expected to be transformed.
[0048] Exemplarily, for the target weight group being the first weight group, the target feature being the first initial feature, and the reference features being the second initial feature and the third initial feature. The above step S121 may be: according to the size of the target feature, upsampling the second initial feature to obtain the scale-transformed second initial feature, so that the size of the scale-transformed second initial feature is the same as the size of the target feature. According to the size of the target feature, upsampling the third initial feature to obtain the scale-transformed third initial feature, so that the size of the scale-transformed third initial feature is the same as the size of the target feature. In some application scenarios, the above step of upsampling the third initial feature to obtain the scale-transformed third initial feature according to the size of the target feature may be directly upsampling the third initial feature once to obtain the scale-transformed third initial feature, so that the size of the scale-transformed third initial feature is the same as the size of the target feature. In other application scenarios, the above step of upsampling the third initial feature to obtain the scale-transformed third initial feature according to the size of the target feature may be upsampling the third initial feature multiple times, so that the size of the scale-transformed third initial feature is the same as the size of the target feature. The step of performing multiple upsampling on the third initial feature may be to perform a first upsampling on the third initial feature according to the size of the second initial feature to obtain the third initial feature after the first scale transformation, so that the size of the third initial feature after the first scale transformation is the same as the size of the second initial feature. Then, according to the size of the first initial feature, perform a second upsampling on the third initial feature after the first scale transformation to obtain the third initial feature after the second scale transformation, so that the size of the third initial feature after the second scale transformation is the same as the size of the first initial feature.
[0049] Exemplarily, when the target weight group is the second weight group, the target feature is the second initial feature, and the reference features are the first initial feature and the third initial feature. The above step S121 may be: according to the size of the target feature, down-sampling the first initial feature to obtain the scale-transformed first initial feature, so that the size of the scale-transformed first initial feature is the same as the size of the target feature. According to the size of the target feature, up-sampling the third initial feature to obtain the scale-transformed third initial feature, so that the size of the scale-transformed third initial feature is the same as the size of the target feature.
[0050] Exemplarily, when the target weight group is the third weight group, the target feature is the third initial feature, and the reference features are the second initial feature and the first initial feature. The above step S121 may be: according to the size of the target feature, down-sampling the second initial feature to obtain the scale-transformed second initial feature, so that the size of the scale-transformed second initial feature is the same as the size of the target feature. According to the size of the target feature, down-sampling the first initial feature to obtain the scale-transformed first initial feature, so that the size of the scale-transformed first initial feature is the same as the size of the target feature. In some application scenarios, the above step of down-sampling the first initial feature to obtain the scale-transformed first initial feature according to the size of the target feature may be directly down-sampling the first initial feature once, so that the size of the scale-transformed first initial feature is the same as the size of the third initial feature. In other application scenarios, the above step of down-sampling the first initial feature to obtain the scale-transformed first initial feature according to the size of the target feature may be down-sampling the first initial feature multiple times, so that the size of the scale-transformed first initial feature is the same as the size of the first initial feature. The step of performing multiple downsampling on the first initial feature may be to first perform a first downsampling on the first initial feature according to the size of the second initial feature to obtain the first initial feature after the first scale transformation, so that the size of the first initial feature after the first scale transformation is the same as the size of the second initial feature. Then, according to the size of the first initial feature, perform a second downsampling on the first initial feature after the first scale transformation to obtain the first initial feature after the second scale transformation, so that the size of the first initial feature after the second scale transformation is the same as the size of the first initial feature.
[0051] The target feature and each reference feature may both be feature maps. In some application scenarios, before step S121, the following steps are also included: performing a first convolution process on each reference feature to obtain each reference feature after the first convolution. The first convolution process may be a 1×1 convolution. The above step S121 includes: according to the size of the target feature, scaling each reference feature after the first convolution so that the size of each reference feature after scaling is the same as the size of the target feature.
[0052] Step S122: splicing the target feature with each scale-transformed reference feature in the channel direction to obtain a fused feature.
[0053] The splicing in the channel direction may be to splice all feature maps in order in the channel dimension. Specifically, the splicing in the channel direction may be to splice the target features and the reference features after each scale transformation in order in the channel dimension. The fused feature is used to represent a feature map of the same size as the target feature obtained by splicing the target features and the reference features after each scale transformation in order, and the target features contained in the fused feature and the reference features after each scale transformation are superimposed in the channel order.
[0054] The fusion feature is a fusion feature corresponding to the target feature. Different target features may correspond to different fusion features. Exemplarily, the fusion feature may include a first fusion feature, a second fusion feature, and a third fusion feature. The first fusion feature is a fusion feature corresponding to the first initial feature when the first initial feature is the target feature. The second fusion feature is a fusion feature corresponding to the second initial feature when the second initial feature is the target feature. The third fusion feature is a fusion feature corresponding to the third initial feature when the third initial feature is the target feature.
[0055] Exemplarily, for the target weight group being the second weight group, the target feature is the second initial feature, and the reference features after the scale transformation are the first initial feature after the scale transformation and the third initial feature after the scale transformation, respectively. The second initial feature is spliced with the first initial feature after the scale transformation and the third initial feature after the scale transformation in the channel direction to obtain a fusion feature corresponding to the target feature. The fusion feature corresponding to the target feature is the fusion feature corresponding to the second initial feature. Specifically, the fusion feature corresponding to the target feature is the second fusion feature. It can be understood that for the case where the target weight group is the first weight group and the fusion feature corresponding to the target feature is the first fusion feature, and for the case where the target weight group is the third weight group and the fusion feature corresponding to the target feature is the third fusion feature, the process of obtaining the fusion feature corresponding to the target feature in these two cases can refer to the process where the target weight group is the second weight group and the fusion feature corresponding to the target feature is the second fusion feature, and will not be repeated here.
[0056] In the case where the size of the target feature is the size of the target feature itself, the above step S121 may be: for each reference feature, the reference feature is scaled to obtain a reference feature after the scale transformation, and the size of the reference feature after the scale transformation is the same as the size of the target feature. For the target feature, the target feature is scaled to obtain a target feature after the scale transformation that has the same size as the size of the target feature expected to be transformed. The above step S122 may be to splice the target feature after the scale transformation with each reference feature after the scale transformation in the channel direction to obtain a fused feature.
[0057] In some other application scenarios, before step S121, the following steps are also included: performing a first convolution process on the target feature and each reference feature respectively to obtain a target feature after the first convolution and each reference feature after the first convolution. The first convolution process can be a 1×1 convolution, in which the size of a convolution kernel is 1×1. The above step S121 may also include the following steps: scaling each reference feature after the first convolution according to the size of the target feature so that the size of each reference feature after the scaling is the same as the size of the target feature. The above step S122 may also include the following steps: splicing the target feature after the first convolution with each reference feature after the scaling in the channel direction to obtain a fused feature.
[0058] In other application scenarios, before the above step S122, the following steps are further included: performing a second convolution process on the target feature to obtain a target feature after the second convolution. Then, performing a second convolution process on each scale-transformed reference feature to obtain each reference feature after the second convolution. The first convolution process may be a 1×1×N convolution, in which the size of a convolution kernel is 1×1, but its depth (or number of channels) is N. For example, the depth (or number of channels) N of the convolution kernel can be set to 32. In other application scenarios, the above step S122 may include the following steps: splicing the target feature after the second convolution with each reference feature after the second convolution in the channel direction to obtain a fusion feature corresponding to the target feature. The above step of splicing the target feature after the first convolution with each reference feature after the scale transformation in the channel direction to obtain a fusion feature may include the following steps: splicing the target feature after the first convolution with each reference feature after the second convolution in the channel direction to obtain a fusion feature corresponding to the target feature.
[0059] Step S123: Based on the fused features, the weights corresponding to the initial features in the weight group are obtained.
[0060] Each target feature may correspond to a fusion feature. Based on the fusion feature, the weight corresponding to each initial feature in the weight group can be obtained by dividing the fusion feature into multiple sub-features according to the channel dimension. Each sub-feature is normalized, and each normalized sub-feature is used as the weight corresponding to each initial feature. In some application scenarios, the channel dimension of each sub-feature is the same as or different from the channel dimension of each initial feature. In the case where the channel dimension of each sub-feature is the same as the channel dimension of each initial feature, the sub-feature with the same channel dimension as the channel dimension of each initial feature is used as the sub-feature corresponding to the initial feature, and the normalized corresponding sub-feature is used as the weight corresponding to the initial feature. It can be understood that in the case where the channel dimension of each sub-feature is different from the channel dimension of each initial feature, the channel dimension of each initial feature can be filtered and screened, and the channel dimension after filtering and screening can be used as the channel dimension of the sub-feature corresponding to each initial feature.
[0061] In some application scenarios, the target feature and each reference feature are respectively subjected to the first convolution process to obtain the target feature after the first convolution and the reference features after each first convolution. According to the size of the target feature, the reference features after each first convolution are scaled to obtain the reference features after each first convolution after the scale transformation. And the reference features after each first convolution after the scale transformation are used as the reference features after the scale transformation. The target feature or the target feature after the first convolution is subjected to the second convolution process to obtain the second convolution result, and the second convolution result is used as the target feature after the second convolution. And, the reference features after each scale transformation are respectively subjected to the second convolution process to obtain the reference features after each scale transformation after the second convolution. And the reference features after each scale transformation after the second convolution are used as the reference features after each second convolution. Then, the step of splicing the reference features after each scale transformation after the second convolution with the reference features after each second convolution in the channel direction to obtain the fused feature is performed. The obtained fused feature is the fused feature corresponding to the target weight group. Each target feature can correspond to one fused feature.
[0062] In some embodiments, the above-mentioned step S123 may include the following steps: performing preset convolution processing on the fused features to obtain multiple preset convolution-induced fused features, each preset convolution-induced fused feature has the same number of weights carried in the weight group; inputting the fused features after each preset convolution into the fully connected layer to obtain the feature vector corresponding to the target feature and the feature vector corresponding to the reference feature; performing activation operation processing on the feature vector corresponding to the target feature and the feature vector corresponding to the reference feature, respectively, to obtain the activation value corresponding to the target feature and the activation value corresponding to the reference feature; using the activation value corresponding to the target feature as the weight corresponding to the target feature in the target weight group, and using the activation value corresponding to the reference feature as the weight corresponding to the reference feature in the target weight group.
[0063] For each fusion feature corresponding to a target feature, the fusion feature is input into a preset convolution layer to obtain multiple fusion features after the preset convolution. Among them, the channel dimension of each fusion feature after the preset convolution is the same as the channel dimension of each initial feature. For each target weight group, each fusion feature after the preset convolution uses the fusion feature after the preset convolution with the same channel dimension as the initial feature as the fusion feature after the preset convolution corresponding to the initial feature. The number of fusion features after each preset convolution is the same as the number of initial features. Each fusion feature after the preset convolution can correspond to one initial feature. The initial feature in the initial feature set has the same number of weights as the weights carried in each weight group. Each initial feature can correspond to one weight in each weight group. For each fusion feature after the preset convolution, the number is the same as the number of weights carried in the weight group. Exemplarily, for one target weight group, the target feature corresponds to one fusion feature. The fusion feature corresponding to the target feature is input into the preset convolution layer to obtain multiple fusion features after the preset convolution. When the number of initial features in the initial feature set is 3, the number of fusion features after the preset convolution is 3. The fused features after the preset convolution may be features having the same channel dimension as the target features in the initial feature set, or may be features having the same channel dimension as the reference features in the initial feature set. The fused features after the preset convolution having the same channel dimension as the target features in the initial feature set are used as the fused features after the preset convolution corresponding to the target features. The fused features after the preset convolution having the same channel dimension as the reference features in the initial feature set are used as the fused features after the preset convolution corresponding to the reference features. It can be understood that the above-mentioned multiple fused features after the preset convolution may be feature maps after the preset convolution. The feature map after the preset convolution may be represented as a feature map after the preset convolution of 3×h×w. 3 is used to represent the number of all feature maps after the preset convolution. h is used to represent the height information in each feature map after the preset convolution. w is used to represent the width information in each feature map after the preset convolution.
[0064] Specifically, the preset convolutional fused features corresponding to the target feature are input into the fully connected layer to obtain the feature vector corresponding to the target feature. The preset convolutional fused features corresponding to each reference feature are input into the fully connected layer to obtain the feature vector corresponding to each reference feature. Exemplarily, when the number of initial features in the initial feature set is 3, the number of feature vectors output by the fully connected layer is 3. The feature vector output by the fully connected layer includes the feature vector corresponding to the target feature and the feature vector corresponding to the reference feature. The feature vector output by the fully connected layer can be a one-dimensional feature vector.
[0065] An activation operation is performed on the feature vector corresponding to the target feature to obtain an activation value corresponding to the target feature. An activation operation is performed on the feature vector corresponding to the reference feature to obtain an activation value corresponding to the reference feature. The activation operation may be a softmax operation.
[0066] In some application scenarios, the activation value corresponding to the target feature is directly used as the weight corresponding to the target feature in the target weight group. The activation value corresponding to the reference feature is directly used as the weight corresponding to the reference feature in the target weight group. In other application scenarios, the activation value corresponding to the target feature is used as the first activation value. The first activation value is normalized to obtain the normalized first activation value, and the normalized first activation value is used as the weight corresponding to the target feature in the target weight group. The activation value corresponding to each reference feature is used as each second activation value. For each second activation value, the second activation value is normalized to obtain the normalized second activation value, and the normalized second activation value is used as the weight corresponding to the reference feature in the target weight group.
[0067] In some embodiments, the above step S13 may include the following steps: for each target feature, select the weight corresponding to each initial feature in the initial feature set from the target weight group as the weight to be fused; based on the product between each initial feature and each weight to be fused, determine each feature to be fused; add and fuse each feature to be fused to obtain an advanced feature after the target feature is updated.
[0068] For each target feature, the weight corresponding to each initial feature in the initial feature set is selected from the target weight group as the weight to be fused; Determine each feature to be fused based on the product of each initial feature and each weight to be fused; The features to be fused are added and fused to obtain the advanced features after the target features are updated.
[0069] The target weight group includes weights corresponding to each initial feature in the initial feature set. For each target feature, the weight corresponding to each initial feature in the initial feature set is selected from the target weight group as the weight to be fused. In some application scenarios, after obtaining the target weight group, the product between each initial feature and each weight to be fused is automatically calculated to obtain a feature table to be fused corresponding to each target weight group. Each feature table to be fused includes features to be fused corresponding to the target feature in the target feature group and features to be fused corresponding to the reference feature. And each feature table to be fused is stored in a preset database. When performing the above-mentioned step of determining each feature to be fused based on the product between each initial feature and each weight to be fused, the features to be fused corresponding to the target feature in each feature table to be fused in the preset database and the features to be fused corresponding to the reference feature are directly obtained. For each feature to be fused in each target weight group, each feature to be fused is added and fused to obtain the advanced feature after the target feature in the target feature group is updated. The above-mentioned step of adding and fusion of each feature to be fused can be splicing each feature to be fused in the target weight group to obtain each feature to be fused after splicing. And the features to be fused after splicing are used as advanced features after the target features are updated.
[0070] See also Figure 3 , Figure 3 It is a schematic diagram of the correspondence between each initial feature and each advanced feature in an embodiment of the target detection method of the present application.
[0071] like Figure 3As shown, the target detection model is used to obtain an initial feature set obtained by performing multi-scale feature extraction on the image to be detected. The initial feature set includes a first initial feature, a second initial feature, and a third initial feature. Based on each initial feature in the initial feature set, multiple weight groups are determined. For each initial feature, the target weight group is used to weightedly fuse each initial feature in the initial feature set to obtain an advanced feature after the initial feature is updated. The advanced features after all the initial features are updated constitute an advanced feature set. The advanced feature set includes a first advanced feature, a second advanced feature, and a third advanced feature. Specifically, for the first initial feature, the first initial feature is used as the target feature, and the second initial feature and the third initial feature are used as reference features. The weight group corresponding to the first initial feature is the target weight group. For the first initial feature, the weight group corresponding to the first initial feature is used to weightedly fuse each initial feature in the initial feature set to obtain an advanced feature after the first initial feature is updated. The advanced feature after the first initial feature is updated may be the first advanced feature. Specifically, for the second initial feature, the second initial feature is used as the target feature, and the first initial feature and the third initial feature are used as reference features. The weight group corresponding to the second initial feature is the target weight group. For the second initial feature, the weight group corresponding to the second initial feature is used to perform weighted fusion on each initial feature in the initial feature set to obtain an advanced feature after the second initial feature is updated. The advanced feature after the second initial feature is updated may be the second advanced feature. Specifically, for the third initial feature, the third initial feature is used as the target feature, and the second initial feature and the first initial feature are used as reference features. The weight group corresponding to the third initial feature is the target weight group. For the third initial feature, the weight group corresponding to the third initial feature is used to perform weighted fusion on each initial feature in the initial feature set to obtain an advanced feature after the third initial feature is updated. The advanced feature after the third initial feature is updated may be the third advanced feature. In some application scenarios, each advanced feature in the advanced feature set may be an aggregated enhanced feature. The first advanced feature may be expressed as AFAE-1 or Y1. The second advanced feature may be expressed as AFAE-2 or Y2. The third advanced feature may be expressed as AFAE-3 or Y3. Exemplarily, taking the second initial feature corresponding weight group as the target weight group as an example, the weights in the target weight group are expressed as follows: the weight corresponding to the first initial feature in the initial feature set can be expressed as A1, the weight corresponding to the second initial feature in the initial feature set can be expressed as A2, and the weight corresponding to the third initial feature in the initial feature set can be expressed as A3. It can be understood that the weight corresponding to the reference feature includes the weight corresponding to the first initial feature and the weight corresponding to the third initial feature. The weight corresponding to the target feature is the weight corresponding to the second initial feature.
[0072] Specifically, the process of obtaining the second advanced feature after the second initial feature is updated can refer to formula (1): Formula (1); Among them, the weight corresponding to the first initial feature in the initial feature set can be expressed as A1, the weight corresponding to the second initial feature in the initial feature set can be expressed as A2, and the weight corresponding to the third initial feature in the initial feature set can be expressed as A3. It can represent the feature to be fused corresponding to the reference feature when the reference feature is the first initial feature. A1 represents the weight to be fused corresponding to the reference feature when the reference feature is the first initial feature. It can represent the reference feature after the scale transformation when the reference feature is the first initial feature. A3 indicates the weight to be fused corresponding to the reference feature when the reference feature is the third initial feature. It can represent the reference feature after the scale transformation when the reference feature is the third initial feature. It can represent the feature to be fused corresponding to the target feature when the target feature is the second initial feature. A2 represents the weight to be fused corresponding to the target feature when the target feature is the second initial feature. In some application scenarios, can represent the target feature, which is also the second initial feature. In other application scenarios, It can represent the target features after the first convolution. It can represent the process of adding and fusing the features to be fused to obtain the advanced features after the target features are updated, and adding and fusing the features to be fused to obtain the second advanced features after the second initial features are updated. Y2 can represent the second advanced features. It can be understood that the process of obtaining the first advanced features after the first initial features are updated and the process of obtaining the third advanced features after the third initial features are updated can refer to the process of obtaining the second advanced features after the second initial features are updated by referring to the above formula (1).
[0073] After the advanced feature set is acquired, the above step S14 may be to obtain the target detection result of the image to be detected by using the first advanced feature, the second advanced feature and the third advanced feature in the advanced feature set.
[0074] In the training of the target detection model, the target detection task pays more attention to the reduced regression accuracy caused by the imbalance problem of the candidate detection boxes corresponding to the prediction results. For example, target detection is considered to be a positioning task, that is, the above-mentioned task related to object positioning. Among them, the imbalance problem includes the imbalance in the number of candidate detection boxes in the candidate detection box group corresponding to each annotation box, and the imbalance in the importance of the candidate detection boxes in the candidate detection box group corresponding to each annotation box. Avoid the target detection model from being overly biased towards certain targets and ignoring other targets during training, thereby improving the overall positioning accuracy of the target detection model. The present application can also solve the problem of reduced regression accuracy caused by the target detection task paying more attention to the imbalance problem of the candidate detection boxes corresponding to the prediction results in the training of the target detection model.
[0075] See also Figure 4 , Figure 4 This is a flow chart of an embodiment of the target detection method of the present application. Figure 3 .
[0076] In some embodiments, the target detection method further includes a step of training the target detection model, and the training step includes: step S41, step S42, step S43 and step S44.
[0077] The target detection model is used to perform target detection on the input image to be detected and output the target detection result of the image to be detected. The target detection model includes an acquisition module, a weight determination module, a weighted fusion module and a target detection module. The above step S11 is performed by the acquisition module in the target detection model. The above step S12 is performed by the weight determination module in the target detection model. The above step S13 is performed by the weighted fusion module in the target detection model. The above step S14 is performed by the target detection module in the target detection model. The image to be detected is input into the acquisition module in the target detection model, and the target detection module in the target detection model outputs the target detection result of the image to be detected.
[0078] In some application scenarios, the target detection module in the target detection model can be a Faster R-CNN model and a Mask R-CNN model. The target detection module in the target detection model obtains the target detection result by first generating candidate regions, and then classifying and regressing the candidate regions into bounding boxes. The target detection module can be a YOLO model series of different versions. The YOLO model series can include versions such as YOLOv1, YOLOv2, YOLOv3, and YOLOv4. The YOLO model series treats the target detection task as a regression problem, and directly predicts the bounding box and category probability in a single forward propagation process.
[0079] Step S41: Obtain a number of candidate detection boxes in the sample image output by the target detection model.
[0080] The sample image may be the same image or the same type of image as the above-mentioned image to be detected. The sample image is input into the target detection model to obtain the target detection result corresponding to the sample image output by the target detection model. The target detection result corresponding to the sample image may be several candidate detection frames in the sample image. Among them, the target detection result corresponding to the sample image may be the target detection result corresponding to the target detection task related to the object positioning task or the object classification task. In some application scenarios, each candidate detection frame corresponding to several candidate detection frames in the sample image contains the positioning information of the object. The positioning information is used to indicate that the position of the sample image where the object or target is located is the area where the candidate detection frame is located. Each candidate detection frame corresponds to the positioning prediction result of an object or target in the sample image. The sample image includes multiple objects or targets. Different candidate detection frames may correspond to the same object or target, or may correspond to different objects or targets. In other application scenarios, each candidate detection frame corresponding to several candidate detection frames in the sample image contains the classification information of the object. The classification information is used to indicate that the position of the sample image where the object or target is located is the area where the candidate detection frame is located, and which preset category the area where the candidate detection frame is located belongs to. For example, the area where the candidate detection frame is located belongs to a cat or a dog. Each candidate detection frame corresponds to a classification prediction result of an object or target in the sample image. The classification prediction result can be the possibility or probability value of the preset category to which the candidate detection frame belongs. The sample image includes multiple objects or targets. Different candidate detection frames can correspond to the same object or target, or to different objects or targets. It can be understood that several candidate detection frames in the sample image can represent multiple prediction results of target detection. The prediction result can be the above-mentioned positioning prediction result or the above-mentioned classification prediction result.
[0081] Step S42: Determine the candidate detection frame groups corresponding to each annotation frame respectively.
[0082] Each candidate detection frame group includes at least one candidate detection frame.
[0083] Each annotation frame is the annotation result after the sample image is annotated. Among them, each annotation frame can be a real result of the sample image. The candidate detection frame group corresponding to each annotation frame can include a candidate detection frame whose real prediction result meets the expected conditions. In some application scenarios, the expected condition can be that for each annotation frame, the candidate detection frame with overlap between the candidate detection frame and the annotation frame is determined as a candidate detection frame that meets the expected conditions, and each candidate detection frame that meets the expected conditions is used as a candidate detection frame in the candidate detection frame group corresponding to the annotation frame. In other application scenarios, the expected condition can be that for each annotation frame, the candidate detection frame whose intersection and union ratio between the candidate detection frame and the annotation frame meets the threshold condition is determined as a candidate detection frame that meets the expected conditions, and each candidate detection frame that meets the expected conditions is used as a candidate detection frame in the candidate detection frame group corresponding to the annotation frame. Among them, the threshold condition can be a screening threshold. It can be understood that at least one candidate detection frame included in each candidate detection frame group is a candidate detection frame that meets the expected conditions. Exemplarily, at least one candidate detection frame included in each candidate detection frame group can be a positive sample frame.
[0084] Among them, a candidate detection frame included in each candidate detection frame group can be in at least one candidate detection frame group.
[0085] In some embodiments, the above step S42 may include the following steps: for each annotated frame, determining the intersection-over-union ratio between each candidate detection frame and the annotated frame. In response to the intersection-over-union ratio satisfying the screening threshold, adding the candidate detection frame corresponding to the intersection-over-union ratio to the candidate detection frame group corresponding to the annotated frame.
[0086] For each annotated box, determine the value of the intersection-and-union ratio between each candidate detection box and the annotated box. The screening threshold may be a preset threshold. The preset threshold may be 0.45 or 0.5. For each annotated box, determine whether the value of the intersection-and-union ratio between each candidate detection box and the annotated box is greater than or equal to the screening threshold. In the case where the value of the intersection-and-union ratio between each candidate detection box and the annotated box is greater than or equal to the screening threshold, in response to the intersection-and-union ratio satisfying the screening threshold, the candidate detection box corresponding to the intersection-and-union ratio is added to the candidate detection box group corresponding to the annotated box. In response to the intersection-and-union ratio satisfying the screening threshold, the candidate detection box corresponding to the intersection-and-union ratio that satisfies the screening threshold is added to the candidate detection box group corresponding to the annotated box.
[0087] It can be considered that each candidate detection frame in each candidate detection frame group determined according to the screening threshold is a positive sample frame. The positive sample frame is directly related to the target task and can help the target detection model to better learn features, thereby improving the accuracy of classification or regression. In addition, by using the positive sample frame, the target detection model can effectively reduce the bias against negative samples, ensure that it can accurately identify the features of the positive sample frame, and improve the accuracy of the target detection results output by the target detection model.
[0088] Step S43: For each candidate detection frame, determine the target loss of the candidate detection frame based on the loss reference factor.
[0089] The loss reference factor includes the score ranking of the candidate detection frame in the candidate detection frame group to which it belongs, and / or the proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups.
[0090] The target loss can be used to measure the difference between a candidate detection frame and the labeled frame corresponding to the candidate detection frame group in which the candidate detection frame is located. The target loss can be a positioning loss or a classification loss. In some application scenarios, when the target loss is a positioning loss, the positioning loss can be used to measure the position difference between the candidate detection frame and the labeled frame corresponding to the candidate detection frame group in which the candidate detection frame is located. In other application scenarios, when the target loss is a classification loss, the classification loss can be used to measure the category difference between the category to which the candidate detection frame belongs and the category to which the labeled frame corresponding to the candidate detection frame group in which the candidate detection frame is located belongs. Specifically, the category difference can be the ratio between the probability value corresponding to the predicted result and the probability value corresponding to the true result.
[0091] In some application scenarios, for each candidate detection frame, the target loss of the candidate detection frame is determined based on the score ranking of the candidate detection frame in the candidate detection frame group. The score ranking of the candidate detection frame in the candidate detection frame group may be a score ranking relationship between the candidate detection frame and each candidate detection frame in the candidate detection frame group. In some application scenarios, the score ranking of the candidate detection frame in the candidate detection frame group may be determined according to the overlap area between each candidate detection frame and the labeled frame corresponding to the candidate detection frame group, and the larger the overlap area, the higher the score ranking. Exemplarily, the overlap area between the candidate detection frame and the labeled frame corresponding to the candidate detection frame group is the largest, and the score ranking is 1. The overlap area between the candidate detection frame and the labeled frame corresponding to the candidate detection frame group is the smallest, and the score ranking is M. Wherein, M is the total number of candidate detection frames in the candidate detection frame group. In some other application scenarios, the score ranking of the candidate detection frame in the candidate detection frame group can be determined according to the intersection-and-union ratio between each candidate detection frame and the labeled frame corresponding to the candidate detection frame in the candidate detection frame group. The larger the intersection-and-union ratio, the higher the score ranking. Exemplarily, the intersection-and-union ratio of the labeled frame between the candidate detection frame and the labeled frame corresponding to the candidate detection frame group is the largest, and the score ranking is 1. The overlapping area between the intersection-and-union ratio of the candidate detection frame and the labeled frame corresponding to the candidate detection frame group is the smallest, and the score ranking is M. Among them, M is the total number of candidate detection frames in the candidate detection frame group. It can be understood that the value of the intersection-and-union ratio can be the ratio of the intersection area of two bounding boxes to the union area of two bounding boxes, and the two bounding boxes are the candidate detection frame and the labeled frame corresponding to the candidate detection frame in the candidate detection frame group. The value of the intersection-and-union ratio can be expressed as . Where i is used to represent the candidate detection box in the two bounding boxes.
[0092] For each candidate detection frame, the target loss of the candidate detection frame is determined based on the score ranking of the candidate detection frame in the candidate detection frame group. Specifically, the score ranking parameter is determined according to the score ranking of the candidate detection frame in the candidate detection frame group. The product of the score ranking parameter and the intersection-over-union loss is used as the target loss. The score ranking can be a ranking value, for example, the above score ranking is 1 or the score ranking is M. The score ranking parameter can be directly the ranking value corresponding to the score ranking. The score ranking parameter can also be the reciprocal of the ranking value corresponding to the score ranking.
[0093] In some application scenarios, based on the first preset intersection-and-union parameter and the value of the intersection-and-union ratio, the intersection-and-union ratio loss is determined. The value of the intersection-and-union ratio can refer to the above content and will not be repeated here. The first preset intersection-and-union ratio parameter can be 1. The first preset intersection-and-union ratio parameter can be set according to the accuracy requirement of the target detection model. Based on the first preset intersection-and-union ratio parameter and the value of the intersection-and-union ratio, the process of determining the intersection-and-union ratio loss can be to subtract the difference obtained by subtracting the value of the intersection-and-union ratio from the first preset intersection-and-union ratio parameter as the intersection-and-union ratio loss. In other application scenarios, based on the first preset intersection-and-union ratio parameter and the value of the intersection-and-union ratio and the second preset intersection-and-union ratio parameter, the intersection-and-union ratio loss is determined. The second intersection-and-union ratio parameter can be used to represent the proportional relationship between the center point distance between the above two bounding boxes and the diagonal length of the minimum enclosed box between the two bounding boxes. Among them, the second intersection-and-union ratio parameter can be the ratio between the square of the center point distance and the square of the diagonal length, the square of the center point distance is the numerator, and the square of the diagonal length is the denominator. The minimum enclosed box between the two bounding boxes can be the overlapping area between the two bounding boxes. Based on the first preset intersection-and-coupled ratio parameter and the value of the intersection-and-coupled ratio and the second preset intersection-and-coupled ratio parameter, the process of determining the intersection-and-coupled ratio loss can be to obtain a difference by subtracting the value of the intersection-and-coupled ratio from the first preset intersection-and-coupled ratio parameter, and to sum the difference with the above-mentioned second preset intersection-and-coupled ratio parameter to obtain the summed value as the intersection-and-coupled ratio parameter.
[0094] Specifically, based on the first preset IoU parameter and the IoU value and the second preset IoU parameter, the process of determining the IoU loss can refer to formula (2): Formula (2); in, The above-mentioned intersection-over-union loss can be expressed as the intersection-over-union loss of each candidate detection frame in each candidate detection frame group. It can represent each candidate detection frame belonging to each candidate detection frame group. For example, It can represent the i-th candidate detection box in each candidate detection box group. Each annotation box can be represented. It can represent the first preset intersection-over-union ratio parameter mentioned above. It can represent the value of the above intersection-and-union ratio. It can represent the above-mentioned second preset intersection-over-combination ratio parameter. It can represent the square of the distance from the above center point. It can represent the center point of the candidate detection box in the above two bounding boxes. It can represent the center point of the candidate detection frame in the annotation frame corresponding to the candidate detection frame group. Exemplarily, the center point distance can be the Euclidean distance between the center point of the candidate detection frame and the center point of the annotation frame corresponding to the candidate detection frame group. The diagonal length can be as mentioned above.
[0095] In some embodiments, the loss reference factor includes the score ranking of the candidate detection frame in the candidate detection frame group, and the above step S43 may include the following steps: taking the ratio between the first preset value and the score ranking as the base of the first preset exponential function, and the exponent of the first preset exponential function is the second preset value. Then, based on the product of the operation result of the first preset exponential function and the intersection-and-union ratio loss corresponding to the candidate detection frame, the target loss corresponding to the candidate detection frame is obtained.
[0096] The ratio between the first preset value and the score ranking is used as the base of the first preset exponential function, and the exponent of the first preset exponential function is the second preset value. The first preset value may be 1 or 2. The first preset value may be set according to the accuracy requirement of the target detection model. The second preset value may be a dynamic balance parameter. The dynamic balance parameter corresponding to the second preset value may be dynamically set according to the accuracy requirement of the target detection model. Then, based on the product between the operation result of the first preset exponential function and the intersection-and-union loss corresponding to the candidate detection frame, the target loss corresponding to the candidate detection frame is obtained. The product obtained by multiplying the operation result of the first preset exponential function and the intersection-and-union loss corresponding to the candidate detection frame is used as the target loss corresponding to the candidate detection frame.
[0097] Specifically, the step of using the ratio between the first preset value and the score ranking as the base of the first preset exponential function, the exponent of the first preset exponential function being the second preset value, and the step of obtaining the target loss corresponding to the candidate detection frame by multiplying the operation result based on the first preset exponential function and the intersection-over-union loss corresponding to the candidate detection frame can refer to formula (3): Formula (3); in, It can represent the operation result of the first preset exponential function. As the base of the first preset exponential function. Serves as an exponent of a first preset exponential function. A second preset value may be indicated. It can represent the ratio between the above-mentioned first preset value and the score ranking. may represent the score ranking of each candidate detection frame in the candidate detection frame group in which it is located. 1 may represent a first preset value. i may represent each candidate detection frame. j may represent the candidate detection frame group in which each candidate detection frame is located. The above-mentioned intersection-over-union loss can be represented by , which is the intersection-over-union loss of each candidate detection frame in each candidate detection frame group. Wherein, i can represent each candidate detection frame belonging to each candidate detection frame group. It is used to represent the product between the operation result of the first preset exponential function and the intersection-over-union loss corresponding to the candidate detection frame. The product can be used as the target loss corresponding to the candidate detection frame. It can represent the target loss corresponding to the candidate detection box.
[0098] In some application scenarios, for each candidate detection frame, a target loss of the candidate detection frame is determined based on a proportional relationship between the number of candidate detection frames included in a candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups.
[0099] After the above step S42, the number of candidate detection frames included in all candidate detection frame groups is counted to obtain a statistical result. The statistical result includes a first number corresponding to the total number of candidate detection frames included in all candidate detection frame groups and a second number corresponding to the number of candidate detection frames included in each candidate detection frame group. It can be understood that each candidate detection frame group corresponds to a second number. The second numbers corresponding to each candidate detection frame group are summed, and the sum value can be equal to the above first number.
[0100] The proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups may be the ratio between the second number corresponding to each candidate detection frame group and the first number corresponding to all candidate detection frame groups, and the ratio is used as the quantity parameter. The process of determining the quantity parameter may be to calculate the ratio between the second number corresponding to each candidate detection frame group and the first number corresponding to all candidate detection frame groups, and the ratio is used as the quantity parameter. In some application scenarios, for each candidate detection frame, the process of determining the target loss of the candidate detection frame based on the proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups may be to first determine the above-mentioned quantity parameter. The product between the above-mentioned quantity parameter and the intersection-and-union ratio loss is directly used as the target loss. In other application scenarios, for each candidate detection frame, the process of determining the target loss of the candidate detection frame based on the proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups may be to first determine the above-mentioned quantity parameter. The product obtained by multiplying the preset quantity weight and the above-mentioned quantity parameter is the new quantity parameter. The preset quantity weight can be set according to the accuracy requirements of the target detection model. The product of the new quantity parameter and the intersection-over-union loss is used as the target loss.
[0101] In some embodiments, the loss reference factor includes the proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups. For each candidate detection frame, the target loss of the candidate detection frame is determined based on the loss reference factor, including: determining the ratio between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups; taking the product of the third preset value and the ratio as the base of a second preset exponential function, the exponent of the second preset exponential function being the fourth preset value; and obtaining the target loss corresponding to the candidate detection frame based on the product of the operation result of the second preset exponential function and the intersection-and-union ratio loss corresponding to the candidate detection frame.
[0102] Determine the ratio between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups; use the product of the third preset value and the ratio as the base of a second preset exponential function, and the exponent of the second preset exponential function is a fourth preset value; Specifically, the process of obtaining the target loss corresponding to the candidate detection frame by multiplying the result of the operation based on the second preset exponential function and the intersection-over-union loss corresponding to the candidate detection frame can refer to formula (4): Formula (4); in, It can represent the calculation result of the second preset exponential function corresponding to each candidate detection frame. The product between the third preset value and the ratio can be expressed as As the base of the second preset exponential function. Serves as an exponent of a second preset exponential function. The fourth preset value may represent a fourth preset value. The fourth preset value may be a dynamic balance parameter. The dynamic balance parameter corresponding to the fourth preset value may be dynamically set according to the accuracy requirement of the target detection model. It can represent the ratio between the number of candidate detection frames included in a candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups. It can represent the total number of candidate detection boxes included in all candidate detection box groups, that is, the first number mentioned above. It can represent the number of candidate detection frames included in the candidate detection frame group, that is, the number of candidate detection frames included in the candidate detection frame group where the candidate detection frame is located, that is, the second number mentioned above. It can represent a third preset value. The third preset value can be set according to the accuracy requirement of the target detection model. The third preset value can be other values except 0.1. i can represent each candidate detection frame. j can represent the candidate detection frame group in which each candidate detection frame is located. The above-mentioned intersection-over-union loss can be represented by , which is the intersection-over-union loss of each candidate detection frame in each candidate detection frame group. Wherein, i can represent each candidate detection frame belonging to each candidate detection frame group. It is used to represent the product between the operation result of the second preset exponential function and the intersection-over-union loss corresponding to the candidate detection frame, and the product can be used as the target loss corresponding to the candidate detection frame. It can represent the target loss corresponding to the candidate detection box.
[0103] In other application scenarios, for each candidate detection frame, the target loss of the candidate detection frame is determined based on the score ranking of the candidate detection frame in the candidate detection frame group to which it belongs and the proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups.
[0104] Specifically, the ratio between the first preset value and the score ranking is used as the base of the first preset exponential function, and the exponent of the first preset exponential function is the second preset value. Determine the ratio between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all candidate detection frame groups; use the product between the third preset value and the ratio as the base of the second preset exponential function, and the exponent of the second preset exponential function is the fourth preset value; calculate the product between the operation result of the first preset exponential function and the operation result of the second preset exponential function, and use the product as the dynamic adjustment parameter. Based on the product between the dynamic adjustment parameter and the intersection-over-union ratio loss corresponding to the candidate detection frame, the target loss corresponding to the candidate detection frame is obtained.
[0105] Specifically, based on the product of the dynamic adjustment parameter and the intersection-over-union loss corresponding to the candidate detection frame, the process of obtaining the target loss corresponding to the candidate detection frame can also refer to formula (5): Formula (5); in, The dynamic adjustment parameter may represent the product of the operation result of the first preset exponential function and the operation result of the second preset exponential function. It is used to represent the operation result of the first preset exponential function. It can be understood that the parameters in the operation result of the first preset exponential function can refer to the relevant content in the above formula (3), which will not be repeated here. Used to represent the operation result of the second preset exponential function. It can be understood that the parameters in the operation result of the second preset exponential function can refer to the relevant content in the above formula (4), which will not be repeated here. i can represent each candidate detection frame. j can represent the candidate detection frame group in which each candidate detection frame is located. The above-mentioned intersection-over-union loss can be represented by , which is the intersection-over-union loss of each candidate detection frame in each candidate detection frame group. Wherein, i can represent each candidate detection frame belonging to each candidate detection frame group. It is used to represent the product of the dynamic adjustment parameter and the intersection-over-union loss corresponding to the candidate detection frame. This product can be used as the target loss corresponding to the candidate detection frame. It can represent the target loss corresponding to the candidate detection box.
[0106] In some application scenarios, for some annotation boxes gt, there are fewer corresponding positive sample boxes. In order to avoid the localization branch or classification branch training in the target detection model ignoring these positive sample boxes, In other application scenarios, for other annotation boxes gt, there are more corresponding samples. In order to avoid the positioning branch or classification branch training in the target detection model being biased towards these positive sample boxes, Reduce its weight. The positioning branch or classification branch in the target detection model refers to each module in the target detection model.
[0107] In other application scenarios, each candidate detection frame in the candidate detection frame group corresponding to each annotation frame gt, that is, each positive sample frame corresponding to each annotation frame, first of all, the positive sample frame with relatively high positioning accuracy (larger intersection and union) is relatively more important, so through To increase its weight. For those positive sample frames with relatively low positioning accuracy (smaller intersection and union), they are relatively less important. Since they account for a relatively large proportion, To relatively reduce its weight. In the case where there are fewer positive sample boxes corresponding to the labeled box gt, even if the positioning accuracy of the sample is relatively low (the intersection and union is relatively small), but its DIoU ranking inside the sample corresponding to the labeled box gt is high, then its weight It can be considered that by adjusting the dynamic adjustment parameters through the changes in the first exponential operation result and / or the second exponential operation result in the above dynamic adjustment parameters, the contribution of positive sample frames from different annotation frames gt to the positioning loss will reach a relatively balanced state, thereby making the positioning branch of the target detection model more balanced and more accurate.
[0108] Step S44: using the target loss of each candidate detection box to adjust the parameters in the target detection model.
[0109] The target losses of all detection boxes are combined into a total loss value. The total loss value is used to adjust the acquisition module, the weight determination module, the weighted fusion module, and the target detection module in the target detection model. In some application scenarios, the process of combining the target losses of all detection boxes into a total loss value may be to directly sum the target losses of all detection boxes and use the sum as the total loss value. In other application scenarios, the process of combining the target losses of all detection boxes into a total loss value may be to directly weight the target losses of all detection boxes and use the weighted sum as the total loss value. The total loss value is used to calculate the gradient of the parameters of each module in the target detection model. The partial derivative of the loss function with respect to the parameters of each module in the target detection model is calculated by the chain rule. The calculated gradient is back-propagated to each module in the target detection model to update the parameters of each module in the target detection model. Each module in the target detection model includes an acquisition module, a weight determination module, a weighted fusion module, and a target detection module.
[0110] The above scheme uses the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, and based on the initial features of different scales in the initial feature set, multiple weight groups that can combine the feature information of each scale are determined. Then, for each initial feature, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain the advanced features after the initial features are updated. Each advanced feature can combine feature information of different scales to make the feature information contained in the advanced feature richer, so that the results obtained by subsequent target detection using each advanced feature are more unified, thereby improving the accuracy of the target detection results.
[0111] See also Figure 5 , Figure 5 It is a structural diagram of an embodiment of the target detection device of the present application. The target detection device 50 includes an acquisition module 51, a weight determination module 52, a weighted fusion module 53 and a target detection module 54. The acquisition module 51 is used to use the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, wherein the initial feature set contains at least two initial features and the scales of each initial feature are different; the weight determination module 52 is used to determine multiple groups of weight groups based on each initial feature in the initial feature set, different weight groups correspond to different initial features, and the number of weights carried in each weight group is the same as the number of initial features contained in the initial feature set; the weighted fusion module 53 is used to use the target weight group to perform weighted fusion on each initial feature in the initial feature set for each initial feature, and obtain the advanced feature after the initial feature is updated, and the target weight group is the weight group corresponding to the initial feature in the multiple weight groups; the target detection module 54 is used to use the advanced features corresponding to each initial feature to obtain the target detection result of the image to be detected.
[0112] The above scheme uses the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, and based on the initial features of different scales in the initial feature set, multiple weight groups that can combine the feature information of each scale are determined. Then, for each initial feature, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain the advanced features after the initial features are updated. Each advanced feature can combine feature information of different scales to make the feature information contained in the advanced feature richer, so that the results obtained by subsequent target detection using each advanced feature are more unified, thereby improving the accuracy of the target detection results.
[0113] Please refer to the target detection method for the functions performed by each module, which will not be repeated here.
[0114] See also Figure 6 , Figure 6 6 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 60 includes a memory 61 and a processor 62, and the processor 62 is used to execute program instructions stored in the memory 61 to implement the steps in the above-mentioned target detection method embodiment. In a specific implementation scenario, the electronic device 60 may include but is not limited to: a multi-camera device, a microcomputer, and a server. In addition, the electronic device 60 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0115] Specifically, the processor 62 is used to control itself and the memory 61 to implement the steps in the above-mentioned target detection method embodiment. The processor 62 can also be called a CPU (Central Processing Unit). The processor 62 may be an integrated circuit chip with signal processing capabilities. The processor 62 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 62 can be implemented by an integrated circuit chip.
[0116] The above scheme uses the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, and based on the initial features of different scales in the initial feature set, multiple weight groups that can combine the feature information of each scale are determined. Then, for each initial feature, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain the advanced features after the initial features are updated. Each advanced feature can combine feature information of different scales to make the feature information contained in the advanced feature richer, so that the results obtained by subsequent target detection using each advanced feature are more unified, thereby improving the accuracy of the target detection results.
[0117] See also Figure 7 , Figure 7 The computer-readable storage medium 70 stores program instructions 701, which implement the steps in any of the above target detection method embodiments when executed by a processor.
[0118] The above scheme uses the target detection model to obtain the initial feature set obtained by multi-scale feature extraction of the image to be detected, and based on the initial features of different scales in the initial feature set, multiple weight groups that can combine the feature information of each scale are determined. Then, for each initial feature, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain the advanced features after the initial features are updated. Each advanced feature can combine feature information of different scales to make the feature information contained in the advanced feature richer, so that the results obtained by subsequent target detection using each advanced feature are more unified, thereby improving the accuracy of the target detection results.
[0119] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0120] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0121] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0122] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0123] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor to execute all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
Claims
1. A target detection method, characterized in that: The method comprises: Using the target detection model, an initial feature set is obtained by performing multi-scale feature extraction on the image to be detected, wherein the initial feature set contains at least two initial features and the scales of the initial features are different; Based on each of the initial features in the initial feature set, a plurality of weight groups are determined, different weight groups correspond to different initial features, and the number of weights carried in each of the weight groups is the same as the number of initial features included in the initial feature set; For each of the initial features, a target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain an advanced feature after the initial features are updated, wherein the target weight group is a weight group corresponding to the initial feature in the multiple weight groups; The object detection result of the image to be detected is obtained by using the advanced features corresponding to each of the initial features.
2. The method according to claim 1, characterized in that The determining of a plurality of weight groups based on each of the initial features in the initial feature set comprises: Perform the following steps for each weight group: The initial feature corresponding to the weight group in the initial feature set is taken as the target feature, the other features in the initial feature set except the target feature are taken as reference features, and the weight group corresponding to the target feature is taken as the target weight group; According to the size of the target feature, the reference features are scaled so that the size of each reference feature after the scale transformation is the same as the size of the target feature; The target feature is concatenated with each of the reference features after the scale transformation in the channel direction to obtain a fusion feature; Based on the fused features, the weights corresponding to the initial features in the weight group are obtained.
3. The method according to claim 2, characterized in that The obtaining, based on the fused features, the weights corresponding to the initial features in the weight group includes: Performing a preset convolution process on the fused features to obtain a plurality of preset convolutional fused features, each of the preset convolutional fused features having the same number of weights as that carried in the weight group; Inputting the fused features after each of the preset convolutions into a fully connected layer to obtain a feature vector corresponding to the target feature and a feature vector corresponding to the reference feature; Performing activation operations on the feature vector corresponding to the target feature and the feature vector corresponding to the reference feature to obtain an activation value corresponding to the target feature and an activation value corresponding to the reference feature; The activation value corresponding to the target feature is used as the weight corresponding to the target feature in the target weight group, and the activation value corresponding to the reference feature is used as the weight corresponding to the reference feature in the target weight group.
4. The method according to claim 2, characterized in that: For each of the initial features, the target weight group is used to perform weighted fusion on the initial features in the initial feature set to obtain an advanced feature after the initial features are updated, including: For each of the target features, selecting a weight corresponding to each of the initial features in the initial feature set from the target weight group as a weight to be fused; Determine each feature to be fused based on the product of each initial feature and each weight to be fused; The features to be fused are added and fused to obtain the advanced features after the target features are updated.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises a step of training the target detection model, wherein the training step comprises: Obtaining a number of candidate detection boxes in the sample image output by the target detection model; Determine candidate detection frame groups corresponding to each labeled frame respectively, each of the candidate detection frame groups includes at least one candidate detection frame; For each of the candidate detection frames, determining a target loss of the candidate detection frame based on a loss reference factor, wherein the loss reference factor includes a score ranking of the candidate detection frame in the candidate detection frame group in which it is located, and / or a proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all the candidate detection frame groups; The target loss of each candidate detection box is used to adjust the parameters in the target detection model.
6. The method according to claim 5, characterized in that The step of respectively determining the candidate detection frame groups corresponding to the respective annotation frames comprises: For each of the labeled boxes, determining an intersection-over-union ratio between each of the candidate detection boxes and the labeled box; In response to the intersection-over-union ratio satisfying a screening threshold, the candidate detection box corresponding to the intersection-over-union ratio is added to the candidate detection box group corresponding to the labeled box.
7. The method according to claim 5, characterized in that The loss reference factor includes a score ranking of the candidate detection frame in the candidate detection frame group, and for each candidate detection frame, determining a target loss of the candidate detection frame based on the loss reference factor includes: Using the ratio between the first preset value and the score ranking as the base of a first preset exponential function, the exponent of the first preset exponential function being the second preset value; Based on the product of the operation result of the first preset exponential function and the intersection-over-union loss corresponding to the candidate detection frame, the target loss corresponding to the candidate detection frame is obtained.
8. The method according to claim 5, characterized in that The loss reference factor includes a proportional relationship between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all the candidate detection frame groups. For each candidate detection frame, determining a target loss of the candidate detection frame based on the loss reference factor includes: Determine a ratio between the number of candidate detection frames included in the candidate detection frame group and the total number of candidate detection frames included in all the candidate detection frame groups; taking the product of the third preset value and the ratio as the base of a second preset exponential function, the exponent of the second preset exponential function being a fourth preset value; Based on the product of the operation result of the second preset exponential function and the intersection-over-union loss corresponding to the candidate detection frame, the target loss corresponding to the candidate detection frame is obtained.
9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the target detection method according to any one of claims 1-8.
10. A computer-readable storage medium, characterized in that: include: A program file is stored, and when the program file is executed by a processor, it is used to implement the target detection method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image feature extraction method, terminal equipment and computer readable storage medium
CN114612690A
Multi-scale weight sharing convolutional neural network and electroencephalogram emotion recognition method thereof
CN117494013A
Small target detection method, apparatus and device, and computer readable storage medium
CN118485903A
Method for recognizing distribution network equipment based on raspberry pi multi-scale feature fusion
US11631238B1
Target detection method and apparatus, computer device and storage medium
WO2021218037A1
