Parameter tuning method and device, electronic equipment and computer readable storage medium

CN115719084BActive Publication Date: 2026-09-04CHINA TELECOM DIGITAL INTELLIGENCE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211478202.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-23
Publication Date
2026-09-04
Estimated Expiration
2042-11-23

AI Technical Summary

Technical Problem

但是,上述方法需要重新开发算法模型,并重新进行工程化转换以及服务部署,即无法快速缓解现场检测服务误检的情况

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115719084B_ABST
    Figure CN115719084B_ABST
Patent Text Reader

Abstract

The application provides a parameter tuning method and device, electronic equipment and computer readable storage medium. The method comprises: obtaining an initial confidence and an initial intersection over union of a trained YOLO v5 model; determining a plurality of test values according to the initial confidence and the initial intersection over union; setting each group of test values in the engineered YOLO v5 model respectively, and using the YOLO v5 model to process each preset picture to obtain a group of test values corresponding to the YOLO v5 model with the highest output result accuracy; and setting the confidence test value and the intersection over union test value in the corresponding group of test values as the confidence and the intersection over union of the engineered YOLO v5 model respectively. In this way, when the YOLO v5 model uses tensorRT7 and the accuracy of the detection result output by the model is low, the situation of false detection of the on-site detection service can be quickly alleviated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and more specifically, to a parameter optimization method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] Currently, in the engineering of YOLO v5 models, when using TensorRT7, the elementwise operator merges into a scale operator when the input is constant and the dimension is greater than 4, causing the model to not support element-based operations. However, when this lack of support for element-based operations occurs, the model does not report an error and can still call the engineered model for detection services normally. The problem is a loss of accuracy after model engineering; that is, when using the engineered YOLO v5 model, the accuracy of its output detection results will be reduced.

[0003] To address the issue of low accuracy in detection results output by the YOLO v5 model when using TensorRT7, a common industry solution is to add an identity (feature value) between the content operator and the elementwise operator during algorithm model development to prevent accuracy issues caused by operator fusion. However, this method requires redeveloping the algorithm model and re-engineering and redeploying the service, meaning it cannot quickly alleviate false positives in on-site detection services. Summary of the Invention

[0004] The purpose of this application is to provide a parameter tuning method, apparatus, electronic device, and computer-readable storage medium to quickly alleviate false detections in on-site detection services when the YOLO v5 model uses tensorRT7 and the accuracy of the model's output detection results is low.

[0005] This invention is implemented as follows:

[0006] In a first aspect, embodiments of this application provide a parameter tuning method, the method comprising: obtaining the initial confidence level and initial intersection-over-union (IoU) ratio of a trained YOLO v5 model; determining multiple sets of test values ​​based on the initial confidence level and the initial IoU ratio, each set of test values ​​including a confidence test value and an IoU ratio test value; setting each set of test values ​​to the engineered YOLO v5 model, and using the YOLO v5 model to process each preset image, obtaining a set of test values ​​corresponding to the YOLO v5 model with the highest output accuracy; and setting the confidence test value and IoU ratio test value in the corresponding set of test values ​​as the confidence level and IoU ratio of the engineered YOLO v5 model, respectively.

[0007] In this embodiment, multiple sets of test values ​​are determined based on the initial confidence level and the initial intersection-union ratio (IU / R). The optimal test value is selected from these multiple sets of test values, and then the confidence test value and IU / R test value from this set are set as the confidence level and IU / R of the engineered YOLO v5 model, respectively. This can improve the accuracy of the detection results output by the engineered YOLO v5 model without rebuilding the algorithm model. This can quickly alleviate the false detection situation in the field detection service when the YOLO v5 model uses tensorRT7 and the accuracy of the model's output detection results is low.

[0008] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, determining multiple sets of test values ​​based on the initial confidence level and the initial crossover-union ratio (CUP) includes: determining a first test range corresponding to the confidence level test value and a second test range corresponding to the CUP test value based on the initial confidence level and the initial CUP; selecting multiple confidence level test values ​​at a first preset interval in the first test range; selecting multiple CUP test values ​​at a second preset interval in the second test range; and combining the selected confidence level test values ​​and CUP test values ​​in pairs to generate multiple sets of test values.

[0009] In this embodiment of the application, by first determining the test range of confidence level and cross-union ratio, then selecting test values ​​of confidence level and cross-union ratio from the test range at preset intervals, and then combining the test values ​​in pairs, multiple sets of test values ​​of confidence level and cross-union ratio can be quickly determined, thereby improving the efficiency of determining the optimal values ​​of confidence level and cross-union ratio, and thus alleviating the situation of false detection in on-site testing services as soon as possible.

[0010] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, determining the first test range corresponding to the confidence test value and the second test range corresponding to the cross-union ratio test value based on the initial confidence level and the initial cross-union ratio includes: subtracting and adding a first preset value from the initial confidence level to obtain a minimum confidence test value and a maximum confidence test value; obtaining the first test range based on the minimum confidence test value and the maximum confidence test value; subtracting and adding a second preset value from the initial cross-union ratio to obtain a minimum cross-union ratio test value and a maximum cross-union ratio test value; and obtaining the second test range based on the minimum cross-union ratio test value and the maximum cross-union ratio test value.

