Adaptive threshold segmentation method, system, medium and electronic device in unsupervised mode

CN123015588APending Publication Date: 2026-10-30CRRC SMART IND INVESTMENT (SHANGHAI) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611297043.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-25
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0006]但现有的无监督分割算法仍然存在以下缺陷:需要人工去标注缺陷图和调节得分阈值:无监督分割算法在许多介绍资料中都提及只需收集正常样本来训练模型,这点本身确实没有错;因为基于深度学习原理的算法的重点在于模型本身,而决定模型的好坏是模型的训练,加上无监督算法的训练范式决定了确实只需训练正常样本

Benefits of technology

[0035](1)与现有技术相比,本发明提供了一种可以真正实现无需标注就能正确评估模型的无监督模式;对于得分结果(即异常得分)的阈值划分不需要人工参与,也可以取到最合适的值(即目标划分阈值),这样可以直接将模型与阈值参数应用于实际的检测中,达到了自适应阈值的智能效果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123015588A_ABST
    Figure CN123015588A_ABST
Patent Text Reader

Abstract

The application provides a self-adaptive threshold segmentation method, system, medium and electronic equipment in an unsupervised mode; the method comprises the following steps: obtaining a verification set; inputting the verification set into an unsupervised image segmentation model to obtain a corresponding score map; obtaining an abnormal score of the corresponding score map according to the value of the score map, and obtaining a qualified array and an unqualified array based on the abnormal score; determining a target division threshold according to the qualified array and the unqualified array, so that the sum of the overkill rate and the missed detection rate is minimum, and then realizing self-adaptive threshold segmentation in the unsupervised mode based on the target division threshold; the application proposes a method for obtaining the best threshold segmentation algorithm by optimizing the sum of the overkill rate and the missed detection rate, and at the same time, human participation in labeling work is not required, and self-adaptive threshold segmentation in the unsupervised mode is truly realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial automation, to deep learning, and particularly to unsupervised segmentation algorithms, specifically an adaptive threshold segmentation method, system, medium, and electronic device under unsupervised mode. Background Technology

[0002] In the defect detection stage of industrial automation, image segmentation or object detection algorithms based on deep learning principles are now widely used. These algorithms first require collecting a large number of defect images, then labeling the defective parts, before model training and validation can proceed. For example, below Figure 1 If a nut in a picture is broken, it falls under the category of defects to be detected. We will then create a corresponding annotated image by marking the location of this defect, such as... Figure 2 As shown, black pixels represent the background, which are not considered defects by humans, while white pixels represent defects.

[0003] However, the shortcomings of the above algorithm are also obvious. First, it requires a lot of manual annotation, which is very time-consuming. Moreover, each image needs to be carefully annotated by engineers to avoid errors or omissions, which further leads to time and labor costs and thus low efficiency. Second, it is difficult to collect a large number of defect samples from many factory parts because almost all parts are qualified samples, i.e., samples without defects, during the production process. As a result, with only a small number of samples, the detection ability of the trained model is often not stable enough.

[0004] Therefore, a new type of deep learning algorithm is gradually emerging, which can train only on qualified samples without training on unqualified samples, while still ensuring the model's ability to detect defects. Since only qualified samples are trained, no manual annotation is needed; this is called anomaly detection algorithms or unsupervised segmentation algorithms. There has been considerable research on this type of algorithm, and it has indeed created algorithms applicable to real-world business scenarios, further promoting the development of defect detection.

[0005] In the field of industrial automation, there is a demand not only for stable detection capabilities but also for high-speed real-time detection. Currently, the most typical algorithm that is suitable for such requirements is EfficientAD, which is also one of the commonly used anomaly detection (unsupervised segmentation) algorithms.

[0006] However, existing unsupervised segmentation algorithms still have the following drawbacks: they require manual annotation of defect maps and adjustment of score thresholds. Many introductory materials on unsupervised segmentation algorithms mention that only normal samples need to be collected to train the model, which is indeed correct. This is because the focus of algorithms based on deep learning principles is on the model itself, and the quality of the model is determined by its training. In addition, the training paradigm of unsupervised algorithms determines that only normal samples need to be trained.

[0007] However, for unsupervised algorithms to achieve true automation, one crucial point needs attention: the score threshold for distinguishing between acceptable and unacceptable segments. Unsupervised segmentation algorithms, like supervised algorithms, output a score map the same size as the original image. The criteria for classifying each pixel as acceptable or unacceptable are also the same: smaller values ​​indicate a lower probability of a defect, while larger values ​​indicate a higher probability. However, unlike supervised segmentation algorithms, which output a probability map ranging from 0 to 255, supervised segmentation algorithms often don't require further threshold adjustment after training; achieving half the upper or lower limit (127) is sufficient. In contrast, unsupervised segmentation theoretically has no upper limit on the score of its anomaly map, and the optimal threshold for effectively distinguishing between acceptable and unacceptable segments is not determined by half the upper or lower limits.

[0008] Therefore, firstly, if there are no defective maps, the threshold can only be determined based on the scores of acceptable maps. However, if the model has never seen the scores of defective maps, it is difficult to guarantee that the previously selected threshold will accurately classify the acceptable and unacceptable classes. Secondly, when defective maps are available, a common approach to achieving an adaptive threshold is to find the optimal threshold by calculating the best F1-Score. However, the F1-Score requires labeling the defects in the defective maps to be calculated.

[0009] In summary, unsupervised algorithms claim that they do not require the collection of defect maps and corresponding annotations. However, the problem of threshold division means that they cannot be used to stably detect defects in one step. Essentially, they still need to collect defect maps and corresponding annotations and then obtain the optimal threshold. Summary of the Invention

[0010] The purpose of this invention is to provide an adaptive threshold segmentation method, system, medium, and electronic device in an unsupervised mode to solve the problems mentioned in the background art.

[0011] In a first aspect, the present invention provides an adaptive threshold segmentation method in an unsupervised mode, the adaptive threshold segmentation method in an unsupervised mode comprising: obtaining a validation set; the validation set comprising a qualified image group and a non-qualified image group; wherein, the qualified image group comprises qualified images; the non-qualified image group comprises non-qualified images; inputting the validation set into an unsupervised image segmentation model to obtain corresponding score maps; obtaining abnormal scores corresponding to the score maps based on the values ​​of the score maps, and obtaining a qualified array and a non-qualified array based on the abnormal scores; wherein, the qualified array comprises abnormal scores of the score maps corresponding to all qualified images; the non-qualified array comprises abnormal scores of the score maps corresponding to all non-qualified images; determining a target segmentation threshold based on the qualified array and the non-qualified array to minimize the sum of the corresponding overkill rate and underkill rate, thereby realizing adaptive threshold segmentation in an unsupervised mode based on the target segmentation threshold.

