Model training method, target detection method, device, equipment and storage medium
By standardizing input preprocessing and using a Siamese network structure, multiple loss functions are calculated and updated asynchronously, solving the false detection problem caused by object category similarity in object detection and improving detection accuracy and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- UBTECH ROBOTICS CORP LTD
- Filing Date
- 2022-08-29
- Publication Date
- 2026-07-24
AI Technical Summary
In object detection tasks, when the similarity between object categories is high, the classification loss function of the network decreases slowly, resulting in a high false detection rate. Existing pre-cleaning data solutions are costly and time-consuming.
We employ normalized input preprocessing, data augmentation, and Siamese network architecture. We identify target features through a trunk network, calculate classification, regression, and triplet loss functions, and asynchronously update the loss functions to train the target detection model.
It improves the object detection model's ability to distinguish fine-grained features, reduces the false detection rate, and optimizes network robustness and training efficiency.
Smart Images

Figure CN115424064B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection network construction technology, and in particular to a model training method, target detection method, apparatus, device and storage medium. Background Technology
[0002] In object detection tasks, if there are many objects to be detected and the categories of the objects are highly similar, the classification loss function of the network will decrease slowly, which can easily lead to false detections in the detection results.
[0003] To avoid inaccurate results from object detection networks, a common approach is to pre-clean the input data during network construction, adding more data that is prone to false positives, thus enabling the classification network to learn to distinguish between difficult-to-detect categories. However, this approach requires significant time and manpower for data acquisition, cleaning, and labeling. Therefore, a more cost-effective optimization scheme for object detection models is urgently needed. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of this application provide a model training method, an object detection method, an apparatus, a device, and a storage medium, the specific solutions of which are as follows: In a first aspect, embodiments of this application provide a model training method, including: Acquire the image to be detected; The image to be detected is subjected to normalized input preprocessing to obtain the data to be detected; A network model is constructed based on the data to be detected. The target features in the data to be detected are identified by a trunk network. A classification loss function and a regression loss function are calculated by a preset detection network. A triplet loss function is calculated based on the target features output by the trunk network. Backpropagation is performed based on the classification loss function, the regression loss function and the triplet loss function to obtain the target detection model. According to a specific embodiment of this application, when constructing a network model based on the data to be detected, the method further includes: The classification loss function and the regression loss function are calculated through the preset detection network in the first preset period. In the second preset period, the classification loss function and regression loss function are calculated through the preset detection network, and the triplet loss function is calculated through the target features output by the trunk network. The first preset period is shorter than the second preset period, and the first preset period and the second preset period are set at an interval.
[0005] According to a specific embodiment of this application, the step of performing normalized input preprocessing on the image to be detected includes: Obtain a standard bounding box image from the image to be detected based on the preset feature annotation content; The image size of the standard frame image is adjusted to obtain the target image; The image to be detected and the target image are augmented using a preset image data augmentation library to obtain the data to be detected.
[0006] According to a specific embodiment of this application, the step of calculating the triplet loss function through the target features output by the trunk network includes: Based on the category of the target features, all target features are divided into positive sample pairs and negative sample pairs, wherein the positive sample pairs are sample pairs whose data belong to the same category, and the negative sample pairs are sample pairs whose data belong to different categories; A corresponding number of sample sets are obtained according to a preset sampling coefficient, wherein the sample sets include the same number of positive sample pairs and negative sample pairs; Based on the index corresponding to each sample set, the sample sets are combined into triplet samples; The triplet loss function is calculated based on the triplet samples.
[0007] According to a specific embodiment of this application, the calculation formula of the triplet loss function includes:
[0008] in, Represents the triplet loss function. This represents the Euclidean distance between positive sample pairs. This represents the Euclidean distance between negative sample pairs. margin It is a constant. As anchor point, As a positive example, This is a negative example.
[0009] According to a specific implementation of this application, the step of performing backpropagation based on the classification loss function, the regression loss function, and the triplet loss function to obtain the target detection model includes: The target loss function is calculated based on the preset weight ratio of each loss function. The target detection model is obtained by backpropagation based on the target loss function.
[0010] Secondly, embodiments of this application provide a target detection method, including: Acquire the image to be detected; The image to be detected is identified by a pre-built target detection model to obtain the location and category of the target features, wherein the target detection model is obtained based on the model training method described in the first aspect.
[0011] According to a specific embodiment of this application, after the step of identifying the image to be detected by a pre-built target detection model to obtain the location and category of target features, the method further includes: The classification loss function and regression loss function are calculated based on the preset detection network of the target detection model. Backpropagation is performed based on the classification loss function and the regression loss function to update the object detection model.
[0012] Thirdly, embodiments of this application provide a model training apparatus, including: The acquisition module is used to acquire the image to be detected; The preprocessing module is used to perform normalized input preprocessing on the image to be detected in order to obtain the data to be detected. The model building module is used to build a network model based on the data to be detected. Specifically, the target features in the data to be detected are identified by a trunk network, a classification loss function and a regression loss function are calculated by a preset detection network, a triplet loss function is calculated by the target features output by the trunk network, and backpropagation is performed based on the classification loss function, the regression loss function and the triplet loss function to obtain the target detection model.
[0013] Fourthly, embodiments of this application provide a target detection device, comprising: The acquisition module is used to acquire the image to be detected; The target detection module is used to identify the image to be detected by a pre-built target detection model to obtain the location and category of target features, wherein the target detection model is obtained based on the model training method described in the first aspect.
[0014] Fifthly, embodiments of this application provide an electronic device, which includes a processor and a memory. The memory stores a computer program, and the computer program executes the model training method described in the first aspect or the target detection method described in the second aspect when it is run on the processor.
[0015] In a sixth aspect, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when run on a processor, executes the model training method described in the first aspect or the target detection method described in the second aspect.
[0016] This application provides a model training method, object detection method, apparatus, device, and storage medium, including: acquiring an image to be detected; performing normalized input preprocessing on the image to be detected to obtain data to be detected; constructing a network model based on the data to be detected, wherein a trunk network is used to identify target features in the data to be detected, a classification loss function and a regression loss function are calculated using a preset detection network, a triplet loss function is calculated using the target features output by the trunk network, and backpropagation is performed based on the classification loss function, the regression loss function, and the triplet loss function to obtain an object detection model. This invention effectively improves the object detection model's ability to distinguish fine-grained features by constructing different types of Siamese networks to calculate multiple loss functions for training the object detection model. Attached Figure Description
[0017] To more clearly illustrate the technical solution of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope of protection of the present invention. In the various drawings, similar components are numbered similarly.
[0018] Figure 1 This illustration shows a flowchart of a model training method provided in an embodiment of this application. Figure 2 This illustration shows a schematic diagram of the network structure of a target detection model obtained by a model training method provided in an embodiment of this application; Figure 3 This illustration shows a flowchart of a target detection method provided in an embodiment of this application. Figure 4 This illustration shows a schematic diagram of a device module for a model training apparatus provided in an embodiment of this application; Figure 5 A schematic diagram of a target detection device module provided in an embodiment of this application is shown. Detailed Implementation
[0019] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0020] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0021] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0022] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0023] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0024] Example 1 refer to Figure 1 This is a schematic diagram of a model training method provided in an embodiment of this application. The model training method provided in this embodiment of the application, such as... Figure 1 As shown, the model training method includes: Step S101: Obtain the image to be detected; Specifically, the images to be detected provided in this embodiment are sample images used for training the target detection model. The number of images to be detected can be adaptively replaced according to the actual application scenario, and is not limited here.
[0025] It should be noted that the number of images to be detected should ensure the training effect of the target detection model. The images to be detected can be obtained from the Internet or other channels. This embodiment does not limit the method of obtaining the images to be detected.
[0026] Step S102: Perform normalized input preprocessing on the image to be detected to obtain the data to be detected; In a specific embodiment, the size of the images to be detected used for model training is kept consistent, which can effectively improve the training effect of the object detection model.
[0027] According to a specific embodiment of this application, the step of performing normalized input preprocessing on the image to be detected includes: Obtain a standard bounding box image from the image to be detected based on the preset feature annotation content; The image size of the standard frame image is adjusted to obtain the target image; The image to be detected and the target image are augmented using a preset image data augmentation library to obtain the data to be detected.
[0028] In a specific embodiment, based on the user-preset ground truth for the image to be detected, the specified detection target is extracted from the image to be detected, and the image size of the extracted detection target is adjusted to a standard size.
[0029] For example, if the original image size is 480*640, the bounding box size is 128*256, and the input size of the body network of the object detection model is 320*320, then it is necessary to first extract the 128*256 bounding box image from the original image, and then scale the bounding box image to 320*320 as the input.
[0030] Specifically, the standard bounding box image includes the specified detection target. The target image is the input to the torso network.
[0031] Furthermore, after acquiring the target image, data augmentation processing is required on both the target image and the original image to improve the robustness of the target detection network.
[0032] Specifically, the preset image data augmentation library can be the Imgaug library or other types of databases used to store data augmentation code. The Imgaug library is a pre-packaged Python library for image data augmentation.
[0033] The selection of the preset image data enhancement library can also be adaptively replaced according to the actual application scenario, and no single limitation is made here.
[0034] Applying the same data augmentation processing to the target image and the original input image to be detected can effectively increase the learning difficulty of the target detection network for the image to be detected, and further optimize the robustness of the target detection network.
[0035] Step S103: Construct a network model based on the data to be detected. The target features in the data to be detected are identified by a trunk network. A classification loss function and a regression loss function are calculated by a preset detection network. A triplet loss function is calculated based on the target features output by the trunk network. Backpropagation is performed based on the classification loss function, the regression loss function and the triplet loss function to obtain the target detection model.
[0036] In a specific embodiment, such as Figure 2 As shown, this implementation requires the establishment of a three-part network structure when constructing the network model. The target detection model includes a backbone network, a pre-defined detection network (Neck & Head), and a re-identification (ReID) branch network.
[0037] Specifically, the ReID branch network and the preset detection network share some weights of the trunk network to form a target detection model with a twin network structure.
[0038] Specifically, the preset detection network is implemented based on the head network and the neck network, and is used for feature detection, classification loss function calculation and regression loss function calculation.
[0039] For the ReID branch network, the triplet loss function is calculated using the feature map output by the trunk network. This allows the target detection model to be obtained by backpropagation based on the classification loss function, regression loss function, and triplet loss function in this embodiment.
[0040] According to a specific embodiment of this application, when constructing a network model based on the data to be detected, the method further includes: In the first preset period, the classification loss function and the regression loss function are calculated through a preset detection network; In the second preset period, a classification loss function and a regression loss function are calculated through a preset detection network, and a triplet loss function is calculated through the target features output by the trunk network. The first preset period is shorter than the second preset period, and the first preset period and the second preset period are set at an interval.
[0041] In a specific embodiment, when training the object detection model, since the detection task performed by the preset detection network is more difficult, while the re-identification task of the ReID branch network is simpler, it is easy for the triple loss function value in the ReID branch network to drop to a very low level, while the classification loss function value in the preset detection network drops slowly.
[0042] Therefore, by asynchronously updating the classification loss function, regression loss function, and triplet loss function, the ReID branch network can be improved to recognize more difficult re-identification tasks, thereby improving the detection performance of the object detection network for difficult cases.
[0043] For example, in the complete training cycle of the object detection model, the classification loss function and regression loss function are calculated in each epoch, and the triplet loss function is calculated once every 5 epochs.
[0044] In this embodiment, the first preset period can be 1 epoch period, the second preset period can be 5 epoch periods, and the complete training period for training the object detection model can be composed of multiple first preset periods and multiple second preset periods, or it can be composed of one first preset period and one second preset period.
[0045] It should be noted that the number of the first preset period and the second preset period can also be adaptively replaced according to the actual application scenario, and there is no unique limitation here.
[0046] The first preset period and the second preset period are spaced apart from each other and are cyclically distributed throughout the complete training period of the target detection model.
[0047] According to a specific embodiment of this application, the step of calculating the triplet loss function through the target features output by the trunk network includes: Based on the category of the target features, all target features are divided into positive sample pairs and negative sample pairs, wherein the positive sample pairs are sample pairs whose data belong to the same category, and the negative sample pairs are sample pairs whose data belong to different categories; A corresponding number of sample sets are obtained according to a preset sampling coefficient, wherein the sample sets include the same number of positive sample pairs and negative sample pairs; Based on the index corresponding to each sample set, the sample sets are combined into triplet samples; The triplet loss function is calculated based on the triplet samples.
[0048] In a specific embodiment, each epoch calculation cycle includes multiple calculation batches.
[0049] In this embodiment, the re-identification task in the ReID branch network mainly uses the feature vector of the target feature to calculate the distance between two vectors, and uses the distance between the two vectors to represent the similarity between the two images.
[0050] Before performing the calculation of the ternary loss function, it is necessary to perform positive and negative sample separation on the target features.
[0051] In this embodiment, a sampler is used to segment the target features. The method for constructing the sampler includes: Step 1: Within a computation batch, determine the number of target features belonging to each category. For example, if a batch size is set to 32, and the 32 images include 14 target feature categories, with the first category comprising 5 images, then each of these 5 images forms a positive sample pair, and these 5 images form a negative sample pair with any one of the remaining 27 images.
[0052] Step two: Set the number of positive and negative sample pairs required in each batch, denoted as the sampling coefficient n. From all combinations of positive and negative sample pairs, randomly select n sample sets as input. These n sample sets need to contain n / 2 positive and n / 2 negative sample pairs. The positive and negative sample pairs in each sample set are combined according to their indices.
[0053] For example, consider 10 images with indices 0-9. These images are divided into two categories: category 1 (5 images each) and category 2 (indices 0-4 and 5-9 respectively). When the sampling coefficient for image 0 is 2, two lists might be generated: [(0,5), (0,6), (0,7), (0,8), (0,9)] and [(0,1), (0,2), (0,3), (0,4)]. These lists store the corresponding combinations of positive and negative samples. If two sample pairs (0,5) and (0,1) are randomly obtained from these lists, their corresponding indices (0,1,5) form a triplet sample, where (0,1) is a positive sample pair and (0,5) is a negative sample pair.
[0054] After obtaining the corresponding triplet samples through the data sampler, the triplet loss function can be calculated based on the corresponding triplets.
[0055] According to a specific embodiment of this application, the calculation formula of the triplet loss function includes:
[0056] in, Represents the triplet loss function. This represents the Euclidean distance between positive sample pairs. This represents the Euclidean distance between negative sample pairs. margin It is a constant. As anchor point, As a positive example, This is a negative example.
[0057] In a specific embodiment, updating the object detection model based on the triplet loss function forces the object detection model to perform deep learning on difficult examples, thereby enabling the anchor point to... and negative examples The distance between them is larger, while making the anchor point and positive examples The distance between them is smaller.
[0058] margin The specific value can be set to a value between 0.3 and 0.7.
[0059] According to a specific implementation of this application, the step of performing backpropagation based on the classification loss function, the regression loss function, and the triplet loss function to obtain the target detection model includes: The target loss function is calculated based on the preset weight ratio of each loss function. The target detection model is obtained by backpropagation based on the target loss function.
[0060] In a specific embodiment, a preset weight ratio can be assigned to each loss function in advance. For example, the ratio of classification loss function:regression loss function:triple loss function is 1:1:1. It should be noted that the preset weight ratio can also be adaptively set according to the actual application scenario; it is not a unique limitation here.
[0061] The model training method provided in this embodiment constrains the object detection network model using the Triplet loss method in ReID, increasing the Euclidean distance between similar objects in the projection space and effectively mitigating false detections between target feature categories. Furthermore, for the input of the ReID branch, the target to be detected is extracted, and the image is processed using the same data augmentation steps as the trunk network and the preset detection network, effectively improving the robustness of the object detection model. To address the issue that the network tends to learn simpler ReID branches during training, making it difficult for the classification loss function in the preset detection network to decrease, an asynchronous update strategy is used to train the network, allowing the classification loss to decrease normally, thus ensuring the training effect of the object detection network.
[0062] refer to Figure 3 This is a schematic flowchart of a target detection method provided in an embodiment of this application. The target detection method provided in this embodiment of the application, such as... Figure 3 As shown, the target detection method includes: Step S301: Obtain the image to be detected; Step S302: Identify the image to be detected using a pre-built target detection model to obtain the location and category of the target features, wherein the target detection model is obtained based on the model training method described in the above embodiments.
[0063] Specifically, the recognition process of the target detection model in this embodiment can be referred to the description in the above embodiments, and will not be repeated here.
[0064] Based on the target detection model in the above embodiments, the category to which the target feature belongs and the location of the target feature in the image to be detected can be accurately identified.
[0065] According to a specific embodiment of this application, after the step of identifying the image to be detected by a pre-built target detection model to obtain the location and category of target features, the method further includes: The classification loss function and regression loss function are calculated based on the preset detection network of the target detection model. Backpropagation is performed based on the classification loss function and the regression loss function to update the object detection model.
[0066] In a specific embodiment, during the inference process using the object detection model, only the preset detection network is used for the object detection model update step, and the ReID branch network is no longer used to perform the re-identification task. This effectively saves the inference time of the object detection model and optimizes the memory usage during inference.
[0067] The target detection method provided in this embodiment can perform fine-grained feature recognition without excessively occupying network memory, thereby optimizing network performance while ensuring the type recognition effect.
[0068] refer to Figure 4 This is a schematic diagram of a model training device 400 provided in an embodiment of this application. The model training device 400 provided in this embodiment of the application, as shown below... Figure 4 As shown, the model training device 400 includes: The acquisition module 401 is used to acquire the image to be detected; The preprocessing module 402 is used to perform normalized input preprocessing on the image to be detected in order to obtain the data to be detected. The model building module 403 is used to build a network model based on the data to be detected. The target features in the data to be detected are identified by the trunk network, the classification loss function and the regression loss function are calculated by the preset detection network, the triplet loss function is calculated by the target features output by the trunk network, and backpropagation is performed based on the classification loss function, the regression loss function and the triplet loss function to obtain the target detection model.
[0069] refer to Figure 5 This is a schematic diagram of a target detection device 500 provided in an embodiment of this application. The target detection device 500 provided in this embodiment of the application, as shown below... Figure 5 As shown, the target detection device 500 includes: The acquisition module 501 is used to acquire the image to be detected; The target detection module 502 is used to identify the image to be detected by a pre-built target detection model to obtain the location and category of the target features, wherein the target detection model is obtained based on the model training method described in the first aspect.
[0070] In addition, this application also provides an electronic device, which includes a processor and a memory. The memory stores a computer program, and the computer program executes the model training method or the target detection method described in the above embodiments when it is run on the processor.
[0071] This application provides a computer-readable storage medium storing a computer program. When the computer program is run on a processor, it executes the model training method or the target detection method described in the above embodiments.
[0072] The specific implementation process of the model training device, target detection device, computer equipment and computer-readable storage medium mentioned in the above embodiments can be found in the specific implementation process of the above method embodiments, and will not be repeated here.
[0073] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, as an alternative implementation, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0074] In addition, the functional modules or units in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0075] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0076] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A model training method, characterized in that, include: Acquire the image to be detected; The image to be detected is subjected to normalized input preprocessing to obtain the data to be detected; A network model is constructed based on the data to be detected. The target features in the data to be detected are identified by a trunk network. A classification loss function and a regression loss function are calculated by a preset detection network. A triplet loss function is calculated based on the target features output by the trunk network. Backpropagation is performed based on the classification loss function, the regression loss function and the triplet loss function to obtain the target detection model. The target detection model includes a trunk network, a preset detection network, and a re-identification branch network. The preset detection network is used for feature detection, calculation of the classification loss function, and calculation of the regression loss function. The re-identification branch network is used to calculate the triplet loss function using the feature map output by the trunk network. When constructing the network model based on the data to be detected, the method further includes: The classification loss function and the regression loss function are calculated through the preset detection network in the first preset period. In the second preset period, the classification loss function and regression loss function are calculated through the preset detection network, and the triplet loss function is calculated through the target features output by the trunk network. The first preset period is shorter than the second preset period, and the first preset period and the second preset period are set at an interval.
2. The method according to claim 1, characterized in that, The step of performing normalized input preprocessing on the image to be detected includes: Obtain a standard bounding box image from the image to be detected based on the preset feature annotation content; The image size of the standard frame image is adjusted to obtain the target image; The image to be detected and the target image are augmented using a preset image data augmentation library to obtain the data to be detected.
3. The method according to claim 1, characterized in that, The step of calculating the triplet loss function using the target features output by the trunk network includes: Based on the category of the target features, all target features are divided into positive sample pairs and negative sample pairs, wherein the positive sample pairs are sample pairs whose data belong to the same category, and the negative sample pairs are sample pairs whose data belong to different categories; A corresponding number of sample sets are obtained according to a preset sampling coefficient, wherein the sample sets include the same number of positive sample pairs and negative sample pairs; Based on the index corresponding to each sample set, the sample sets are combined into triplet samples; The triplet loss function is calculated based on the triplet samples.
4. The method according to claim 1, characterized in that, The formula for calculating the triplet loss function includes: in, Represents the triplet loss function. This represents the Euclidean distance between positive sample pairs. This represents the Euclidean distance between negative sample pairs. margin It is a constant. As anchor point, As a positive example, This is a negative example.
5. The method according to claim 1, characterized in that, The step of performing backpropagation based on the classification loss function, the regression loss function, and the triplet loss function to obtain the object detection model includes: The target loss function is calculated based on the preset weight ratio of each loss function. The target detection model is obtained by backpropagation based on the target loss function.
6. A target detection method, characterized in that, include: Acquire the image to be detected; The image to be detected is identified by a pre-constructed target detection model to obtain the location and category of target features, wherein the target detection model is obtained based on the model training method described in any one of claims 1-5.
7. The method according to claim 6, characterized in that, After the step of identifying the image to be detected using a pre-built target detection model to obtain the location and category of target features, the method further includes: The classification loss function and regression loss function are calculated based on the preset detection network of the target detection model. Backpropagation is performed based on the classification loss function and the regression loss function to update the object detection model.
8. A model training device, characterized in that, include: The acquisition module is used to acquire the image to be detected; The preprocessing module is used to perform normalized input preprocessing on the image to be detected in order to obtain the data to be detected. The model building module is used to build a network model based on the data to be detected. Specifically, the target features in the data to be detected are identified through the trunk network, the classification loss function and the regression loss function are calculated through the preset detection network, the triplet loss function is calculated through the target features output by the trunk network, and backpropagation is performed based on the classification loss function, the regression loss function and the triplet loss function to obtain the target detection model. The target detection model includes a trunk network, a preset detection network, and a re-identification branch network. The preset detection network is used for feature detection, calculation of the classification loss function, and calculation of the regression loss function. The re-identification branch network is used to calculate the triplet loss function using the feature map output by the trunk network. The construction of the network model based on the data to be detected also includes: The classification loss function and the regression loss function are calculated through the preset detection network in the first preset period. In the second preset period, the classification loss function and regression loss function are calculated through the preset detection network, and the triplet loss function is calculated through the target features output by the trunk network. The first preset period is shorter than the second preset period, and the first preset period and the second preset period are set at an interval.
9. A target detection device, characterized in that, include: The acquisition module is used to acquire the image to be detected; The target detection module is used to identify the image to be detected by a pre-built target detection model to obtain the location and category of target features, wherein the target detection model is obtained based on the model training method described in any one of claims 1-5.
10. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory storing a computer program, which, when run on the processor, executes the model training method according to any one of claims 1 to 5, or the target detection method according to claim 6 or 7.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when run on a processor, executes the model training method of any one of claims 1 to 5, or the target detection method of claim 6 or 7.