[0011] In this application, the first test range and the second test range can be obtained conveniently and quickly based on the initial confidence level, the initial crossover ratio, the first preset value, and the second preset value, thereby improving the efficiency of determining multiple test values ​​and thus improving the efficiency of obtaining the optimal values ​​of confidence level and crossover ratio.

[0012] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, the step of setting each set of test values ​​to the engineered YOLO v5 model and using the YOLO v5 model to process each preset image to obtain a set of test values ​​corresponding to the YOLO v5 model with the highest output accuracy includes: setting each set of test values ​​to the engineered YOLO v5 model, using the YOLO v5 model to process each preset image, obtaining the target image output by the YOLO v5 model for each preset image, wherein the target image includes at least one target contour region labeled by the YOLO v5 model and the target type corresponding to the target contour region; obtaining the F1 score corresponding to each set of test values ​​based on each target image and each labeled image, wherein the labeled image is an image after labeling the target contour region and target type of each preset image; and setting the set of test values ​​corresponding to the optimal F1 score as the corresponding set of test values.

[0013] In this embodiment, the F1 score corresponding to each set of test values ​​is obtained through each target image and each identifier image. Then, by setting the set of test values ​​corresponding to the optimal F1 score as the corresponding set of test values, the optimal confidence level and the optimal intersection-union ratio can be accurately selected. This can improve the accuracy of the detection results output by the engineered YOLO v5 model, thereby significantly reducing the false detection situation in on-site detection services.

[0014] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, obtaining the F1 score corresponding to each group of test values ​​based on each target image and each labeled image includes: performing the following processing on each target image and each labeled image corresponding to each group of test values: determining a first quantity, a second quantity, and a third quantity corresponding to different target types based on each target image and each labeled image, wherein the first quantity is the number of targets whose intersection-over-union ratio (IoU) is greater than a preset threshold, the second quantity is the number of targets whose IoU is less than a preset threshold, and the third quantity is the number of targets in a preset image where the target object exists but the target image predicts no such target object; obtaining the precision of the YOLO v5 model with the test value set for that target type based on the first quantity and the second quantity; obtaining the recall rate of the YOLO v5 model with the test value set for that target type based on the first quantity and the third quantity; and obtaining the F1 score based on the precision and the recall rate for each target type.

[0015] In conjunction with the technical solution provided in the first aspect above, in some possible implementations, the expression for obtaining the F1 score based on the precision and recall corresponding to each target object is as follows: Where n is the total number of target types, P n R represents the accuracy for the nth target category. n Let be the recall rate for the nth target category.

[0016] Secondly, embodiments of this application provide a parameter tuning device, the device comprising: an acquisition module, configured to acquire the initial confidence level and initial intersection-over-union (IoU) ratio of a trained YOLO v5 model; a first processing module, configured to determine multiple sets of test values ​​based on the initial confidence level and the initial IoU ratio, each set of test values ​​including a confidence level test value and an IoU ratio test value; a second processing module, configured to set each set of test values ​​to the engineered YOLO v5 model, and use the YOLO v5 model to process each preset image to obtain a set of test values ​​corresponding to the optimal output result of the YOLO v5 model; and a tuning module, configured to set the confidence level test value and IoU ratio test value in the set of test values ​​to the confidence level and IoU ratio of the engineered YOLO v5 model, respectively.

[0017] In conjunction with the technical solution provided in the second aspect above, in some possible implementations, the first processing module is specifically used to determine a first test range corresponding to the confidence test value and a second test range corresponding to the crossover ratio test value based on the initial confidence level and the initial crossover ratio; in the first test range, select multiple confidence test values ​​at a first preset interval; in the second test range, select multiple crossover ratio test values ​​at a second preset interval; and combine the selected confidence test values ​​and crossover ratio test values ​​in pairs to generate multiple sets of test values.

[0018] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory, the processor and the memory being connected; the memory being used to store a program; the processor being used to invoke the program stored in the memory to execute the method provided by the embodiments of the first aspect described above and / or some possible implementations of the embodiments of the first aspect described above.

[0019] Fourthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, the computer program executing, when run by a processor, the methods provided as described in the first aspect embodiments and / or some possible implementations of the first aspect embodiments. Attached Figure Description

[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0021] Figure 1 A flowchart illustrating the steps of a parameter tuning method provided in this application embodiment.

[0022] Figure 2 This is a schematic diagram illustrating the engineering process of a YOLO v5 model, as provided in an embodiment of this application.

[0023] Figure 3 This is a structural block diagram of a parameter tuning device provided in an embodiment of this application.

[0024] Figure 4 This is a structural block diagram of an electronic device provided in an embodiment of this application. Detailed Implementation

[0025] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0026] Given the issue of low accuracy in detection results when using TensorRT7 with the YOLO v5 model, a common industry solution is to add an identity layer between the constant and elementwise operators during algorithm development to prevent accuracy issues caused by operator fusion. However, this method requires redeveloping the algorithm model and re-engineering and redeploying the service, meaning it cannot quickly alleviate false positives in on-site detection services.

[0027] YOLO v5 is the name of an object detection algorithm. YOLO redefines object detection as a regression problem, applying a single convolutional neural network (CNN) to the entire image, dividing it into a grid, and predicting the class probability and bounding box for each grid. YOLO v5 is a collective name for a major version release. Tensor is a C++ library that facilitates high-performance inference on NVIDIA graphics processing units (GPUs). It is designed to work in a complementary manner with training frameworks such as TensorFlow, Caffe, PyTorch, and MXNet, specifically focusing on fast and efficient network inference on GPUs. tensorRT7 is a collective name for a major version release.