[0012] This invention proposes an optimal threshold segmentation algorithm (i.e., target segmentation threshold) that optimizes the sum of the overkill rate and the underkill rate, without requiring human intervention in the annotation process, thus truly achieving adaptive threshold segmentation in an unsupervised mode.

[0013] In one implementation of the first aspect, obtaining the abnormal score corresponding to the score map based on the value of the score map includes: arranging the values ​​of the score map in descending order and taking the value at a preset position as the abnormal score.

[0014] In one implementation of the first aspect, determining the target partitioning threshold based on the qualified array and the unqualified array includes: comparing the smallest value in the qualified array with the smallest value in the unqualified array; if the smallest value in the qualified array is less than the smallest value in the unqualified array, then comparing the values ​​in the qualified array with the smallest value in the unqualified array in ascending order until a first target value in the qualified array is greater than or equal to the smallest value in the unqualified array, so as to calculate the target partitioning threshold based on the first value and the second value; wherein, the first value is the qualified array... The first value is the value that is less than the first target value and closest to the first target value; the second value is the smallest value in the unqualified array; if the smallest value in the qualified array is greater than or equal to the smallest value in the unqualified array, then the values ​​in the unqualified array are compared with the smallest value in the qualified array in ascending order until a second target value appears in the unqualified array that is greater than the smallest value in the qualified array, so as to calculate the target division threshold based on the third value and the fourth value; wherein, the third value is the smallest value in the qualified array; and the fourth value is the second target value.

[0015] This implementation provides a method for determining the target segmentation threshold. The entire process does not require manual intervention in the labeling process similar to supervised segmentation, nor does it require human intervention in adjusting the threshold parameters for segmenting qualified and unqualified images. At the same time, it achieves the ideal segmentation effect and realizes an adaptive threshold segmentation algorithm in unsupervised mode.

[0016] In one implementation of the first aspect, the formula for calculating the target partitioning threshold is:

[0017] K = (A + B) / 2;

[0018] Wherein, K represents the target segmentation threshold; A represents the first value or the third value; when A represents the first value, B represents the second value; when A represents the third value, B represents the fourth value.

[0019] In one implementation of the first aspect, the formula for calculating the overkill rate is:

[0020] P1 = (L1 - m) / L1;

[0021] Wherein, P1 represents the overkill rate; L1 represents the length of the qualified array; m is 1, or m is the number of comparisons in which the values ​​in the qualified array are compared with the smallest value in the unqualified array, m is a positive integer, and m≤L1;

[0022] The formula for calculating the false negative rate is:

[0023] P2 = (n-1) / L2;

[0024] Wherein, P2 represents the false negative rate; L2 represents the length of the non-conforming array; when m is 1, n is the number of comparisons in which the values ​​in the non-conforming array are compared with the smallest value in the conforming array, n is a positive integer, and n≤L2; when m is the number of comparisons in which the values ​​in the conforming array are compared with the smallest value in the non-conforming array, n is 1.

[0025] In one implementation of the first aspect, the adaptive threshold segmentation method in unsupervised mode further includes: calculating a target distance based on the first value and the second value, or based on the third value and the fourth value, and using the target distance as an evaluation index to optimize the unsupervised image segmentation model; the formula for calculating the target distance is:

[0026] D = (BA) / (max - min);

[0027] Wherein, D represents the target distance; A represents the first value or the third value; when A represents the first value, B represents the second value; when A represents the third value, B represents the fourth value; max represents the maximum value of the abnormal scores corresponding to all the score maps; min represents the minimum value of the abnormal scores corresponding to all the score maps.

[0028] This implementation proposes a new evaluation metric, which enables a more detailed assessment of whether the model is better, thereby saving the better model and improving the model's detection performance.

[0029] In one implementation of the first aspect, before the step of obtaining the abnormal scores corresponding to the score map based on the values ​​of the score map, the adaptive threshold segmentation method in unsupervised mode further includes: arranging the values ​​of the score map in descending order to obtain a feature distribution curve; determining a reference point; the abscissa of the reference point is the abscissa of the first point greater than 0 from right to left on the feature distribution curve, and the ordinate of the reference point is the negative of the maximum value of the score map; traversing the points on the feature distribution curve from right to left until the slope between the target point and the reference point is less than the slope between the inflection point and the reference point; wherein, the inflection point is located at... The turning point is the point closest to the target point, located to the right of the target point. The ordinate of the turning point is the 90th percentile value. The ordinate of the midpoint is the 99th percentile value. The midpoint is located on the feature distribution curve, with its x-coordinate being the center of the x-coordinate of the turning point and 0. The score map is standardized based on the 90th percentile value and the 99th percentile value to obtain a standardized score map. Obtaining the abnormal scores corresponding to the score map based on the scores includes: stretching and transforming the standardized score map into a one-dimensional vector, and then obtaining the abnormal scores based on the scores of the standardized score map.

[0030] In this implementation, a standardization algorithm is provided. By finding a suitable inflection point based on the feature distribution curve, a more suitable distribution of background points (corresponding to the 90th percentile value) and outliers (corresponding to the 99th percentile value) is determined, which improves the stability of standardization and makes the unsupervised segmentation algorithm more effective with a wide range of datasets.

[0031] Secondly, the present invention provides an adaptive threshold segmentation system in an unsupervised mode, the adaptive threshold segmentation system in an unsupervised mode comprising: a first acquisition module, configured to acquire a validation set; the validation set includes a qualified image group and an unqualified image group; wherein the qualified image group includes qualified images; the unqualified image group includes unqualified images; a model input module, configured to input the validation set into an unsupervised image segmentation model to acquire corresponding score maps; a second acquisition module, configured to acquire abnormal scores corresponding to the score maps based on the values ​​of the score maps, so as to acquire a qualified array and an unqualified array based on the abnormal scores; wherein the qualified array includes abnormal scores of the score maps corresponding to all qualified images; the unqualified array includes abnormal scores of the score maps corresponding to all unqualified images; and a threshold determination module, configured to determine a target segmentation threshold based on the qualified array and the unqualified array, so as to minimize the sum of the corresponding overkill rate and underkill rate, thereby realizing adaptive threshold segmentation in an unsupervised mode based on the target segmentation threshold.

[0032] Thirdly, the present invention provides an electronic device comprising: a processor and a memory; the memory for storing a computer program; and the processor for executing the computer program stored in the memory to enable the electronic device to perform the above-described adaptive threshold segmentation method in unsupervised mode.

[0033] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, characterized in that the program, when executed by an electronic device, implements the above-described adaptive threshold segmentation method in unsupervised mode.

[0034] As described above, the adaptive threshold segmentation method, system, medium, and electronic device in unsupervised mode of the present invention have the following beneficial effects:

