A target detection algorithm testing method and system based on a python language
By developing a target detection algorithm testing method and system based on the Python language, the problem of existing tools being unable to perform efficient batch testing has been solved. This has enabled automated and accurate target detection result analysis and report generation, thereby improving detection efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANDONG LUNENG SOFTWARE TECH
- Filing Date
- 2022-11-22
- Publication Date
- 2026-05-29
AI Technical Summary
Existing object detection algorithm testing tools suffer from problems such as inability to perform batch testing, high labor costs, low testing efficiency, inability to calculate and statistically analyze test metrics, and inability to provide visualization.
Design a test method and system for object detection algorithms based on Python. Through steps such as preparing test data, uploading images, reading annotation files, calculating intersection ratios, generating statistical charts, and automatically sending emails, the system achieves automated testing and result analysis.
It achieves efficient and automated target detection algorithm testing, improving the accuracy and efficiency of detection results. It supports multi-target, multi-threaded concurrent detection, has flexibility and configurability, and can automatically generate test reports and charts for easy and rapid defect location.
Smart Images

Figure CN115757146B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology, specifically relating to a testing method and system for object detection algorithms based on the Python language. Background Technology
[0002] Object detection, which involves identifying all objects of interest in an image and determining their category and location, is one of the core problems in computer vision. Due to the different appearances, shapes, and poses of various objects, coupled with interference from factors such as lighting and occlusion during imaging, object detection has always been one of the most challenging problems in computer vision.
[0003] The main functions of object detection algorithm testing tools are to test the accuracy of the algorithm's recognition, to collect statistical test metrics, and to save the test results. Existing object detection algorithm testing methods include the following:
[0004] The first method: Manually testing via the web system.
[0005] Upload images to the object detection module via the system's web page; the system processes the images and returns the recognition results. The advantages are convenience, speed, and simplicity. The disadvantages are the need for repetitive operations, inability to perform batch testing, high labor costs, and inability to calculate and statistically analyze test metrics.
[0006] The first method: using API testing tools.
[0007] The process involves uploading images to an algorithm interface to obtain recognition information and then checking whether the recognition information conforms to assertions. The advantages are low cost and simple operation. The disadvantages are long testing time and low efficiency, difficulty in manipulating and processing test data, difficulty in manipulating and processing interface return information, inability to calculate and statistically analyze test metrics, inability to categorize and save images based on test results, inability to draw target rectangles on test images using recognition information, and inability to visualize batch test data.
[0008] Both of the above methods have their own technical defects. In view of this, it is necessary to provide a test method and system for target detection algorithms based on Python language to solve the above-mentioned technical defects in the prior art. Summary of the Invention
[0009] The purpose of this invention is to address the shortcomings of the existing technology by providing a test method and system for object detection algorithms based on the Python language, thereby solving the aforementioned technical problems.
[0010] To achieve the above objectives, the present invention provides the following technical solution:
[0011] A testing method for object detection algorithms based on the Python language includes the following steps:
[0012] S1: Steps for preparing test data. In this step...
[0013] Prepare test images for target detection and annotate the test images to generate XML files with corresponding coordinate points;
[0014] S2: The steps for testing the upload of images to the algorithm interface to obtain response data.
[0015] S3: The step of reading data from the XML annotation file. In this step:
[0016] Read the coordinates of the rectangle and draw a green rectangle on the test image; write the coordinates of the rectangle to a txt file and save it to the groundtr uths expected results directory;
[0017] S4: Test the steps for saving images by category.
[0018] S5: Steps for statistical analysis of test results
[0019] S6: Steps for automatically sending emails, in which:
[0020] Upon completion of the test, a test report is generated, which displays the results of the test case execution. An email is automatically sent upon completion of the test, containing a test description and the test report, and is sent to the test manager.
[0021] Preferably, in step S2: the test image is uploaded to the algorithm interface, and the recognition algorithm identifies the target in the image; after identification, the recognition algorithm returns data through the algorithm interface in the form of target rectangle coordinate point data; a red rectangle is drawn on the test image according to the rectangle coordinate point data; the rectangle coordinate point data is written to a txt file and saved to the actual results directory of the detections.
[0022] Preferably, in step S4: the intersection ratio IOU of the coordinates of the left-side points of the rectangle is calculated, where IOU = the intersection area of the two rectangles / the union area of the two rectangles; if IOU is greater than the expected value of 0.5 (a general test indicator), the test image is saved to the normal directory; if IOU is less than the expected value of 0.5 (a general test indicator), the test image is saved to the false detection directory; if the number of targets identified is lower than the actual number, the test image is guaranteed to be saved to the missed detection directory.
[0023] Preferably, in step S5:
[0024] Generate an IOU frequency distribution histogram to visually display the data distribution; generate a success rate pie chart to visually display the success rate, false positive rate, and false negative rate of this test; generate a txt file to statistically analyze test information, recording details such as the number of tests, success rate, false positive rate, false negative rate, IOU, and average IOU.
[0025] This invention also provides a test system for object detection algorithms based on the Python language, comprising:
[0026] The test data preparation module is used to: prepare test images for target detection and annotate the test images to generate corresponding coordinate point XL files;
[0027] The module for uploading test images to the algorithm interface to obtain response data is used for: uploading test images to the algorithm interface, where the recognition algorithm identifies the targets in the images; returning data through the algorithm interface in the form of target bounding box coordinates after recognition; drawing red bounding boxes in the test images based on the bounding box coordinates; and writing the bounding box coordinates to a txt file and saving it to the actual results directory of the detections.
[0028] The module for reading XML annotation file data is used to: read the coordinate point data of a rectangle and draw a green rectangle on the test image; and write the coordinate point data of the rectangle to a txt file and save it to the groundtruths expected results directory.
[0029] This test image categorization and saving module is used for:
[0030] Calculate the intersection ratio IOU of the coordinates of the left-hand points of the rectangles, where IOU = the area of the intersection of the two rectangles / the area of the union of the two rectangles; if IOU is greater than the expected value of 0.5 (a general test indicator), the test image is saved to the normal directory; if IOU is less than the expected value of 0.5 (a general test indicator), the test image is saved to the false detection directory; if the number of targets identified is lower than the actual number, the test image is guaranteed to be saved to the missed detection directory.
[0031] The statistical test results module is used for:
[0032] Generate an IOU frequency distribution histogram to visually display the data distribution; generate a success rate pie chart to visually display the success rate, false positive rate, and false negative rate of this test; generate a txt file to statistically analyze test information, recording details such as the number of tests, success rate, false positive rate, false negative rate, IOU, and average IOU.
[0033] The automatic email sending module is used for:
[0034] Upon completion of the test, a test report is generated, which displays the results of the test case execution. An email is automatically sent upon completion of the test, containing a test description and the test report, and is sent to the test manager.
[0035] The beneficial effects of this invention are as follows: through layered design and development using Python, this solution has the advantages of low implementation cost, high execution efficiency, and accurate detection results; it is data-driven, using data to drive the execution of test cases, with n test cases automatically executed n times for n data points; the configurability of the method is achieved through configuration files, which greatly improves the flexibility of the detection tool, and the tool's extended use is enriched through functions such as automatic image and text processing; it supports multi-target, multi-threaded concurrent detection, meeting business needs and greatly improving detection efficiency and accuracy. Test images and labeled XML files are automatically paired and stored in a parameter list as dictionary key-value pairs, which are then passed to the algorithm interface. The data is isolated from each other to maintain independence, ensuring the accuracy of the test data itself. It supports testing by cropping partial images. In special cases where a complete image is too blurry for overall recognition, this tool can crop the portion to be detected from the entire image and regenerate the labeled XML file for testing. Automatic plotting is provided: red rectangles are drawn on the test image based on the actual result coordinates, and green rectangles are drawn based on the expected result coordinates. By comparing the area ratio of the intersection of the two rectangles, the accuracy of the algorithm's recognition can be intuitively judged. Test data can be categorized and saved as successful, false positives, and missed detections for easy and quick viewing of defect location information. Test report statistics charts are automatically generated to display the overall trend of test information.
[0036] Furthermore, the design principle of this invention is reliable, the structure is simple, and it has a very wide range of application prospects.
[0037] Therefore, it is evident that the present invention has outstanding substantive features and significant progress compared with the prior art, and the beneficial effects of its implementation are also obvious. Attached Figure Description
[0038] Figure 1 This is a flowchart of a test method for a target detection algorithm based on the Python language provided by the present invention.
[0039] Figure 2 This is a block diagram illustrating the principle of a test system for a target detection algorithm based on the Python language, provided by this invention.
[0040] The module consists of 1- test data preparation module, 2- test image upload to algorithm interface to obtain response data module, 3- XML annotation file data reading module, 4- test image classification and saving module, 5- test result statistics module, and 6- automatic email sending module. Detailed Implementation
[0041] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments. The following embodiments are explanations of the present invention, but the present invention is not limited to the following implementation methods.
[0042] Example 1:
[0043] like Figure 1 As shown in the figure, this embodiment provides a test method for a target detection algorithm based on the Python language, which includes the following steps:
[0044] S1: Steps for preparing test data. In this step...
[0045] Prepare test images for target detection and annotate the test images to generate XML files with corresponding coordinate points;
[0046] S2: The step of uploading the test image to the algorithm interface to obtain response data: Upload the test image to the algorithm interface, and the recognition algorithm will identify the target in the image; After the recognition algorithm identifies the target, it returns the data through the algorithm interface in the form of target rectangle coordinate point data; Draw a red rectangle in the test image according to the rectangle coordinate point data; Write the rectangle coordinate point data to a txt file and save it to the actual results directory of the detections.
[0047] S3: The step of reading data from the XML annotation file. In this step:
[0048] Read the coordinates of the rectangle and draw a green rectangle on the test image; write the coordinates of the rectangle to a txt file and save it to the groundtr uths expected results directory;
[0049] S4: Steps for classifying and saving test images: Calculate the intersection ratio IOU of the coordinates of the left points of the rectangles, where IOU = intersection area of the two rectangles / union area of the two rectangles; if IOU is greater than the expected value of 0.5 (general test metric), the test image is saved to the normal directory; if IOU is less than the expected value of 0.5 (general test metric), the test image is saved to the false detection directory; if the number of targets identified is lower than the actual number, the test image is guaranteed to be saved to the missed detection directory.
[0050] S5: Steps for statistical testing results: Generate an IOU frequency distribution histogram to visually display the data distribution; generate a success rate pie chart to visually display the success rate, false positive rate, and false negative rate of this test; generate a txt file to statistically analyze test information, recording details such as the number of tests, success rate, false positive rate, false negative rate, IOU, and average IOU.
[0051] S6: Steps for automatically sending emails, in which:
[0052] Upon completion of the test, a test report is generated, which displays the results of the test case execution. An email is automatically sent upon completion of the test, containing a test description and the test report, and is sent to the test manager.
[0053] Example 2:
[0054] like Figure 2 As shown, this embodiment provides a test system for object detection algorithms based on the Python language, including:
[0055] Module 1 for preparing test data is used to: prepare test images for target detection and annotate the test images to generate xml files with corresponding coordinate points;
[0056] Module 2, which uploads test images to the algorithm interface to obtain response data, is used for: uploading test images to the algorithm interface, where the recognition algorithm identifies the targets in the images; returning data through the algorithm interface in the form of target bounding box coordinates after recognition; drawing red bounding boxes in the test images based on the bounding box coordinates; and writing the bounding box coordinates to a txt file and saving it to the actual results directory of the detections.
[0057] Module 3, which reads XML annotation file data, is used to: read the coordinate point data of the rectangle and draw a green rectangle on the test image; and write the coordinate point data of the rectangle to a txt file and save it to the groundtruths expected results directory.
[0058] Test image categorization and saving module 4, this module is used for:
[0059] Calculate the intersection ratio IOU of the coordinates of the left-hand points of the rectangles, where IOU = the area of the intersection of the two rectangles / the area of the union of the two rectangles; if IOU is greater than the expected value of 0.5 (a general test indicator), the test image is saved to the normal directory; if IOU is less than the expected value of 0.5 (a general test indicator), the test image is saved to the false detection directory; if the number of targets identified is lower than the actual number, the test image is guaranteed to be saved to the missed detection directory.
[0060] Statistical test results module 5, this module is used for:
[0061] Generate an IOU frequency distribution histogram to visually display the data distribution; generate a success rate pie chart to visually display the success rate, false positive rate, and false negative rate of this test; generate a txt file to statistically analyze test information, recording details such as the number of tests, success rate, false positive rate, false negative rate, IOU, and average IOU.
[0062] Automatic email sending module 6, this module is used for:
[0063] Upon completion of the test, a test report is generated, which displays the results of the test case execution. An email is automatically sent upon completion of the test, containing a test description and the test report, and is sent to the test manager.
[0064] The above-disclosed embodiments are merely preferred embodiments of the present invention, but the present invention is not limited thereto. Any non-creative variations that can be conceived by those skilled in the art, as well as any improvements and modifications made without departing from the principles of the present invention, should fall within the protection scope of the present invention.
Claims
1. A testing method for an object detection algorithm based on the Python language, characterized in that, Includes the following steps: S1: Steps for preparing test data. In this step... Prepare test images for target detection and annotate the test images to generate XML files with corresponding coordinate points; S2: The steps for testing the upload of images to the algorithm interface to obtain response data; S3: The steps for reading data from an XML annotation file, in which: Read the rectangle's coordinates and draw a green rectangle on the test image; write the rectangle's coordinates to a txt file and save it to the groundtruths expected results directory. S4: Test the steps for saving image categories; S5: Steps for statistical analysis of test results; S6: Steps for automatically sending emails, in which: Upon completion of the test, a test report is generated, which displays the results of the test case execution. An email is also automatically sent upon completion of the test, containing a test description and a test report, and is sent to the test manager. In step S2: the test image is uploaded to the algorithm interface, and the recognition algorithm performs recognition processing on the target in the image; After identification, the recognition algorithm returns data through the algorithm interface in the form of the coordinate points of the target rectangle. Draw a red rectangle on the test image based on the rectangle's coordinate points; write the rectangle's coordinate points data into a txt file and save it to the actual results directory of the detections folder; In step S4: calculate the intersection ratio (IOU) of the coordinates of the left-side points of the rectangles, where IOU = intersection area of the two rectangles / union area of the two rectangles; if the IOU is greater than the expected value of 0.5, the test image is saved to the normal directory; if the IOU is less than the expected value of 0.5, the test image is saved to the false detection directory; if the number of targets identified is lower than the actual number, the test image is guaranteed to be saved to the missed detection directory. In step S5: a histogram of IOU frequency distribution is generated to visually display the data distribution; a pie chart of success rate is generated to visually display the success rate, false positive rate, and false negative rate of this test; and a txt file is generated to collect test information, recording details of the number of tests, success rate, false positive rate, false negative rate, IOU, and average IOU.
2. A test system for object detection algorithms based on the Python language, characterized in that, include: The test data preparation module is used to: prepare test images for target detection and annotate the test images to generate XML files with corresponding coordinate points; The module for uploading test images to the algorithm interface to obtain response data is used to: upload test images to the algorithm interface, and have the recognition algorithm identify and process the targets in the images; After identification, the recognition algorithm returns data through the algorithm interface in the form of the coordinate points of the target rectangle. Draw a red rectangle on the test image based on the rectangle's coordinate points; write the rectangle's coordinate points data into a txt file and save it to the actual results directory of the detections folder; The module for reading XML annotation file data is used to: read the coordinate point data of a rectangle and draw a green rectangle on the test image; Write the coordinate data of the rectangle to a txt file and save it to the desired results directory of Groundtruths; This test image categorization and saving module is used for: Calculate the Intersection over Union (IOU) of the coordinates of the left-hand points of the rectangles. IOU = Intersection area of the two rectangles / Union area of the two rectangles. If the IOU is greater than the expected value of 0.5, the test image is saved to the normal directory. If the IOU is less than the expected value of 0.5, the test image is saved to the false detection directory. If the number of targets identified is lower than the actual number, the test image is guaranteed to be saved to the missed detection directory. The statistical test results module is used for: Generate an IOU frequency distribution histogram to visually display the data distribution; generate a success rate pie chart to visually display the success rate, false positive rate, and false negative rate of this test; generate a txt file to statistically analyze test information, recording details such as the number of tests, success rate, false positive rate, false negative rate, IOU, and average IOU. The automatic email sending module is used for: Upon completion of the test, a test report is generated, which displays the results of the test case execution. An email is automatically sent upon completion of the test, containing a test description and the test report, and is sent to the test manager.