[0028] The inventors of this application, through research and exploration, propose the following embodiments to improve the above-mentioned problems.

[0029] The following combination Figure 1 This application describes the specific process and steps of a parameter tuning method. This embodiment provides a parameter tuning method that can be applied to servers and can be used when the YOLO v5 model uses TensorRT7 and the accuracy of the model's output detection results is low.

[0030] It should be noted that the parameter tuning method provided in this application embodiment is not based on Figure 1 The following order is a restriction.

[0031] Step S101: Obtain the initial confidence score and initial crossover ratio of the trained YOLO v5 model.

[0032] Wherein, confidence level is the confidence level of the predicted target, and intersection-union ratio is the ratio of the intersection and union of the predicted target location and the actual target location.

[0033] It should be noted that the trained YOLO v5 model will generate a current optimal confidence score and crossover ratio (CUP), which are the initial confidence score and initial CUP obtained above.

[0034] After obtaining the initial confidence and initial crossover ratio of the trained YOLO v5 model, this method can continue to step S102.

[0035] Step S102: Determine multiple sets of test values ​​based on the initial confidence level and the initial crossover ratio.

[0036] Each set of test values ​​includes a confidence level test value and an intersection-over-union (IoU) test value.

[0037] Specifically, based on the initial confidence level and the initial crossover ratio (CUP), a first test range corresponding to the confidence level test value and a second test range corresponding to the CUP test value can be determined; within the first test range, multiple confidence level test values ​​are selected at a first preset interval; within the second test range, multiple CUP test values ​​are selected at a second preset interval; the selected confidence level test values ​​and CUP test values ​​are combined in pairs to generate multiple sets of test values.

[0038] The first preset interval and the second preset interval can be limited according to the actual situation, and they can be the same or different. The first preset interval and the second preset interval can both be any value between 0.01 and 0.1. For example, the first preset interval and the second preset interval are both 0.02, 0.05, or 0.07; or the first preset interval is 0.02 and the second preset interval is 0.03; or the first preset interval is 0.05 and the second preset interval is 0.03; or the first preset interval is 0.04 and the second preset interval is 0.05.

[0039] It is understandable that when the first preset interval and the second preset interval are the same, the selected confidence test value and cross-union ratio test value can be more evenly distributed, which can avoid the situation where there are too many test values ​​selected for one test value and too few test values ​​for another test value. This is beneficial for determining the optimal confidence and cross-union ratio from the selected confidence test value and cross-union ratio test value.

[0040] In this embodiment of the application, by first determining the test range of confidence level and cross-union ratio, then selecting test values ​​of confidence level and cross-union ratio from the test range at preset intervals, and then combining the test values ​​in pairs, multiple sets of test values ​​of confidence level and cross-union ratio can be quickly determined, thereby improving the efficiency of determining the optimal values ​​of confidence level and cross-union ratio, and thus alleviating the situation of false detection in on-site testing services as soon as possible.

[0041] Furthermore, determining the first test range corresponding to the confidence level test value and the second test range corresponding to the crossover ratio (CUP) test value based on the initial confidence level and the initial CUP can specifically include: subtracting and adding a first preset value to the initial confidence level to obtain the minimum confidence level test value and the maximum confidence level test value; obtaining the first test range based on the minimum confidence level test value and the maximum confidence level test value; subtracting and adding a second preset value to the initial CUP to obtain the minimum CUP test value and the maximum CUP test value; and obtaining the second test range based on the minimum CUP test value and the maximum CUP test value.

[0042] The first and second preset values ​​can be set according to the actual situation, and they can be the same or different. Both the first and second preset values ​​can be any value between 0.1 and 0.4. For example, the first and second preset values ​​can both be 0.15, or 0.2, or 0.25, or 0.3; or the first preset value can be 0.2 and the second preset value can be 0.25; or the first preset value can be 0.2 and the second preset value can be 0.15; or the first preset value can be 0.3 and the second preset value can be 0.25.

[0043] For example, the initial confidence level is 0.7, the initial crossover ratio is 0.5, the first preset value and the second preset value are both 0.1, and the first preset interval and the second preset interval are both 0.05.

[0044] Subtracting the first preset value from the initial confidence level yields the minimum confidence test value, which is 0.5; adding the first preset value to the initial confidence level yields the maximum confidence test value, which is 0.9; correspondingly, the minimum confidence test value can be used as the minimum value in the first test range, and the maximum confidence test value can be used as the maximum value in the first test range, thus obtaining the first test range, which is [0.6, 0.8].

[0045] Subtracting the second preset value from the initial cross-union ratio (CUNR) yields the minimum CUNR test value, which is 0.3; adding the second preset value to the initial CUNR yields the maximum CUNR test value, which is 0.7; correspondingly, the minimum CUNR test value can be used as the minimum value in the second test range, and the maximum CUNR test value can be used as the maximum value in the second test range, thus obtaining the second test range, which is [0.4, 0.6].