[0035] (1) Compared with the prior art, the present invention provides an unsupervised mode that can truly realize the correct evaluation of the model without labeling; the threshold division of the scoring results (i.e. abnormal scores) does not require manual intervention and can also obtain the most suitable value (i.e. target division threshold), so that the model and threshold parameters can be directly applied to the actual detection, achieving the intelligent effect of adaptive threshold.

[0036] (2) The present invention uses a more detailed evaluation index (i.e. target distance) to evaluate the quality of the model, thereby obtaining a model that can better distinguish between normal samples and abnormal samples, and improving the detection effect of the model.

[0037] (3) For algorithms where the score graph is composed of two parts of the result graph, the traditional method will have problems with the performance on a small number of datasets due to the standardization process of values. This invention proposes a more advanced and intelligent algorithm to solve this problem, making the unsupervised segmentation algorithm more effective on a wide range of datasets. Attached Figure Description

[0038] Figure 1 The diagram shown is a schematic representation of a non-conforming diagram in the prior art.

[0039] Figure 2 The diagram shown is a schematic representation of a prior art annotation.

[0040] Figure 3 The flowchart shown is an example of an adaptive threshold segmentation method in unsupervised mode according to an embodiment of the present invention.

[0041] Figure 4 This diagram illustrates the distribution of abnormal scores for qualified and unqualified images according to an embodiment of the present invention.

[0042] Figure 5 This is a schematic diagram showing the distribution of abnormal scores for qualified and unqualified images according to another embodiment of the present invention.

[0043] Figure 6 This diagram illustrates the distribution of abnormal scores for qualified and unqualified images when a dataset, as described in this embodiment of the invention, first reaches a kill rate and a false kill rate of 0 on the validation set during the training process.

[0044] Figure 7 This diagram illustrates the distribution of abnormal scores for qualified and unqualified images in later epochs during the training process of the dataset described in this embodiment of the invention.

[0045] Figure 8 This diagram illustrates the relationship between the score and ranking of a model on the validation set for a dataset as described in an embodiment of the present invention.

[0046] Figure 9 The datasets shown in this embodiment of the invention were found using conventional methods. and A schematic diagram.

[0047] Figure 10 Displayed as Figure 9 A partially enlarged schematic diagram.

[0048] Figure 11 The diagram shown is a schematic representation of the reference point as described in an embodiment of the present invention.

[0049] Figure 12The illustration is shown as described in the embodiments of the present invention. and A schematic diagram.

[0050] Figure 13 The diagram shown is a structural schematic of the adaptive threshold segmentation system in unsupervised mode according to an embodiment of the present invention. Detailed Implementation

[0051] The following specific examples illustrate the implementation of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and various details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that, unless otherwise specified, the following embodiments and features described therein can be combined with each other.

[0052] It should be noted that the illustrations provided in the following embodiments are only schematic representations of the basic concept of the present invention. The illustrations only show the components related to the present invention and are not drawn according to the actual number, shape and size of the components in the actual implementation. In the actual implementation, the form, quantity and proportion of each component can be arbitrarily changed, and the layout of the components may also be more complex.

[0053] See Figures 3 to 13 The following embodiments of this invention provide an adaptive threshold segmentation method, system, medium, and electronic device in an unsupervised mode. Compared with existing technologies, this invention can truly achieve an unsupervised mode that can correctly evaluate the model without annotation; the threshold division of the scoring results (i.e., abnormal scores) does not require manual intervention and can obtain the most suitable value (i.e., the target segmentation threshold), so that the model and threshold parameters can be directly applied to actual detection, achieving the intelligent effect of adaptive thresholding; this invention uses a more detailed evaluation index (i.e., target distance) to evaluate the quality of the model, thereby obtaining a model that can better distinguish between normal and abnormal samples, improving the detection effect of the model; for algorithms where the score map is composed of two parts of the result map, the traditional method's performance on a small number of datasets will be problematic due to the value standardization process. This invention proposes a more advanced and intelligent algorithm to solve this problem, making the unsupervised segmentation algorithm perform better on a wider range of datasets.

[0054] The technical solutions of the present invention will now be described in detail with reference to the accompanying drawings.

[0055] like Figure 3 As shown, in one embodiment, the present invention provides an adaptive threshold segmentation method in an unsupervised mode, the adaptive threshold segmentation method in an unsupervised mode comprising:

[0056] Step S1: Obtain the verification set.

[0057] In this embodiment, the verification set includes a qualified image group and an unqualified image group; wherein, the qualified image group includes qualified images; and the unqualified image group includes unqualified images.

[0058] It should be noted that a qualified image refers to an image that is defect-free and conforms to standards (judged as defect-free based on preset quality standards (such as size, appearance, and location)); a non-qualified image refers to an image that has defects or exceeds tolerances (deviations from standards (such as scratches, damage, or dimensional errors)).

[0059] Step S2: Input the validation set into the unsupervised image segmentation model to obtain the corresponding score map.

[0060] Specifically, all qualified and unqualified images in the validation set are input into the unsupervised image segmentation model to obtain the score maps corresponding to all qualified and unqualified images respectively.

[0061] It should be noted that the unsupervised image segmentation model, and the input of the image into the unsupervised image segmentation model to obtain the corresponding score map, both adopt existing technologies in the field. Their specific working principles are not considered as limiting conditions of the present invention, and therefore will not be described in detail here.

[0062] Furthermore, the size of the score image is the same as the size of the corresponding qualified or unqualified image.

[0063] Step S3: Obtain the abnormal scores corresponding to the score graph based on the values ​​of the score graph, and obtain the qualified array and the unqualified array based on the abnormal scores.

[0064] In this embodiment, the qualified array includes the abnormal scores of the score maps corresponding to all qualified images; the unqualified array includes the abnormal scores of the score maps corresponding to all unqualified images.

[0065] In one embodiment, obtaining the abnormal score corresponding to the score map based on the value of the score map includes: arranging the values ​​of the score map in descending order and taking the value at a preset position as the abnormal score.

[0066] It should be noted that for the score map, each pixel has a corresponding score value (i.e., the "value of the score map"). These score values ​​are sorted, and a certain proportion of pixels with large scores are marked as outliers, thereby obtaining the outlier score.

[0067] It should be noted that the preset position, and the specific value set, is not a limitation of the present invention. In practical applications, it can be set according to the specific application scenario.

[0068] In one embodiment, the preset position is the position 0.0001 before the target position.

[0069] It should be noted that in this embodiment, the value at the first 0.0001 position is taken instead of the maximum value because if a small noise point in a qualified image causes the maximum value of the score image to be too large, then an abnormal score that cannot reflect most of the pixels in the image will be obtained. However, if it is a qualified image, the proportion of the abnormal score obtained after the defective part is processed by the model will definitely be greater than 0.0001 of the whole image. Therefore, taking the value at the first 0.0001 position is sufficient to represent whether the whole image is a qualified or unqualified image, and it is not necessary to perform a global calculation on the score of the whole image.

