A model optimization method, an electronic device, and a computer-readable storage medium
By calculating the threshold optimization search range of the textile defect detection model and selecting the target threshold that meets the preset conditions, the problems of excessively large segmentation result range and excessive noise in the reverse distillation model are solved, thus improving the detection accuracy.
Patent Information
- Application Number
- CN202311279736.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2043-09-28
AI Technical Summary
In existing technologies, the reverse distillation model based on reconstruction and knowledge distillation has problems in textile defect detection, such as the segmentation result being too large and noisy due to the inaccurate feature cosine similarity threshold obtained during teacher and student network training.
By acquiring the pixel values of the target image, calculating the average pixel value and standard deviation, determining the threshold optimization search range in the classification model, and selecting the target threshold that meets the preset conditions within this range, the threshold of the classification model is optimized.
This improved the classification accuracy of the classification model in textile defect detection, reduced excessive detection range and noise, and enhanced the accuracy of detection results.
Smart Images

Figure CN117292191B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of machine learning, and in particular to a model optimization method, an electronic device and a computer readable storage medium. BACKGROUND
[0002] Textile patterns are complex and diverse, and as market demand and fashion trends change, experienced workers are needed to complete manual visual inspection. By using computer vision technologies such as image segmentation and classification detection, learning from labeled defect-free training image samples, small-batch, complex-pattern textile defect intelligent detection is achieved to reduce manual visual inspection costs, improve product quality and economic benefits.
[0003] In the prior art, a Reverse Distillation method based on reconstruction and knowledge distillation is generally used to determine whether there is an anomaly in the sample by comparing the cosine similarity of the features between the teacher network and the student network. However, the Reverse Distillation model can identify anomalies, but the cosine similarity threshold of the features obtained during training of the teacher and student networks is not accurate enough, which can result in problems such as excessively large segmentation result range and excessive noise. SUMMARY
[0004] The present application aims to provide a model optimization method, an electronic device and a computer readable storage medium, which can solve the problem of excessively large range and excessive noise when a classification model performs classification detection, and help to improve the classification accuracy of the classification model when classifying images.
[0005] To achieve the above-mentioned purposes:
[0006] In a first aspect, the embodiments of the present application provide a model optimization method, which comprises the following steps:
[0007] Obtaining pixel values of at least one target image, the target image being obtained by an initial classification model classifying at least one image;
[0008] Determining a search range for optimizing a threshold in the classification model according to the pixel values of the target image;
[0009] Determining a target threshold according to the search range, and taking the target threshold as the threshold in the optimized classification model.
[0010] In an embodiment, the step of determining a search range for optimizing a threshold in the classification model according to the pixel values of the target image comprises:
[0011] According to a pixel value of the target image, an average pixel value corresponding to the target image and a standard deviation of the pixel value are obtained;
[0012] According to a difference between the average pixel value and a target value and a sum of the average pixel value and the target value, a search range for optimizing a threshold in the classification model is determined; the target value is a product of the standard deviation and a preset parameter.
[0013] In an embodiment, the step of determining a target threshold according to the search range comprises:
[0014] According to a pixel value obtained after normalization processing of the target image, it is detected whether a current threshold satisfies a preset condition; the current threshold is an arbitrary numerical value selected from the search range after the normalization processing;
[0015] If yes, it is determined that the current threshold is the target threshold.
[0016] In an embodiment, the step of detecting whether the current threshold satisfies the preset condition according to the pixel value obtained after the normalization processing of the target image comprises:
[0017] The current threshold is taken as the threshold in the classification model to perform classification detection on a known sample image;
[0018] If a classification detection result is consistent with a known classification result of the known sample image, it is determined that the current threshold satisfies the preset condition.
[0019] In an embodiment, the method further comprises:
[0020] In a case where the preset condition is not satisfied, the current threshold is updated in the search range until it is determined that the current threshold satisfies the preset condition.
[0021] In an embodiment, the method further comprises:
[0022] In a case where none of the current thresholds in the search range satisfies the preset condition, the preset parameter is increased to update the search range for optimizing the threshold in the classification model, and the current threshold is reselected in the updated search range.
[0023] In an embodiment, the classification model comprises at least one of the following:
[0024] A reverse distillation model, a self-encoder model, a variational self-encoder model, a convolutional neural network model and a generative adversarial network model.
[0025] In an embodiment, before the pixel value of the at least one target image is obtained, the method further comprises:
[0026] At least one image is input into an initial classification model to obtain at least one target image obtained by classifying the at least one image based on an initial threshold; the initial threshold is obtained by training the initial classification model based on a preset image dataset.
[0027] Secondly, embodiments of this application disclose an electronic device, specifically including:
[0028] processor;
[0029] Memory used to store the processor's executable instructions;
[0030] The processor is configured to execute the instructions for performing the model optimization method as described in the first aspect.
[0031] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program, wherein when the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to implement the model optimization method as described in the first aspect.
[0032] This application provides a model optimization method, electronic device, and readable storage medium. The method includes the following steps: acquiring pixel values of at least one target image, wherein the target image is obtained by classifying at least one image using an initial classification model; determining a search range for optimizing a threshold in the classification model based on the pixel values of the target image; determining a target threshold based on the search range, and using the target threshold as the threshold in the optimized classification model. This solves the problems of excessively large search ranges and high noise levels encountered by classification models during classification detection, and helps improve the classification accuracy of classification models when classifying and detecting images. Attached Figure Description
[0033] Figure 1 A schematic flowchart of the model optimization method provided in an embodiment of the present invention;
[0034] Figure 2 This is a schematic diagram illustrating classification using a reverse distillation model in existing technologies.
[0035] Figure 3 A schematic diagram illustrating a specific embodiment of the model optimization method provided in this invention;
[0036] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0037] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0038] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0039] It should be understood that although the terms first, second, third, etc., may be used herein to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if," as used herein, can be interpreted as "when," "when," or "in response to determination." Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms "comprising," "including," indicate the presence of the stated feature, step, operation, element, component, item, kind, and / or group, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. The terms "or" and "and / or" as used herein are to be interpreted as inclusive, or mean any one or any combination thereof. Therefore, "A, B, or C" or "A, B, and / or C" means "any one of the following: A; B; C; A and B; A and C; B and C; A, B, and C". Exceptions to this definition will only occur if the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.
[0040] It should be understood that although the steps in the flowcharts of this application's embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0041] It should be noted that step designations such as S101 and S102 are used in this document for the purpose of more clearly and concisely describing the corresponding content, and do not constitute a substantial limitation on the order. In specific implementation, those skilled in the art may execute S102 first and then S101, etc., but these should all be within the protection scope of this application.
[0042] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0043] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0044] See Figure 1 This application provides a model optimization method, which can be executed by a model optimization device provided in this application. The model optimization device can be implemented in software and / or hardware, such as electronic devices like servers or computers. The model optimization method provided in this embodiment includes:
[0045] Step S1: Obtain the pixel values of at least one target image, wherein the target image is obtained by the initial classification model classifying at least one image.
[0046] The at least one image can be an image of textiles, a person, a building, etc., and is not specifically limited here. Classifying the at least one image means classifying the at least one image based on its pixel values using an initial classification model to obtain classification results for each image. The target image can be an abnormal image detected during anomaly detection of the at least one image, or an image of a certain category obtained during classification detection of the at least one image, etc.
[0047] In one embodiment, before acquiring the pixel values of at least one target image, the method further includes:
[0048] At least one image is input into an initial classification model to obtain at least one target image obtained by classifying the at least one image based on an initial threshold; the initial threshold is obtained by training the initial classification model based on a preset image dataset.
[0049] Optionally, an initial classification model can be trained using a pre-set image dataset to obtain an initial threshold for the classification model. Then, at least one image can be input into the trained classification model, allowing the model to classify and detect the input image based on the initial threshold, determining whether it is a target image or a non-target image.
[0050] Step S2: Determine the search range for optimizing the threshold in the classification model based on the pixel values of the target image.
[0051] Specifically, based on the determined pixel values of each target image, the average pixel value, variance, and standard deviation of the target image are calculated. The search range for optimizing the threshold in the classification model is then determined based on the calculated average pixel value and standard deviation. It can be understood that smaller variance and standard deviation mean that anomalous pixel values are more concentrated, potentially requiring a narrower threshold range to detect smaller anomalies, while larger variance and standard deviation mean that anomalous pixel values are more dispersed, potentially requiring a wider threshold range.
[0052] In one embodiment, the step of determining the search range for optimizing the threshold in the classification model based on the pixel values of the target image includes:
[0053] Based on the pixel values of the target image, obtain the average pixel value and the standard deviation of the pixel values corresponding to the target image;
[0054] The search range for optimizing the threshold in the classification model is determined based on the difference between the average pixel value and the target value, and the sum of the average pixel value and the target value; the target value is the product of the standard deviation and the preset parameter.
[0055] Optionally, based on the pixel values of each target image, an average pixel value among the target images is determined. Here, the average pixel value of the target images can serve as a reference point for a threshold. A lower average pixel value may indicate a greater number of outliers in the image, while a higher average pixel value may indicate fewer outliers. The variance of the pixel values of the target images is calculated based on the determined average pixel value. Variance helps assess the dispersion of pixel values. A smaller variance indicates that the pixel values in the target images are relatively concentrated, while a larger variance indicates a higher degree of dispersion. The standard deviation of the pixel values of the target images is then calculated based on the variance. Here, the standard deviation is the square root of the variance. The standard deviation can be used to determine information about the range of fluctuations in the pixel values of the target images; a larger standard deviation indicates greater fluctuations in the pixel values of the target images.
[0056] Optionally, after calculating the standard deviation of the pixel values of the target image, the product of the standard deviation and the preset parameter is calculated to determine the target value. The difference between the average pixel value and the target value is used as the minimum value of the search range for optimizing the threshold in the classification model, and the sum of the average pixel value and the target value is used as the maximum value of the search range for optimizing the threshold in the classification model, thereby determining the search range for optimizing the threshold in the classification model.
[0057] Step S3: Determine the target threshold based on the search range, and use the target threshold as the threshold in the optimized classification model.
[0058] Here, a target threshold is selected within a defined search range, and this target threshold is used as the threshold in the optimized classification model for image classification and detection.
[0059] In one embodiment, the step of determining the target threshold based on the search range includes:
[0060] Based on the pixel values obtained after normalizing the target image, it is determined whether the current threshold meets the preset conditions; the current threshold is any value selected from the search range after normalization.
[0061] If the conditions are met, then the current threshold is determined to be the target threshold.
[0062] Optionally, in image processing and computer vision, pixel values are typically represented as a range of 0 to 255, where 0 represents black and 255 represents white. Dividing the pixel value by 255 maps it to a normalized range of 0 to 1, facilitating subsequent calculations and processing. Therefore, the pixel values of the target image and the search range can be normalized by dividing them by 255 respectively, and a value can be randomly selected from the normalized search range as the current threshold. It can then be determined whether the selected current threshold meets the preset conditions.
[0063] In one embodiment, the step of detecting whether the current threshold meets a preset condition based on the pixel values obtained after normalizing the target image includes:
[0064] The current threshold is used as the threshold in the classification model to classify and detect known sample images;
[0065] If the classification detection result is consistent with the known classification result of the known sample image, then the current threshold is determined to meet the preset condition.
[0066] Optionally, after selecting a value as the current threshold within the search range after normalization, the selected current threshold is substituted into the classification model, and the known sample image is detected by the classification model. Here, the known sample image is a sample image that has already been classified and the classification result of the image has been determined. Optionally, after obtaining the classification detection result of the classification model on the known sample image based on the selected current threshold, it is determined whether the classification detection result obtained by the classification model is consistent with the known classification result of the known sample image, that is, whether the classification detection result obtained by the classification model is the same as the known classification result of the known sample image. If it is determined that the classification detection result of the classification model is consistent with the known classification result of the known sample image, then it is determined that the current threshold meets the preset condition. Here, the known classification result of the known sample image can also be a visual result that can be distinguished by a human. Correspondingly, if the classification detection result of the classification model on the known sample image is consistent with the visual result of the classification detection of the known sample image, then it is determined that the classification detection result of the classification model is consistent with the known classification result of the known sample image, thereby determining that the current threshold meets the preset condition.
[0067] In one embodiment, the method further includes:
[0068] If the preset conditions are not met, the current threshold is updated within the search range until it is determined that the current threshold meets the preset conditions.
[0069] Optionally, if it is determined that the classification detection result of the classification model is inconsistent with the known classification result of the known sample image, then it is determined that the current threshold does not meet the preset condition. In the search range after normalization processing, other values are reselected as the current threshold. The reselected current threshold is used as the model for classification detection, and it is detected whether the reselected current threshold meets the preset condition. This process continues until it is determined that the current threshold meets the preset condition, and the corresponding target threshold is determined.
[0070] In one embodiment, the method further includes:
[0071] If none of the current thresholds in the search range meet the preset conditions, the preset parameter is increased to update the search range for optimizing the thresholds in the classification model, and the current threshold is reselected in the updated search range.
[0072] Optionally, if none of the current thresholds selected within the search range meet the preset conditions, the value of the preset parameter is increased to correspondingly expand the search range for optimizing the thresholds in the classification model. Then, the current threshold is reselected within the expanded search range until a current threshold is found that meets the preset conditions. For example, if the preset parameter is set to 1 when initially determining the search range for optimizing the thresholds in the classification model, the current threshold is directly searched within the normalized range of "average pixel value - standard deviation" and "average pixel value + standard deviation." If none of the current thresholds selected within this search range meet the preset conditions, the preset parameter can be adjusted to 2, and the search continues within the normalized range of "average pixel value - 2 * standard deviation" and "average pixel value + 2 * standard deviation" until a current threshold is found that meets the preset conditions, and this determined current threshold is used as the target threshold.
[0073] In one embodiment, the classification model includes at least one of the following:
[0074] Inverse distillation model, autoencoder model, variational autoencoder model, convolutional neural network model, generative adversarial network model.
[0075] Optionally, the target threshold determined in this application is mainly used for image classification or anomaly detection using a classification model. The classification model here includes, but is not limited to, reverse distillation models, autoencoder models, variational autoencoder models, convolutional neural network models, and generative adversarial network models. Here, this paper mainly uses the reverse distillation (RD) model as an example, such as... Figure 2 As shown, the Reverse Distillation model is a model based on reconstruction and knowledge distillation. Its main principle is to detect and judge the samples by comparing the cosine similarity of features between the teacher network and the student network. If the cosine similarity of features from the two networks on a certain sample is high, it can be judged as a normal sample; if the cosine similarity is low, it can be judged as an abnormal sample. In this way, the features extracted by the teacher network are used to guide the student network to learn features from the samples, and normal / abnormal samples are classified according to feature similarity.
[0076] In other implementations, after determining the search range, a value is directly selected within the search range as the current threshold. This selected current threshold is then substituted into the classification model to detect known sample images. The model is then used to determine whether the classification result matches the known classification result of the known sample images. If they match, the current threshold is determined to meet a preset condition. If they do not match, a new value is selected within the search range as the current threshold, and this process continues until the current threshold is determined to meet the preset condition.
[0077] In summary, the model optimization method provided in the above embodiments, by calculating the search range of the threshold and determining the optimal target threshold in the classification model based on the search range, can solve the problems of excessively large range and excessive noise in the classification model when performing classification detection, and helps to improve the classification accuracy of the classification model when performing image classification detection.
[0078] Based on the same inventive concept as the foregoing embodiments, the model optimization method provided in this embodiment will be described in detail below through a specific example. In this example, the image is a textile image and the classification model is a reverse distillation (RD) model.
[0079] like Figure 2 As shown, in the backdistillation model, the teacher network is treated as a downsampling filter and the student network as an upsampling filter. This reverse structure avoids confusion caused by the inability to distinguish between filters. Simultaneously, the low-dimensional embeddings fed into the student network serve as the information bottleneck layer for normal pattern recovery, and the compact embeddings help prevent anomalous features from propagating to the student model. The backdistillation model described above can achieve anomaly detection in textiles, solving the problem of traditional manual visual inspection. However, due to the lack of anomalous textile samples and the different types of textiles, the feature cosine similarity thresholds obtained during the training of the teacher and student networks are often inaccurate, leading to an overly large detection range and inaccurate detection results.
[0080] To address the aforementioned issues, this embodiment provides a model optimization method, namely, optimizing the detection threshold of the reverse distillation model to achieve anomaly detection in textile images, such as... Figure 3 As shown, it includes the following steps:
[0081] Step S101: Obtain the anomaly image detected by the initial reverse distillation model.
[0082] Optionally, a dataset used for developing and evaluating textile patterns is input into the backdistillation model to train the model, determining an initial threshold for anomaly detection in textile images. The trained backdistillation model then performs anomaly classification and detection on the textile images requiring anomaly detection based on this initial threshold. At least one anomalous image of the textile detected by the backdistillation model is obtained.
[0083] Step S102: Calculate the average pixel value, variance, and standard deviation of the abnormal image.
[0084] The average pixel value can be calculated using the formula: "Average pixel value = (pixel value 1 + pixel value 2 + ... + pixel value n) / number of abnormal images"; the variance can be calculated using the formula: "Variance = [(pixel value 1 - average pixel value)]". 2 +(pixel value 2 - average pixel value) 2 +……+(pixel value n - average pixel value) 2 The standard deviation is calculated as the number of abnormal images; the standard deviation is the square root of the variance.
[0085] Step S103: Determine the search range of the threshold based on the average pixel value, variance, and standard deviation of the abnormal image.
[0086] Optionally, the range of threshold search is limited according to preset parameters. The difference between the determined average pixel value and the standard value of the preset parameter multiple, and the sum of the average pixel value and the preset parameter multiple, are determined as the search range of the threshold in the reverse distillation model.
[0087] Step S104: Select a threshold and test its effect, and determine the optimal threshold.
[0088] Within the defined search range, a value is selected as the detection threshold and substituted into the reverse distillation model for detection. It is then determined whether this threshold satisfies the conditions for anomaly detection and classification of the textile image. If it does, this value is identified as the optimal image for anomaly detection. If not, a new value is selected from the search range as the detection threshold, and the detection and judgment process continues until a value is found that satisfies the conditions for anomaly detection and classification of the textile image.
[0089] In summary, the model optimization method provided in the above embodiments can solve the problems of excessive range and noise in classification models when performing classification detection, and helps to improve the classification accuracy of classification models when performing image classification detection.
[0090] Based on the same inventive concept as the foregoing embodiments, this invention provides an electronic device, such as... Figure 4As shown, the electronic device includes: a processor 210 and a memory 311 storing a computer program; wherein, Figure 4 The processor 210 shown in the diagram does not refer to a single processor 210, but rather to its positional relationship relative to other devices. In practical applications, there can be one or more processors 210. Figure 4 The memory 211 illustrated in the diagram has the same meaning, that is, it is only used to indicate the positional relationship of memory 211 relative to other devices. In practical applications, there can be one or more memories 211. When the processor 210 runs the computer program, it implements the model optimization method described above.
[0091] The electronic device may also include at least one network interface 212. The various components of the electronic device are coupled together via a bus system 213. It is understood that the bus system 213 is used to implement communication between these components. In addition to a data bus, the bus system 213 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 4 The general designated all buses as Bus System 213.
[0092] The memory 211 can be volatile or non-volatile, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), SyncLink Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memory 211 described in the embodiments of the present invention is intended to include, but is not limited to, these and any other suitable types of memory.
[0093] The memory 211 in this embodiment of the invention is used to store various types of data to support the operation of the electronic device. Examples of this data include: any computer programs used to operate on the electronic device, such as operating systems and applications; contact data; phonebook data; messages; pictures; videos, etc. The operating system includes various system programs, such as a framework layer, core library layer, driver layer, etc., used to implement various basic services and handle hardware-based tasks. Applications can include various applications, such as media players, browsers, etc., used to implement various application services. Here, the program implementing the method of this embodiment of the invention can be included in the application.
[0094] Based on the same inventive concept as the foregoing embodiments, this embodiment also provides a computer-readable storage medium storing a computer program. The computer-readable storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM), etc.; it can also be various devices including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc. When the computer program stored in the computer-readable storage medium is executed by a processor, it implements the above-described model optimization method. For the specific steps implemented when the computer program is executed by the processor, please refer to [link to relevant documentation]. Figure 1 The description of the illustrated embodiments will not be repeated here.
[0095] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0096] In this document, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, which includes not only the elements listed but also other elements not expressly listed.
[0097] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A model optimization method, characterized by, The method comprises the following steps: acquiring pixel values of at least one target image, the target image being obtained by an initial classification model classifying at least one image; determining a search range for optimizing a threshold in the classification model according to the pixel values of the target image; determining a target threshold according to the search range, and taking the target threshold as the threshold in the optimized classification model; the step of determining the target threshold according to the search range comprises: detecting whether a current threshold meets a preset condition according to pixel values obtained after normalizing the target image; the current threshold being any value selected from the normalized search range; if yes, determining that the current threshold is the target threshold; the step of detecting whether the current threshold meets the preset condition according to the pixel values obtained after normalizing the target image comprises: taking the current threshold as the threshold in the classification model to classify and detect a known sample image; if the classification and detection result is consistent with a known classification result of the known sample image, determining that the current threshold meets the preset condition; the method further comprises: in the case of not meeting the preset condition, updating the current threshold in the search range until it is determined that the current threshold meets the preset condition.
2. The method of claim 1, wherein, the step of determining the search range for optimizing the threshold in the classification model according to the pixel values of the target image comprises: acquiring an average pixel value and a standard deviation of pixel values corresponding to the target image according to the pixel values of the target image; determining the search range for optimizing the threshold in the classification model according to a difference between the average pixel value and a target value and a sum of the average pixel value and the target value; the target value being a product of the standard deviation and a preset parameter.
3. The method of claim 2, wherein, the method further comprises: in the case that none of the current thresholds in the search range meets the preset condition, increasing the preset parameter to update the search range for optimizing the threshold in the classification model, and reselecting a current threshold in the updated search range.
4. The method of claim 1, wherein the classification model comprises at least one of: a reverse distillation model, a self-encoder model, a variational self-encoder model, a convolutional neural network model, and a generative adversarial network model.
5. The method of claim 1, wherein, Before the step of acquiring the pixel values of at least one target image, the method further comprises: inputting at least one image into an initial classification model to acquire at least one target image obtained by the classification model classifying the at least one image based on an initial threshold; the initial threshold being obtained by training the initial classification model based on a preset image dataset.
6. An electronic device, comprising: comprise: a processor; a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the model optimization method of any one of claims 1-5.
7. A computer readable storage medium characterized in that, When the instructions in the computer-readable storage medium are executed by the processor, the model optimization method of any one of claims 1-5 is implemented.
Citation Information
Patent Citations
Defect detection and classification method and device, electronic equipment and storage medium
CN114764768A
Defect detection method and device, electronic equipment and computer readable storage medium
CN114764774A