[0046] Furthermore, based on the determined first and second test ranges, multiple confidence level test values ​​can be determined within the first test range according to a first preset interval, namely: 0.6, 0.65, 0.7, 0.75, and 0.8; and multiple intersection-over-union (IoU) test values ​​can be determined within the second test range according to a second preset interval, namely: 0.4, 0.45, 0.5, 0.55, and 0.6. By combining each determined confidence level test value and IoU test value in pairs, multiple sets of test values ​​can be obtained. For example, when the confidence level test value is 0.6, the possible test values ​​are: confidence level 0.6, IoU 0.4; confidence level 0.6, IoU 0.45; confidence level 0.6, IoU 0.5; confidence level 0.6, IoU 0.55; and confidence level 0.6, IoU 0.6.

[0047] It is understandable that the confidence score and crossover ratio (CUP) of the YOLO v5 model cannot be negative. Therefore, when the obtained minimum confidence score test value or minimum CUP test value is negative, the minimum confidence score test value or minimum CUP test value can be set to a preset minimum value, such as 0.01, 0.02, or 0.1.

[0048] In this application, the first test range and the second test range can be obtained conveniently and quickly based on the initial confidence level, the initial crossover ratio, the first preset value, and the second preset value, thereby improving the efficiency of determining multiple test values ​​and thus improving the efficiency of obtaining the optimal values ​​of confidence level and crossover ratio.

[0049] As another optional implementation, determining multiple sets of test values ​​based on the initial confidence level and the initial crossover ratio (CUP) may specifically include: selecting a corresponding set of confidence test values ​​from a preset set of confidence test values ​​based on the initial confidence level, wherein the confidence test values ​​include multiple confidence test values; selecting a corresponding set of crossover ratio (CUP) test values ​​from a preset set of crossover ratio (CUP) test values ​​based on the initial crossover ratio (CUP); and combining each confidence test value and each CUP test value in the selected set of corresponding confidence test values ​​and the selected set of corresponding crossover ratio (CUP) test values ​​in pairs to generate multiple sets of test values.

[0050] For example, the confidence level is divided into two confidence test values: confidence test value 1 and confidence test value 2. The confidence test value 1 ranges from 0.1 to 0.5, and includes confidence test values ​​of 0.1, 0.2, 0.3, 0.4, and 0.5. The confidence test value 2 ranges from 0.51 to 0.9, and includes confidence test values ​​of 0, 0.51, 0.6, 0.7, 0.8, and 0.9. If the initial confidence level is 0.7, it can be determined that the initial confidence level value falls within confidence test value 2, and therefore, each test value in confidence test value 2 can be used as a confidence test value. Correspondingly, the cross-union test value can also be obtained in the same way as the confidence test value, and will not be elaborated further here.

[0051] In this application, the corresponding test values ​​for each confidence level and each crossover ratio can be directly obtained based on the initial confidence level and the initial crossover ratio, thereby improving the efficiency of obtaining each set of test values.

[0052] After obtaining multiple sets of test values, this method can continue to step S103.

[0053] Step S103: Set each set of test values ​​to the engineered YOLO v5 model, and use the YOLO v5 model to process each preset image to obtain the set of test values ​​corresponding to the YOLO v5 model with the highest output accuracy.

[0054] The engineered YOLO v5 model refers to the YOLO v5 model after using tensorRT7.

[0055] Please see Figure 2The specific process of YOLO v5 model engineering is as follows: first, model conversion is performed, then model deployment and service invocation are carried out. After confirming that the service invocation is normal, the parameter tuning method of this application can be implemented. Specifically, the model conversion process is as follows: for the pt file provided by the algorithm side (i.e., the model file format output by the training framework under PyTorch), a general model conversion is performed using the export.py provided by the YOLO model (i.e., the general model format conversion script provided by the PyTorch training framework) and the model loading method consistent with PyTorch, resulting in an ONNX / WTS format model file; then, for the converted ONNX / WTS format model, an engineering GPU-accelerated model conversion is performed using the YOLO v5 conversion or trtexec method provided by TensorRT7, resulting in an engine format model file. The model deployment and service invocation process is as follows: replace the engine format model file in the YOLO module of the project engineering pipeline, start the triton service, and provide the HTTP protocol port for calling the service. After the service starts, a smoke test can be performed using a Python service call script. If the smoke test passes, the parameter tuning method of this application can be implemented; otherwise, an alarm will be issued, indicating that it is necessary to confirm with the algorithm side whether the model file structure is correct and whether the model conversion correctly meets the project requirements. It should be noted that the specific principles of the above model conversion, model deployment, and service call can refer to the principles of model engineering in existing technologies, and will not be elaborated here to avoid repetition.

[0056] It is understood that in the embodiments of this application, each set of test values ​​is set in the engineered YOLO v5 model, and the YOLO v5 model is used to process each preset image. In actual operation, each set of test values ​​can be set in the engineered YOLO v5 model, and then a service call operation (i.e., calling the Triton service) can be performed to realize the use of the engineered YOLO v5 model.

[0057] Furthermore, setting each set of test values ​​onto the engineered YOLO v5 model and using the YOLO v5 model to process each preset image, obtaining the set of test values ​​corresponding to the YOLO v5 model with the highest output accuracy can specifically include: setting each set of test values ​​onto the engineered YOLO v5 model, using the YOLO v5 model to process each preset image, obtaining the target image output by the YOLO v5 model for each preset image; obtaining the F1 score value corresponding to each set of test values ​​based on each target image and each labeled image; and setting the set of test values ​​corresponding to the optimal F1 score value as the corresponding set of test values.

