Training method and device of target detection model, computer device and storage medium
By performing similarity threshold clustering and label transformation on the bounding boxes of sample images during object detection model training, the problem of poor model training performance caused by the single image annotation method is solved, and higher training accuracy and detection accuracy are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FAW JIEFANG AUTOMOTIVE CO
- Filing Date
- 2023-04-25
- Publication Date
- 2026-05-29
AI Technical Summary
In the training of existing object detection models, the image annotation method is singular, resulting in either overly fine-grained or overly coarse-grained annotations, which affects the training effect and detection accuracy of the model.
By obtaining the bounding boxes in the sample images, the original annotation names are clustered according to the target similarity threshold and transformed into target training labels. The target detection model is then trained based on these labels.
This improved the training accuracy and image annotation accuracy of the object detection model, thereby enhancing the model's detection performance.
Smart Images

Figure CN116543257B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to a method, apparatus, computer device, and storage medium for training an object detection model. Background Technology
[0002] In recent years, with the development of deep learning, object detection technology has made great strides and has been widely applied. A common approach is to perform object detection using object detection models. The prerequisite for using object detection models is to acquire sample images, annotate these images to form a training set, and then train the object detection model to ensure the accuracy of object detection using the trained model.
[0003] Existing image annotation methods for object detection are relatively simple and cannot be adapted to object detection models. They are prone to poor training results due to overly fine or coarse annotation methods, resulting in low accuracy of object detection using such models. Summary of the Invention
[0004] Therefore, it is necessary to provide a training method, apparatus, computer equipment, and storage medium for an object detection model that can improve the training accuracy of the object detection model, in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a method for training an object detection model. The method includes:
[0006] Acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images;
[0007] Based on the content of the elements included in the first external annotation box, obtain the first original annotation name corresponding to the first external annotation box;
[0008] Based on the target similarity threshold and the similarity between different first original label names, all first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold;
[0009] The first original label name in the first clustering result is converted into the same target training label and used as the target training label of the corresponding first sample image;
[0010] The target detection model is trained based on the first sample image with target training labels.
[0011] In one embodiment, the process of determining the target similarity threshold includes:
[0012] Acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images;
[0013] Based on the content of the elements included in the second outer annotation box, obtain the second original annotation name corresponding to the second outer annotation box;
[0014] Based on different similarity thresholds and the similarity between different second original label names, all second original label names are clustered to obtain the second clustering result corresponding to each similarity threshold;
[0015] The second original label name in each second clustering result is converted into the same reference training label and used as the reference training label for the corresponding second sample image.
[0016] The target detection model is trained based on a second sample image with reference training labels to obtain training evaluation parameters corresponding to each similarity threshold.
[0017] Based on the training evaluation parameters corresponding to each similarity threshold, the target similarity threshold is selected from all similarity thresholds.
[0018] In one embodiment, the step of clustering all first original label names based on the target similarity threshold and the similarity between different first original label names to obtain the first clustering result corresponding to the target similarity threshold includes:
[0019] Based on the target similarity threshold and the similarity between different first original label names, perform initial clustering on all first original label names to obtain the first initial clustering result corresponding to the target similarity threshold;
[0020] If the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original label name does not conform to the name labeling rule, the first original label name of the first sample image in the first initial clustering result is corrected to obtain the corrected first original label name;
[0021] Based on the target similarity threshold and the similarity between different corrected first original label names, all corrected first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold.
[0022] In one embodiment, training the target detection model based on a second sample image with reference training labels to obtain training evaluation parameters corresponding to each similarity threshold includes:
[0023] The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained.
[0024] Based on the trained object detection model, the training evaluation parameters corresponding to each similarity threshold are obtained.
[0025] In one embodiment, the training evaluation parameter is the average accuracy; the step of selecting the target similarity threshold from all similarity thresholds based on the training evaluation parameter corresponding to each similarity threshold includes:
[0026] Determine the maximum value in the average precision corresponding to each similarity threshold, and use the similarity threshold corresponding to the maximum value as the target similarity threshold.
[0027] In one embodiment, the first sample image contains multiple detection objects; training the target detection model based on the first sample image with target training labels includes:
[0028] Obtain the position coordinates of each first bounding box in the first sample image with target training labels;
[0029] The target detection model is trained based on the location coordinates, target training labels, and the corresponding first sample image.
[0030] Secondly, this application also provides a training device for an object detection model. The device includes:
[0031] The image acquisition module is used to acquire multiple first sample images and determine the first bounding box of the detected object in the first sample image;
[0032] The name labeling module is used to obtain the first original label name corresponding to the first external label box based on the content of the elements included in the first external label box;
[0033] The clustering module is used to cluster all the first original label names according to the target similarity threshold and the similarity between different first original label names, and obtain the first clustering result corresponding to the target similarity threshold;
[0034] The label conversion module is used to convert the first original label name in the first clustering result into the same target training label, and use it as the target training label of the corresponding first sample image;
[0035] The model training module is used to train the object detection model based on a first sample image with target training labels.
[0036] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the methods in any of the above embodiments.
[0037] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the methods in any of the above embodiments.
[0038] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the methods in any of the above embodiments.
[0039] The aforementioned training method, apparatus, computer equipment, and storage medium for the object detection model determine the first original annotation names corresponding to the elements contained in the first bounding boxes of the detected objects in multiple first sample images. Based on a target similarity threshold and the similarity between different first original annotation names, all first original annotation names are clustered to obtain a first clustering result corresponding to the target similarity threshold. The first original annotation names in the first clustering result are then converted into the same target training labels and used as the target training labels for the corresponding first sample images. The object detection model is then trained based on the first sample images with target training labels. Compared to the traditional technique of manually labeling sample images, which suffers from low accuracy, this application clusters all first original annotation names based on a target similarity threshold to obtain a first clustering result, and converts the first original annotation names in the first clustering result into the same target training labels. This improves the accuracy of labeling the first sample images, resulting in better training of the object detection model. Attached Figure Description
[0040] Figure 1 This is a flowchart illustrating the training method of the target detection model provided in the embodiments of this application;
[0041] Figure 2 This is a schematic diagram of a first sample image provided in one embodiment;
[0042] Figure 3 This is a flowchart illustrating the process of determining the target similarity threshold in one embodiment;
[0043] Figure 4 This is a flowchart illustrating the process of obtaining the first clustering result corresponding to the target similarity threshold in one embodiment;
[0044] Figure 5This is a structural block diagram of a training device for an object detection model provided in an embodiment of this application;
[0045] Figure 6 This is an internal structural diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0047] In this embodiment, a training method for an object detection model is provided. This embodiment uses the application of this method to a computer device as an example for illustration. It can be understood that this method can also be applied to a server, and can also be applied to a system including a computer device and a server, and can be implemented through the interaction between the computer device and the server.
[0048] Figure 1 This is a flowchart illustrating the training method of the target detection model provided in this application embodiment. The method is applied in a computer device. In one embodiment, such as... Figure 1 As shown, it includes the following steps:
[0049] S101, acquire multiple first sample images, and determine the first bounding box of the detected object in the first sample image.
[0050] The first sample image is an image containing the target object detected by the object detection model. The first sample image can be obtained by taking a picture with a camera, downloading from the internet, or converting a PDF document using a document-to-image tool such as pymupdf. The detected object is the target object detected by the object detection model. The first bounding box is a bounding box used to determine the region where the detected object is located in the first sample image. The shape of the first bounding box can be rectangular, and there is no specific limitation.
[0051] Taking an animal as the detection object as an example, the first bounding box is, for example, a rectangle, and the first sample image is an image containing the animal. A schematic diagram of the first sample image is shown below. Figure 2 As shown, Figure 2 The shaded area A represents an animal, and B is the first bounding box of A.
[0052] S102, based on the content of the elements included in the first outer annotation box, obtain the first original annotation name corresponding to the first outer annotation box.
[0053] The element content consists of relevant information about the detected object in the first sample image. Taking an animal as an example, the element content can be color, species, or size.
[0054] In some embodiments, the first original label name corresponding to the first outer label box is obtained according to the first name labeling rule, and the first name labeling rule is set manually.
[0055] Examples of the rules for labeling the first name are shown in Table 1 below.
[0056] Table 1 Rules for Labeling the First Name
[0057] Element content Wings It has a tail Large size Transparent body surface Carnivores yes 1 1 1 1 1 no 0 0 0 0 0
[0058] If the detected object in the first sample image is an elephant, then the first original annotation name corresponding to the first bounding box of the elephant is 01100; if the detected object in the first sample image is a sparrow, then the first original annotation name corresponding to the first bounding box of the sparrow is 11000.
[0059] The primary name labeling rules allow for labeling using numbers, letters, or a combination of both; there are no specific restrictions. For example, when using letters, 'a' represents terrestrial animals, 'b' represents marine animals, and 'c' represents flying animals.
[0060] S103, based on the target similarity threshold and the similarity between different first original annotation names, cluster all first original annotation names to obtain the first clustering result corresponding to the target similarity threshold.
[0061] In some embodiments, if the similarity between different first original label names is equal to the target similarity threshold, the corresponding first original label names are clustered together; if the similarity between different first original label names is not equal to the target similarity threshold, the corresponding first original label names are not clustered. If a certain first original label name is clustered with multiple first original label names, multiple first clustering results are generated.
[0062] For example, if all the original first annotation names are a011, a100, a000, b111, and c100, and the target similarity threshold is 75%, then the first type of first clustering result is a011, a100 and a000, b111, and c100, a total of 4 classes; the second type of first clustering result is a011, a100 and c100, a000, and b111, a total of 4 classes.
[0063] S104, convert the first original label name in the first clustering result into the same target training label, and use it as the target training label of the corresponding first sample image.
[0064] The number of categories in the first clustering result is equal to the number of target training labels.
[0065] Taking the first clustering result as a total of four classes (a011, a100, a000, b111, c100), the method to convert the first original label names in the first clustering result into the same target training label is as follows: a011 is converted to M, a100 and a000 are both converted to N, b111 is converted to P, and c100 is converted to Q. M, N, P, and Q are the target training labels used to distinguish the first clustering result. The target training label can be a letter, a number, or a mixture of numbers and letters; there are no specific limitations.
[0066] S105, Train the target detection model based on the first sample image with target training labels.
[0067] Here, the object detection model is the model used for image detection. For example, the object detection model is the YOLO v5 model.
[0068] The target detection model training method provided in this embodiment determines the first original annotation names corresponding to the elements included in the first bounding box of the detected object in multiple first sample images. Based on a target similarity threshold and the similarity between different first original annotation names, all first original annotation names are clustered to obtain a first clustering result corresponding to the target similarity threshold. The first original annotation names in the first clustering result are then converted into the same target training label and used as the target training label for the corresponding first sample image. The target detection model is then trained based on the first sample image with the target training label. Compared to the traditional technique of manually labeling sample images, which suffers from low accuracy, this embodiment clusters all first original annotation names based on a target similarity threshold to obtain a first clustering result, and converts the first original annotation names in the first clustering result into the same target training label. This improves the accuracy of labeling the first sample images, resulting in better training of the target detection model.
[0069] In one embodiment, a flowchart illustrating the process of determining the target similarity threshold is shown below. Figure 3 As shown, it includes the following:
[0070] S301, acquire multiple second sample images, and determine the second bounding box of the detected object in the second sample images.
[0071] The second sample image is an image containing the target object detected by the object detection model. The second sample image can be obtained by taking a picture with a camera, downloading from the internet, or converting a PDF document using a document-to-image tool such as pymupdf. The detected object is the target object detected by the object detection model. The second bounding box is a bounding box used to determine the region where the detected object is located in the second sample image. The shape of the second bounding box can be rectangular, and there is no specific limitation.
[0072] S302, based on the content of the elements included in the second outer annotation box, obtain the second original annotation name corresponding to the second outer annotation box.
[0073] The element content contains information about the detected object in the second sample image.
[0074] In some embodiments, the second original label name corresponding to the second outer label box is obtained according to the second naming labeling rule. The second naming labeling rule is manually set and may be the same as or different from the first naming labeling rule.
[0075] Secondary name labeling rules allow for labeling using numbers, letters, or a combination of numbers and letters; there are no specific restrictions.
[0076] S303, based on different similarity thresholds and the similarity between different second original annotation names, cluster all second original annotation names to obtain the second clustering result corresponding to each similarity threshold.
[0077] Different similarity thresholds are determined based on the second original label name. For example, if the second original label name is a 5-digit code, then different similarity thresholds can be set to 0%, 20%, 40%, 60%, 80%, and 100%; if the second original label name is a 4-digit code, then different similarity thresholds can be set to 0%, 25%, 50%, 75%, and 100%.
[0078] In some embodiments, for each similarity threshold, if the similarity between different second original label names is equal to the threshold, the corresponding second original label names are clustered together; if the similarity between different second original label names is not equal to the threshold, the corresponding second original label names are not clustered. If a certain second original label name is clustered with multiple second original label names, multiple second clustering results are generated.
[0079] S304, convert the second original label name in each second clustering result into the same reference training label, and use it as the reference training label for the corresponding second sample image.
[0080] The reference training labels are used to distinguish the second clustering results, and the number of reference training labels is consistent with the number of categories included in the second clustering results. Reference training labels can be letters, numbers, or a mixture of letters and numbers; there are no specific restrictions.
[0081] S305, Based on the second sample image with reference training labels, train the object detection model to obtain the training evaluation parameters corresponding to each similarity threshold.
[0082] Among them, the training evaluation parameters are parameters used to evaluate the image detection capability of the object detection model.
[0083] S306, Based on the training evaluation parameters corresponding to each similarity threshold, select the target similarity threshold from all similarity thresholds.
[0084] In this embodiment, the second original annotation names corresponding to the second bounding boxes of the detected objects in multiple second sample images are clustered using different similarity thresholds to obtain second clustering results. The second original annotation names in each second clustering result are converted into the same reference training labels. The target detection model is trained based on the second sample images with reference training labels to obtain training evaluation parameters corresponding to each similarity threshold. Thus, the target similarity threshold is selected from all similarity thresholds. This ensures that the first clustering result obtained based on the target similarity threshold and the first sample images with target training labels determined based on the first clustering result have a better effect on training the target detection model, thereby improving the accuracy of the first sample image annotation.
[0085] In one embodiment, a flowchart illustrating the process of clustering all first original annotation names based on a target similarity threshold and the similarity between different first original annotation names to obtain the first clustering result corresponding to the target similarity threshold is shown below. Figure 4 As shown, it includes the following steps:
[0086] S401, based on the target similarity threshold and the similarity between different first original annotation names, perform initial clustering on all first original annotation names to obtain the first initial clustering result corresponding to the target similarity threshold.
[0087] S402, if the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original annotation name does not conform to the name annotation rule, the first original annotation name of the first sample image in the first initial clustering result is corrected to obtain the corrected first original annotation name.
[0088] The target preset range and the naming rules are both manually set.
[0089] S403, based on the target similarity threshold and the similarity between different corrected first original annotation names, cluster all corrected first original annotation names to obtain the first clustering result corresponding to the target similarity threshold.
[0090] In this embodiment, the first original label name of the first sample image in the first initial clustering result is corrected, which can correct the inaccuracy of the first original label name, thereby improving the accuracy of the first original label name and thus improving the accuracy of the obtained first clustering result.
[0091] In one embodiment, the object detection model is trained based on a second sample image with reference training labels to obtain training evaluation parameters corresponding to each similarity threshold, including:
[0092] The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained.
[0093] Based on the trained object detection model, the training evaluation parameters corresponding to each similarity threshold are obtained.
[0094] The preset fluctuation range is set manually.
[0095] In this embodiment, the training evaluation parameters corresponding to each similarity threshold are obtained based on the trained target detection model. The trained target detection model is obtained using the same standard, so the training evaluation parameters corresponding to each similarity threshold are based on the same training degree of the target detection model. This ensures that the training evaluation parameters are obtained under the same standard and avoids differences in training evaluation parameters caused by different training degrees of the target detection model.
[0096] In one embodiment, the training evaluation parameter is the average accuracy; based on the training evaluation parameter corresponding to each similarity threshold, the target similarity threshold is selected from all similarity thresholds, including:
[0097] Determine the maximum value in the average precision corresponding to each similarity threshold, and use the similarity threshold corresponding to the maximum value as the target similarity threshold.
[0098] The average precision (mAP) is used to evaluate the image detection capability of the target detection model.
[0099] In this embodiment, the greater the average precision, the better the image detection ability of the target detection model. Therefore, selecting the similarity threshold corresponding to the maximum value as the target similarity threshold can improve the training accuracy of the target detection model.
[0100] In one embodiment, there are multiple detection objects in the first sample image; training the target detection model based on the first sample image with target training labels includes:
[0101] Obtain the position coordinates of each first external annotation box in the first sample image with target training labels;
[0102] Train the target detection model based on the position coordinates, target training labels, and the corresponding first sample image.
[0103] There are multiple detection objects in the first sample image. For example Figure 2 There are two detection objects in the first sample image shown. The shaded area A is a certain animal, and the shaded area A' is an animal different from A. The position coordinates of the first external annotation box B are 52 < x < 1860, 348 < y < 836, where x is the horizontal coordinate of the first external annotation box and y is the vertical coordinate of the first external annotation box.
[0104] In this embodiment, it is also applicable to the first sample image with multiple detection objects, which can expand the training data of the target detection model.
[0105] Here, the training method of the target detection model provided by this application is described in the form of a complete embodiment. First, determine the target similarity threshold. The determination process includes: ]>
[0106] Obtain multiple second sample images and determine the second external annotation boxes of the detection objects in the second sample images;
[0107] According to the element content included in the second external annotation box, obtain the second original annotation name corresponding to the second external annotation box;
[0108] Perform initial clustering on all the second original annotation names according to the similarity between different similarity thresholds and different second original annotation names, and obtain the second initial clustering result corresponding to each similarity threshold;
[0109] In the case where the number of second sample images corresponding to the second initial clustering result is not within the reference preset range or the second original annotation name does not conform to the second name annotation rule, correct the second original annotation name of the second sample image in the second initial clustering result to obtain the corrected second original annotation name;
[0110] Based on different similarity thresholds and the similarity between different corrected second original label names, all corrected second original label names are clustered to obtain the second clustering result corresponding to each similarity threshold;
[0111] The second original label name in each second clustering result is converted into the same reference training label and used as the reference training label for the corresponding second sample image.
[0112] The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained.
[0113] Based on the trained target detection model, the training evaluation parameters corresponding to each similarity threshold are obtained. The training evaluation parameters are the average accuracy.
[0114] Determine the maximum value in the average precision corresponding to each similarity threshold, and use the similarity threshold corresponding to the maximum value as the target similarity threshold.
[0115] Then, multiple first sample images are acquired, and the first bounding boxes of the detected objects in the first sample images are determined. Based on the content of the elements included in the first bounding boxes, the first original annotation names corresponding to the first bounding boxes are obtained. Based on the target similarity threshold and the similarity between different first original annotation names, all first original annotation names are initially clustered to obtain the first initial clustering result corresponding to the target similarity threshold. If the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original annotation names do not conform to the naming rules, the first original annotation names of the first sample images in the first initial clustering result are corrected to obtain corrected first original annotation names. Based on the target similarity threshold and the similarity between different corrected first original annotation names, all corrected first original annotation names are clustered to obtain the first clustering result corresponding to the target similarity threshold. The first original annotation names in the first clustering result are converted into the same target training labels and used as the target training labels for the corresponding first sample images.
[0116] The first sample image contains multiple detection objects. The position coordinates of each first bounding box and the target training label in the first sample image with target training labels are obtained. Based on the position coordinates, target training labels and the corresponding first sample image, the target detection model is trained.
[0117] The target detection model training method provided in this embodiment determines the target similarity threshold, clusters all first original annotation names based on the target similarity threshold to obtain the first clustering result, and converts the first original annotation names in the first clustering result into the same target training label, which can improve the accuracy of the annotation of the first sample image, thereby ensuring better training effect of the target detection model.
[0118] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0119] Based on the same inventive concept, this application also provides a training apparatus for a target detection model to implement the training method for the target detection model described above. The solution provided by this apparatus is similar to the implementation described in the above method. Therefore, the specific limitations of one or more training apparatus embodiments for target detection models provided below can be found in the limitations of the target detection model training method described above, and will not be repeated here.
[0120] See Figure 5 , Figure 5 This is a structural block diagram of a training device for an object detection model provided in an embodiment of this application. The device 500 includes: an image acquisition module 501, a name labeling module 502, a clustering module 503, a label conversion module 504, and a model training module 505, wherein:
[0121] Image acquisition module 501 is used to acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images;
[0122] The name labeling module 502 is used to obtain the first original label name corresponding to the first outer label box based on the content of the elements included in the first outer label box;
[0123] Clustering module 503 is used to cluster all first original label names according to the target similarity threshold and the similarity between different first original label names, and obtain the first clustering result corresponding to the target similarity threshold;
[0124] The label conversion module 504 is used to convert the first original label name in the first clustering result into the same target training label, and use it as the target training label of the corresponding first sample image.
[0125] The model training module 505 is used to train the object detection model based on a first sample image with target training labels.
[0126] The target detection model training device provided in this embodiment determines the first original annotation names corresponding to the element content included in the first bounding box of the detection object in multiple first sample images. Based on a target similarity threshold and the similarity between different first original annotation names, it clusters all first original annotation names to obtain a first clustering result corresponding to the target similarity threshold. The first original annotation names in the first clustering result are then converted into the same target training label and used as the target training label for the corresponding first sample image. The target detection model is then trained based on the first sample image with the target training label. Compared to the traditional technique of manually labeling sample images, which suffers from low accuracy, this embodiment clusters all first original annotation names based on a target similarity threshold to obtain a first clustering result, and converts the first original annotation names in the first clustering result into the same target training label. This improves the accuracy of labeling the first sample images, resulting in better training of the target detection model.
[0127] Optionally, the device 500 also includes:
[0128] The bounding box determination module is used to acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images.
[0129] The label name acquisition module is used to obtain the second original label name corresponding to the second outer label box based on the content of the elements included in the second outer label box;
[0130] The clustering result acquisition module is used to cluster all second original label names according to different similarity thresholds and the similarity between different second original label names, and obtain the second clustering result corresponding to each similarity threshold;
[0131] The training label determination module is used to convert the second original label name in each second clustering result into the same reference training label, and use it as the reference training label for the corresponding second sample image.
[0132] The evaluation parameter acquisition module is used to train the target detection model based on a second sample image with reference training labels and obtain the training evaluation parameters corresponding to each similarity threshold.
[0133] The target similarity threshold determination module is used to select the target similarity threshold from all similarity thresholds based on the corresponding training evaluation parameters for each similarity threshold.
[0134] Optionally, clustering module 503 includes:
[0135] The initial clustering unit is used to perform initial clustering on all first original label names based on the target similarity threshold and the similarity between different first original label names, so as to obtain the first initial clustering result corresponding to the target similarity threshold;
[0136] The correction unit is used to correct the first original label name of the first sample image in the first initial clustering result when the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original label name does not conform to the name labeling rule, so as to obtain the corrected first original label name.
[0137] The clustering unit is used to cluster all the modified first original label names according to the target similarity threshold and the similarity between different modified first original label names, so as to obtain the first clustering result corresponding to the target similarity threshold.
[0138] Optionally, the evaluation parameter acquisition module includes:
[0139] The model training unit is used to input the second sample image with reference training labels into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training stops and the corresponding trained target detection model is obtained.
[0140] The evaluation parameter acquisition unit is used to acquire the training evaluation parameters corresponding to each similarity threshold based on the trained target detection model.
[0141] Optionally, the training evaluation parameter is the average accuracy; the target similarity threshold determination module includes:
[0142] The target similarity threshold determination unit is used to determine the maximum value in the average precision corresponding to each similarity threshold, and the similarity threshold corresponding to the maximum value is used as the target similarity threshold.
[0143] Optionally, the first sample image contains multiple detection objects; the model training module 505 includes:
[0144] The position coordinate acquisition unit is used to acquire the position coordinates of each first bounding box in the first sample image with target training labels;
[0145] The model training unit is used to train the object detection model based on the location coordinates, target training labels, and the corresponding first sample image.
[0146] The modules in the training device of the aforementioned object detection model can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0147] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 6 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as target training labels. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a training method for a target detection model.
[0148] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0149] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of the training method for the target detection model provided in the above embodiment:
[0150] Acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images;
[0151] Based on the content of the elements included in the first outer annotation box, obtain the first original annotation name corresponding to the first outer annotation box;
[0152] Based on the target similarity threshold and the similarity between different first original label names, all first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold;
[0153] The first original label name in the first clustering result is converted into the same target training label and used as the target training label of the corresponding first sample image;
[0154] The target detection model is trained based on the first sample image with target training labels.
[0155] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0156] Acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images;
[0157] Based on the content of the elements included in the second outer annotation box, obtain the second original annotation name corresponding to the second outer annotation box;
[0158] Based on different similarity thresholds and the similarity between different second original label names, all second original label names are clustered to obtain the second clustering result corresponding to each similarity threshold;
[0159] The second original label name in each second clustering result is converted into the same reference training label and used as the reference training label for the corresponding second sample image.
[0160] The target detection model is trained based on a second sample image with reference training labels to obtain the training evaluation parameters corresponding to each similarity threshold.
[0161] Based on the training evaluation parameters corresponding to each similarity threshold, the target similarity threshold is selected from all similarity thresholds.
[0162] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0163] Based on the target similarity threshold and the similarity between different first original label names, perform initial clustering on all first original label names to obtain the first initial clustering result corresponding to the target similarity threshold;
[0164] If the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original label name does not conform to the name labeling rules, the first original label name of the first sample image in the first initial clustering result is corrected to obtain the corrected first original label name;
[0165] Based on the similarity between the target similarity threshold and the similarity between different modified first original label names, cluster all modified first original label names to obtain the first clustering result corresponding to the target similarity threshold.
[0166] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0167] The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained.
[0168] Based on the trained object detection model, the training evaluation parameters corresponding to each similarity threshold are obtained.
[0169] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0170] The training evaluation parameter is the average precision; the maximum value of the average precision corresponding to each similarity threshold is determined, and the similarity threshold corresponding to the maximum value is used as the target similarity threshold.
[0171] In one embodiment, the processor, when executing a computer program, also performs the following steps:
[0172] The first sample image contains multiple detection objects; obtain the position coordinates of each first bounding box in the first sample image with target training labels;
[0173] The target detection model is trained based on the location coordinates, target training labels, and the corresponding first sample image.
[0174] The implementation principle and technical effects of the above embodiments are similar to those of the above method embodiments, and will not be repeated here.
[0175] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the training method for the target detection model provided in the above embodiment:
[0176] Acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images;
[0177] Based on the content of the elements included in the first outer annotation box, obtain the first original annotation name corresponding to the first outer annotation box;
[0178] Based on the target similarity threshold and the similarity between different first original label names, all first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold;
[0179] The first original label name in the first clustering result is converted into the same target training label and used as the target training label of the corresponding first sample image;
[0180] The target detection model is trained based on the first sample image with target training labels.
[0181] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0182] Acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images;
[0183] Based on the content of the elements included in the second outer annotation box, obtain the second original annotation name corresponding to the second outer annotation box;
[0184] Based on different similarity thresholds and the similarity between different second original label names, all second original label names are clustered to obtain the second clustering result corresponding to each similarity threshold;
[0185] The second original label name in each second clustering result is converted into the same reference training label and used as the reference training label for the corresponding second sample image.
[0186] The target detection model is trained based on a second sample image with reference training labels to obtain the training evaluation parameters corresponding to each similarity threshold.
[0187] Based on the training evaluation parameters corresponding to each similarity threshold, the target similarity threshold is selected from all similarity thresholds.
[0188] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0189] Based on the target similarity threshold and the similarity between different first original label names, perform initial clustering on all first original label names to obtain the first initial clustering result corresponding to the target similarity threshold;
[0190] If the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original label name does not conform to the name labeling rules, the first original label name of the first sample image in the first initial clustering result is corrected to obtain the corrected first original label name;
[0191] Based on the similarity between the target similarity threshold and the similarity between different modified first original label names, cluster all modified first original label names to obtain the first clustering result corresponding to the target similarity threshold.
[0192] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0193] The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained.
[0194] Based on the trained object detection model, the training evaluation parameters corresponding to each similarity threshold are obtained.
[0195] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0196] The training evaluation parameter is the average precision; the maximum value of the average precision corresponding to each similarity threshold is determined, and the similarity threshold corresponding to the maximum value is used as the target similarity threshold.
[0197] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0198] The first sample image contains multiple detection objects; obtain the position coordinates of each first bounding box in the first sample image with target training labels;
[0199] The target detection model is trained based on the location coordinates, target training labels, and the corresponding first sample image.
[0200] The implementation principle and technical effects of the above embodiments are similar to those of the above method embodiments, and will not be repeated here.
[0201] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the training method for the target detection model provided in the above embodiments:
[0202] Acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images;
[0203] Based on the content of the elements included in the first outer annotation box, obtain the first original annotation name corresponding to the first outer annotation box;
[0204] Based on the target similarity threshold and the similarity between different first original label names, all first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold;
[0205] The first original label name in the first clustering result is converted into the same target training label and used as the target training label of the corresponding first sample image;
[0206] The target detection model is trained based on the first sample image with target training labels.
[0207] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0208] Acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images;
[0209] Based on the content of the elements included in the second outer annotation box, obtain the second original annotation name corresponding to the second outer annotation box;
[0210] Based on different similarity thresholds and the similarity between different second original label names, all second original label names are clustered to obtain the second clustering result corresponding to each similarity threshold;
[0211] The second original label name in each second clustering result is converted into the same reference training label and used as the reference training label for the corresponding second sample image.
[0212] The target detection model is trained based on a second sample image with reference training labels to obtain the training evaluation parameters corresponding to each similarity threshold.
[0213] Based on the training evaluation parameters corresponding to each similarity threshold, the target similarity threshold is selected from all similarity thresholds.
[0214] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0215] Based on the target similarity threshold and the similarity between different first original label names, perform initial clustering on all first original label names to obtain the first initial clustering result corresponding to the target similarity threshold;
[0216] If the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original label name does not conform to the name labeling rules, the first original label name of the first sample image in the first initial clustering result is corrected to obtain the corrected first original label name;
[0217] Based on the similarity between the target similarity threshold and the similarity between different modified first original label names, cluster all modified first original label names to obtain the first clustering result corresponding to the target similarity threshold.
[0218] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0219] The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained.
[0220] Based on the trained object detection model, the training evaluation parameters corresponding to each similarity threshold are obtained.
[0221] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0222] The training evaluation parameter is the average precision; the maximum value of the average precision corresponding to each similarity threshold is determined, and the similarity threshold corresponding to the maximum value is used as the target similarity threshold.
[0223] In one embodiment, when the computer program is executed by a processor, it also performs the following steps:
[0224] The first sample image contains multiple detection objects; obtain the position coordinates of each first bounding box in the first sample image with target training labels;
[0225] The target detection model is trained based on the location coordinates, target training labels, and the corresponding first sample image.
[0226] The implementation principle and technical effects of the above embodiments are similar to those of the above method embodiments, and will not be repeated here.
[0227] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, 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, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0228] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0229] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A training method for an object detection model, characterized in that, The method includes: Acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images; According to the first name annotation rule, the content of the elements included in the first outer annotation box is converted into codes, which serve as the first original annotation name corresponding to the first outer annotation box; the content of the elements is the relevant information of the detected object in the first sample image; Based on the target similarity threshold and the similarity between different first original label names, all first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold; The first original label name in the first clustering result is converted into the same target training label and used as the target training label of the corresponding first sample image; The target detection model is trained based on the first sample image with target training labels; The process of determining the target similarity threshold includes: Acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images; Based on the content of the elements included in the second outer annotation box, obtain the second original annotation name corresponding to the second outer annotation box; Based on different similarity thresholds and the similarity between different second original label names, all second original label names are clustered to obtain the second clustering result corresponding to each similarity threshold; The second original label name in each second clustering result is converted into the same reference training label and used as the reference training label for the corresponding second sample image. The target detection model is trained based on a second sample image with reference training labels to obtain training evaluation parameters corresponding to each similarity threshold. Based on the training evaluation parameters corresponding to each similarity threshold, the target similarity threshold is selected from all similarity thresholds.
2. The method according to claim 1, characterized in that, The step of clustering all first original annotation names based on the target similarity threshold and the similarity between different first original annotation names to obtain the first clustering result corresponding to the target similarity threshold includes: Based on the target similarity threshold and the similarity between different first original label names, perform initial clustering on all first original label names to obtain the first initial clustering result corresponding to the target similarity threshold; If the number of first sample images corresponding to the first initial clustering result is not within the target preset range or the first original label name does not conform to the name labeling rule, the first original label name of the first sample image in the first initial clustering result is corrected to obtain the corrected first original label name; Based on the target similarity threshold and the similarity between different corrected first original label names, all corrected first original label names are clustered to obtain the first clustering result corresponding to the target similarity threshold.
3. The method according to claim 1, characterized in that, The target detection model is trained based on a second sample image with reference training labels to obtain training evaluation parameters corresponding to each similarity threshold, including: The second sample image with reference training labels is input into the target detection model until the fluctuation of the loss curve of the target detection model is within the preset fluctuation range, then the training is stopped and the corresponding trained target detection model is obtained. Based on the trained object detection model, the training evaluation parameters corresponding to each similarity threshold are obtained.
4. The method according to claim 1, characterized in that, The training evaluation parameter is the average accuracy. The step of selecting the target similarity threshold from all similarity thresholds based on the training evaluation parameters corresponding to each similarity threshold includes: Determine the maximum value in the average precision corresponding to each similarity threshold, and use the similarity threshold corresponding to the maximum value as the target similarity threshold.
5. The method according to any one of claims 1 to 4, characterized in that, The first sample image contains multiple detection objects; the step of training the target detection model based on the first sample image with target training labels includes: Obtain the position coordinates of each first bounding box in the first sample image with target training labels; The target detection model is trained based on the location coordinates, target training labels, and the corresponding first sample image.
6. A training device for an object detection model, characterized in that, The device includes: The image acquisition module is used to acquire multiple first sample images and determine the first bounding box of the detected object in the first sample images; The name labeling module is used to convert the content of the elements included in the first outer labeling box into codes according to the first name labeling rules, which serve as the first original labeling name corresponding to the first outer labeling box; the content of the elements is the relevant information of the detected object in the first sample image; The clustering module is used to cluster all the first original label names according to the target similarity threshold and the similarity between different first original label names, and obtain the first clustering result corresponding to the target similarity threshold; The label conversion module is used to convert the first original label name in the first clustering result into the same target training label, and use it as the target training label of the corresponding first sample image; The model training module is used to train the object detection model based on a first sample image with target training labels; The bounding box determination module is used to acquire multiple second sample images and determine the second bounding box of the detected object in the second sample images. The label name acquisition module is used to obtain the second original label name corresponding to the second outer label box based on the content of the elements included in the second outer label box; The clustering result acquisition module is used to cluster all second original label names according to different similarity thresholds and the similarity between different second original label names, and obtain the second clustering result corresponding to each similarity threshold; The training label determination module is used to convert the second original label name in each second clustering result into the same reference training label, and use it as the reference training label for the corresponding second sample image. The evaluation parameter acquisition module is used to train the target detection model based on a second sample image with reference training labels to obtain the training evaluation parameters corresponding to each similarity threshold. The target similarity threshold determination module is used to select the target similarity threshold from all similarity thresholds based on the corresponding training evaluation parameters for each similarity threshold.
7. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.