[0070] Step S4: Determine the target segmentation threshold based on the qualified array and the unqualified array to minimize the sum of the corresponding over-detection rate and under-detection rate, and then realize adaptive threshold segmentation in unsupervised mode based on the target segmentation threshold.

[0071] It should be noted that after each score image has a corresponding outlier score, the next step is to use these outlier scores to perform a threshold segmentation optimization problem, that is, how to choose the threshold so that the model can best separate qualified images from unqualified images.

[0072] Since this application focuses on defect and anomaly detection tasks in industrial automation, the common considerations in this field are the over-detection rate of qualified images (i.e., the proportion of actually qualified images that are classified as unqualified by the algorithm) and the under-detection rate of unqualified images (i.e., the proportion of actually unqualified images that are classified as qualified by the algorithm). Clearly, it's desirable for both metrics to be as low as possible. Ideally, the anomaly scores for all qualified images should be less than a certain value, while the anomaly scores for all unqualified images should be greater than a certain value. If this value is chosen as the threshold, the over-detection rate for qualified images and the under-detection rate for unqualified images will be 0%; as follows: Figure 4 As shown in the figure, the point set in category 0 represents the abnormal score point set of qualified images in one embodiment, and the points in category 1 represent the abnormal score point set of unqualified images in one embodiment. It can be seen that the green line in the middle can distinguish the two point sets. Therefore, under this data distribution, as long as an appropriate threshold is selected, qualified samples and unqualified samples can be completely distinguished.

[0073] However, more often than not, abnormal scores from both substandard and standard images are mixed together, making it difficult to automatically select a suitable threshold for classification; as follows: Figure 5 As shown, regardless of the value taken, there will always be missed detections or over-detections; where, the point set in category 0 in the figure represents the abnormal score point set of qualified images in another embodiment, and the points in category 1 represent the abnormal score point set of unqualified images in another embodiment.

[0074] Therefore, choosing a suitable threshold is not a simple matter. Moreover, for the same unchanging model, the direction of threshold adjustment often results in a lower over-detection rate for qualified images and a higher under-detection rate for unqualified images, or vice versa. Since we want to balance both, this invention sets an optimization objective: to find a threshold that minimizes the sum of the over-detection rate for qualified images and the under-detection rate for unqualified images. This minimum sum means that neither the over-detection rate nor the under-detection rate is too high. In this way, a single indicator can balance two important indicators and achieve the most ideal segmentation effect.

[0075] In one embodiment, determining the target segmentation threshold based on the qualified array and the unqualified array includes:

[0076] Step S41: Compare the smallest value in the qualified array with the smallest value in the unqualified array.

[0077] Step S42: If the smallest value in the qualified array is less than the smallest value in the unqualified array, then compare the values ​​in the qualified array with the smallest value in the unqualified array in ascending order until a first target value in the qualified array is greater than or equal to the smallest value in the unqualified array. The target segmentation threshold is then calculated based on the first value and the second value. The first value is the value in the qualified array that is less than the first target value and closest to it; the second value is the smallest value in the unqualified array.

[0078] Step S43: If the smallest value in the qualified array is greater than or equal to the smallest value in the unqualified array, then in ascending order, compare the values ​​in the unqualified array with the smallest value in the qualified array until a second target value appears in the unqualified array that is greater than the smallest value in the qualified array. The target segmentation threshold is then calculated based on the third and fourth values. The third value is the smallest value in the qualified array, and the fourth value is the second target value.

[0079] In one embodiment, the formula for calculating the target segmentation threshold is:

[0080] K = (A + B) / 2;

[0081] Wherein, K represents the target segmentation threshold; A represents the first value or the third value; when A represents the first value, B represents the second value; when A represents the third value, B represents the fourth value.

[0082] In one embodiment, the overkill rate is calculated using the following formula:

[0083] P1 = (L1 - m) / L1;

[0084] Wherein, P1 represents the overkill rate; L1 represents the length of the qualified array; m is 1, or m is the number of comparisons in which the values ​​in the qualified array are compared with the smallest value in the unqualified array, m is a positive integer, and m≤L1;

[0085] The formula for calculating the false negative rate is:

[0086] P2 = (n-1) / L2;

[0087] Wherein, P2 represents the false negative rate; L2 represents the length of the non-conforming array; when m is 1, n is the number of comparisons in which the values ​​in the non-conforming array are compared with the smallest value in the conforming array, n is a positive integer, and n≤L2; when m is the number of comparisons in which the values ​​in the conforming array are compared with the smallest value in the non-conforming array, n is 1.

[0088] In one embodiment, the values ​​of the qualified array and the unqualified array are arranged in ascending order.

[0089] In this embodiment, determining the target segmentation threshold based on the qualified array and the unqualified array includes:

[0090] Compare the value at the first position in the qualified array with the value at the first position in the unqualified array.

[0091] If the value at the first position in the qualified array is less than the value at the first position in the unqualified array, then the value at the next position in the qualified array is compared with the value at the first position in the unqualified array, until the first target value at the current position in the qualified array is greater than or equal to the value at the first position in the unqualified array, so as to calculate the target division threshold based on the first value and the second value; wherein, the first value is the value in the qualified array that is to the left of the current position and closest to the current position; and the second value is the value at the first position in the unqualified array.

[0092] If the value at the first position in the qualified array is greater than or equal to the value at the first position in the unqualified array, then the value at the next position in the unqualified array is compared with the value at the first position in the qualified array, until the second target value at the current position in the unqualified array is greater than the value at the first position in the qualified array, so as to calculate the target division threshold based on the third value and the fourth value; wherein, the third value is the value at the first position in the qualified array; and the fourth value is the second target value.

[0093] The working principle of determining the target segmentation threshold based on the qualified array and the unqualified array of the present invention will be further explained through specific embodiments below.

[0094] In one embodiment, the anomaly scores of all qualified images and all unqualified images are first sorted in ascending order to obtain two corresponding arrays. (Corresponding qualified array) and (Corresponding to the unqualified array).

[0095] If the initial over-detection rate and under-detection rate are both defined as 1, then the sum of the initial over-detection rate and under-detection rate is 2.

[0096] Next, we use two pointers and Always satisfied This condition,

[0097] If this condition is met, and considering the monotonicity of the array, then the following conclusion can be drawn:

[0098] ;

[0099] for The length, i.e. Including A number.