[0058] The F1 score combines the precision and recall scores of the YOLO v5 model into a single score. The target image includes at least one target contour region labeled by the YOLO v5 model and the corresponding target category. Compared to its corresponding preset image, the target image adds at least one target contour region labeled by the YOLO v5 model and the corresponding target category. For example, given a preset image containing a waiter and a chef, the YOLO v5 model can process the preset image to obtain a target image labeled with both the waiter and chef. This target image has two target contour regions: one region is the area where the waiter is located, and the target category for this region is "human"; the other region is the area where the chef is located, and the target category for this region is "chef".

[0059] The labeled image is an image after the target contour region and target type are labeled for each preset image. It can be understood that the target contour region and target type labeled in the labeled image are standard values, that is, the target contour region and target type labeled in the target image can be used as the standard.

[0060] Furthermore, the selection of preset images is related to the targets that the trained YOLO v5 model can detect. For example, if the trained YOLO v5 model is used to detect people and chefs in images, then the preset images can be images of people and chefs in different environments, such as images of people and chefs in a kitchen or in a restaurant; rather than images of other objects, such as images of animals or plants.

[0061] For example, there are three sets of test values: Test Value 1, Test Value 2, and Test Value 3. First, Test Value 1 is set in the engineered YOLO v5 model, and this model is used to process 50 preset images, resulting in 50 target images, each corresponding to one of the preset and target images. Next, the F1 score corresponding to Test Value 1 is obtained based on the 50 target and 50 labeled images, again with a one-to-one correspondence. Following the method for obtaining F1 score 1, the F1 score 2 corresponding to Test Value 2 and the F1 score 3 corresponding to Test Value 3 can be obtained. After obtaining the F1 scores for each set of test values ​​(i.e., F1 score 1, F1 score 2, and F1 score 3), if F1 score 2 is the optimal score, then Test Value 2 can be set as the corresponding set of test values.

[0062] It is understandable that the preset and labeled images used can be the same when obtaining the F1 scores for different test values. Furthermore, the optimal F1 score can be the largest F1 score among all the F1 scores for each test value group. For example, continuing the previous example, if the F1 score for test value 1 is 0.5, the F1 score for test value 2 is 0.6, and the F1 score for test value 3 is 0.7, then the optimal F1 score can be determined as 0.7, and test value 3 can be set as the corresponding test value group.

[0063] Furthermore, the optimal F1 score can be the largest F1 score among all test values ​​in each group, and the F1 score corresponding to the test value must be greater than the preset value. The preset value can be between 0.55 and 0.8, for example: 0.6, 0.65, 0.7, or 0.75.

[0064] For example, there are four sets of test values: test value a, test value b, test value c, and test value d. Test value a has an F1 score of 0.5 and precision of 0.6; test value b has an F1 score of 0.6 and precision of 0.4; test value c has an F1 score of 0.7 and precision of 0.4; and test value d has an F1 score of 0.6 and precision of 0.6. Since the preset value is 0.6, it can be determined that the F1 score corresponding to test value d is the optimal F1 score value, i.e., the optimal F1 score value is 0.6. Therefore, test value d can be set as the corresponding set of test values.

[0065] It should be noted that when the optimal F1 score is set to the largest F1 score among all test values ​​and the accuracy value of the test value is greater than the preset value, there may be a situation where the accuracy of all test values ​​is less than or equal to the preset value. In this case, no subsequent operations will be performed, and the YOLO v5 model needs to be retrained.

[0066] The example above illustrates obtaining all test values ​​first, and then retrieving the F1 score for each test value individually. In practice, one can also obtain the F1 score for each test value first, then obtain another test value, and so on, to obtain the F1 score for all test values.

[0067] Specifically, after obtaining the first preset range and the second preset range in step S102, a first preset interval can be applied to the first preset range, and a second preset interval can be applied to the second preset range to perform a nested loop of confidence test values ​​and intersection-over-union (IoU) test values. That is, it is not necessary to pre-calculate each set of test values; instead, during the execution of the engineered YOLO v5 model using the test values, the values ​​are sequentially selected based on whether the next value falls within the preset range. It should be noted that the specific principle of the nested loop can be found in existing technologies, and will not be elaborated upon here to avoid redundancy. The following describes the scheme using the nested loop method:

[0068] First, the minimum confidence test value within a first preset range and the minimum intersection-over-union (IoU) test value within a second preset range are used as the first set of test values. These first set of test values ​​are then applied to the engineered YOLO v5 model. The YOLO v5 model is used to process each preset image, obtaining the target image output by the YOLO v5 model for each preset image. Next, based on each target image and each labeled image, the F1 score corresponding to the first set of test values ​​is obtained. After obtaining the F1 score corresponding to the first set of test values, a second preset interval is added to the minimum IoU test value, and it is determined whether the latest obtained IoU test value is within the second preset range. If it is, the minimum confidence test value and the latest obtained IoU test value are used as the second set of test values, and the F1 score corresponding to the second set of test values ​​is obtained.

[0069] Repeat the above operation until the latest obtained Crossover Union (CUC) test value is not within the second preset range. Then, add the first preset interval to the minimum confidence test value and determine whether the latest obtained confidence test value is within the first preset range. If it is, use the latest obtained confidence test value and the minimum CUC test value as the latest set of test values, and obtain the F1 score of the latest set of test values. Then, continuously update the CUC test value using the above method to obtain the next set of test values ​​until the latest obtained CUC test value is not within the second preset range. Repeat the operation of updating the confidence test value until the latest obtained confidence test value is not within the first preset range, thereby traversing each confidence test value and CUC test value.

