Detection model training method, device, target detection method, equipment and medium
Through an iterative training method, combined with supervised learning and unsupervised contrastive representation methods, the detection model is trained, which solves the problem of low anchor-free target detection accuracy and achieves the effect of improving detection performance and accuracy at low cost.
Patent Information
- Application Number
- CN202011095394.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-14
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2040-10-14
AI Technical Summary
The traditional anchorless object detection method has the problem of low detection accuracy, and the feature extractor trained by the existing unsupervised training method on classification tasks is not necessarily suitable for object detection tasks.
By obtaining the first image set with target labels and the second image set without target labels, an iterative training method is adopted. First, supervised learning is used to train the initial detection model to obtain the first initial detection model, and then unsupervised comparison is used. The representation method trains the model to obtain a second initial detection model, and repeats this process until the preset convergence conditions are reached.
Without increasing the amount of calculation and requiring no additional manual annotation of image sets, the detection performance of the detection model is improved, the accuracy of target detection is ensured, and the obtained detection model is targeted at target detection.
Smart Images

Figure CN112418264B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer vision technology, and in particular to a detection model training method, device, target detection method, equipment and medium. Background Art
[0002] Object detection is an important visual perception task. Generally, object detection can be divided into single-stage anchor detection, two-stage anchor detection and single-stage anchor-free detection. Among them, single-stage anchor-free detection is simple to implement and can be learned and deployed quickly, but the detection performance is low.
[0003] In traditional technology, in order to improve the detection performance of anchor-free detection, the model is usually trained on classification tasks to obtain a feature extractor with better performance, and then the corresponding detection module is connected to the feature extractor to achieve target detection.
[0004] However, traditional methods for improving the detection performance of anchor-free detection suffer from the problem of low target detection accuracy. Summary of the invention
[0005] Based on this, it is necessary to provide a detection model training method, device, target detection method, equipment and medium that can improve the accuracy of target detection in response to the above technical problems.
[0006] A method for training a detection model, the method comprising:
[0007] Acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label;
[0008] Performing an iterative training operation; the iterative training operation includes: using the first image set and adopting a supervised learning method to train a preset initial detection model to obtain a first initial detection model;
[0009] Using the first image set and the second image set, and adopting an unsupervised contrast representation method to train the first initial detection model to obtain a second initial detection model;
[0010] The second initial detection model is used as a new initial detection model, and the iterative training operation is returned to be executed until a preset convergence condition is reached, and the second initial detection model corresponding to when the preset convergence condition is reached is determined as the detection model.
[0011] In one embodiment, the first image set and the second image set are used to train the first initial detection model using an unsupervised contrast representation method to obtain a second initial detection model, including:
[0012] Inputting the first image and the second image into the first initial detection model simultaneously to obtain feature vectors corresponding to the first image and the second image;
[0013] Obtaining a value of an optimization function of the first initial detection model according to the feature vector;
[0014] The first initial detection model is trained according to the value of the optimization function to obtain the second initial detection model.
[0015] In one embodiment, obtaining the value of the optimization function of the first initial detection model according to the feature vector includes:
[0016] According to the feature vector, a metric vector corresponding to the feature vector is obtained; the metric vector is used to store the feature vector and update the feature vector;
[0017] A value of an optimization function of the first initial detection model is obtained according to the feature vector and the metric vector.
[0018] In one embodiment, the step of simultaneously inputting the first image and the second image into the first initial detection model to obtain feature vectors corresponding to the first image and the second image includes:
[0019] Inputting the first image and the second image into the first initial detection model at the same time to obtain classification head heat maps corresponding to the first image and the second image;
[0020] The number of peak points in the classification head heat map is counted, and the feature vectors corresponding to the first image and the second image are obtained according to the number of peak points in the classification head heat map.
[0021] In one embodiment, the first image set is used to train a preset initial detection model using a supervised learning method to obtain a first initial detection model, including:
[0022] Inputting the images in the first image set into the initial detection model to obtain a detection result;
[0023] Obtaining a value of a loss function of the initial detection model according to the detection result and a target label of each image in the first image set;
[0024] The parameters of the initial detection model are adjusted according to the value of the loss function to obtain the first initial detection model.
[0025] In one of the embodiments, the detection model is any type of network in an anchor-free network.
[0026] A target detection method, the method comprising:
[0027] Acquire the image to be detected;
[0028] The image to be detected is input into the detection model to obtain the detection result of the target in the image to be detected; wherein the detection model is obtained by performing an iterative training operation, and the iterative training operation includes: using a first image set with a target label, adopting a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and a second image set without a target label, adopting an unsupervised contrast representation method to train the first initial detection model to obtain a second initial detection model, using the second initial detection model as a new initial detection model, returning to perform the iterative training operation, and determining the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
[0029] A training device for a detection model, the device comprising:
[0030] A first acquisition module is used to acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label;
[0031] An operation module is used to perform an iterative training operation; the iterative training operation includes: using the first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, using an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model;
[0032] A determination module is used to use the second initial detection model as a new initial detection model, return to execute the iterative training operation until a preset convergence condition is reached, and determine the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
[0033] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0034] Acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label;
[0035] Performing an iterative training operation; the iterative training operation includes: using the first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, using an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model;
[0036] The second initial detection model is used as a new initial detection model, and the iterative training operation is returned to be executed until a preset convergence condition is reached, and the second initial detection model corresponding to when the preset convergence condition is reached is determined as the detection model.
[0037] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0038] Acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label;
[0039] Performing an iterative training operation; the iterative training operation includes: using the first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, using an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model;
[0040] The second initial detection model is used as a new initial detection model, and the iterative training operation is returned to be executed until a preset convergence condition is reached, and the second initial detection model corresponding to when the preset convergence condition is reached is determined as the detection model.
[0041] The training method, device, target detection method, equipment and medium of the above detection model, by acquiring a first image set with a target label and a second image set without a target label, firstly use the first image set to adopt a supervised learning method to train the preset initial detection model to obtain a first initial detection model, and then use the first image set and the second image set to adopt an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model, and then use the second initial detection model as a new initial detection model, and repeat the training steps until the preset convergence condition is reached, and determine the second initial detection model corresponding to the preset convergence condition when the preset convergence condition is reached as the detection model, so that without changing the calculation amount and without the need for additional manual annotation of the image set, the detection performance of the obtained detection model is improved by repeatedly performing the above training steps, thereby ensuring the accuracy of target detection using the detection model; in addition, the training method is an end-to-end training method for target detection, which ensures that the obtained detection model is a model for target detection, and then the obtained detection model can be used to accurately detect the target, thereby improving the accuracy of target detection using the detection model. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 A schematic diagram of the internal structure of a computer device provided by an embodiment;
[0043] Figure 2 A schematic diagram of a flow chart of a method for training a detection model in one embodiment;
[0044] Figure 3 A schematic diagram of a flow chart of a method for training a detection model in another embodiment;
[0045] Figure 4 A schematic diagram of a flow chart of a method for training a detection model in another embodiment;
[0046] Figure 5 Schematic diagram of a target detection method in one embodiment;
[0047] Figure 6 is a structural block diagram of a training device for a detection model in one embodiment;
[0048] Figure 7 FIG. 4 is a structural block diagram of a target detection device in an embodiment. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0050] The detection model training method and target detection method provided in the embodiments of the present application can be applied to Figure 1 The computer device shown. The computer device includes a processor and a memory connected by a system bus, and a computer program is stored in the memory. When the processor executes the computer program, the steps of the following method embodiment can be executed. Optionally, the computer device may also include a network interface, a display screen and an input device. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory, and the non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. Optionally, the computer device can be a server, a personal computer, a personal digital assistant, or other terminal devices, such as a tablet computer, a mobile phone, etc., or a cloud or remote server. The embodiment of the present application does not limit the specific form of the computer device.
[0051] Object detection is an important visual perception task, which can be specifically divided into single-stage anchor detection, dual-stage anchor detection and single-stage anchor-free detection. However, single-stage anchor detection and dual-stage anchor detection require a large number of labeled sample images, and the supervised learning method is complex to train the model, which has certain difficulties in application. Single-stage anchor-free detection is simple to implement and can be learned and deployed quickly, but the performance of single-stage anchor-free detection of targets is lower than that of anchor detection. The most direct way to improve the performance of the model is to introduce more training data, but the annotation cost of training data is high. In order to improve the performance of the detection model at a low cost, unsupervised training methods are usually used to train the model. However, the existing unsupervised training methods all train the model on the classification task, thereby obtaining a feature extractor with better performance, and then connecting the corresponding detection module after the feature extractor to realize the detection of the target. However, the training process is staged, not end-to-end. The feature extractor obtained through unsupervised training on the classification task is not necessarily the most suitable for the target detection task, and there is a problem of low target detection accuracy. To this end, the present application proposes a detection model training method, device, target detection method, equipment and medium, aiming to solve the above-mentioned problems.
[0052] In one embodiment, Figure 2 As shown, a method for training a detection model is provided, and the method is applied to Figure 1 The computer device in the example is used to illustrate, including the following steps:
[0053] S201, obtaining a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label.
[0054] Among them, the first image in the first image set is an image with a target label, that is, the target in the first image in the first image set is labeled, and the target in the first image has a corresponding target label; the second image in the second image set is an image without a target label, that is, the target in the second image in the second image set is not labeled, and the target in the second image has no corresponding target label. Specifically, the computer device obtains a first image set with a target label and a second image set without a target label. Optionally, the first image set can be a coco image set or a VOC image set. Optionally, the computer device can obtain the above-mentioned first image set and second image set from a commonly used image library that has been disclosed on the Internet.
[0055] S202, perform iterative training operations; the iterative training operations include: using the first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, using an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model.
[0056] Specifically, the computer device performs an iterative training operation, wherein the iterative training operation includes: using the above-mentioned first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, and using the above-mentioned first image set and the above-mentioned second image set, using an unsupervised contrast representation method to train the above-mentioned first initial detection model to obtain a second initial detection model. Optionally, the initial detection model can be a CenterNet model. Among them, using a supervised learning method to train the preset initial detection model refers to the process of adjusting the parameters of the classifier of the initial detection model using a set of samples of known categories to achieve the required performance; using an unsupervised contrast representation method to train the first initial detection model refers to the process of training the first initial detection model using a second image without a target label in the second image set and a first image with a target label in the first image set. It can be understood that the above-mentioned iterative training operation is to use the first image set to adopt a supervised learning method to train the initial detection model to obtain the first initial detection model, and to use the first image set and the second image set to adopt an unsupervised contrast representation method to train the first initial detection model to obtain the second initial detection model. This is end-to-end training, and the training method is directly performed on the target detection task and is suitable for target detection.
[0057] S203, taking the second initial detection model as a new initial detection model, returning to perform iterative training operations until a preset convergence condition is reached, and determining the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
[0058] Specifically, the computer device uses the second initial detection model obtained above as a new initial detection model, returns to perform the above iterative training operation, until the preset convergence condition is reached, and determines the second initial detection model corresponding to the preset convergence condition as the detection model. Optionally, the preset convergence condition can be a preset number of iterations. Optionally, the detection model is any type of network in the anchor-free network. It can be understood that the detection model is obtained by jointly training the initial detection model using a supervised learning method and an unsupervised comparative representation method. Therefore, the initial detection model can be any type of network in the anchor-free network, and then the detection model obtained by training the initial detection model is also any type of network in the anchor-free network. Exemplarily, CenterNet is one of the anchor-free networks.
[0059] In the above-mentioned detection model training method, the computer device obtains a first image set with a target label and a second image set without a target label, and first uses the first image set to adopt a supervised learning method to train a preset initial detection model to obtain a first initial detection model, and then uses the first image set and the second image set to adopt an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model, and then uses the second initial detection model as a new initial detection model, and repeatedly executes the training step until a preset convergence condition is reached, and determines the second initial detection model corresponding to the preset convergence condition when the preset convergence condition is reached as the detection model, so that the detection performance of the obtained detection model is improved by repeatedly executing the above-mentioned training steps without changing the amount of calculation and without the need for additional manual annotation of the image set, thereby ensuring the accuracy of target detection using the detection model; in addition, the training method is an end-to-end training method for target detection, which ensures that the obtained detection model is a model for target detection, and then the obtained detection model can be used to accurately detect the target, thereby improving the accuracy of target detection using the detection model.
[0060] In the scenario where the computer device uses the first image set and the second image set to train the first initial detection model using an unsupervised contrast representation method to obtain the second initial detection model, the computer device may train the first initial detection model according to the optimization function of the obtained first initial detection model to obtain the second initial detection model. In one embodiment, Figure 3As shown, in the above S202, the first image set and the second image set are used to train the first initial detection model using an unsupervised contrast representation method to obtain a second initial detection model, including:
[0061] S301, inputting the first image and the second image into a first initial detection model simultaneously to obtain feature vectors corresponding to the first image and the second image.
[0062] Specifically, the computer device simultaneously inputs the first image in the first image set and the second image in the second image set into the first initial detection model to obtain feature vectors corresponding to the first image and the second image. Optionally, the computer device can simultaneously input the first image and the second image into the first initial detection model to obtain a classification head heat map corresponding to the first image and the second image, count the number of peak points in the classification head heat map, and obtain feature vectors corresponding to the first image and the second image according to the number of peak points in the classification head heat map.
[0063] S302: Obtain a value of an optimization function of a first initial detection model according to the feature vector.
[0064] Specifically, the computer device obtains the value of the optimization function of the first initial detection model based on the feature vectors corresponding to the first image and the second image obtained above. Optionally, the computer device can obtain the metric vector corresponding to the feature vector based on the feature vectors corresponding to the first image and the second image, and obtain the value of the optimization function of the first initial detection model based on the feature vectors and the obtained metric vector. The metric vector is used to store the feature vectors corresponding to the first image and the second image and update the feature vector. Exemplarily, it is assumed that the computer device inputs the first image and the second image into the first initial detection model at the same time, obtains the peak points on the classification head heat map corresponding to the first image and the second image, and thereby obtains the feature vector corresponding to the classification head heat map on the feature map in the first initial detection model as [v1,v2,L,v N ] N×C , where N is the number of peak points in the classification head heat map corresponding to the first image and the second image, and C is the number of channels corresponding to the feature map. The computer device first uses the feature vector [v1,v2,L,v N ] N×C Update the metric vector (where the initial value of the elements in the metric vector is 0), and then the difference between these feature vectors is maximized using the contrast representation loss, and the optimization function is: In the formula, Optionally, the computer device may update the metric vector using the following formula: Where β is the attenuation coefficient.
[0065] S303: Train the first initial detection model according to the value of the optimization function to obtain a second initial detection model.
[0066] Specifically, the computer device trains the first initial detection model according to the value of the optimization function of the first initial detection model obtained above to obtain the second initial detection model. It can be understood that the optimization function of the first initial detection model is the loss function of the first initial detection model, and the computer device can determine the corresponding first initial detection model as the second initial detection model when the value of the optimization function reaches a stable value or a minimum value.
[0067] In this embodiment, the computer device can obtain the feature vectors corresponding to the first image and the second image by simultaneously inputting the first image and the second image into the first initial detection model. Since the feature vectors obtained are obtained based on the first image and the second image, the accuracy of the feature vectors obtained in this way is relatively high. Therefore, the computer device can accurately obtain the value of the optimization function of the first initial detection model based on the feature vectors corresponding to the first image and the second image. In this way, the computer device can accurately train the first initial detection model based on the value of the optimization function of the obtained first initial detection model, thereby obtaining a second initial detection model with higher accuracy, thereby improving the accuracy of the obtained second initial detection model.
[0068] In the scenario where the computer device uses the first image set and a supervised learning method to train a preset initial detection model to obtain a first initial detection model, the computer device can obtain the value of the loss function of the initial detection model to train the initial detection model to obtain the first initial detection model. In one embodiment, Figure 4 As shown, in the above S202, the first image set is used to train the preset initial detection model using a supervised learning method to obtain a first initial detection model, including:
[0069] S401, inputting images in the first image set into an initial detection model to obtain detection results.
[0070] Specifically, the computer device inputs the image in the first image set into the initial detection model to obtain a detection result for the image in the first image set. For example, if the image in the first image set is an image corresponding to a football field, the computer device inputs the image into the initial detection model, and the detection result obtained for the image may be a football or a person.
[0071] S402, obtaining a value of a loss function of an initial detection model according to the detection result and the target label of each image in the first image set.
[0072] Specifically, the computer device obtains the value of the loss function of the initial detection model based on the above-obtained detection results and the target labels of each image in the first image set. Optionally, the computer can compare the above-obtained detection results with the target labels of each image in the first image set to obtain the value of the loss function of the initial detection model.
[0073] S403, adjusting the parameters of the initial detection model according to the value of the loss function to obtain a first initial detection model.
[0074] Specifically, the computer device adjusts the parameters of the initial detection model according to the obtained value of the loss function of the initial detection model to obtain the first initial detection model. Optionally, the computer device may adjust the parameters of the initial detection model according to the value of the loss function of the initial detection model, and obtain the first initial detection model when the value of the loss function of the initial detection model reaches a stable value or a minimum value.
[0075] In this embodiment, the computer device inputs the images in the first image set into the initial detection model, and can accurately obtain the detection results of each image in the first image set through the initial detection model, and then can accurately obtain the value of the loss function of the initial detection model based on the detection results and the target labels of each image in the first image set. In this way, the parameters of the initial detection model can be accurately adjusted according to the value of the loss function of the initial detection model, thereby obtaining a first initial detection model with higher accuracy, thereby improving the accuracy of the obtained first initial detection model.
[0076] In one embodiment, Figure 5 As shown, a target detection method is provided, which is applied to Figure 1 The computer device in the example is used to illustrate, including the following steps:
[0077] S501, obtaining an image to be detected.
[0078] Specifically, the computer device acquires the image to be detected. Optionally, the computer device can acquire the image to be detected in real time, or can acquire the image to be detected from a preset database. Optionally, the image to be detected can be an image of a crossroads, or an image of a football field, etc.
[0079] S502, input the image to be detected into the detection model to obtain the detection result of the target in the image to be detected; wherein, the detection model is obtained by performing an iterative training operation, and the iterative training operation includes: using a first image set with a target label, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and a second image set without a target label, using an unsupervised contrast representation method to train the first initial detection model to obtain a second initial detection model, using the second initial detection model as a new initial detection model, returning to perform the iterative training operation, and determining the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
[0080] Specifically, the computer device inputs the above-mentioned image to be detected into the detection model to obtain the detection result of the target in the above-mentioned image to be detected. The detection model is obtained by performing an iterative training operation, and the iterative training operation includes: using a first image set with a target label, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and a second image set without a target label, using an unsupervised contrast representation method to train the first initial detection model to obtain a second initial detection model, using the second initial detection model as a new initial detection model, returning to perform the iterative training operation, and determining the second initial detection model corresponding to the preset convergence condition as the above-mentioned detection model. Optionally, the detection model can be any type of network in an anchor-free network. Among them, using the supervised learning method to train the preset initial detection model refers to the process of adjusting the parameters of the classifier of the initial detection model using a set of samples of known categories to achieve the required performance; using the first image set and the second image set without target labels, using the unsupervised contrast representation method to train the first initial detection model refers to the process of training the first initial detection model using the second image without target labels in the second image set and the first image with target labels in the first image set.
[0081] In this embodiment, since the detection model is obtained through an iterative training operation, and the iterative training operation includes using a first image set with a target label to train a preset initial detection model using a supervised learning method to obtain a first initial detection model, using the first image set and a second image set without a target label to train the first initial detection model using an unsupervised contrast representation method to obtain a second initial detection model, using the second initial detection model as a new initial detection model, returning to perform the iterative training operation, and determining the second initial detection model corresponding to the preset convergence condition as the detection model, through the training process, the computer device can obtain a detection model with higher accuracy, thereby improving the accuracy of the obtained detection model, and then the detection model can be used to accurately detect the target in the image to be detected, thereby obtaining a detection result with higher accuracy.
[0082] To facilitate understanding by those skilled in the art, the target detection method provided by the present application is described in detail below. The method may include:
[0083] S601, obtaining a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label.
[0084] S602: Input the images in the first image set into an initial detection model to obtain detection results.
[0085] S603, obtaining a value of a loss function of an initial detection model according to the detection result and the target label of each image in the first image set.
[0086] S604, adjusting the parameters of the initial detection model according to the value of the loss function to obtain a first initial detection model.
[0087] S605: Input the first image and the second image into the first initial detection model at the same time to obtain classification head heat maps corresponding to the first image and the second image.
[0088] S606, counting the number of peak points in the classification head heat map, and obtaining feature vectors corresponding to the first image and the second image according to the number of peak points in the classification head heat map.
[0089] S607, obtaining a metric vector corresponding to the eigenvector according to the eigenvector; the metric vector is used to store the eigenvector and update the eigenvector.
[0090] S608, obtaining a value of an optimization function of the first initial detection model according to the feature vector and the metric vector, and training the first initial detection model according to the value of the optimization function to obtain a second initial detection model.
[0091] S609, taking the second initial detection model as the new initial detection model, returning to execute the above S602-S608 until the preset convergence condition is reached, and determining the second initial detection model corresponding to when the preset convergence condition is reached as the detection model; wherein the detection model is any type of network in the anchor-free network.
[0092] S610: Acquire an image to be detected.
[0093] S611, input the image to be detected into the detection model to obtain the detection result of the target in the image to be detected.
[0094] It should be noted that for the description in the above S601-S611, reference may be made to the relevant description in the above embodiment, and the effects are similar, which will not be repeated in this embodiment.
[0095] It should be understood that although Figure 2-5 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2-5 At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0096] In one embodiment, Figure 6 As shown, a detection model training device is provided, comprising: a first acquisition module, an operation module and a determination module, wherein:
[0097] The first acquisition module is used to acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label.
[0098] An operation module is used to perform an iterative training operation; the iterative training operation includes: using the first image set, adopting a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, adopting an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model.
[0099] The determination module is used to use the second initial detection model as a new initial detection model, return to perform iterative training operations until a preset convergence condition is reached, and determine the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
[0100] Optionally, the detection model is any type of network in the anchor-free network.
[0101] The detection model training device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0102] On the basis of the above embodiment, optionally, the above operation module includes: a first acquisition unit, a second acquisition unit and a first training unit, wherein:
[0103] The first acquisition unit is used to input the first image and the second image into the first initial detection model at the same time to obtain the feature vectors corresponding to the first image and the second image.
[0104] The second acquisition unit is used to obtain the value of the optimization function of the first initial detection model according to the feature vector.
[0105] The first training unit is used to train the first initial detection model according to the value of the optimization function to obtain the second initial detection model.
[0106] The detection model training device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0107] Based on the above embodiment, optionally, the above second acquisition unit is specifically used to obtain a measurement vector corresponding to the feature vector based on the feature vector; the measurement vector is used to store the feature vector and update the feature vector; based on the feature vector and the measurement vector, the value of the optimization function of the first initial detection model is obtained.
[0108] The detection model training device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0109] Based on the above embodiment, optionally, the above-mentioned first acquisition unit is specifically used to input the first image and the second image into the first initial detection model at the same time to obtain the classification head heat map corresponding to the first image and the second image; count the number of peak points in the classification head heat map, and obtain the feature vectors corresponding to the first image and the second image according to the number of peak points in the classification head heat map.
[0110] The detection model training device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0111] On the basis of the above embodiment, optionally, the above operation module further includes: a third acquisition unit, a fourth acquisition unit, and a second training unit, wherein:
[0112] The third acquisition unit is used to input the images in the first image set into the initial detection model to obtain the detection result.
[0113] The fourth acquisition unit is used to obtain the value of the loss function of the initial detection model according to the detection result and the target label of each image in the first image set.
[0114] The second training unit is used to adjust the parameters of the initial detection model according to the value of the loss function to obtain a first initial detection model.
[0115] The detection model training device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0116] For the specific definition of the training device of the detection model, please refer to the definition of the training method of the detection model above, which will not be repeated here. The various modules in the above-mentioned training device of the detection model can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0117] In one embodiment, Figure 7 As shown, a target detection device is provided, comprising: a second acquisition module and a detection module, wherein:
[0118] The second acquisition module is used to acquire the image to be detected.
[0119] The detection module is used to input the image to be detected into the detection model to obtain the detection result of the target in the image to be detected; wherein the detection model is obtained by performing an iterative training operation, and the iterative training operation includes: using a first image set with a target label, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and a second image set without a target label, using an unsupervised contrast representation method to train the first initial detection model to obtain a second initial detection model, using the second initial detection model as a new initial detection model, returning to perform the iterative training operation, and determining the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
[0120] For the specific definition of the target detection device, please refer to the definition of the target detection method above, which will not be repeated here. Each module in the above target detection device can be implemented in whole or in part by software, hardware and a combination thereof. The above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0121] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0122] Acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label;
[0123] Performing an iterative training operation; the iterative training operation includes: using the first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, using an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model;
[0124] The second initial detection model is used as a new initial detection model, and the iterative training operation is returned to be performed until a preset convergence condition is reached, and the second initial detection model corresponding to when the preset convergence condition is reached is determined as the detection model.
[0125] The implementation principle and technical effect of the computer device provided in the above embodiment are similar to those of the above method embodiment, and will not be repeated here.
[0126] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0127] Acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label;
[0128] Performing an iterative training operation; the iterative training operation includes: using the first image set, using a supervised learning method to train a preset initial detection model to obtain a first initial detection model, using the first image set and the second image set, using an unsupervised comparative representation method to train the first initial detection model to obtain a second initial detection model;
[0129] The second initial detection model is used as a new initial detection model, and the iterative training operation is returned to be performed until a preset convergence condition is reached, and the second initial detection model corresponding to when the preset convergence condition is reached is determined as the detection model.
[0130] The computer-readable storage medium provided in the above embodiment has similar implementation principles and technical effects as those of the above method embodiment, and will not be described in detail here.
[0131] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0132] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0133] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for training a detection model, characterized in that: The method comprises: Acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label; Performing an iterative training operation; the iterative training operation includes: using a supervised learning training method to input the images in the first image set into an initial detection model to obtain a detection result; obtaining a value of a loss function of the initial detection model according to the detection result and the target label of each image in the first image set; adjusting the parameters of the initial detection model according to the value of the loss function to obtain a first initial detection model; wherein the initial detection model is any type of network in an anchor-free network; Using an unsupervised learning training method, the first image and the second image are simultaneously input into the first initial detection model to obtain classification head heat maps corresponding to the first image and the second image; counting the number of peak points in the classification head heat map, and obtaining feature vectors corresponding to the first image and the second image according to the number of peak points in the classification head heat map; According to the feature vector, a metric vector corresponding to the feature vector is obtained; the metric vector is used to store the feature vector and update the feature vector; Obtaining a value of an optimization function of the first initial detection model according to the feature vector and the metric vector; Training the first initial detection model according to the value of the optimization function to obtain a second initial detection model; The second initial detection model is used as a new initial detection model, and the iterative training operation is performed again until a preset convergence condition is reached, and the second initial detection model corresponding to the preset convergence condition is determined as the detection model; The metric vector is updated in the following way: Where β is the attenuation coefficient; is the metric vector; vj is the feature vector; Wherein, obtaining the value of the optimization function of the first initial detection model according to the feature vector and the metric vector includes: updating the metric vector using the feature vector; maximizing the difference of the feature vector by comparing the representation loss to obtain the optimization function, and the optimization function is: In the formula, 2. The method according to claim 1, characterized in that The detection model is any type of network in an anchor-free network.
3. The method according to claim 1, characterized in that The initial detection model includes a CenterNet model.
4. The method according to claim 1, characterized in that: The preset convergence condition includes a preset number of iterations.
5. The method according to claim 1, characterized in that The first image set includes at least one of a coco image set and a VOC image set.
6. A target detection method, characterized in that: The method comprises: Acquire the image to be detected; Input the image to be detected into the detection model to obtain the detection result of the target in the image to be detected; wherein the detection model is obtained by performing an iterative training operation, and the iterative training operation includes: using a supervised learning training method to input the image in the first image set into the initial detection model to obtain the detection result; according to the detection result and the target label of each image in the first image set, obtain the value of the loss function of the initial detection model; according to the value of the loss function, adjust the parameters of the initial detection model to obtain the first initial detection model; wherein the initial detection model is any network in the anchor-free network; using an unsupervised learning training method, input the first image and the second image into the first initial detection model at the same time to obtain the classification head heat map corresponding to the first image and the second image; count the number of peak points in the classification head heat map, and obtain the feature vectors corresponding to the first image and the second image according to the number of peak points in the classification head heat map; according to the feature vector, obtain the metric vector corresponding to the feature vector; the metric vector is used to store the feature vector and update the feature vector; according to the feature vector and the metric vector, obtain the value of the optimization function of the first initial detection model; The first initial detection model is trained according to the value of the optimization function to obtain a second initial detection model; the second initial detection model is used as a new initial detection model, and the iterative training operation is performed again, and the second initial detection model corresponding to the preset convergence condition is determined as the detection model; the metric vector is updated in the following manner: Where β is the attenuation coefficient; is the metric vector; vj is the feature vector; Wherein, obtaining the value of the optimization function of the first initial detection model according to the feature vector and the metric vector includes: updating the metric vector using the feature vector; maximizing the difference of the feature vector by comparing the representation loss to obtain the optimization function, and the optimization function is: In the formula, 7. A detection model training device, characterized in that: The device comprises: A first acquisition module is used to acquire a first image set and a second image set; the first image in the first image set is an image with a target label, and the second image in the second image set is an image without a target label; An operation module, used to adopt a supervised learning training method to input the images in the first image set into the initial detection model to obtain a detection result; according to the detection result and the target label of each image in the first image set, obtain the value of the loss function of the initial detection model; according to the value of the loss function, adjust the parameters of the initial detection model to obtain a first initial detection model; wherein the initial detection model is any network in an anchor-free network; adopt an unsupervised learning training method to input the first image and the second image into the first initial detection model at the same time to obtain a classification head heat map corresponding to the first image and the second image; count the number of peak points in the classification head heat map, and according to the number of peak points in the classification head heat map, obtain the feature vector corresponding to the first image and the second image; according to the feature vector, obtain the metric vector corresponding to the feature vector; the metric vector is used to store the feature vector and update the feature vector; according to the feature vector and the metric vector, obtain the value of the optimization function of the first initial detection model; according to the value of the optimization function, train the first initial detection model to obtain a second initial detection model; the metric vector The way to update the quantity vector is as follows Where β is the attenuation coefficient; is the metric vector; v j is a feature vector; wherein, obtaining the value of the optimization function of the first initial detection model according to the feature vector and the metric vector includes: updating the metric vector using the feature vector; maximizing the difference of the feature vector by comparing the representation loss to obtain the optimization function, and the optimization function is: In the formula, A determination module is used to use the second initial detection model as a new initial detection model, return to perform iterative training operations until a preset convergence condition is reached, and determine the second initial detection model corresponding to when the preset convergence condition is reached as the detection model.
8. The device according to claim 7, characterized in that The detection model is any type of network in an anchor-free network.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Efficient pedestrian re-identification method based on neural network unsupervised contrast learning
CN111611880A