[0100] That is The first to the ( The value of the +1 bit is less than The middle ( +1) The value from the last digit to the next digit. If the threshold selected at this point is the midpoint between these two values, i.e. Therefore, the overkill rate of qualified images is at most... ( for (length), the false negative rate of defective images is at most If these two pointers are initially set to 0, then, under the premise of satisfying the above conditions, they should be moved forward as far as possible. and to avoid moving as much as possible This minimizes both the false negative rate and the false positive rate.

[0101] The specific method is to move forward each time. Observe whether the conditions are met. If the conditions are still met, observe whether the sum of the over-detection rate and the under-detection rate calculated by the two pointers is smaller than the minimum sum. If it is smaller, update the sum and record the current pointer. If the conditions are not met, then start moving. This process continues until the condition is met again. Then, the sum of the current over-detection rate and under-detection rate is calculated and compared with the minimum value. If it is smaller, the result is updated.

[0102] After going through the above process, all possible scenarios that could produce smaller values ​​have been explored. Then, the two recorded pointers can be used to calculate the ideal over-detection rate and under-detection rate, as well as the corresponding thresholds.

[0103] In summary, the adaptive threshold segmentation method in unsupervised mode provided by this invention does not require manual participation in the same annotation process as supervised segmentation, nor does it require human intervention in adjusting the threshold parameters for classifying qualified and unqualified segments, while achieving ideal segmentation results. Therefore, it realizes an adaptive threshold segmentation algorithm in unsupervised mode.

[0104] It should be noted that the sum of the over-detection rate and the under-detection rate mentioned above is taken as the target to be optimized by the algorithm of this invention. The goal is to minimize the sum of the over-detection rate and the under-detection rate. When the sum of the over-detection rate and the under-detection rate is minimized, the corresponding threshold to be solved is the target segmentation threshold.

[0105] It's important to note that current model evaluation metrics are too simplistic. The F1-score is commonly used to evaluate model performance, but in some cases, this metric alone cannot distinguish whether a model is better or worse. For example, if the F1-score reaches its maximum value in a certain epoch (an epoch is the process of fully "learning" from all training data, meaning the model has gone through all samples and adjusted its internal settings), indicating that both the false negative rate and the false positive rate are 0, then in subsequent epochs, the model might improve through training, or it might worsen (but the F1-score would remain unchanged). In this situation, is it still necessary to save the model? If not, better models might be missed; if saved, the saved model might perform slightly worse than the original.

[0106] Therefore, using only the F1-score metric is too simplistic and cannot provide a more detailed assessment of the model's ability to distinguish between unqualified and qualified images.

[0107] Suppose that at a certain epoch, the model has been trained to the point where both the over-detection rate and the under-detection rate are 0, that is, the maximum value of the abnormal score of qualified images is less than the minimum value of the abnormal score of unqualified images. If only the sum of the over-detection rate and the under-detection rate mentioned above is used as the evaluation metric, then the optimal sum of the over-detection rate and the under-detection rate at all epochs has been achieved to 0. The model will not be updated further because it can already completely classify the validation set dataset correctly.

[0108] However, achieving the best performance on this dataset may not fully realize the model's potential. The model trained in subsequent epochs may be even stronger and better able to distinguish between acceptable and unacceptable images. For example... Figure 6 and Figure 7 As shown, Figure 6 This refers to the distribution of abnormal scores for qualified and unqualified images when a dataset first achieves a kill rate and a false kill rate of 0 on the validation set during the training process (where the point set in category 0 represents the abnormal score point set for qualified images, and the points in category 1 represent the abnormal score point set for unqualified images). Figure 6 The green line in the diagram is just enough to distinguish between qualified and unqualified samples, and Figure 7 Is with Figure 6 Similarly, the distribution of abnormal scores for qualified and unqualified images in later epochs during the training process of this dataset is also observed.

[0109] It is obvious that Figure 7 The corresponding data distribution is better, and the dividing line is relatively farther away from the nearest qualified and unqualified points. Therefore, it is necessary to establish a second evaluation metric in addition to the first one to reflect the model's performance. If this metric is better than the previous best value in the current epoch, then save the current model and update this metric. After training is complete, the saved model will be the best-performing model across all epochs.

[0110] The above phenomena also reveal that this second indicator needs to reflect the "distance" between the distributions of abnormal scores for qualified and unqualified images. The larger this distance, the stronger the discrimination ability, and vice versa. Using clustering algorithms commonly found in machine learning, it's easy to think of using the mean of the abnormal scores for qualified and unqualified images as the "distance" between the two classes. However, unlike common classification methods, the abnormal scores output by unqualified images in anomaly detection algorithms have no upper limit. If an unstable model is trained in a certain epoch, resulting in a very large mean abnormal score for the unqualified class, thus increasing this "distance," it might be mistakenly believed that the model is better than before, when in fact its performance may be even more unstable.

[0111] Therefore, the quantitative definition of this distance is particularly crucial. Based on the aforementioned qualified and unqualified arrays, corresponding evaluation indicators are proposed, that is, using... and These two values ​​represent the maximum value in the qualified array and the minimum value in the unqualified array after removing misclassified values ​​under the optimal segmentation condition. Since the threshold for classifying qualified and unqualified classes can be taken as their median, these two values ​​can also be used to reflect the distance between the two classes. The larger the difference between these two values, the greater the difference in anomaly scores between other correctly classified qualified and unqualified anomalies. As for potentially misclassified graphs, there is no need to consider them, because since they have already been misclassified, whether the "distance" from their correct class is close or far will not affect the final indicators that need to be focused on, namely the over-detection rate and the false negative rate.

[0112] However, directly using the difference between the two as the distance also has problems, because for unsupervised segmentation algorithms, the upper and lower bounds of the score map obtained by the model trained on the original image are completely irregular. During the same training process, models at different epochs may have some output values ​​with large overall differences in their upper and lower bounds, while others may have smaller differences. Therefore, models with large overall differences in the distribution of upper and lower bounds of their output scores... and The difference between the scores will likely be large, thus failing to effectively prove its ability to classify the scores into qualified and unqualified classes. Therefore, measuring this distance requires considering not only the aforementioned difference but also the overall distribution of the score data. Since the maximum and minimum values ​​are calculated during the iteration of the validation set, these two values ​​can be used to normalize the "distance" between the two classes.

[0113] Therefore, in summary, the approach of this invention for the second evaluation index is to calculate... and The difference between the maximum and minimum values ​​is then normalized by dividing by the difference between the maximum and minimum values. The final value reflects the distance between the unqualified and qualified images in the abnormal score distribution of the model. The greater the distance, the stronger the model's ability to distinguish between unqualified and qualified images.

[0114] In one embodiment, the adaptive threshold segmentation method in unsupervised mode further includes: calculating a target distance based on the first value and the second value, or based on the third value and the fourth value, and using the target distance as an evaluation index to optimize the unsupervised image segmentation model; the formula for calculating the target distance is:

[0115] D = (BA) / (max - min);

[0116] Wherein, D represents the target distance; A represents the first value or the third value; when A represents the first value, B represents the second value; when A represents the third value, B represents the fourth value; max represents the maximum value of the abnormal scores corresponding to all the score maps; min represents the minimum value of the abnormal scores corresponding to all the score maps.

[0117] In one embodiment, combining the sum of the overkill rate and the underkill rate mentioned above with the target distance index proposed here, the following rules are set for the conditions of saving the model:

[0118] The model is updated in only two scenarios: First, if the sum of the over-detection rate and the under-detection rate in the current epoch is better than the optimal sum, the model and all metrics to be updated, including the sum of the over-detection rate and the under-detection rate, target distance, over-detection rate, under-detection rate, and target segmentation threshold, are updated. Second, if the sum of the over-detection rate and the under-detection rate is equal to the optimal sum, but the target distance is greater than the optimal target distance, the model and the aforementioned metrics are also updated. Using these two evaluation metrics, the optimal model can be preserved, and the optimal segmentation threshold (i.e., the target segmentation threshold) can also be obtained. Theoretically, it can be directly applied to actual defect detection, truly realizing an algorithm for finding the optimal model and adaptively setting the optimal threshold.

[0119] It should be noted that the existing technical solutions mentioned above, particularly the EfficientAD network which has proven highly suitable for anomaly detection in industrial automation, actually output an anomaly map as the average of two types of maps. One type is suitable for detecting structural anomalies (such as scratches, stains, etc.), while the other is suitable for detecting logical anomalies (such as redundant or misaligned parts, etc.). The numerical distributions of the two anomaly maps may be completely different. Directly adding them and taking the average would lead to incorrect results due to their different magnitudes. Therefore, it is necessary to scale them to a roughly consistent size distribution before taking the average; this is the process of standardization.

[0120] In the original approach, the output image of all qualified training images (corresponding to the score image in this invention) was directly taken, and the values ​​ranked from smallest to largest as the 99th and 90th percentiles were used as the output images. and This is because values ​​in the 99th percentile are considered outliers by default, while values ​​in the 90th percentile are considered the scores of most qualified pixels in the target area. The standardization process involves subtracting [something] from the output. Divide by ( - Finally, multiply by 0.1. The normal range of the standardized value is between 0 and 0.1. Values ​​less than 0 are background values, and values ​​greater than 0.1 are outliers.

[0121] However, this approach is too simplistic and crude. For example, in some datasets, outliers are very few, and the top 99% of values ​​are almost identical to the top 90%, leading to calculation errors. and If the values ​​are very close or even the same, the final standardized value will be positive infinity, which will lead to instability in the standardization process.

[0122] Therefore, before standardization, a reasonable calculation should be made based on the output distribution of qualified images. and This is a crucial point, as it determines the stability of standardization; otherwise, it would be difficult to achieve a universal effect on any dataset.

[0123] It should be noted that, as mentioned earlier, on some datasets, the 90th and 99th percentile values ​​of the score graph may be equal when sorted from smallest to largest. Therefore, it is advisable to first plot the distribution of the score graph values ​​and rankings, and then design how to obtain the most reasonable sum by observing the characteristics of the curves.

[0124] It should be noted that for most datasets, following the above standardization practices will not cause any problems. For example... Figure 8The image shows the relationship between the score and ranking of a model on the validation set for a certain dataset (the values ​​are sorted from largest to smallest, with smaller values ​​indicating higher rankings).

[0125] Depend on Figure 8 As can be seen in the figure The values ​​to the left of the point are relatively large and few in number, which perfectly matches the characteristics of outliers. The point values ​​to the right are all relatively small and show a slow decreasing trend, which is also a characteristic pattern of background points in most images. Therefore... and The value corresponds exactly to the outlier and background points, so it was found using the traditional method. and These are two suitable values ​​that can achieve the goal of standardizing the output score graph.

[0126] However, as Figure 9 As shown, some datasets were found using traditional methods. and Very close or even equal.

[0127] Depend on Figure 9 As can be seen, the scores of qualified images in this dataset are generally low, which causes the 99% and 90% scores to be on the same level, resulting in the aforementioned problem.

[0128] By observing the characteristic patterns of this curve, a specialized algorithm can be designed to find suitable... and .

[0129] Depend on Figure 9 It can be further observed that the leftmost part of this curve shows a rapid downward trend, then stabilizes after reaching a certain inflection point, and may then resemble... Figure 8 It will drop rapidly again and then stabilize, or it will directly resemble... Figure 9 It tends to stabilize directly and then declines slowly. Figure 9 Looking at the turning point magnified, such as Figure 10 As shown, there are actually two transitional parts, but they don't appear as... Figure 8 That would allow for a smooth transition between the two descent sections.

[0130] Based on the characteristics of the curves described above, we can find the first inflection point from right to left where the curve changes from flat to rapid for each new dataset. Then in 0 and The middle point of the ranking is used as , It must be in a period where the overall level is higher than Within that range, it could be a flat area or the leftmost rapidly descending area, but it will absolutely not appear as... and The situation where they are on the same horizontal line, that is and no the same.

[0131] Since the goal is to find the inflection point, a characteristic naturally comes to mind to characterize it: the slope. The slope at this inflection point must be completely different from the steady phase on the right and the rapid descent phase on the left. However, if we use the tangent slope as an indicator to find the inflection point, firstly, this slope is neither the maximum nor the minimum, and secondly, it is not easy to solve practically, because the curve here is, after all, a set of points, not an actual function curve that can be calculated by differentiation.

[0132] Ultimately, through observation and experimentation, the present invention designed the following algorithm to find the inflection point on the curve.

[0133] In one embodiment, before the step of obtaining the abnormal scores corresponding to the score map based on the values ​​of the score map, the adaptive threshold segmentation method in unsupervised mode further includes:

[0134] Step S51: Arrange the values ​​of the score graph in descending order to obtain the characteristic distribution curve.

[0135] It should be noted that the horizontal axis of this feature distribution curve represents the ranking, and the vertical axis represents the value of the score graph.

[0136] Step S52: Determine the reference point; the x-coordinate of the reference point is the x-coordinate of the first point greater than 0 from right to left on the feature distribution curve, and the y-coordinate of the reference point is the opposite of the maximum value of the score graph.

[0137] Specifically, first determine one of the points used to calculate the slope, namely the reference point. Then, by traversing the points on the characteristic distribution curve and calculating the slope of the straight line formed by each point and the reference point, the slope is used to determine which point is the turning point. The calculation method is to divide the difference of the vertical coordinates by the difference of the horizontal coordinates.

[0138] It should be noted that when traversing from right to left, the slope between each point on the characteristic distribution curve and the rightmost point of the characteristic distribution curve that is just greater than 0 increases. After passing the inflection point, the slope will gradually decrease. So, as long as we find the maximum value of this slope, we have found the inflection point. Therefore, the x-coordinate of the reference point is taken as the x-coordinate of the first point greater than 0 from right to left.

[0139] Regarding the ordinate of the benchmark point, the initial design simply set it to 0. Experiments revealed that on a very small number of datasets, the flattened areas of the curve were not always smooth. During the right-to-left traversal, some points exhibited significant fluctuations, causing the calculated slope to suddenly increase and then decrease, leading to premature stopping and obtaining an undesirable inflection point. To address this, it was observed that the non-monotonic change in slope caused by small fluctuations in the output value was related to the close proximity of the values ​​of the two points involved in the slope calculation. If the ordinate values ​​of the two points differed significantly, even with small fluctuations at a particular point, the slope would still be monotonically increasing. Therefore, this invention modified the ordinate of the benchmark point by directly using the negative of the maximum value. Experiments showed that this slope change was very stable and could be obtained from... Figure 11 It can be seen that once the ordinate of the reference point O is lowered to the opposite of its maximum value, the slope between the two points will inevitably increase monotonically as the traversal proceeds from right to left. After the inflection point, it will begin to decrease monotonically, just as the slope of the straight line between each point from p6 to p2 and the reference point O in the diagram increases monotonically, and then decreases monotonically from p2 to p1. An error-prone inflection point will only be identified if the jump in a value before the inflection point is greater than the sudden drop near the maximum value on the left. However, according to the characteristic curve distribution of anomaly detection, this is impossible; the flat middle part of the curve will never exhibit the rapid drop seen on the left.

[0140] Step S53: Traverse the points on the feature distribution curve from right to left until the slope between the target point and the reference point is less than the slope between the inflection point and the reference point; wherein, the inflection point is located to the right of the target point, and the inflection point is the point closest to the target point; the ordinate of the inflection point is the value ranked 90th; the ordinate of the middle point is the value ranked 99th; the middle point is on the feature distribution curve, and the x-coordinate is the center between the x-coordinate of the inflection point and 0.

[0141] It's important to note that we need to stop when we find a local maximum of the slope. This is because when traversing to the left, on some datasets, we might encounter a second inflection point. It's uncertain which of the two inflection points forms a larger slope with respect to the baseline O, so we can't directly use the maximum value as the basis for finding the first inflection point. Therefore, we only need to find a local maximum while traversing from right to left—that is, a slope value smaller than the previous one—and then we can return to the previous point.

[0142] Step S54: Standardize the score graph based on the value ranked in the 90th percentile and the value ranked in the 99th percentile to obtain a standardized score graph.

[0143] In this embodiment, obtaining the abnormal score corresponding to the score map based on the value of the score map includes: stretching and transforming the standardized score map into a one-dimensional vector, and then obtaining the abnormal score based on the value of the standardized score map.

[0144] It should be noted that the above algorithm effectively solves the problem of instability in standardization, such as... Figure 9 The corresponding curve in the image, obtained through the algorithm described above, was found. and It will not appear on the horizontal line, and the effect is as follows: Figure 12 As shown.

[0145] Depend on Figure 12 It can be seen that, It is located right at the turning point. Naturally, it is located in the same place as... The position is high, and it is neither too large nor too small, so the final value range distribution is relatively uniform.

[0146] In summary, this method can standardize the score graph, ensuring that the magnitudes of the two result graphs output by the model remain largely consistent. By directly adding them together and taking the average, the information from both sets of result graphs can be fully utilized. Combined with an adaptive threshold algorithm, the final result is much more stable than traditional methods.

[0147] The scope of protection of the adaptive threshold segmentation method in unsupervised mode described in this embodiment is not limited to the execution order of the steps listed in this embodiment. Any solution implemented by adding, subtracting, or replacing steps in the prior art based on the principle of this invention is included within the scope of protection of this invention.

[0148] This invention also provides an electronic device, which includes a processor and a memory; the memory is used to store a computer program; the processor is used to execute the computer program stored in the memory, so that the electronic device performs the above-described adaptive threshold segmentation method in unsupervised mode.

[0149] This invention also provides a computer-readable storage medium storing a computer program that, when executed by an electronic device, implements the above-described adaptive threshold segmentation method in unsupervised mode.

[0150] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing a processor. The program can be stored in a computer-readable storage medium, which is a non-transitory medium, such as random access memory, read-only memory, flash memory, hard disk, solid-state drive, magnetic tape, floppy disk, optical disk, and any combination thereof. The storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. This available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state drive (SSD)).

[0151] This invention also provides an adaptive threshold segmentation system in an unsupervised mode. The adaptive threshold segmentation system in an unsupervised mode can implement the adaptive threshold segmentation method in an unsupervised mode described in this invention. However, the implementation device of the adaptive threshold segmentation method in an unsupervised mode described in this invention includes, but is not limited to, the structure of the adaptive threshold segmentation system in an unsupervised mode listed in this embodiment. All structural modifications and substitutions of the prior art made in accordance with the principles of this invention are included within the protection scope of this invention.

[0152] like Figure 13 As shown, in one embodiment, the present invention provides an adaptive threshold segmentation system in unsupervised mode, the adaptive threshold segmentation system in unsupervised mode comprising:

[0153] The first acquisition module 131 is used to acquire a verification set; the verification set includes a qualified image group and an unqualified image group; wherein, the qualified image group includes qualified images; and the unqualified image group includes unqualified images.

[0154] The model input module 132 is used to input the validation set into the unsupervised image segmentation model to obtain the corresponding score map.

[0155] The second acquisition module 133 is used to acquire abnormal scores corresponding to the score map based on the value of the score map, so as to acquire a qualified array and an unqualified array based on the abnormal scores; wherein, the qualified array includes abnormal scores of the score maps corresponding to all qualified images; and the unqualified array includes abnormal scores of the score maps corresponding to all unqualified images.

[0156] The threshold determination module 134 is used to determine the target segmentation threshold based on the qualified array and the unqualified array, so as to minimize the sum of the corresponding over-detection rate and under-detection rate, and then realize adaptive threshold segmentation in unsupervised mode based on the target segmentation threshold.

[0157] It should be noted that the structure and principle of the first acquisition module 131, the model input module 132, the second acquisition module 133 and the threshold determination module 134 correspond one-to-one with the steps (steps S1 to S4) in the adaptive threshold segmentation method under the above-mentioned unsupervised mode. The specific working principle can also be referred to the introduction of the adaptive threshold segmentation method under the unsupervised mode in the foregoing embodiment, so it will not be repeated here.

[0158] In the embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, or methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of modules / units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or units may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of apparatuses or modules or units may be electrical, mechanical, or other forms.

[0159] The modules / units described as separate components may or may not be physically separate. The components shown as modules / units may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules / units can be selected to achieve the objectives of the embodiments of the present invention, depending on actual needs. For example, the functional modules / units in the various embodiments of the present invention may be integrated into one processing module, or each module / unit may exist physically separately, or two or more modules / units may be integrated into one module / unit.

[0160] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0161] The descriptions of the processes or structures corresponding to the above figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.

[0162] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the invention. Any person skilled in the art can modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by those skilled in the art without departing from the spirit and technical concept disclosed in the present invention should still be covered by the claims of the present invention.

Claims

1. An adaptive threshold segmentation method in an unsupervised mode, characterized in that, The unsupervised adaptive threshold segmentation method includes: Obtain a verification set; the verification set includes a qualified image group and an unqualified image group; wherein, the qualified image group includes qualified images; and the unqualified image group includes unqualified images. The validation set is input into an unsupervised image segmentation model to obtain the corresponding score map; Based on the value of the score map, obtain the abnormal scores corresponding to the score map, and obtain a qualified array and an unqualified array based on the abnormal scores; wherein, the qualified array includes the abnormal scores of the score maps corresponding to all qualified images; the unqualified array includes the abnormal scores of the score maps corresponding to all unqualified images; The target segmentation threshold is determined based on the qualified array and the unqualified array to minimize the sum of the corresponding over-detection rate and under-detection rate, and then adaptive threshold segmentation in unsupervised mode is achieved based on the target segmentation threshold.

2. The adaptive threshold segmentation method in unsupervised mode according to claim 1, characterized in that, The step of obtaining the abnormal score corresponding to the score graph based on the value of the score graph includes: arranging the values ​​of the score graph in descending order, and taking the value at a preset position as the abnormal score.

3. The adaptive threshold segmentation method in unsupervised mode according to claim 1, characterized in that, Determining the target segmentation threshold based on the qualified array and the unqualified array includes: Compare the smallest value in the qualified array with the smallest value in the unqualified array; If the smallest value in the qualified array is less than the smallest value in the unqualified array, then the values ​​in the qualified array are compared with the smallest value in the unqualified array in ascending order until a first target value in the qualified array is greater than or equal to the smallest value in the unqualified array. The target segmentation threshold is then calculated based on the first value and the second value. The first value is the value in the qualified array that is less than the first target value and closest to it; the second value is the smallest value in the unqualified array. If the smallest value in the qualified array is greater than or equal to the smallest value in the unqualified array, then the values ​​in the unqualified array are compared with the smallest value in the qualified array in ascending order until a second target value appears in the unqualified array that is greater than the smallest value in the qualified array. The target segmentation threshold is then calculated based on the third and fourth values. The third value is the smallest value in the qualified array, and the fourth value is the second target value.

4. The adaptive threshold segmentation method in unsupervised mode according to claim 3, characterized in that, The formula for calculating the target segmentation threshold is: K = (A + B) / 2; Wherein, K represents the target segmentation threshold; A represents the first value or the third value; when A represents the first value, B represents the second value; when A represents the third value, B represents the fourth value.

5. The adaptive threshold segmentation method in unsupervised mode according to claim 3, characterized in that, The formula for calculating the overkill rate is: P1 = (L1 - m) / L1; Wherein, P1 represents the overkill rate; L1 represents the length of the qualified array; m is 1, or m is the number of comparisons in which the values ​​in the qualified array are compared with the smallest value in the unqualified array, m is a positive integer, and m≤L1; The formula for calculating the false negative rate is: P2 = (n-1) / L2; Wherein, P2 represents the false negative rate; L2 represents the length of the non-conforming array; when m is 1, n is the number of comparisons in which the values ​​in the non-conforming array are compared with the smallest value in the conforming array, n is a positive integer, and n≤L2; when m is the number of comparisons in which the values ​​in the conforming array are compared with the smallest value in the non-conforming array, n is 1.

6. The adaptive threshold segmentation method in unsupervised mode according to any one of claims 3 to 5, characterized in that, The adaptive threshold segmentation method in the unsupervised mode further includes: calculating a target distance based on the first value and the second value, or based on the third value and the fourth value, and using the target distance as an evaluation index to optimize the unsupervised image segmentation model; the formula for calculating the target distance is: D = (BA) / (max - min); Wherein, D represents the target distance; A represents the first value or the third value; when A represents the first value, B represents the second value; when A represents the third value, B represents the fourth value; max represents the maximum value of the abnormal scores corresponding to all the score maps; min represents the minimum value of the abnormal scores corresponding to all the score maps.

7. The adaptive threshold segmentation method in unsupervised mode according to claim 1, characterized in that, Before the step of obtaining the abnormal scores corresponding to the score map based on the values ​​of the score map, the adaptive threshold segmentation method in unsupervised mode further includes: The values ​​of the score graph are arranged in descending order to obtain the characteristic distribution curve; Determine a benchmark point; the x-coordinate of the benchmark point is the x-coordinate of the first point greater than 0 from right to left on the feature distribution curve, and the y-coordinate of the benchmark point is the negative of the maximum value of the score graph. Traverse the points on the feature distribution curve from right to left until the slope between the target point and the reference point is less than the slope between the inflection point and the reference point; wherein, the inflection point is located to the right of the target point, and the inflection point is the point closest to the target point; the ordinate of the inflection point is the value ranked 90th; the ordinate of the midpoint is the value ranked 99th; the midpoint is on the feature distribution curve, and its x-coordinate is the center between the x-coordinate of the inflection point and 0; The score graph is standardized based on the value ranked in the 90th percentile and the value ranked in the 99th percentile to obtain a standardized score graph. The step of obtaining the abnormal score corresponding to the score graph based on the value of the score graph includes: stretching and transforming the standardized score graph into a one-dimensional vector, and then obtaining the abnormal score based on the value of the standardized score graph.

8. An adaptive threshold segmentation system in an unsupervised mode, characterized in that, The unsupervised adaptive threshold segmentation system includes: The first acquisition module is used to acquire a verification set; the verification set includes a qualified image group and an unqualified image group; wherein, the qualified image group includes qualified images; and the unqualified image group includes unqualified images. The model input module is used to input the validation set into the unsupervised image segmentation model to obtain the corresponding score map; The second acquisition module is used to acquire abnormal scores corresponding to the score map based on the value of the score map, so as to acquire a qualified array and an unqualified array based on the abnormal scores; wherein, the qualified array includes abnormal scores of the score maps corresponding to all qualified images; the unqualified array includes abnormal scores of the score maps corresponding to all unqualified images; The threshold determination module is used to determine the target segmentation threshold based on the qualified array and the unqualified array, so as to minimize the sum of the corresponding over-detection rate and under-detection rate, and then realize adaptive threshold segmentation in unsupervised mode based on the target segmentation threshold.

9. An electronic device, characterized in that, The electronic device includes: a processor and a memory; The memory is used to store computer programs; The processor is configured to execute the computer program stored in the memory to cause the electronic device to perform the adaptive threshold segmentation method in unsupervised mode as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by an electronic device, the program implements the adaptive threshold segmentation method in unsupervised mode as described in any one of claims 1 to 7.