[0070] In this embodiment, the F1 score corresponding to each set of test values ​​is obtained through each target image and each identifier image. Then, by setting the set of test values ​​corresponding to the optimal F1 score as the corresponding set of test values, the optimal confidence level and the optimal intersection-union ratio can be accurately selected. This can improve the accuracy of the detection results output by the engineered YOLO v5 model, thereby significantly reducing the false detection situation in on-site detection services.

[0071] Furthermore, obtaining the F1 score corresponding to each set of test values ​​based on each target image and each labeled image can specifically include: performing the following processing on each target image and each labeled image corresponding to each set of test values: determining the first, second, and third quantities corresponding to different target categories based on each target image and each labeled image; obtaining the precision of the YOLO v5 model with test values ​​set for each target category based on the first and second quantities; obtaining the recall rate of the YOLOv5 model with test values ​​set for each target category based on the first and third quantities; and obtaining the F1 score based on the precision and recall rate for each target category.

[0072] The first quantity is the number of objects whose cross-over ratio (CUP) is greater than a preset threshold, the second quantity is the number of objects whose CUP is less than a preset threshold, and the third quantity is the number of objects in a preset image that are not predicted to exist in the target image.

[0073] The preset threshold can be set according to the actual situation. For example, the preset threshold can be 0.4, 0.5, 0.6, or 0.7. There is no limitation here.

[0074] Furthermore, based on the first and second quantities corresponding to each target type, the specific formula for obtaining the accuracy of the YOLO v5 model with test values ​​set for that target is as follows:

[0075]

[0076] Where P represents the aforementioned precision, TP represents the aforementioned first quantity, and FP represents the aforementioned second quantity.

[0077] The specific formula for obtaining the recall rate of the YOLO v5 model with test values ​​for each target item, based on the first and third quantities corresponding to each target category, is as follows:

[0078]

[0079] Where R is the recall rate, TP is the first quantity, and FN is the second quantity.

[0080] Continuing the previous example, for the engineered YOLO v5 model with test value 1, the output is 50 target images. Each target image has a labeled target contour region and its corresponding target category. Taking one target image as an example, this image is labeled with target contour region 1 and target contour region 2. Target contour region 1 corresponds to the target category of "human," and target contour region 2 corresponds to the target category of "chef." The target image is compared with its corresponding labeled image. First, the target categories of target contour region 1 and the corresponding target contour region in the labeled image are compared. If they are correct, the intersection-union ratio (IUR) is calculated based on the coordinates of target contour region 1 and the corresponding target contour region in the labeled image. If the IUR is greater than a preset threshold, the case is classified as the first number of cases corresponding to the target object being "human." If the IUR is incorrect and the IUR is less than the preset threshold, the case is classified as the second number of cases corresponding to the target object being "human." When the labeled image contains a target outline region for a person, but this target outline region is not labeled in the target image, this situation can be categorized into the third category corresponding to the target being a person. Correspondingly, this method can also be used to classify the various cases where the target is a chef (i.e., the target type is chef).

[0081] After obtaining the first, second, and third number of targets for the category of "human" and the first, second, and third number of targets for the category of "chef" based on 50 target images and 50 detection images, the precision of the YOLO v5 model with a test value of 1 for the target category of "human" can be obtained based on the first and second number of targets for the target category of "human". The recall rate of the YOLO v5 model with a test value of 1 for the target category of "human" can be obtained based on the first and third number of targets for the target category of "human". The precision of the YOLO v5 model with a test value of 1 for the target category of "chef" can be obtained based on the first and second number of targets for the target category of "chef". The recall rate of the YOLO v5 model with a test value of 1 for the target category of "chef" can also be obtained based on the first and third number of targets for the target category of "chef".

[0082] Next, based on the precision and recall corresponding to the target category "human" for test value 1, and the precision and recall corresponding to the target category "chef" for test value 1, the F1 score for test value 1 can be obtained. Furthermore, the F1 scores for test values ​​2 and 3 can also be obtained using the same method.

[0083] Furthermore, based on the precision and recall corresponding to each target, the expression for obtaining the F1 score is as follows: Where n is the total number of target types, P nR represents the accuracy for the nth target category. n Let be the recall rate for the nth target category.

[0084] Continuing the previous example, when the target categories for test value 1 are "people" and "chefs," and the precision and recall of the YOLO v5 model for "people" with test value 1 are P1 and R1, respectively, and the precision and recall of the YOLO v5 model for "chefs" with test value 1 are P2 and R2, then the F1 score for test value 2 is...

[0085] It is understood that the precision and recall corresponding to each of the above target categories can be referred to the description of precision and recall in the foregoing embodiments, and will not be repeated here to avoid redundancy.

[0086] In this embodiment of the application, by using the above expression to obtain the F1 score value based on the precision and recall of each target object, the F1 score value corresponding to each group of test values ​​can be obtained quickly and accurately, thereby quickly alleviating the situation of false detection in on-site testing services.

[0087] After setting the set of test values ​​corresponding to the optimal F1 score as the corresponding set of test values, this method can continue to step S104.

