A method and system for candidate reconfiguration diagnosis of unknown defects
By freezing the target detection model and acquiring candidate intermediate data, performing post-processing reconstruction and consistency verification, the problem of performance limitation judgment in unknown defect detection is solved, providing reliable diagnostic basis and consistency verification, and clarifying the limiting links in the candidate localization and unknown identification stages.
Patent Information
- Application Number
- CN202611622038.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-20
- Publication Date
- 2026-11-27
AI Technical Summary
In existing technologies, it is difficult to determine whether the performance limitation of unknown defect detection originates from the candidate localization stage or the unknown identification stage, and there is a lack of strict consistency constraints between the reconstruction results and the original detection results, making it difficult to conduct comparable stage-based analysis.
By freezing the model parameters and native post-processing conditions of the target detection model, candidate intermediate data is obtained and persisted. Post-processing reconstruction and consistency verification are performed without repeating the forward calculation, and the true bounding box annotation information of unknown defects is diagnosed in stages.
It enables the differentiation of unknown defect detection limitations without changing the model's operating state, providing verifiable diagnostic basis for model improvement and ensuring consistency between reconstructed detection results and original detection results.
Smart Images

Figure CN123181971A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and specifically to a diagnostic method and system for unknown defect candidate reconstruction. Background Technology
[0002] With the development of industrial machine vision and open-world object detection, new types of defects that were not supervised during the training phase may appear in actual detection. Therefore, in addition to the known defect detection capabilities, it is also necessary to evaluate the model's ability to locate candidates of unknown defects and its ability to output unknown categories in order to determine where the model's capabilities are limited.
[0003] Currently, in existing methods, typical target detection models generate candidate bounding boxes, category responses, and related intermediate quantities from the detection head. Then, after post-processing such as score filtering, category box selection, non-maximum suppression, candidate number limitation, and coordinate restoration, the final detection result is obtained. The overall performance of the model is usually evaluated directly based on the final average precision, recall rate, or open set evaluation index.
[0004] In the aforementioned prior art, it is difficult to determine whether the performance limitation originates from the candidate localization stage or the unknown identification stage based solely on the final indicators; when reconstructing and analyzing candidate intermediate data, if there is a lack of consistency constraints between the reconstruction results and the original results, it is difficult to eliminate the influence of differences in candidate acquisition, persistence, and post-processing; different models have different post-processing methods, and post-processing also needs to be reconstructed under fixed operating conditions in order to conduct comparable staged analysis. Summary of the Invention
[0005] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for diagnosing unknown defect candidate reconstruction, thereby solving the technical problems in the prior art, such as the difficulty in determining whether performance limitations originate from the candidate localization stage or the unknown identification stage based solely on the final unknown defect detection index, the lack of strict consistency constraints between the reconstruction results and the original detection results when reconstructing and analyzing intermediate candidate data, and the difficulty in performing comparable staged analysis under the same fixed operating conditions due to different post-processing methods of different detection models.
[0006] This invention provides a method for diagnosing unknown defect candidate reconstructions, comprising: Model freezing steps: Obtain the target detection model to be evaluated, freeze the model parameters and original post-processing conditions of the target detection model, and obtain the frozen running conditions; Data acquisition steps: Acquire the qualification verification image and the ground truth bounding box annotation information of the unknown defects therein. Under the frozen running conditions, input the qualification verification image into the target detection model for native forward computation, and acquire and persistently save the candidate intermediate data before the target detection model performs native post-processing. Reconstruction detection steps: Read the candidate intermediate data, and without repeating the original forward computation of the target detection model, perform post-processing reconstruction on the candidate intermediate data based on the original post-processing conditions to obtain the reconstruction detection result; Consistency verification steps: Based on the frozen running conditions, obtain the original detection results of the qualification verification image obtained by the target detection model, and perform consistency verification between the reconstructed detection results and the original detection results to obtain the consistency verification results; The phased diagnostic steps are as follows: If the consistency verification result is successful, then the candidate reachability state of the unknown defect true bounding box in the unknown defect true bounding box annotation information is determined based on the candidate intermediate data, the final unknown output state of the unknown defect true bounding box is determined based on the reconstruction detection result, and the phased diagnostic result is determined based on the candidate reachability state and the final unknown output state.
[0007] By freezing the model parameters and native post-processing conditions of the target detection model, and obtaining candidate intermediate data before performing native post-processing, and then performing post-processing reconstruction and consistency verification on the candidate intermediate data, the candidate reachable state and the final unknown output state are determined after the verification is passed. This allows the limited links of the unknown defect detection capability to be divided into candidate stage and final output stage without changing the running state of the model to be evaluated, providing a verifiable diagnostic basis for model improvement.
[0008] In some embodiments of the present invention, the data acquisition step further includes: The qualification verification image is input into the target detection model for forward computation. The target detection model outputs reference candidate boxes, bounding box regression values, classification responses, and class probabilities through its detection head. The reference candidate boxes are then subjected to regression transformation based on the bounding box regression values to obtain regression candidate boxes. A candidate source index is established based on the row-by-row correspondence between the reference candidate box, the regression candidate box, the classification response, and the category probability; Before the target detection model performs native post-processing, the reference candidate box, the regression candidate box, the classification response, the category probability, and the candidate source index are used as the candidate intermediate data.
[0009] By outputting reference candidate boxes, bounding box regression values, classification responses, and class probabilities through the detection head, and obtaining regression candidate boxes through regression transformation, a candidate source index is established. This fully preserves the key intermediate quantities and their corresponding relationships in the candidate generation process, enabling subsequent reconstruction to faithfully reproduce the original candidate data without re-performing the forward computation, and providing a data foundation for determining the reachability of candidates.
[0010] In some embodiments of the present invention, the reconstruction detection step specifically includes: Based on the original post-processing conditions, the regression candidate boxes and the category probabilities in the candidate intermediate data are filtered to obtain the filtered candidate boxes. Select candidate boxes corresponding to each category from the filtered candidate boxes to obtain category candidate boxes. Then, deduplicate the category candidate boxes to obtain deduplicated candidate boxes. The deduplicated candidate boxes are sorted and truncated to obtain the retained candidate boxes and the corresponding reconstruction detection scores and reconstruction category labels of the retained candidate boxes; The coordinates of the retained candidate boxes are restored and the output is encapsulated to obtain the reconstruction detection boxes. The reconstruction detection boxes, the reconstruction detection scores, and the reconstruction category labels constitute the reconstruction detection results.
[0011] By filtering regression candidate boxes and class probabilities according to the original post-processing conditions, selecting class boxes, deduplicating results, sorting and truncating results, restoring coordinates, and encapsulating output, detection results consistent with the original post-processing path are reconstructed based on the candidate intermediate data. This enables the reconstructed detection results to be used for consistency verification and provides a reliable basis for judging the final unknown output state.
[0012] In some embodiments of the present invention, the consistency verification step specifically includes: The qualification verification image is subjected to native forward computation to obtain native candidate boxes, native classification responses, and native regression values; wherein, the native forward computation and the native forward computation for obtaining the candidate intermediate data are the same native forward computation. Based on the native classification response and the native regression, the native candidate boxes are subjected to native post-processing to obtain native detection boxes, native detection scores and native category labels; The native detection bounding box, the native detection score, and the native category label are used as the native detection result.
[0013] By performing native forward computation on the qualification verification image and native post-processing on the native candidate boxes based on the native classification response and native regression, the native detection boxes, native detection scores, and native category labels are obtained. This clarifies the source and composition of the native detection results, enabling them to be compared item by item with the reconstructed detection results, thus providing a benchmark for consistency verification.
[0014] In some embodiments of the present invention, the consistency verification step further includes: The original detection results and the reconstructed detection results are arranged according to a preset sorting rule to obtain an original ordered result sequence and a reconstructed ordered result sequence, and an item-by-item correspondence between the original ordered result sequence and the reconstructed ordered result sequence is established. Based on the item-by-item correspondence, comparison terms are determined between the original ordered result sequence and the reconstructed ordered result sequence. The differences between the items in the comparison terms are compared to obtain the consistency verification result.
[0015] By arranging the original detection results and reconstructed detection results according to preset sorting rules, establishing a correspondence between each item, and obtaining consistency verification results based on the comparison of differences in the comparison items, it is possible to eliminate the interference of differences in candidate acquisition, persistence, and post-processing on the diagnostic conclusions, and ensure that subsequent phased diagnosis is based on the reconstruction results faithfully reflecting the original reasoning.
[0016] In some embodiments of the present invention, the consistency verification step further includes: Based on the item-by-item correspondence, determine the item-by-item corresponding result entries between the original ordered result sequence and the reconstructed ordered result sequence, and count the number of results; The evaluation metrics for the original detection results and the reconstructed detection results are calculated respectively, and the comparison items are obtained based on the evaluation metrics, the result items, and the number of results; If none of the differences in the comparison items exceed the preset tolerance, the consistency verification result is determined to be verified as passed. If any difference in the comparison items exceeds the corresponding preset tolerance, the consistency verification result is determined to be a verification failure.
[0017] By identifying and counting the corresponding result items, calculating evaluation indicators, obtaining comparison items based on evaluation indicators, result items, and quantities, and determining that the verification is passed when the difference does not exceed the preset tolerance, a quantifiable judgment standard is provided for consistency verification, thereby improving the objectivity and verifiability of reconstruction fidelity judgment.
[0018] In some embodiments of the present invention, the phased diagnostic steps specifically include: Spatial matching is performed between the ground truth bounding box of the unknown defect and the regression candidate bounding box in the candidate intermediate data to obtain the first spatial overlap degree; If there is a regression candidate box in the candidate intermediate data whose first spatial overlap with the unknown defect real box reaches a preset overlap threshold, then the value of the candidate reachable state is the first value. If there is no regression candidate box in the candidate intermediate data whose first spatial overlap with the true unknown defect box reaches a preset overlap threshold, then the value of the candidate reachable state is the second value.
[0019] By spatially matching the ground truth bounding box of the unknown defect with the regression candidate bounding box in the intermediate candidate data, and determining the reachability of the candidate based on whether there is a regression candidate bounding box that reaches a preset overlap threshold, it is possible to determine whether the unknown defect has been effectively spatially covered before the final result is selected, thus providing a basis for distinguishing between insufficient candidates and candidates that have been covered.
[0020] In some embodiments of the present invention, the staged diagnostic steps further include: The unknown defect real bounding box is spatially matched with the detection box in the reconstructed detection result to obtain the second spatial overlap degree; If the reconstruction detection result contains a detection box whose second spatial overlap with the real unknown defect box reaches a preset overlap threshold and satisfies the pre-frozen unknown determination condition, then the value of the final unknown output state is the first value. If there is no detection box in the reconstructed detection result that has a second spatial overlap with the real unknown defect box that reaches a preset overlap threshold and satisfies the pre-frozen unknown determination conditions, then the value of the final unknown output state is the second value.
[0021] By spatially matching the actual bounding boxes of unknown defects with the bounding boxes in the reconstructed detection results, and determining the final unknown output state based on whether there are bounding boxes that reach a preset overlap threshold and meet the pre-frozen unknown judgment conditions, it is possible to determine whether unknown defects form unknown output in the final output, providing a basis for distinguishing between unknown output that has not formed and unknown output that has formed.
[0022] In some embodiments of the present invention, the staged diagnostic steps further include: If the value of the candidate reachable state is the second value, then the phased diagnosis result is insufficient candidates; If the value of the candidate reachable state is the first value and the value of the final unknown output state is the second value, then the phased diagnosis result is that the candidate has been covered but no unknown output has been formed. If the value of the candidate reachable state is the first value and the value of the final unknown output state is the first value, then the phased diagnosis result is candidate coverage and an unknown output is formed.
[0023] By determining the combination of candidate reachable state and final unknown output state, three types of diagnostic results are identified: insufficient candidates, candidates covered but no unknown output is formed, and candidates covered and unknown output is formed. This allows the limited detection capability stage to be clearly located in the candidate generation stage or the unknown identification stage, providing clear and verifiable diagnostic conclusions for subsequent targeted improvements.
[0024] Some embodiments of the present invention further provide an unknown defect candidate reconstruction diagnostic system, including: The model freezing module is used to obtain the target detection model to be evaluated, freeze the model parameters and original post-processing conditions of the target detection model, and obtain the frozen running conditions. The data acquisition module is used to acquire the qualification verification image and the ground truth bounding box annotation information of the unknown defects therein. Under the frozen running condition, the qualification verification image is input into the target detection model for native forward computation, and candidate intermediate data is acquired before the target detection model performs native post-processing. The reconstruction detection module is used to perform post-processing reconstruction on the candidate intermediate data based on the original post-processing conditions to obtain the reconstruction detection result; The consistency verification module is used to obtain the original detection result of the qualification verification image obtained by the target detection model based on the frozen running conditions, and to perform consistency verification between the reconstructed detection result and the original detection result to obtain the consistency verification result; The phased diagnosis module is used to determine the candidate reachability state of the unknown defect real box in the unknown defect real box annotation information based on the candidate intermediate data after determining that the consistency verification result is verified as passed, determine the final unknown output state of the unknown defect real box based on the reconstruction detection result, and determine the phased diagnosis result based on the candidate reachability state and the final unknown output state. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A flowchart illustrating a method for diagnosing unknown defect candidate reconstructions provided in an embodiment of the present invention; Figure 2 A flowchart of another unknown defect candidate reconstruction diagnosis method provided in an embodiment of the present invention; Figure 3 This invention provides a flowchart for obtaining candidate intermediate data and post-processing reconstruction. Figure 4 A flowchart of a consistency verification step provided in an embodiment of the present invention; Figure 5 A flowchart of a phased diagnostic procedure is provided as an embodiment of the present invention; Figure 6 This is a structural diagram of an unknown defect candidate reconstruction diagnostic system provided in an embodiment of the present invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of this application clearer, the application is described and illustrated below with reference to 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. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0028] It should be noted that the terminology used herein is for the purpose of describing particular implementations only and is not intended to limit the exemplary implementations according to this application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. Furthermore, it should be understood that the terms “comprising” and “having”, and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such process, method, product, or apparatus.
[0029] Industrial vision inspection systems typically use target detection models to locate and classify defects on product surfaces. In open-world industrial inspection scenarios, new defects that were not supervised during the training phase may appear during actual production or inspection. Therefore, in addition to the known defect detection capabilities, it is also necessary to evaluate the model's ability to locate candidates for unseen defect areas and its ability to output unknown categories. For a typical target detection model, the detection head first forms candidate bounding boxes, category responses, and related intermediate quantities. Then, it undergoes post-processing operations such as score filtering, category box selection, non-maximum suppression, candidate number limitation, and coordinate restoration to obtain the final detection result. Existing evaluation methods typically rely directly on final average precision, recall, or open set evaluation metrics to characterize the overall performance of the model. However, whether the unknown defects have been effectively covered in the candidate stage and whether they form an unknown output in the final detection results are two different technical aspects. On the other hand, when performing reconstruction analysis based on the saved intermediate candidate data of the detector, if the acquisition time, saved content or result selection conditions of the candidate data are inconsistent with the original inference path, the analysis results may not accurately reflect the true operating status of the model to be evaluated. In existing technologies, relying solely on the final unknown defect detection index makes it difficult to determine whether the performance limitation mainly stems from the candidate localization stage or from the unknown identification, sorting, or background suppression stage after candidate formation. When reconstructing and analyzing candidate intermediate data, if there is a lack of strict consistency constraints between the reconstruction results and the original detection results, it is difficult to rule out the impact of differences in candidate acquisition, data persistence, and post-processing on the diagnostic results. Different detection models have different score selection, non-maximum suppression, and candidate number restriction methods. The post-processing process needs to be reconstructed under the fixed operating conditions of the same model to be evaluated in order to conduct a comparable staged analysis of the candidate coverage ability and the final unknown identification ability.
[0030] Where there is no conflict, the embodiments and features in the embodiments of the present invention can be combined with each other.
[0031] The technical solution of the present invention will be described in detail below with reference to specific embodiments and accompanying drawings.
[0032] like Figure 1 and Figure 2 As shown, the present invention provides a method for diagnosing unknown defect candidate reconstructions, comprising: Model freezing step S1: Obtain the target detection model to be evaluated, freeze the model parameters and original post-processing conditions of the target detection model, and obtain the frozen running conditions; Furthermore, the target detection model to be evaluated is an industrial defect detection model that has been trained and whose parameters are no longer updated. Its model structure can be a two-stage detection model, a one-stage detection model, or a query-based detection model. As long as it can output candidate intermediate quantities such as candidate bounding boxes, category responses, category probabilities, and bounding box regression values in the forward computation, and can output the final detection results according to its own native post-processing path, it is acceptable. Freezing model parameters means fixing all weights and biases of the target detection model so that it does not participate in training or reverse update during a diagnosis process. This ensures that the model state on which the original forward computation and candidate intermediate data acquisition are based is unique and reproducible. Freezing conditions include not only the frozen model parameters, but also numerical accuracy, software operating environment, image preprocessing method and original post-processing conditions. Among them, numerical precision refers to the floating-point or fixed-point calculation precision used in model inference, software operating environment refers to the deep learning framework, operator library, hardware driver and operating system on which model inference depends, and image preprocessing method refers to the scaling, cropping, filling, normalization and channel conversion operations used when transforming the original qualification verification image into the model input image, as well as the corresponding inverse transformation relationship. The inverse transformation relationship is used to restore the candidate box coordinates in the model input coordinate system to the original image coordinate system in the subsequent process. The native post-processing conditions refer to the fixed conditions on which the target detection model selects and restores the final result of the candidate intermediate quantities output by the detection head in its native inference path. These conditions include at least one of the following: score threshold, category box selection rules, non-maximum suppression or equivalent result selection parameters, candidate number limit, deterministic ranking rules, and coordinate restoration rules. The score threshold is used to filter class probabilities or classification responses; the class box selection rule is used to select candidate boxes of the corresponding class from the filtered candidates based on whether the model uses class-related regression or class-independent regression; the non-maximum suppression or equivalent result selection parameter is used to remove duplicate candidate boxes of the same class. When the model does not use non-maximum suppression, its native equivalent result selection operation or identity operation is used instead; the candidate number limit is used to sort the deduplicated candidate boxes and truncate the final candidates. Its specific form is Top-K limit; the deterministic ranking rule is used to perform deterministic ranking of candidate boxes; the coordinate restoration rule is used to restore the coordinates of candidate boxes in the model input coordinate system to the original image coordinate system and only performs inverse transformation on the geometric transformation in image preprocessing without inverting other running conditions such as the score threshold and non-maximum suppression parameter. The aforementioned model parameters, numerical accuracy, software operating environment, image preprocessing methods, and original post-processing conditions together constitute the frozen operating conditions and remain unchanged during the same diagnostic process. This provides the same set of operating benchmarks for the acquisition of candidate intermediate data, post-processing reconstruction, and acquisition of original detection results, enabling the reconstructed detection results to be compared with the original detection results under the same conditions, ensuring consistency verification and the verifiability of phased diagnostic conclusions. If the model parameters or native post-processing conditions change during the diagnosis process, the saved candidate intermediate data will no longer correspond to the current model state, and the reconstructed detection results will not faithfully reflect the native inference results. Therefore, freezing the running conditions is a prerequisite for the subsequent steps to be valid.
[0033] Data acquisition step S2: Obtain the qualification verification image and the ground truth bounding box annotation information of the unknown defects in it. Under the frozen running condition, input the qualification verification image into the target detection model for native forward calculation, and acquire and persistently save the candidate intermediate data before the target detection model performs native post-processing. In some embodiments, the data acquisition step S2 specifically includes: The qualification verification image is input into the target detection model for forward computation. The target detection model outputs reference candidate boxes, bounding box regression values, classification responses, and class probabilities through its detection head. The reference candidate boxes are then subjected to regression transformation based on the bounding box regression values to obtain regression candidate boxes. A candidate source index is established based on the row-by-row correspondence between reference candidate boxes, regression candidate boxes, classification responses, and class probabilities. Before performing native post-processing on the object detection model, reference candidate boxes, regression candidate boxes, classification responses, class probabilities, and candidate source indices are used as candidate intermediate data.
[0034] By outputting reference candidate boxes, bounding box regression values, classification responses, and class probabilities through the detection head, and obtaining regression candidate boxes through regression transformation, a candidate source index is established. This fully preserves the key intermediate quantities and their corresponding relationships in the candidate generation process, enabling subsequent reconstruction to faithfully reproduce the original candidate data without re-performing the forward computation, and providing a data foundation for determining the reachability of candidates.
[0035] Furthermore, obtain the qualification verification image and the ground truth bounding box annotation information of the unknown defects in it. This can be obtained directly from the existing qualification verification dataset, or it can be constructed by leaving out the defect category. When constructing the model by leaving out defect categories, a category is selected from the defect category set as the left-out defect category, so that the left-out defect category does not participate in the training label, training supervision, hyperparameter selection and model weight selection of the target detection model; For training images with paired defect-free template images, the corresponding regions in the template images can be used to replace the defective regions and the corresponding training annotations can be removed. The above processing is used to form the qualification verification conditions for the retention category. During qualification verification, images containing the unknown defects to be verified and their ground truth bounding box annotations are used for spatial matching and diagnosis. The qualification verification data, the detection model to be evaluated, and the frozen operating conditions jointly determine a diagnostic process. The expression for the qualification verification dataset is:
[0036] in, The sequence number of the qualification verification image; For the first A qualification verification image; To and The set of unknown defect ground truth boxes in the corresponding unknown defect ground truth box annotation information; The number of images required for qualification verification; The target detection model to be evaluated is denoted as ,in These are the frozen model parameters; The conditions for freezing operation are denoted as At least the following conditions are included: numerical accuracy and software operating environment, image preprocessing method, score threshold, category box selection rules, non-maximum suppression or equivalent result selection parameters, candidate number limit, deterministic sorting rules and coordinate recovery rules. These conditions remain unchanged during the diagnostic process, so that the acquisition, reconstruction and consistency verification of subsequent candidate intermediate data are all carried out under the same operating benchmark. Before selecting the final result, the object detection model will generate multiple candidate entries in the output of the detection head. A candidate entry can be understood as a preliminary candidate given by the detection head for the location of a possible target in the qualification verification image. It corresponds to at least one reference candidate box, a set of classification responses and a set of bounding box regressions. For the A qualification verification image is generated by the object detection model before the final result selection. The candidate entry, the first The candidate entries satisfy ; The classification response and class probability are the results of the detection head's judgment on whether a candidate item belongs to each class. To represent these classes, the object detection model has a set of output labels. ; The output tag set should include at least the following: Known categories and background categories When the object detection model has an explicitly unknown category, it also includes the unknown category. ; Known categories refer to the defect categories that participate in supervised learning during the training phase; background categories refer to the categories that indicate that the candidate position does not belong to any detection target; unknown categories refer to the categories used to represent the unknown in the model output label set, or categories that are determined to be unknown by a pre-frozen unknown decision function. The purpose of the output label set is to provide a classification response and class probability for each candidate item in each category, thereby providing a basis for subsequent score filtering and class box selection; like Figure 3 As shown, the classification response is the raw value directly output by the detector head, while the class probability is the value obtained after normalizing the classification response. For the implementation using Softmax classification, the class probability is calculated as follows:
[0037] in, For the first The first qualification verification image Candidate entries in category Classification response on For this candidate entry in category The class probability on; When using Sigmoid, energy score, or other classification methods, the Softmax formula mentioned above is not used. Instead, the model's original response and its fixed transformation rules are preserved so that the class probabilities can be obtained in a manner consistent with the original path during subsequent reconstruction. Reference candidate boxes and regression candidate boxes are spatial representations of candidate items. The reference candidate boxes corresponding to each candidate item are denoted as follows: It is the candidate box given by the detection head before the regression transformation; The bounding box regression value is denoted as It is the offset given by the detection head to correct the reference candidate box; the frozen bounding box transformation function. Regression transformation is performed on the reference candidate box and bounding box regressors to obtain the regression candidate boxes. Its expression is:
[0038] Reference candidate boxes are mainly used to trace the regression source, while regression candidate boxes are candidate boxes after regression correction. In subsequent phased diagnosis, when determining whether the true box of an unknown defect is covered by the candidate box, regression candidate boxes are used instead of reference candidate boxes. The candidate source index is used to maintain a row-by-row correspondence between reference candidate boxes, regression candidate boxes, classification responses, and class probabilities; Because a candidate item corresponds to a reference candidate box, a regression candidate box, a set of classification responses, and a set of class probabilities, if the correspondence between these data is misaligned when saving, the score or class of one candidate box will be used for another candidate box during subsequent reconstruction, resulting in the reconstruction detection results being inconsistent with the original detection results. The candidate source index is used to record this row-by-row correspondence, so that when reading intermediate candidate data later, it can accurately know which set of classification responses and category probabilities belong to which regression candidate box.
[0039] The candidate intermediate data is obtained before the object detection model performs native post-processing. At this time, score threshold filtering, class box selection, non-maximum suppression and Top-K truncation have not yet been performed. Therefore, the candidate intermediate data retains candidate information that has not yet been finally filtered and discarded. For the The qualification verification image, together with the required fields, frozen running conditions, and nullable auxiliary attributes, forms a persistent reconstruction data packet, denoted as:
[0040] in, and These are the sets of reference candidate boxes and the sets of regression candidate boxes, respectively. and These are the classification response matrix and the category probability matrix, respectively; Index for candidate sources; To reconstruct the required frozen operating conditions; This is an optional set of auxiliary attributes; the empty set is used when the target detection model does not have the corresponding attribute. Candidate target scores may be included and feature level For query-based detectors, a query index may also be included; An empty set of optional auxiliary attributes does not affect the completion of the refactoring based on the required fields and the frozen execution conditions; The purpose of persistent reconstruction data packets is to enable candidate intermediate data to self-containedly support subsequent reconstruction after being saved. After reading the data packet, there is no need to re-execute the forward calculation of the target detection model. The original post-processing can be redone based on the required fields and frozen running conditions. In this way, the candidate intermediate data, from the raw candidate information output by the detection head, undergoes the calculation of classification response and category probability, the transformation from reference candidate box to regression candidate box, the establishment of candidate source index, and the encapsulation of persistent data packets, and finally becomes the data foundation that can be directly read and used in subsequent reconstruction detection steps.
[0041] Reconstruction detection step S3: Read the candidate intermediate data, and without repeating the original forward computation of the target detection model, perform post-processing reconstruction on the candidate intermediate data based on the original post-processing conditions to obtain the reconstruction detection result; In some embodiments, the reconstruction detection step S3 specifically includes: Based on the original post-processing conditions, the regression candidate boxes and category probabilities in the candidate intermediate data are filtered to obtain the filtered candidate boxes; Select the candidate boxes corresponding to each category from the filtered candidate boxes to obtain category candidate boxes. Then, remove duplicate candidate boxes from the category candidate boxes to obtain duplicate candidate boxes. The deduplicated candidate boxes are sorted and truncated to obtain the retained candidate boxes and their corresponding reconstruction detection scores and reconstruction category labels. The coordinates of the retained candidate boxes are restored and the output is encapsulated to obtain the reconstructed detection boxes. The reconstructed detection boxes, the reconstructed detection scores, and the reconstructed category labels constitute the reconstructed detection results.
[0042] By filtering regression candidate boxes and class probabilities according to the original post-processing conditions, selecting class boxes, deduplicating results, sorting and truncating results, restoring coordinates, and encapsulating output, detection results consistent with the original post-processing path are reconstructed based on the candidate intermediate data. This enables the reconstructed detection results to be used for consistency verification and provides a reliable basis for judging the final unknown output state.
[0043] Furthermore, the forward computation of the object detection model includes feature extraction and detection head computation. When the object detection model includes a region proposal module, the forward computation also includes region proposal computation. The candidate intermediate data in these computation results has been persistently saved. Therefore, feature extraction, detection head forward computation and region proposal computation are no longer repeatedly executed. Instead, the saved candidate intermediate data is directly read and post-processing reconstruction is performed on it according to the post-processing conditions consistent with the original inference path. The purpose of this is to avoid the additional computational overhead and runtime differences caused by repeated forward computation, while ensuring that the reconstructed detection results are obtained on the same candidate data and can be meaningfully compared with the original detection results; The post-processing reconstruction is based on the original post-processing conditions in the frozen running conditions. The original post-processing conditions include at least one of the following: score threshold, category box selection rules, non-maximum suppression or equivalent result selection parameters, candidate number limit, sorting rules, and coordinate recovery rules. During post-processing reconstruction, the background category is first removed from the output label set to obtain the non-background detection category set. Its expression is:
[0044] Then, on the non-background detection category set, the category probabilities in the candidate intermediate data are filtered by score according to the fixed score threshold in the frozen running conditions; For the The qualification verification image is denoted as the category probability matrix. The fixed score threshold is denoted as The filtered candidate set can be represented as:
[0045] in, The set of filtered candidate boxes is selected by retaining only those candidate entries whose class probability in a certain non-background detection category reaches a fixed score threshold, and candidate entries that do not reach the threshold are not included in the subsequent class box selection; After obtaining the filtered candidate set, select the candidate boxes corresponding to each category from the filtered candidates according to the category box selection rules in the frozen running conditions. The category box selection rules vary depending on whether the object detection model uses class-related regression or class-independent regression. When the object detection model uses category-related regression, each category corresponds to a set of regression candidate boxes, and the category box selection rule selects the candidate box corresponding to the category from the regression candidate boxes of that category; When the object detection model uses class-independent regression, multiple classes share the same set of regression candidate boxes, and the class box selection rule selects the candidate box corresponding to the corresponding class from the shared regression candidate boxes; For the Image for qualification verification, number 1 The regression candidate boxes corresponding to each candidate item are denoted as follows: The category selection box can be represented as:
[0046] in, For the first Candidate entries in category The selected category candidate box below, This represents a fixed selection function in the freeze execution conditions; By selecting candidate boxes for deduplication in the subsequent results from the remaining candidate items after filtering, according to their corresponding categories; After obtaining the candidate boxes for each category, for each detection category, the filtered candidate boxes and the corresponding detection scores are input into the same category or batch non-maximum suppression program as the original path to obtain the suppressed set for that category. For the Image for qualification verification, number 1 The suppressed set of each detection category is denoted as This process can be represented as:
[0047] in, This indicates a nonmaximum suppression procedure; This represents the non-maximum suppression parameter in the freeze operation conditions; When the object detection model does not use nonmaximum suppression, the above nonmaximum suppression is replaced by its native equivalent result selection operation or identity operation; by deduplicating overlapping candidate boxes under the same category, only the most representative candidate boxes are retained to avoid the same target being output repeatedly; After obtaining the suppressed sets for each detection category, the union of the suppressed sets for each detection category within the category index range is calculated to form the deduplicated candidate boxes. These candidate boxes are then sorted according to the deterministic sorting rules in the freeze-run conditions, and the top K final candidates are truncated according to the candidate quantity limit in the freeze-run conditions to obtain the set of retained candidate boxes. This process can be represented as:
[0048] in, Indicates the first The set of candidate bounding boxes retained after sorting and cropping in a qualification verification image; This indicates a limit on the number of candidates in the freeze operation conditions; The set of candidate boxes retained is used to reconstruct the final detection result. It is different from the set of candidate boxes used to determine the reachability of candidates in the phased diagnosis. The latter is the set of candidate coverage formed from the regression candidate boxes before post-processing reconstruction, while the former is the set of candidate boxes retained after score filtering, class box selection, result deduplication, sorting and truncation. After obtaining the set of candidate boxes to be retained, coordinate restoration and output encapsulation consistent with the original path are performed on the candidate boxes to obtain the reconstructed detection entries in the original image coordinate system. The coordinate restoration is based on the coordinate restoration rules in the frozen running conditions, which are then set to... This represents the geometric preprocessing transformation of the nth image, mapping it from the original image coordinate system to the model input coordinate system. Conditions for freezing operation ; Coordinate recovery only applies to Perform the inverse transformation without inverting other operating conditions such as the fractional threshold and nonmaximum suppression parameter; For the The coordinate restoration of the retained candidate boxes corresponding to each candidate item can be expressed as:
[0049] in, The coordinates of the detection box after restoring it to the original image coordinate system; Geometric preprocessing transformation inverse transform; For implementations that only scale the width and height without cropping or padding, the four coordinates can be restored according to the ratio of the original image width and height to the model input width and height; If it involves fill, clipping, or other geometric transformations, then use geometric preprocessing transformations. inverse transform Restore coordinates; After coordinate restoration, the restored detection bounding boxes, detection scores, and class labels are encapsulated as the reconstructed detection bounding boxes, reconstructed detection scores, and reconstructed class labels, respectively, to obtain the first... Reconstruction detection results of a qualification verification image; Following the steps described above, the first step can be obtained without re-performing the forward calculation of the object detection model. The reconstructed detection results of the qualification verification image are used for subsequent consistency verification with the original detection results, and to provide a basis for judging the final unknown output state.
[0050] Consistency verification step S4: Based on the frozen running conditions, obtain the original detection results of the qualification verification image obtained by the target detection model, and perform consistency verification between the reconstructed detection results and the original detection results to obtain the consistency verification results; In some embodiments, the consistency verification step S4 specifically includes: The qualification verification image is subjected to native forward computation to obtain native candidate boxes, native classification responses, and native regression values; wherein, the native forward computation and the native forward computation to obtain the candidate intermediate data are the same native forward computation. Based on the native classification response and native regression, the native candidate boxes are post-processed to obtain the native detection boxes, native detection scores and native category labels. The native detection bounding box, native detection score, and native category label are used as the native detection result.
[0051] By performing native forward computation on the qualification verification image and native post-processing on the native candidate boxes based on the native classification response and native regression, the native detection boxes, native detection scores, and native category labels are obtained. This clarifies the source and composition of the native detection results, enabling them to be compared item by item with the reconstructed detection results, thus providing a benchmark for consistency verification.
[0052] Furthermore, the native detection result is the final detection result obtained after performing full native inference on the qualification verification image under frozen running conditions. The full native inference mentioned here means that the target detection model performs native forward computation and then performs native post-processing according to its own native inference path, rather than just reading the saved candidate intermediate data and redoing the post-processing. Native forward computation includes feature extraction and detection head computation. When the target detection model includes a region proposal module, it also includes region proposal computation. After the native forward computation is completed, the detection head outputs native candidate boxes, native classification responses, and native regression values. These values are the inputs to the native post-processing. The native post-processing then performs score filtering, class box selection, non-maximum suppression or equivalent result selection, candidate number limitation, sorting, and coordinate restoration on the native candidate boxes, native classification responses, and native regression values in accordance with the native post-processing conditions in the frozen running conditions. Finally, the native detection boxes, native detection scores, and native class labels are obtained. The native candidate boxes, native classification responses, and native regression values correspond to the reference candidate boxes, regression candidate boxes, classification responses, and bounding box regression values in the candidate intermediate data in the native inference path, respectively. In other words, the candidate intermediate data is truncated and saved after the native forward computation and before the native post-processing, while the native inference path continues to complete the native post-processing to obtain the native detection results. Both use the results of the same native forward computation, the difference being that one is saved before post-processing and the other is output after post-processing. Therefore, the original detection results and the reconstructed detection results have the same candidate source. The only difference is that the reconstructed detection results are obtained by reprocessing the saved intermediate candidate data, while the original detection results are obtained by reprocessing the original inference path after it is executed normally. The original post-processing is executed according to the original post-processing conditions in the frozen running conditions. Its operation content is the same as that of post-processing reconstruction, including at least one of the following: score filtering, category box selection, result deduplication, candidate number limitation, sorting, and coordinate restoration. The difference lies in the execution object. The object of the original post-processing is the original candidate box, original classification response, and original regression value directly output by the original forward computation, while the object of the post-processing reconstruction is the regression candidate box and category probability in the saved candidate intermediate data. Since both are based on the same set of original post-processing conditions and the candidate source is the same, if the acquisition time, saved content, and result selection conditions of the candidate intermediate data are consistent with the original inference path, then the reconstructed detection result should be the same as the original detection result or have a very small error. The native detection results are composed of the native detection bounding boxes, the native detection scores, and the native category labels. The native detection bounding boxes are the detection boxes in the original image coordinate system obtained after coordinate restoration and output encapsulation in the native post-processing. The native detection scores are the detection scores retained along with the candidate boxes in the native post-processing. The native category labels are the category labels retained along with the candidate boxes in the native post-processing. These three are used as the native detection results.
[0053] In some embodiments, the consistency verification step S4 further includes: Based on the preset sorting rules, the original detection results and the reconstructed detection results are arranged separately to obtain the original ordered result sequence and the reconstructed ordered result sequence, and a one-to-one correspondence between the original ordered result sequence and the reconstructed ordered result sequence is established; Based on the item-by-item correspondence, the comparison terms between the original ordered result sequence and the reconstructed ordered result sequence are determined. The differences between the items in the comparison terms are compared to obtain the consistency verification results.
[0054] By arranging the original detection results and reconstructed detection results according to preset sorting rules, establishing a correspondence between each item, and obtaining consistency verification results based on the comparison of differences in the comparison items, it is possible to eliminate the interference of differences in candidate acquisition, persistence, and post-processing on the diagnostic conclusions, and ensure that subsequent phased diagnosis is based on the reconstruction results faithfully reflecting the original reasoning.
[0055] In some embodiments, the consistency verification step S4 further includes: Based on the item-by-item correspondence, the item-by-item correspondence between the original ordered result sequence and the reconstructed ordered result sequence is determined, and the number of results is counted. Evaluation metrics for the original detection results and the reconstructed detection results are calculated separately. Based on the evaluation metrics, result items, and number of results, comparison items are obtained. If none of the differences in the comparison items exceed the preset tolerance, the consistency verification result is determined to be successful. If any difference in the comparison items exceeds the corresponding preset tolerance, the consistency verification result is determined to be a verification failure.
[0056] By identifying and counting the corresponding result items, calculating evaluation indicators, obtaining comparison items based on evaluation indicators, result items, and result quantities, and determining that the verification is passed when the difference does not exceed the preset tolerance, a quantifiable judgment standard is provided for consistency verification, thereby improving the objectivity and verifiability of reconstruction fidelity judgment.
[0057] Furthermore, such as Figure 4 As shown, the preset sorting rules are used to arrange the original detection results and the reconstructed detection results into ordered result sequences, and to establish a one-to-one correspondence between the two. For the The qualification verification image, the original detection results and the reconstructed detection results are denoted as the original ordered result sequence. and reconstructed ordered result sequence ,in , These represent the number of results for the two paths, respectively. and These represent the first two paths respectively. One result item, The result number is... and Each consists of a bounding box, a detection score, and a class label, namely:
[0058]
[0059] in, The first in the original detection results The native detection bounding box of each result; The first in the original detection results The native detection score of each result; The first in the original detection results The original category label of each result; To reconstruct the detection results of the first Reconstructed detection boxes for each result; To reconstruct the detection results of the first The reconstruction detection score of each result; To reconstruct the detection results of the first Reconstructed category labels for each result; The two sets of results are arranged according to the same deterministic ranking rule, which includes at least one of the following: descending order of detection scores, order of category labels, and order of bounding box coordinates. After the arrangement is completed, a correspondence is established item by item in sequence, so that the first item in the original detection results is... The result and the first in the reconstruction detection result The results correspond to each other; Item-by-item comparison is performed only after the number of results in the two paths is consistent and a deterministic correspondence is established. If the number of results is inconsistent, a complete item-by-item correspondence cannot be established, and the consistency verification result is directly judged as verification failure. The comparison items include at least one of the following: number of results, label sequence, bounding box coordinates, detection score, and evaluation metric; where the number of results refers to the number of results contained in the original ordered result sequence and the reconstructed ordered result sequence respectively. The label sequence refers to the category label sequence in the original ordered result sequence and the category label sequence in the reconstructed ordered result sequence after being arranged according to a preset sorting rule; Bounding box coordinate differences refer to the differences between corresponding result items in the original detection results. The original detection bounding box of the first result and the reconstructed detection result of the second result The coordinate differences between the reconstructed detection boxes of each result; The difference in detection scores refers to the difference between the corresponding result items in the original detection results. The original detection score of the first result and the reconstructed detection score of the second result The difference between the reconstruction detection scores of the results; Evaluation metrics refer to the index vectors calculated using the same qualification verification real annotation and the same evaluation procedure for both the original detection results and the reconstructed detection results; Regarding evaluation indicators, and These represent the evaluation index vectors for the original detection results and the reconstructed detection results, respectively. and For the first Items, Take 1 to The selected indicators and their calculation methods are frozen before diagnosis, that is:
[0060]
[0061] in, The first element in the evaluation index vector representing the original detection result Item; The first element in the evaluation index vector representing the reconstructed detection results is... Item; Indicates the serial number of the evaluation indicator; This indicates the total number of evaluation indicators; and All were calculated using the same qualification verification and the same evaluation procedure, and the selected indicators and their calculation methods were frozen before diagnosis. Evaluation metrics may include at least one of recall, average precision, or open set evaluation metrics. The specific metrics to be selected and how to calculate them shall be determined in advance before reading the eligibility verification results and remain unchanged in the same diagnosis. The differences in each item in the comparison section are calculated according to the corresponding error metric, including the bounding box error. Detection score error and evaluation index error The maximum absolute error of the corresponding values of the two paths or a pre-defined equivalent error metric are used for calculation, namely:
[0062]
[0063]
[0064] in, This indicates taking the maximum absolute value of the differences between the coordinates of the bounding box; Indicates taking the absolute value; For each qualification verification image, extract the corresponding bounding boxes from the original detection results and the reconstructed detection results, and compare their bounding box coordinate differences. This includes all images and all corresponding results. Then, take the largest absolute value among these coordinate differences; this maximum value is the bounding box error. It reflects the most severe inconsistency between the reconstructed detection box and the original detection box in terms of spatial location; For each qualification verification image, extract the corresponding detection scores from the original detection results and the reconstructed detection results, compare their score differences, including all images and all corresponding results, and then take the largest absolute value among these score differences. This maximum value is the detection score error. It reflects the most severe inconsistency in detection scores between the reconstructed detection results and the original detection results; Compare the differences between the corresponding evaluation index vectors of the original detection results and the reconstructed detection results, and take the largest absolute value of these differences; this maximum value is the evaluation index error. It reflects the most severe inconsistency between the reconstructed detection results and the original detection results in terms of overall evaluation metrics; If any difference exceeds the tolerance, it can be detected, thus avoiding the masking of local inconsistencies due to a small average error; In other embodiments, a predefined equivalent error metric, such as mean squared error, mean absolute error, or other metrics that can characterize the difference between the two paths, can be used, as long as the metric is frozen before diagnosis and remains unchanged in the same diagnosis. The consistency verification results are represented by a consistency flag. A consistency flag is set when the number of results and the label sequence for each qualifying verification image are consistent, and the bounding boxes, detection scores, and evaluation index errors of all images do not exceed their respective preset tolerances. A value of 1 indicates that the consistency verification result is successful; if any condition is not met, the command is executed. A value of 0 indicates that the consistency verification result has failed. This judgment can be expressed as:
[0065] in, This indicates that all qualified images are valid; This indicates a logical AND operation. , and These are the consistency tolerances for the bounding box, detection score, and evaluation metrics, all of which are frozen before diagnosis. The consistency flag is 1 only when the number of results for all images is consistent, the label sequence for all images is consistent, and the bounding box error does not exceed the bounding box tolerance, the detection score error does not exceed the detection score tolerance, and the evaluation index error does not exceed the evaluation index tolerance; if any of the above conditions are not met, the consistency flag is 0. Item-by-item comparison is only performed after the quantities are consistent and a definite correspondence is established. If the quantities are inconsistent, no further item-by-item comparison will be performed, and the verification will be directly judged as a failure. The consistency flag determines whether subsequent phased diagnosis can be carried out. When the consistency flag is equal to 1, phased diagnosis is allowed to be carried out using the corresponding candidate intermediate data. This is because at this time, the reconstructed detection result is consistent with the original detection result or the error is within the tolerance. This indicates that the candidate intermediate data can faithfully reproduce the original inference result. The candidate reachable state and the final unknown output state obtained based on the candidate intermediate data are reliable. When the consistency flag is equal to 0, stop using the candidate intermediate data to form a model capability conclusion and output the failure item, because at this time the impact of differences in candidate acquisition, data persistence and post-processing on the diagnostic results cannot be ruled out. If the staged diagnosis is still based on the candidate intermediate data, an incorrect diagnostic conclusion may be obtained. Failure items can include at least one of the following: inconsistent number of results, inconsistent label sequence, bounding box error exceeding the tolerance, detection score error exceeding the tolerance, and evaluation index error exceeding the tolerance. The purpose of outputting failure items is to facilitate the location of the source of inconsistency in reconstruction and to provide a basis for subsequent correction of the acquisition time, content to be saved, or result selection conditions of candidate intermediate data. It should be noted that the quantity and label requirements are completely consistent. The bounding box, detection score, and evaluation metric tolerance are preset according to the numerical accuracy. The tolerance is only used to judge the reconstruction fidelity and is not used to adjust the detection performance of the model to be evaluated, so as to avoid confusing the reconstruction consistency judgment with the model performance evaluation.
[0066] Phased diagnostic step S5: If the consistency verification result is successful, then determine the candidate reachable state of the unknown defect true box in the unknown defect true box annotation information based on the candidate intermediate data, determine the final unknown output state of the unknown defect true box based on the reconstruction detection result, and determine the phased diagnostic result based on the candidate reachable state and the final unknown output state.
[0067] In some embodiments, the phased diagnostic step S5 specifically includes: Spatial matching is performed between the ground truth bounding boxes of unknown defects and the regression candidate bounding boxes in the candidate intermediate data to obtain the first spatial overlap degree; If there is a regression candidate box in the candidate intermediate data whose first spatial overlap with the unknown defect true box reaches a preset overlap threshold, then the value of the candidate reachable state is the first value. If there is no regression candidate box in the candidate intermediate data whose first spatial overlap with the unknown defect true box reaches a preset overlap threshold, then the value of the candidate reachable state is the second value.
[0068] By spatially matching the ground truth bounding box of the unknown defect with the regression candidate bounding box in the intermediate candidate data, and determining the reachability of the candidate based on whether there is a regression candidate bounding box that reaches a preset overlap threshold, it is possible to determine whether the unknown defect has been effectively spatially covered before the final result is selected, thus providing a basis for distinguishing between insufficient candidates and candidates that have been covered.
[0069] In some embodiments, the phased diagnostic step S5 further includes: Spatial matching is performed between the ground truth bounding box of the unknown defect and the detection bounding box in the reconstructed detection result to obtain the second spatial overlap degree; If the reconstructed detection result contains a detection box whose second space overlap with the real unknown defect box reaches a preset overlap threshold and satisfies the pre-frozen unknown judgment condition, then the final unknown output state value is the first value. If there is no detection box in the reconstructed detection result that overlaps with the real unknown defect box in the second space to a preset overlap threshold and meets the pre-frozen unknown judgment conditions, then the final unknown output state value is the second value.
[0070] By spatially matching the actual bounding boxes of unknown defects with the bounding boxes in the reconstructed detection results, and determining the final unknown output state based on whether there are bounding boxes that reach a preset overlap threshold and meet the pre-frozen unknown judgment conditions, it is possible to determine whether unknown defects form unknown output in the final output, providing a basis for distinguishing between unknown output that has not formed and unknown output that has formed.
[0071] In some embodiments, the phased diagnostic step S5 further includes: If the value of the candidate reachable state is the second value, then the phased diagnosis result is insufficient candidates; If the value of the candidate reachable state is the first value and the value of the final unknown output state is the second value, then the phased diagnosis result is that the candidate has been covered but no unknown output has been formed. If the value of the candidate reachable state is the first value and the value of the final unknown output state is the first value, then the phased diagnosis result is candidate coverage and an unknown output is formed.
[0072] By determining the combination of candidate reachable state and final unknown output state, three types of diagnostic results are identified: insufficient candidates, candidates covered but no unknown output is formed, and candidates covered and unknown output is formed. This allows the limited detection capability stage to be clearly located in the candidate generation stage or the unknown identification stage, providing clear and verifiable diagnostic conclusions for subsequent targeted improvements.
[0073] Furthermore, such as Figure 5 As shown, after the consistency verification is passed, spatial matching is performed on the same unknown defect real bounding box in the candidate stage and the final output stage respectively. The ground truth bounding boxes for unknown defects are derived from the ground truth bounding box annotation information for unknown defects. Image for qualification verification, number 1 An unknown defect is realistically framed as follows: ,and The set of ground truth bounding boxes for unknown defects in this image , Take 1 to , Indicates the first The number of unknown defect ground truth bounding boxes in each qualification image, and the sum of the number of unknown defect ground truth bounding boxes in all qualification images is denoted as . ,Right now ; The degree of spatial overlap is determined using the cross-union ratio (CUNR) or a pre-fixed equivalent overlap metric. The CUNR is calculated using the following formula:
[0074] in, Represents candidate boxes or detection boxes participating in spatial matching; Indicates the first An unknown defect in the true frame; express and The area of their intersection; express and The area of the union of the two sets is calculated, and dividing the two gives the intersection-union ratio; the larger the intersection-union ratio, the more likely it is that the union area is larger than the intersection-union area. and The higher the degree of spatial overlap; During the candidate stage, regression candidate boxes from the intermediate candidate data are used as the basis for determining whether unknown defect true boxes are covered. These regression candidate boxes constitute the entire candidate set, denoted as... This is used to determine whether the ground truth bounding box of an unknown defect has spatial reachability in the candidate stage; Since the final output is limited by the number of candidates, to avoid budget inconsistencies caused by using all regression candidate boxes in the candidate stage but using the truncated results in the final output, the regression candidate boxes can be sorted according to the candidate scoring function frozen before diagnosis, and the top K candidate boxes can be selected to form a budget-constrained candidate set, denoted as . ; The candidate scoring function is used to score and rank candidate boxes. It can use at least one of the following: native unknown category probability, target score, or candidate quality score, but remains unchanged in the same diagnosis. For ease of consistent description, the entire candidate set and the budget constraint candidate set will be denoted as... ,in Select a marker for the set; when Pick hour, Represents the complete candidate set At this point, all regression candidate boxes are used for spatial matching, but score ranking and Top-K truncation are not performed; when Pick hour, Represents the candidate set of budget constraints At this point, spatial matching is performed by sorting the candidate boxes by the candidate scoring function and extracting the first K boxes. Spatial matching is performed between the ground truth bounding boxes of unknown defects and the regression candidate bounding boxes in the candidate intermediate data, and the degree of spatial overlap obtained by the matching is taken as the first degree of spatial overlap. For the The first qualification verification image An unknown defect in the real frame If set At least one candidate box is in the middle. If the degree of overlap in the first spatial region reaches a preset overlap threshold, it is determined that the ground truth bounding box of the unknown defect is covered in the candidate stage, and the candidate reachable state is determined. Take the first value as 1; If set There are no candidate boxes in the middle. If the degree of overlap in the first spatial region reaches a preset overlap threshold, it is determined that the ground truth bounding box of the unknown defect is not covered in the candidate stage, and the candidate reachable state is determined. Take the second value as 0; The candidate reachability state is used to indicate whether the unknown defect ground truth box has spatial reachability in the candidate stage. The first value indicates reachability, and the second value indicates inaccessibility. Its calculation can be expressed as:
[0075] in, Indicates the first The first qualification verification image An unknown defect's true bounding box is in the candidate set. Candidate reachable states; Indicates the preset overlap threshold; This indicates that the first value is taken if the condition inside the parentheses is true, and the second value is taken otherwise. The candidate reachability states are calculated separately for each unknown defect ground truth bounding box. To measure the proportion of unknown defects covered in the candidate stage as a whole, the candidate reachability states of the entire image and all unknown defect ground truth bounding boxes are summed and then divided by the total number of unknown defect ground truth bounding boxes. The candidate reachability is obtained; Since candidate reachability can be calculated based on all regression candidate boxes or on the budget-constrained candidate set, the candidate reachability also has two forms. The candidate reachability obtained based on all regression candidate boxes is called the all-candidate reachability, and the candidate reachability obtained based on the budget-constrained candidate set is called the budget-constrained candidate recall. The reachability of a candidate can be expressed as:
[0076] in, Indicates the reachability of candidates. Pick Time represents the reachability of all candidates. Pick The time represents the budget-constrained candidate recall rate; After determining whether the ground truth bounding boxes of unknown defects are covered in the candidate stage, it is also necessary to determine in the final output stage whether the same ground truth bounding box of unknown defects forms an unknown defect output in the reconstructed detection result. Since not all detection boxes in the reconstructed detection result are of the unknown category, an unknown determination function needs to be pre-frozen to determine which detection boxes belong to the unknown output from the reconstructed detection result; The unknown determination function is denoted as ,in This represents a reconstruction detection entry in the reconstruction detection results. The unknown determination function is used to determine whether Y belongs to unknown output based on the model's native and pre-frozen rules. It takes 1 when it is determined to be unknown, and 0 otherwise. The conditions for pre-frozen unknown determination are as follows: for models with explicit unknown categories, the determination is based on the category label; for other models, the determination is based on their native and pre-frozen unknown criteria. The reconstructed detection results already inherit the frozen candidate number limit, so there is no need to re-enforce the candidate number limit. Detection boxes that satisfy the unknown decision function are directly extracted from them to form a subset of unknown labels. ,Right now:
[0077] Among them, the unknown tag subset This represents the set of detection boxes in the reconstructed detection results that satisfy the unknown decision function. Indicates the detection entries from reconstruction. The detection frame extracted from the image; If the tag subset is unknown An empty set indicates that there are no bounding boxes belonging to the unknown category in the reconstructed detection results. In this case, spatial matching is unnecessary, and the final unknown output state of the ground truth bounding box of the unknown defect can be directly determined. The second value is 0; only when the unknown tag subset is used. When the set is not empty, the unknown defect bounding box is spatially matched with the detection box in the set, so there is no problem of taking the maximum value of an empty set; The final unknown output state can be represented as:
[0078] in, Indicates the first The first qualification verification image The final unknown output state of a ground truth bounding box with unknown defects; Spatial matching is performed between the ground truth bounding box of the unknown defect and the detection bounding box in the reconstructed detection result, and the degree of spatial overlap obtained by the matching is used as the second degree of spatial overlap. If set At least one detection box is in the middle. If the overlap in the second space reaches a preset overlap threshold, it indicates that the ground truth bounding box of the unknown defect has matched an unknown category bounding box in the reconstructed detection result, and it is determined that it forms an unknown defect output. Take the first value as 1; if the set Not empty but without any detection boxes If the overlap in the second space reaches a preset overlap threshold, it indicates that the ground truth bounding box of the unknown defect did not match an unknown category bounding box in the reconstruction detection result, and it is determined that no unknown defect output was generated. Take the second value as 0; To measure the proportion of unknown outputs resulting from unknown defects in the final output stage, the final unknown output states of all images and all unknown defect ground truth bounding boxes are summed, and then divided by the total number of unknown defect ground truth bounding boxes. To obtain the final unknown output recall rate ,Right now:
[0079] Add up the final unknown output states of all unknown defect ground truth boxes to get the number of unknown defect ground truth boxes that form unknown defect output in the final output stage. Then divide by the total number of unknown defect ground truth boxes to get the proportion of unknown defect output in the final output stage. If the object detection model does not have a native unknown determination rule that can be frozen, then the indicator is marked as inapplicable, rather than claiming that the model's unknown recognition ability is zero. After obtaining the candidate reachable states and the final unknown output state, the two are combined for phased bottleneck diagnosis; the phased bottleneck diagnosis uses all candidate reachable states. With the final unknown output state Compare; When all candidate reachable states When the value equals 0, it means that the true bounding box of the unknown defect was not covered in the candidate stage. At this time, the phased diagnosis result is determined to be insufficient candidates. When all candidate reachable states Equal to the first value 1 and the final output state is unknown. When the value equals the second value of 0, it means that the unknown defect true bounding box has been covered in the candidate stage, but no unknown output has been formed in the final output stage. At this time, the phased diagnosis result is determined to be that the candidate has been covered but no unknown output has been formed. When all candidate reachable states and the final unknown output state When all values are 1, it means that the true bounding box of the unknown defect is covered in the candidate stage and forms an unknown output in the final output stage. At this time, the phased diagnosis result is determined to be candidate coverage and form an unknown output. To further measure the proportion of budget-constrained candidates that are transformed into final unknown hits, the conditional transformation rate can also be calculated; the conditional transformation rate uses the reachable states of candidates under the same Top-K budget. and the final unknown output state ,Right now:
[0080] in, Indicates the conditional conversion rate; Indicates the th under the same Top-K budget The first qualification verification image Candidate reachable states of a ground truth bounding box with an unknown defect; Indicates the th under the same Top-K budget The first qualification verification image The final unknown output state of an unknown defect true bounding box, the numerator represents the number of unknown defect true bounding boxes that are both covered by candidates and form the final unknown output, and the denominator represents the number of unknown defect true bounding boxes that have been covered by candidates. The denominator of the conditional transition rate is the number of unknown defect true boxes that have been covered by candidates. The metric is calculated when the denominator is greater than 0. When the denominator is equal to 0, it means that no unknown defect true boxes have been covered by candidates. In this case, the conditional transition rate is not calculated, and the bottleneck stage is directly recorded as the candidate coverage stage. The spatial matching threshold, candidate scoring function, K value, unknown decision function, evaluation index and frozen operation conditions are all predetermined before reading the qualification verification results and remain unchanged in the same diagnosis; It should be noted that in one model diagnostic embodiment, the candidate coverage rate is significantly higher than the final unknown identification recall rate, indicating that a large number of unknown defect ground truth boxes have been covered by candidate boxes but have not formed the final unknown output. This result is used to prove that the present invention can distinguish between the candidate generation stage and the unknown identification stage, and does not mean that the model to be evaluated has already achieved ideal unknown defect detection performance.
[0081] Based on the above-mentioned unknown defect candidate reconstruction diagnostic method, the model parameters and original post-processing conditions of the target detection model are frozen, and candidate intermediate data is obtained before performing original post-processing. Then, the candidate intermediate data is reconstructed and its consistency is verified. After the verification is passed, the candidate reachable state and the final unknown output state are determined respectively. Thus, without changing the running state of the model to be evaluated, the limited links of the unknown defect detection capability can be divided into the candidate stage and the final output stage, providing a verifiable diagnostic basis for model improvement.
[0082] like Figure 6 As shown, this embodiment of the invention also provides an unknown defect candidate reconstruction diagnostic system, including: The model freezing module is used to obtain the target detection model to be evaluated, freeze the model parameters and original post-processing conditions of the target detection model, and obtain the frozen running conditions. The data acquisition module is used to acquire the qualification verification image and the ground truth bounding box annotation information of the unknown defects therein. Under the frozen running condition, the qualification verification image is input into the target detection model for native forward calculation, and candidate intermediate data is acquired before the target detection model performs native post-processing. The reconstruction detection module is used to reconstruct candidate intermediate data based on the original post-processing conditions to obtain reconstruction detection results. The consistency verification module is used to obtain the original detection results of the qualification verification image obtained by the target detection model based on the frozen running conditions, and to perform consistency verification between the reconstructed detection results and the original detection results to obtain the consistency verification results. The phased diagnosis module is used to determine the candidate reachability state of the unknown defect true bounding box in the unknown defect true bounding box annotation information based on the candidate intermediate data after the consistency verification result is determined to be verified. It also determines the final unknown output state of the unknown defect true bounding box based on the reconstruction detection result, and determines the phased diagnosis result based on the candidate reachability state and the final unknown output state.
[0083] It should be noted that the above is a reference method and system for diagnosing unknown defect candidate reconstruction, and the present invention is not limited thereto.
[0084] This invention addresses the technical problems in existing technologies, such as difficulty in determining whether performance limitations originate from the candidate localization stage or the unknown identification stage based solely on the final unknown defect detection index, lack of strict consistency constraints between the reconstruction results and the original detection results when reconstructing candidate intermediate data, and difficulty in performing comparable staged analysis under the same fixed operating conditions due to different post-processing methods of different detection models.
[0085] Finally, it should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0086] The above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications can still be made to the specific implementation of the present invention or equivalent substitutions can be made to some technical features without departing from the spirit of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the scope of the technical solutions claimed in the present invention.
Claims
1. A method for diagnosing candidate reconstructions of unknown defects, characterized in that, include: Model freezing steps: Obtain the target detection model to be evaluated, freeze the model parameters and original post-processing conditions of the target detection model, and obtain the frozen running conditions; Data acquisition steps: Acquire the qualification verification image and the ground truth bounding box annotation information of the unknown defects therein. Under the frozen running conditions, input the qualification verification image into the target detection model for native forward computation, and acquire and persistently save the candidate intermediate data before the target detection model performs native post-processing. Reconstruction detection steps: Read the candidate intermediate data, and without repeating the original forward computation of the target detection model, perform post-processing reconstruction on the candidate intermediate data based on the original post-processing conditions to obtain the reconstruction detection result; Consistency verification steps: Based on the frozen running conditions, obtain the original detection results of the qualification verification image obtained by the target detection model, and perform consistency verification between the reconstructed detection results and the original detection results to obtain the consistency verification results; The phased diagnostic steps are as follows: If the consistency verification result is successful, then the candidate reachability state of the unknown defect true bounding box in the unknown defect true bounding box annotation information is determined based on the candidate intermediate data, the final unknown output state of the unknown defect true bounding box is determined based on the reconstruction detection result, and the phased diagnostic result is determined based on the candidate reachability state and the final unknown output state.
2. The unknown defect candidate reconstruction diagnosis method according to claim 1, characterized in that, The data acquisition steps are as follows: The qualification verification image is input into the target detection model for forward computation. The target detection model outputs reference candidate boxes, bounding box regression values, classification responses, and class probabilities through its detection head. The reference candidate boxes are then subjected to regression transformation based on the bounding box regression values to obtain regression candidate boxes. A candidate source index is established based on the row-by-row correspondence between the reference candidate box, the regression candidate box, the classification response, and the category probability; Before the target detection model performs native post-processing, the reference candidate box, the regression candidate box, the classification response, the category probability, and the candidate source index are used as the candidate intermediate data.
3. The unknown defect candidate reconstruction diagnosis method according to claim 1, characterized in that, The reconstruction detection step is specifically as follows: Based on the original post-processing conditions, the regression candidate boxes and the category probabilities in the candidate intermediate data are filtered to obtain the filtered candidate boxes. Select candidate boxes corresponding to each category from the filtered candidate boxes to obtain category candidate boxes. Then, deduplicate the category candidate boxes to obtain deduplicated candidate boxes. The deduplicated candidate boxes are sorted and truncated to obtain the retained candidate boxes and the corresponding reconstruction detection scores and reconstruction category labels of the retained candidate boxes; The coordinates of the retained candidate boxes are restored and the output is encapsulated to obtain the reconstruction detection boxes. The reconstruction detection boxes, the reconstruction detection scores, and the reconstruction category labels constitute the reconstruction detection results.
4. The unknown defect candidate reconstruction diagnosis method according to claim 1, characterized in that, The consistency verification steps are as follows: The qualification verification image is subjected to native forward computation to obtain native candidate boxes, native classification responses, and native regression values; wherein, the native forward computation and the native forward computation for obtaining the candidate intermediate data are the same native forward computation. Based on the native classification response and the native regression, the native candidate boxes are subjected to native post-processing to obtain native detection boxes, native detection scores and native category labels; The native detection bounding box, the native detection score, and the native category label are used as the native detection result.
5. The unknown defect candidate reconstruction diagnosis method according to claim 1, characterized in that, The consistency verification step also includes: The original detection results and the reconstructed detection results are arranged according to a preset sorting rule to obtain an original ordered result sequence and a reconstructed ordered result sequence, and an item-by-item correspondence between the original ordered result sequence and the reconstructed ordered result sequence is established. Based on the item-by-item correspondence, comparison terms are determined between the original ordered result sequence and the reconstructed ordered result sequence. The differences between the items in the comparison terms are compared to obtain the consistency verification result.
6. The unknown defect candidate reconstruction diagnosis method according to claim 5, characterized in that, The consistency verification step also includes: Based on the item-by-item correspondence, determine the item-by-item corresponding result entries between the original ordered result sequence and the reconstructed ordered result sequence, and count the number of results; The evaluation metrics for the original detection results and the reconstructed detection results are calculated respectively, and the comparison items are obtained based on the evaluation metrics, the result items, and the number of results; If none of the differences in the comparison items exceed the preset tolerance, the consistency verification result is determined to be verified as passed. If any difference in the comparison items exceeds the corresponding preset tolerance, the consistency verification result is determined to be a verification failure.
7. The unknown defect candidate reconstruction diagnosis method according to claim 2, characterized in that, The specific steps of the phased diagnosis are as follows: Spatial matching is performed between the ground truth bounding box of the unknown defect and the regression candidate bounding box in the candidate intermediate data to obtain the first spatial overlap degree; If there is a regression candidate box in the candidate intermediate data whose first spatial overlap with the unknown defect real box reaches a preset overlap threshold, then the value of the candidate reachable state is the first value. If there is no regression candidate box in the candidate intermediate data whose first spatial overlap with the true unknown defect box reaches a preset overlap threshold, then the value of the candidate reachable state is the second value.
8. The method for diagnosing unknown defect candidate reconstruction according to claim 7, characterized in that, The phased diagnostic steps also include: The unknown defect real bounding box is spatially matched with the detection box in the reconstructed detection result to obtain the second spatial overlap degree; If the reconstruction detection result contains a detection box whose second spatial overlap with the real unknown defect box reaches a preset overlap threshold and satisfies the pre-frozen unknown determination condition, then the value of the final unknown output state is the first value. If there is no detection box in the reconstructed detection result that has a second spatial overlap with the real unknown defect box that reaches a preset overlap threshold and satisfies the pre-frozen unknown determination conditions, then the value of the final unknown output state is the second value.
9. The unknown defect candidate reconstruction diagnosis method according to claim 8, characterized in that, The phased diagnostic steps also include: If the value of the candidate reachable state is the second value, then the phased diagnosis result is insufficient candidates; If the value of the candidate reachable state is the first value and the value of the final unknown output state is the second value, then the phased diagnosis result is that the candidate has been covered but no unknown output has been formed. If the value of the candidate reachable state is the first value and the value of the final unknown output state is the first value, then the phased diagnosis result is candidate coverage and an unknown output is formed.
10. A diagnostic system for candidate reconstruction of unknown defects, characterized in that, include: The model freezing module is used to obtain the target detection model to be evaluated, freeze the model parameters and original post-processing conditions of the target detection model, and obtain the frozen running conditions. The data acquisition module is used to acquire the qualification verification image and the ground truth bounding box annotation information of the unknown defects therein. Under the frozen running condition, the qualification verification image is input into the target detection model for native forward computation, and candidate intermediate data is acquired before the target detection model performs native post-processing. The reconstruction detection module is used to perform post-processing reconstruction on the candidate intermediate data based on the original post-processing conditions to obtain the reconstruction detection result; The consistency verification module is used to obtain the original detection result of the qualification verification image obtained by the target detection model based on the frozen running conditions, and to perform consistency verification between the reconstructed detection result and the original detection result to obtain the consistency verification result; The phased diagnosis module is used to determine the candidate reachability state of the unknown defect real box in the unknown defect real box annotation information based on the candidate intermediate data after determining that the consistency verification result is verified as passed, determine the final unknown output state of the unknown defect real box based on the reconstruction detection result, and determine the phased diagnosis result based on the candidate reachability state and the final unknown output state.