[0088] Step S104: Set the confidence test value and crossover ratio (CUP) test value in the corresponding set of test values ​​as the confidence and CUP of the engineered YOLO v5 model, respectively.

[0089] In this embodiment, multiple sets of test values ​​are determined based on the initial confidence level and the initial intersection-union ratio (IU / R). The optimal test value is selected from these multiple sets of test values, and then the confidence test value and IU / R test value from this set are set as the confidence level and IU / R of the engineered YOLO v5 model, respectively. This can improve the accuracy of the detection results output by the engineered YOLO v5 model without rebuilding the algorithm model. This can quickly alleviate the false detection situation in the field detection service when the YOLO v5 model uses tensorRT7 and the accuracy of the model's output detection results is low.

[0090] Please see Figure 3 Based on the same inventive concept, this application also provides a parameter tuning device 100, which includes: an acquisition module 101, a first processing module 102, a second processing module 103, and a tuning module 104.

[0091] The acquisition module 101 is used to acquire the initial confidence and initial crossover ratio of the trained YOLO v5 model.

[0092] The first processing module 102 is used to determine multiple sets of test values ​​based on the initial confidence level and the initial crossover ratio (CUP). Each set of test values ​​includes a confidence test value and an CUP test value.

[0093] The second processing module 103 is used to set each set of test values ​​onto the engineered YOLO v5 model, and use the YOLO v5 model to process each preset image to obtain a set of test values ​​corresponding to the optimal output result of the YOLO v5 model.

[0094] The tuning module 104 is used to set the confidence test value and crossover ratio (CUP) test value in the set of test values ​​as the confidence and CUP of the engineered YOLO v5 model, respectively.

[0095] Optionally, the first processing module 102 is specifically used to determine a first test range corresponding to the confidence test value and a second test range corresponding to the crossover ratio test value based on the initial confidence level and the initial crossover ratio; select multiple confidence test values ​​at a first preset interval in the first test range; select multiple crossover ratio test values ​​at a second preset interval in the second test range; and combine the selected confidence test values ​​and crossover ratio test values ​​in pairs to generate multiple sets of test values.

[0096] Optionally, the first processing module 102 is specifically used to subtract and add a first preset value to the initial confidence level to obtain the minimum confidence level test value and the maximum confidence level test value; obtain a first test range based on the minimum confidence level test value and the maximum confidence level test value; subtract and add a second preset value to the initial crossover ratio (CUP) to obtain the minimum CUP test value and the maximum CUP test value; and obtain a second test range based on the minimum CUP test value and the maximum CUP test value.

[0097] Optionally, the second processing module 103 is specifically used to set each set of test values ​​onto the engineered YOLO v5 model, use the YOLO v5 model to process each preset image, obtain the target image output by the YOLO v5 model for each preset image, the target image includes at least one target contour region labeled by the YOLO v5 model and the target type corresponding to the target contour region; obtain the F1 score value corresponding to each set of test values ​​based on each target image and each labeled image, the labeled image is the image after labeling the target contour region and target type of each preset image; and set the set of test values ​​corresponding to the optimal F1 score value as the corresponding set of test values.

[0098] Optionally, the second processing module 103 is specifically used to perform the following processing on each target image and each labeled image corresponding to each group of test values: Based on each target image and each labeled image, determine the first quantity, second quantity, and third quantity corresponding to different target types. The first quantity is the number of targets whose intersection-over-union ratio (IoU) is greater than a preset threshold; the second quantity is the number of targets whose IoU is less than a preset threshold; and the third quantity is the number of targets in a preset image that are not predicted to contain the target. Based on the first and second quantities corresponding to each target type, obtain the precision of the YOLO v5 model with test values ​​set for that target type. Based on the first and third quantities corresponding to each target type, obtain the recall of the YOLO v5 model with test values ​​set for that target type. Based on the precision and recall corresponding to each target type, obtain the F1 score.

[0099] Please see Figure 4 Based on the same inventive concept, this application provides a schematic structural block diagram of an electronic device 200, which can be used to implement the parameter tuning method described above. In this application embodiment, the electronic device 200 can be, but is not limited to, a personal computer (PC), smartphone, tablet computer, personal digital assistant (PDA), mobile internet device (MID), etc. Structurally, the electronic device 200 may include a processor 210 and a memory 220.

[0100] Processor 210 and memory 220 are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. Processor 210 can be an integrated circuit chip with signal processing capabilities. Processor 210 can also be a general-purpose processor, such as a Central Processing Unit (CPU), Digital Signal Processor (DSP), Application Specific Integrated Circuit (ASIC), discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. Furthermore, the general-purpose processor can be a microprocessor or any conventional processor.

[0101] The memory 220 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), and electrically erasable programmable read-only memory (EEPROM). The memory 220 is used to store programs, which the processor 210 executes upon receiving an execution instruction.

[0102] It should be understood that Figure 4 The structure shown is for illustrative purposes only. The electronic device 200 provided in this application embodiment may also have a more advanced design. Figure 4 Fewer or more components, or having the same Figure 4 The different configurations shown. Furthermore... Figure 4 The components shown can be implemented through software, hardware, or a combination thereof.

[0103] It should be noted that, as those skilled in the art will clearly understand, for the sake of convenience and brevity, the specific working processes of the systems, devices and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0104] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium storing a computer program thereon, which executes the methods provided in the above embodiments when the computer program is run.

[0105] The storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that integrates one or more available media. The available medium can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).

[0106] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0107] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0108] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0109] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.

[0110] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A parameter tuning method, characterized in that, The method includes: Obtain the initial confidence score and initial intersection-union ratio of the trained YOLO v5 model; Based on the initial confidence level and the initial crossover ratio (CUP), multiple sets of test values ​​are determined, each set of test values ​​including a confidence level test value and a crossover ratio (CUP) test value. Each set of test values ​​is set on the engineered YOLO v5 model, and the YOLO v5 model is used to process each preset image to obtain a set of test values ​​corresponding to the YOLO v5 model with the highest output accuracy. The confidence test value and cross-union ratio test value in the corresponding set of test values ​​are respectively set as the confidence and cross-union ratio of the engineered YOLO v5 model; The step of determining multiple sets of test values ​​based on the initial confidence level and the initial crossover ratio includes: Based on the initial confidence level and the initial crossover ratio (CUP), determine the first test range corresponding to the confidence level test value and the second test range corresponding to the CUP test value; Within the first test range, multiple confidence test values ​​are selected at a first preset interval; Within the second test range, multiple crossover ratio (CUP) test values ​​are selected at a second preset interval; The selected confidence test values ​​and crossover ratio (CUP) test values ​​are combined in pairs to generate multiple sets of test values.

2. The method according to claim 1, characterized in that, The step of determining the first test range corresponding to the confidence test value and the second test range corresponding to the cross-union ratio test value based on the initial confidence level and the initial cross-union ratio includes: Subtracting and adding the first preset value from the initial confidence level respectively yields the minimum confidence test value and the maximum confidence test value; The first test range is obtained based on the minimum confidence test value and the maximum confidence test value; Subtracting and adding the second preset value from the initial crossover-union ratio (CUIR) respectively, we obtain the minimum CUIR test value and the maximum CUIR test value; The second test range is obtained based on the minimum cross-union ratio test value and the maximum cross-union ratio test value.

3. The method according to claim 1, characterized in that, The step involves setting each set of test values ​​onto the engineered YOLO v5 model, processing each preset image using the YOLO v5 model, and obtaining a set of test values ​​corresponding to the YOLO v5 model with the highest output accuracy, including: Each set of test values ​​is set on the engineered YOLO v5 model, and the YOLO v5 model is used to process each preset image to obtain the target image output by the YOLO v5 model for each preset image. The target image includes at least one target contour region labeled by the YOLO v5 model and the target type corresponding to the target contour region. Based on each target image and each labeled image, obtain the F1 score corresponding to each group of test values. The labeled image is an image after labeling the target contour region and target type of each preset image. Set the set of test values ​​corresponding to the optimal F1 score as the corresponding set of test values.

4. The method according to claim 3, characterized in that, The step of obtaining the F1 score corresponding to each group of test values ​​based on each target image and each labeled image includes: The following processing is performed on each target image and each labeled image corresponding to each group of test values: Based on each target image and each labeled image, a first quantity, a second quantity, and a third quantity corresponding to different target types are determined. The first quantity is the number of target objects whose cross-union ratio is greater than a preset threshold. The second quantity is the number of target objects whose cross-union ratio is less than a preset threshold. The third quantity is the number of target objects that exist in a preset image but are predicted not to exist in the target image. Based on the first quantity and the second quantity corresponding to each of the target types, obtain the accuracy of the YOLO v5 model with the test value set for that target type; Based on the first quantity and the third quantity corresponding to each target type, obtain the recall rate of the YOLO v5 model with the test value set for that target type; The F1 score is obtained based on the precision and recall corresponding to each target category.

5. The method according to claim 4, characterized in that, The expression for obtaining the F1 score based on the precision and recall corresponding to each target is as follows: ; in, The total number of the target types. For the first Accuracy of each target category For the first Recall rate for each target category.

6. A parameter tuning device, characterized in that, The device includes: The acquisition module is used to obtain the initial confidence score and initial intersection-over-union ratio of the trained YOLO v5 model; The first processing module is used to determine multiple sets of test values ​​based on the initial confidence level and the initial crossover ratio (CUP), wherein each set of test values ​​includes a confidence level test value and a crossover ratio (CUP) test value. The second processing module is used to set each set of test values ​​into the engineered YOLO v5 model, and use the YOLO v5 model to process each preset image to obtain a set of test values ​​corresponding to the optimal output result of the YOLO v5 model. The tuning module is used to set the confidence test value and cross-union ratio test value in the set of test values ​​as the confidence and cross-union ratio of the engineered YOLO v5 model, respectively. The first processing module is specifically used to determine a first test range corresponding to the confidence test value and a second test range corresponding to the crossover ratio test value based on the initial confidence level and the initial crossover ratio; in the first test range, select multiple confidence test values ​​at a first preset interval; in the second test range, select multiple crossover ratio test values ​​at a second preset interval; and combine the selected confidence test values ​​and crossover ratio test values ​​in pairs to generate multiple sets of test values.

7. An electronic device, characterized in that, include: A processor and a memory, wherein the processor and the memory are connected; The memory is used to store programs; The processor is used to run a program stored in the memory and perform the method as described in any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a computer, performs the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Model testing method and device, terminal and storage medium

    CN114120162A

  • Small target detection method and device based on improved YOLOv5

    CN115223009A