A dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection

CN122289906BActive Publication Date: 2026-09-29ZHEJIANG UNIV OF TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202610756589.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-05-29
Publication Date
2026-09-29
Estimated Expiration
2046-05-29

AI Technical Summary

Technical Problem

[0008]针对现有技术中存在的边缘设备上传策略适应性差、固定阈值难以适应异常分数分布动态变化、难以在带宽受限条件下兼顾异常样本命中率与传输效率等问题,本发明提供了一种面向云边协同工业视觉检测的动态异常感知采样方法

Benefits of technology

[0019]其一,本发明通过在边缘设备侧引入异常评分、滑动窗口统计分析和动态阈值判定机制,避免了固定阈值方法难以适应异常分数分布变化的问题,使采样策略能够随工业现场运行状态的变化而自适应调整,提高了上传决策的灵活性和适应性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289906B_ABST
    Figure CN122289906B_ABST
Patent Text Reader

Abstract

The application discloses a kind of dynamic abnormality perception sampling methods for cloud edge collaborative industrial vision detection, comprising: the time series image of industrial object is collected, and current image is input into abnormal score module to carry out abnormal degree evaluation;Extract the multi-layer feature of current input image and carry out local context enhancement and multi-scale fusion, obtain fusion feature map;Fusion feature map is matched with multi-scale normal feature prototype library, and pixel-level initial abnormal score is generated;Further distinguish pixel-level initial abnormal score, obtain pixel-level abnormal score chart, and generate image-level abnormal score;Establish sliding window to store image-level abnormal score;Dynamic sampling threshold is generated;Image-level abnormal score is compared with dynamic sampling threshold and whether to upload is decided;The above process is continuously repeated.The application introduces abnormal score, sliding window statistical analysis and dynamic threshold determination mechanism in edge device side, avoid the problem that fixed threshold method is difficult to adapt to abnormal score distribution change.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of industrial visual inspection and cloud-edge collaborative intelligent analysis technology, specifically a dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection. Background Technology

[0002] With the continuous development of industrial automation and intelligent manufacturing technologies, industrial vision inspection systems have been widely applied in fields such as textiles, metal processing, electronics manufacturing, and materials processing. These systems are used to automatically identify surface defects, texture abnormalities, damage, contamination, cracks, wrinkles, color differences, and other appearance anomalies on products. Compared to manual inspection methods, industrial vision inspection offers advantages such as high inspection speed, strong continuous working capability, and good consistency, making it one of the important technical means for modern industrial quality control.

[0003] Existing industrial vision inspection systems typically deploy edge devices near the production line, using industrial cameras to acquire images in real time and perform analysis at the edge. This approach effectively reduces response latency and meets the rapid inspection needs of industrial sites. However, because edge devices are usually limited by computing power, storage resources, and power consumption, the scale and complexity of the models deployed on them are often significantly restricted. When new anomalies, fine-grained anomalies, or complex background interference occur in the industrial environment, edge-side models are prone to problems such as unstable scoring, missed detections, or false detections.

[0004] On the other hand, cloud servers typically possess stronger computing power and larger storage space, enabling the deployment of more complex analysis models for more in-depth identification, verification, and processing of anomalous samples. Therefore, cloud-edge collaborative architecture has become one of the important development directions for industrial visual inspection. However, in practical applications, continuously uploading all images acquired at the edge to the cloud significantly increases the network link bandwidth burden. Especially in high-frame-rate continuous acquisition scenarios, massive amounts of normal samples will consume a large amount of transmission resources, not only increasing system operating costs but also reducing the uploading efficiency of truly high-value anomalous samples.

[0005] To reduce upload volume, existing technologies typically employ strategies such as fixed threshold sampling, periodic sampling, or static proportional sampling. For example, an image is uploaded only when its anomaly score exceeds a preset threshold; otherwise, it is not uploaded. While these methods are relatively simple to implement, the distribution of images in industrial settings dynamically fluctuates with changes in raw materials, equipment status, process parameters, ambient lighting, and production batches. Consequently, the anomaly score distribution also drifts over time. Fixed thresholds are difficult to adapt to this change in the long term: when the overall anomaly score decreases, truly analytically valuable anomalies may be difficult to trigger uploads; conversely, when the overall anomaly score increases, the number of uploads may increase significantly, potentially exceeding the link bandwidth's allowable range.

[0006] Furthermore, industrial inspection image streams typically exhibit continuity and temporal correlation. Images acquired at adjacent moments often show strong correlations in imaging conditions, target appearance, background state, and equipment operating status. Therefore, anomaly scores at a particular moment should not be judged in isolation from the overall distribution of recent image streams. However, many existing upload strategies primarily rely on single-frame images for decision-making, lacking the ability to model the statistical distribution of recent anomaly scores. This makes it difficult to accurately reflect whether the current sample is more anomalous or analytically valuable compared to recent samples. Especially when there is a slow drift in the production line environment, even a high single-frame score may simply be a result of an overall increase in the distribution.

[0007] Therefore, there is an urgent need to provide a new dynamic anomaly perception sampling method that enables edge devices to score the current input image and adaptively generate a dynamic sampling threshold by combining the statistical distribution of anomaly scores within a recent time window. This allows for the priority uploading of image samples with greater anomaly risk and analytical value under bandwidth-constrained conditions, thereby improving the operating efficiency and environmental adaptability of cloud-edge collaborative industrial vision inspection systems. Summary of the Invention

[0008] To address the problems in existing technologies, such as poor adaptability of edge device upload strategies, difficulty in adapting fixed thresholds to dynamic changes in abnormal score distribution, and difficulty in balancing abnormal sample hit rate and transmission efficiency under bandwidth-limited conditions, this invention provides a dynamic abnormality perception sampling method for cloud-edge collaborative industrial visual inspection.

[0009] To achieve the above objectives, the present invention provides the following technical solution: A dynamic anomaly perception sampling method for cloud-edge collaborative industrial vision inspection includes: Step 1: The edge device acquires time-series images of industrial objects in real time and inputs the current image into the anomaly scoring module on the edge side for anomaly assessment; Step 2: The anomaly scoring module extracts multi-layer features from the current input image and performs local context enhancement and multi-scale fusion to obtain a fused feature map; Step 3: Match the fused feature map with the multi-scale normal feature prototype library to generate pixel-level initial anomaly scores; Step 4: The lightweight discriminator further discriminates the initial pixel-level anomaly scores to obtain a pixel-level anomaly score map, and generates an image-level anomaly score through spatial aggregation. Step 5: Establish a sliding window of length W to store the image-level anomaly scores corresponding to the most recent W input images; Step 6: Calculate the window mean and window standard deviation based on the image-level anomaly scores in the sliding window; Step 7: Generate a dynamic sampling threshold based on the window mean, window standard deviation, fluctuation compensation term, and safety margin; Step 8: Compare the image-level anomaly score with the dynamic sampling threshold and decide whether to upload; Step 9: As industrial time-series images continue to be input, repeat steps 1-8 and recursively update window statistics to upload images with high anomaly risk.

[0010] Further, step 2 includes: For the current input image, a pre-trained feature extraction network is used to extract multi-layer feature representations. The multi-layer feature representations correspond to information at different scales and semantic levels. For each spatial location in the feature map of each layer, local context information within a preset neighborhood is aggregated with that spatial location as the center to obtain an enhanced local feature representation. Then, the enhanced feature maps of each layer are uniformly adjusted to the same spatial size and spliced ​​along the channel dimension to obtain a fused feature map.

[0011] Further, step 3 includes: The feature vectors corresponding to each spatial location in the fused feature map are similarly matched with the prototype vectors in a pre-built and stored multi-scale normal feature prototype library. Based on the matching results, pixel-level initial anomaly scores are calculated for each spatial location to characterize the degree of deviation of the current input image from the normal pattern at different spatial locations. The multi-scale normal feature prototype library is constructed from normal sample images after feature extraction via a pre-trained feature extraction network, and is used to describe the typical feature distribution of normal industrial objects at different scales. The pixel-level initial anomaly score s at any spatial location in the current input image is... ij Calculated using the following formula: , Where P is a multi-scale normal feature prototype library, f ij The feature vector at spatial location (i,j) of the fused feature map is p, which is the prototype vector in the multi-scale normal feature prototype library, and max() is the maximum value function.

[0012] Further, step 4 includes: The initial pixel-level anomaly score is input into the lightweight discriminator to obtain the pixel-level anomaly score map corresponding to the current input image. Then, spatial dimension maximum aggregation is performed on the pixel-level anomaly score map to obtain the image-level anomaly score corresponding to the current input image. The image-level anomaly score S... t The expression is: , in, Let be the anomaly response value of the pixel-level anomaly score map at spatial location (i,j), where i and j are spatial location indices. This means taking the maximum value across all spatial locations in the pixel-level anomaly score map.

[0013] Further, step 5 includes: A sliding window of length W is established in the edge device to store the image-level anomaly scores corresponding to the most recent W input images. When a new image-level anomaly score is obtained, the new image-level anomaly score is written into the sliding window, and the anomaly score that entered the sliding window earliest is removed.

[0014] Further, step 6 includes: Based on the image-level anomaly scores within the sliding window, calculate the window mean and standard deviation for the current time step. and window standard deviation The expressions are as follows: , , Among them, S k Let t be the image-level anomaly score corresponding to the k-th input image within the sliding window, and t be the time.

[0015] Further, step 7 includes: A dynamic sampling threshold is constructed based on the window mean, window standard deviation, fluctuation compensation term, and safety margin. This allows the dynamic sampling threshold to adaptively adjust to changes in data distribution during industrial production. The dynamic sampling threshold T t The expression is: , in, The fluctuation compensation term is represented by γ, the compensation coefficient, and Δ, which is the safety margin. The safety margin Δ is related to the window standard deviation. The proportional setting is expressed as follows: , Where c is a preset constant, and the expression for the compensation coefficient γ is: , Where λ is the compression coefficient, ε is a minimal constant to prevent the denominator from being zero, and tanh() is the hyperbolic tangent function.

[0016] Further, step 8 includes: The image-level anomaly score S corresponding to the current input image. t With dynamic sampling threshold T t Compare; when the image-level anomaly score S t Greater than the dynamic sampling threshold T t When the current input image is identified as an abnormal sample to be uploaded, it is uploaded to the cloud server; when the image-level anomaly score S... t Not greater than the dynamic sampling threshold T tWhen this happens, the current input image is determined to be a locally retained sample and is not uploaded.

[0017] Further, step 9 includes: As industrial image sequences are continuously input, steps 1 through 8 are repeated. The window mean is updated recursively, and its expression is: , Among them, S t S is the image-level anomaly score corresponding to the current input image. t-W The earliest image-level anomaly score removed from the sliding window.

[0018] Compared with the prior art, the beneficial effects of the present invention are:

[0019] Firstly, by introducing anomaly scoring, sliding window statistical analysis, and dynamic threshold determination mechanisms on the edge device side, this invention avoids the problem that fixed threshold methods are difficult to adapt to changes in the distribution of anomaly scores, enabling the sampling strategy to adaptively adjust with changes in the operating status of the industrial site, thereby improving the flexibility and adaptability of uploading decisions.

[0020] Secondly, this invention bases the current image upload decision on the statistical results of the recent time window, enabling the system to not only identify abnormal samples in an absolute sense, but also to identify samples with greater abnormal risk and analytical value relative to the current time period, thus better conforming to the actual operating characteristics of continuous industrial image streams.

[0021] Third, this invention improves the reliability of edge-side anomaly scoring through multi-layer feature extraction, local context enhancement, and multi-scale normal feature prototype matching, enabling more complete characterization of local minor anomalies, fine-grained texture changes, and multi-scale anomaly patterns, thus providing a more accurate scoring basis for subsequent dynamic sampling.

[0022] Fourth, by setting fluctuation compensation terms and safety margins, this invention can suppress small fluctuations in abnormal scores caused by short-term process disturbances, illumination fluctuations, imaging noise, and changes in equipment status, thereby reducing the problem of frequent switching of upload status for samples near the threshold and improving the stability of system operation.

[0023] Fifth, the present invention uses a sliding window and recursive update method to calculate the window mean and related statistics, eliminating the need to repeatedly count all historical data each time a new sample arrives. Therefore, it can effectively reduce the computational complexity and resource consumption of edge devices, making it easier to deploy and implement in resource-constrained scenarios.

[0024] Sixth, this invention can be widely applied to various industrial visual inspection scenarios such as textile defect detection, metal surface defect detection, electronic component appearance inspection, display panel defect detection, composite material crack detection, and packaging printing quality inspection, and has strong versatility and engineering application value. Attached Figure Description

[0025] Figure 1 This is a flowchart of a dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection in an embodiment of the present invention. Detailed Implementation

[0026] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0027] Reference Figure 1 A dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection includes the following steps:

[0028] Step 1: The edge device continuously collects image data of the industrial object to be detected, forming a sequence of industrial images input in chronological order, and sends the current input image to the edge-side anomaly scoring module for anomaly assessment.

[0029] Step 2: For the current input image, a pre-trained feature extraction network is used to extract multi-layer feature representations. These multi-layer feature representations correspond to information at different scales and semantic levels. For each spatial location in each feature map layer, local contextual information within a preset neighborhood is aggregated around that location to obtain an enhanced local feature representation. Then, the enhanced feature maps from each layer are uniformly adjusted to the same spatial size and concatenated along the channel dimension to obtain a fused feature map. This method simultaneously preserves shallow texture information and deep semantic information, enhancing the ability to express anomaly patterns at different scales, local texture changes, defect boundary changes, and surface flaw detail changes.

[0030] Step 3: Perform similarity matching between the feature vectors corresponding to each spatial location in the fused feature map and the prototype vectors in the pre-built and stored multi-scale normal feature prototype library. Calculate the initial pixel-level anomaly score for each spatial location based on the matching results to characterize the degree of deviation of the current input image from the normal pattern at different spatial locations. The multi-scale normal feature prototype library is constructed from normal sample images after feature extraction via a pre-trained feature extraction network, and is used to describe the typical feature distribution of normal industrial objects at different scales. The initial pixel-level anomaly score s at any spatial location in the current input image.ij Calculated using the following formula:

[0031]

[0032] Where P is a multi-scale normal feature prototype library, f ij The feature vector at spatial location (i,j) of the fused feature map is p, which is the prototype vector in the multi-scale normal feature prototype library, and max() is the maximum value function.

[0033] Step 4: Input the initial pixel-level anomaly score into the lightweight discriminator to obtain the pixel-level anomaly score map corresponding to the current input image. Then, perform spatial maximum aggregation on the pixel-level anomaly score map to obtain the image-level anomaly score corresponding to the current input image. The lightweight discriminator is used to further discriminate and analyze the initial pixel-level anomaly score to output a more stable anomaly response map; spatial maximum aggregation is used to highlight the anomaly response corresponding to the most significant anomaly regions in the image; and the image-level anomaly score is used to characterize the overall anomaly degree of the current input image. Image-level anomaly score S t The expression is:

[0034]

[0035] in, Let be the anomaly response value of the pixel-level anomaly score map at spatial location (i,j), where i and j are spatial location indices. This means taking the maximum value across all spatial locations in the pixel-level anomaly score map.

[0036] Step 5: Establish a sliding window of length W in the edge device to store the image-level anomaly scores corresponding to the W most recent input images. The sliding window tracks the statistical distribution of anomaly scores in the industrial image stream over a recent period to accommodate anomaly score distribution drift caused by changes in raw material properties, equipment status, process parameters, ambient lighting, or batch variations. When a new image-level anomaly score is obtained, it is written into the sliding window, and the earliest anomaly score entered into the window is removed.

[0037] Step 6: Based on the image-level outlier scores within the sliding window, calculate the window mean and window standard deviation for the current time period. The window mean reflects the average level of outlier scores within the current time period, while the window standard deviation characterizes the fluctuation of outlier scores within the current time period. Window Mean and window standard deviation The expressions are as follows:

[0038]

[0039]

[0040] Among them, S k Let t be the image-level anomaly score corresponding to the k-th input image within the sliding window, and t be the time.

[0041] Step 7: Construct a dynamic sampling threshold based on the window mean, window standard deviation, fluctuation compensation term, and safety margin. This allows the dynamic sampling threshold to adaptively adjust to changes in data distribution during industrial production. The fluctuation compensation term compensates for small fluctuations in image-level anomaly scores caused by process variations, lighting disturbances, imaging noise, or changes in equipment status, reducing the sensitivity of anomaly detection to short-term disturbances and improving sampling stability. The safety margin adds a safety boundary to the dynamic sampling threshold to suppress false uploads caused by frequent fluctuations in samples near the boundary. Dynamic sampling threshold T t The expression is:

[0042]

[0043] in, The fluctuation compensation term is represented by γ, the compensation coefficient, and Δ, which is the safety margin. The safety margin Δ is related to the window standard deviation. The proportional setting is expressed as follows:

[0044]

[0045] Where c is a preset constant; the compensation coefficient γ in the fluctuation compensation term is adaptively determined based on the dispersion of the image-level anomaly score within the sliding window, and its expression is:

[0046]

[0047] Where λ is the compression coefficient, ε is a minimal constant to prevent the denominator from being zero, and tanh() is the hyperbolic tangent function. The dynamic sampling threshold is used to automatically adjust the sampling boundary upwards or downwards when the distribution of industrial image data drifts. This ensures that when the overall image-level anomaly score decreases, the dynamic sampling threshold decreases accordingly to reduce the missed transmission of high-value anomaly samples; conversely, when the overall image-level anomaly score increases, the dynamic sampling threshold increases accordingly to reduce the risk of uploading data exceeding the bandwidth limit.

[0048] Step 8: Compare the image-level anomaly score of the current input image with the dynamic sampling threshold. If the image-level anomaly score is greater than the dynamic sampling threshold, the current input image is determined to be an anomaly sample to be uploaded and uploaded to the cloud server. If the image-level anomaly score is not greater than the dynamic sampling threshold, the current input image is determined to be a locally retained sample and not uploaded. The upload determination rule is expressed as follows:

[0049]

[0050] Among them, Upload(x t ) represents the upload decision result of the current input image, and I() is the indicator function; when S t >T t At that time, Upload(x) t )=1 indicates that the current input image is uploaded; when S t ≤T t At that time, Upload(x) t )=0 means that the current input image will not be uploaded.

[0051] Step 9: As industrial image sequences continue to be input, repeat steps 1 to 8 to prioritize uploading image samples with higher anomaly risk and higher information value to the cloud under bandwidth-constrained conditions. This reduces the amount of redundant normal samples transmitted and improves the efficiency of screening target anomaly samples. The window mean is updated recursively, and its expression is:

[0052]

[0053] Among them, S t-W The earliest image-level outlier score removed from the sliding window is used; the window standard deviation is updated recursively to avoid repeated variance statistics on all historical outlier scores within the sliding window, thereby reducing the online computational complexity and memory access overhead of edge devices.

[0054] Example: This example discloses a dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection, applied to textile defect detection scenarios. Edge devices are installed near the inspection station on the production line. Industrial cameras continuously acquire images of the fabric surface and input them sequentially to the edge-side processing module. A cloud server connects to the edge devices via a local area network or industrial private network to receive anomaly samples to be uploaded and perform further analysis. In this example, the resolution of a single frame image acquired by the industrial camera is set to 640×640 pixels, and the acquisition frame rate is set to 20 frames / second. The edge device performs anomaly scoring and upload determination for each received frame.

[0055] In this embodiment, the system completes model initialization and parameter configuration before formal operation. Specifically, the pre-trained feature extraction network, lightweight discriminator, and multi-scale normal feature prototype library are all pre-loaded into the edge device's memory; operating parameters such as sliding window length, compression coefficient, preset constant, minimum constant, and upload rate limit are pre-set by the edge-side control program. After the system starts, the edge device enters an online operating state of continuous acquisition, continuous scoring, and continuous judgment, thereby meeting the needs of long-term continuous operation in industrial sites.

[0056] In step 1, the edge device continuously acquires image data of the industrial object to be detected, forming a sequence of industrial images input in chronological order. The currently input image is then sent to the edge-side anomaly scoring module for anomaly assessment. In this embodiment, the edge device can cache the image stream acquired within the most recent second for streaming management and time synchronization. However, anomaly scoring and upload determination are both completed on a single-frame basis, ensuring the real-time performance of edge-side processing. For high-speed production lines, this single-frame determination method can complete the upload decision without significantly increasing the waiting time.

[0057] In step 2, for the current input image, a pre-trained feature extraction network is used to extract multi-layer feature representations. In this embodiment, three-layer feature maps are selected as multi-layer feature representations, denoted as follows: , and The dimensions are 80×80×64, 40×40×128, and 20×20×256, respectively. For each spatial location in the feature map of each layer, local context information within a preset neighborhood is aggregated around that spatial location. In this embodiment, the local context aggregation neighborhood is set to 3×3, i.e., p=3. After the feature maps of each layer are enhanced, they are uniformly adjusted to a spatial size of 80×80 and stitched along the channel dimension to finally obtain a fused feature map O with a size of 80×80×448. t In this way, the system can simultaneously retain shallow texture information and deep semantic information in the same feature representation, improving its ability to express minute defects, local anomalies, and anomaly patterns at different scales.

[0058] In step 3, the feature vectors corresponding to each spatial location in the fused feature map are compared with a pre-built and stored multi-scale normal feature prototype library for similarity matching. Based on the matching results, the initial pixel-level anomaly score for each spatial location is calculated. In this embodiment, the multi-scale normal feature prototype library P is extracted offline from normal sample images, retaining 50 normal feature prototypes at each scale, for a total of 150 prototype vectors across the three layers. For any spatial location (i,j) in the fused feature map, the 448-dimensional feature vector f... ij Its pixel-level initial anomaly score s ij The calculation is still performed according to formula (1), that is:

[0059] (1)

[0060] For example, when the cosine similarity between the feature vector of a certain spatial location and its closest prototype vector is 0.82, according to formula (1), the initial pixel-level anomaly score of that location is 0.18; when the maximum cosine similarity of another location is 0.41, according to formula (1), the initial pixel-level anomaly score of that location is 0.59. Therefore, it can be seen that the greater the deviation of a local region from the normal pattern, the higher its anomaly score.

[0061] In step 4, the initial pixel-level anomaly score is input into the lightweight discriminator to obtain the pixel-level anomaly score map corresponding to the current input image. In this embodiment, the lightweight discriminator adopts a 3-layer convolutional structure, with the kernel size of each convolutional layer set to 3×3, in order to achieve further integration and enhancement of the anomaly response with lower computational overhead. The lightweight discriminator outputs a pixel-level anomaly score map with a size of 80×80. Subsequently, spatial dimension maximum aggregation is performed on the anomaly score map according to formula (2) to obtain the image-level anomaly score S. t ,Right now:

[0062] (2)

[0063] For example, when the anomaly response value corresponding to the most significant abnormal region in a frame of an image is 0.63, according to formula (2), the image-level anomaly score of that frame is 0.63. Since maximum value aggregation can highlight local significant anomalies, it is particularly suitable for industrial scenarios where local small defects determine the upload value of the entire frame of an image.

[0064] In step 5, the edge device establishes a sliding window of length W to store the image-level anomaly scores corresponding to the most recent W input images. In this embodiment, the sliding window length is 20, meaning the window stores the image-level anomaly scores of the most recent 20 frames. Assume the 20 historical image-level anomaly scores in the current sliding window are, in order: 0.31, 0.28, 0.35, 0.33, 0.29, 0.30, 0.34, 0.32, 0.36, 0.37, 0.35, 0.33, 0.31, 0.30, 0.34, 0.36, 0.38, 0.35, 0.37, and 0.39. When a new input image arrives and a new image-level anomaly score of 0.63 is calculated, the system writes 0.63 into the sliding window and removes the earliest anomaly score of 0.31 from the window. In this way, the sliding window always reflects the changes in the anomaly level of the image stream over a recent period.

[0065] In step 6, the window mean and window standard deviation are calculated based on the image-level anomaly score within the sliding window. The window mean and window standard deviation are calculated using formulas (3) and (4), respectively:

[0066] (3)

[0067] (4)

[0068] For the aforementioned 20 historical outlier scores, in this embodiment, the window mean calculated by formula (3) is approximately 0.3365, and the window standard deviation calculated by formula (4) is approximately 0.0304. The window mean is used to reflect the average level of outlier scores within the current time period, and the window standard deviation is used to reflect the strength of fluctuations in outlier scores within the current time period.

[0069] In step 7, a dynamic sampling threshold is constructed based on the window mean, window standard deviation, fluctuation compensation term, and safety margin. In this embodiment, the compression coefficient λ is set to 0.5, the minimum constant ε to prevent the denominator from being zero is set to 0.001, and the preset constant c is set to 0.6. The dynamic sampling threshold is calculated according to formula (5), that is:

[0070] (5)

[0071] The safety margin is calculated according to formula (6), that is:

[0072] (6)

[0073] The compensation coefficient is calculated according to formula (7), that is:

[0074] (7)

[0075] Substituting the specific values ​​from this embodiment into the above formula: According to formula (6), when c=0.6, When λ=0.5, the safety margin is approximately 0.0182; according to formula (7), when λ=0.5, , When ε=0.001, the compensation coefficient γ is approximately 0.0449, therefore the fluctuation compensation term... Approximately 0.0014; substituting this into formula (5), we can obtain the current dynamic sampling threshold T. t It is approximately 0.3561. That is to say, within the current time window, when the average level of the image-level anomaly score is approximately 0.339 and the fluctuation range is approximately 0.033, the dynamic sampling threshold automatically generated by the system is approximately 0.3561.

[0076] It should be noted that in this invention, the fluctuation compensation term compensates for short-term abnormal score fluctuations caused by process disturbances, lighting changes, imaging noise, or equipment operation fluctuations, ensuring that the dynamic sampling threshold is not overly sensitive to small instantaneous changes. The safety margin adds an extra boundary to the threshold to reduce frequent jittering of samples near the threshold. Therefore, this invention does not simply use the window mean plus a fixed multiple of the standard deviation to construct the threshold, but rather comprehensively considers fluctuation compression and safety margins to make the threshold more adaptable to the dynamic characteristics of industrial environments.

[0077] In step 8, the image-level anomaly score corresponding to the current input image is compared with the dynamic sampling threshold, and the upload determination is performed according to formula (8), that is:

[0078] (8)

[0079] In this embodiment, if the image-level anomaly score of the current input image is 0.63 and the dynamic sampling threshold is 0.3561, then since 0.63 is greater than 0.3561, according to formula (8), Upload(x) can be obtained. t =1, therefore the image is determined to be uploaded and sent to the cloud server as an abnormal sample to be uploaded. If the image-level anomaly score of another frame is 0.34, then since 0.34 is less than 0.3561, according to formula (8), Upload(x) = 1. t If the score is 0, the image is determined not to be uploaded but instead stored locally on the edge device. This demonstrates that the present invention does not rely solely on absolute score magnitude for judgment, but rather considers the statistical distribution within the current time window to determine whether the image has higher upload value.

[0080] In this embodiment, anomalous samples uploaded to the cloud server can further enter the cloud analysis module for higher-precision anomaly identification, anomaly verification, anomaly classification, sample archiving, or subsequent model update support. For locally retained samples that are not uploaded, the edge device can retain only their anomaly scoring results or keep a short-term cache to reduce local storage usage. By combining edge screening with deep cloud processing, transmission resources can be used more to serve high-value samples, thereby improving the resource allocation efficiency of the entire cloud-edge collaborative system.

[0081] In step 9, as the industrial image sequence continues to be input, steps 1 to 8 are repeated to prioritize uploading image samples with high anomaly risk and high information value to the cloud under bandwidth-constrained conditions. In this embodiment, the system presets an upload rate cap of 25%, meaning that on average, a maximum of one high-value anomaly sample is uploaded out of every four images. Through the linkage adjustment of the sliding window and the dynamic threshold, when the overall anomaly score in the industrial field increases, the dynamic sampling threshold will also increase accordingly to suppress the rapid increase in upload volume; when the overall anomaly score decreases, the dynamic sampling threshold will decrease accordingly, thereby preventing high-value anomaly samples from being missed.

[0082] Furthermore, in this embodiment, the window mean is updated recursively, and its expression still uses formula (9), that is:

[0083] (9)

[0084] For example, if the window mean at the previous moment was 0.339, the image-level anomaly score of the newly entered window was 0.63, the earliest image-level anomaly score removed was 0.31, and the window length W was 20, then according to formula (9), the updated window mean is approximately 0.3525. The window standard deviation is also updated recursively to avoid repeatedly counting all historical anomaly scores within the window, thereby reducing the online computational complexity of edge devices and improving the real-time operating efficiency of the system.

[0085] It should be understood that the above parameter settings are merely an example in this embodiment. In different industrial scenarios, the sliding window length can be adjusted according to the image acquisition rate and the rate of abnormal changes; the number of prototypes can be set according to the complexity of normal samples; and the compression coefficient and safety margin ratio constant can be selected according to the strength of bandwidth constraints and upload sensitivity requirements. For example, in scenarios with rapid abnormal changes, the sliding window length can be appropriately reduced to improve the threshold update speed; in scenarios with more limited network bandwidth, the dynamic sampling threshold can be appropriately increased by adjusting relevant parameters, thereby further compressing the upload ratio. The above parameter adjustments do not affect the core technical idea of ​​this invention.

[0086] In addition to the aforementioned textile defect detection scenarios, this invention is also applicable to various industrial visual inspection scenarios, such as metal surface defect detection, electronic component solder joint defect detection, display panel surface defect detection, composite material surface crack detection, and packaging and printing quality inspection. In different application scenarios, parameters such as image resolution, number of feature layers, sliding window length, number of prototypes, compression coefficient, safety margin proportional constant, and upload rate limit can all be adjusted according to production line speed, image acquisition frequency, network bandwidth, and anomaly type, but all remain within the core principles of this invention.

[0087] As can be seen from the above embodiments, this invention revolves around the technical main lines of edge scoring, window statistics, dynamic thresholding, and upload determination, organically combining anomaly perception in industrial images with upload decisions under bandwidth-constrained conditions. Compared with existing static sampling methods, this invention not only focuses on the degree of anomaly in the image itself, but also on its relative position and statistical significance within the current time window. Therefore, it can achieve more practical anomaly sample screening in continuous industrial image stream scenarios. The method has a clear structure and well-defined implementation path, making it suitable for real-time deployment on edge devices and easy to integrate with cloud-based analysis systems.

[0088] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A dynamic anomaly perception and sampling method for cloud-edge collaborative industrial visual inspection, characterized in that, include: Step 1: The edge device acquires time-series images of industrial objects in real time and inputs the current image into the anomaly scoring module on the edge side for anomaly assessment; Step 2: The anomaly scoring module extracts multi-layer features from the current input image and performs local context enhancement and multi-scale fusion to obtain a fused feature map; Step 3: Match the fused feature map with the multi-scale normal feature prototype library to generate pixel-level initial anomaly scores; Step 4: The lightweight discriminator further discriminates the initial pixel-level anomaly scores to obtain a pixel-level anomaly score map, and generates an image-level anomaly score through spatial aggregation. Step 5: Establish a sliding window of length W to store the image-level anomaly scores corresponding to the most recent W input images; Step 6: Calculate the window mean and window standard deviation based on the image-level anomaly scores within the sliding window, including: Based on the image-level anomaly scores within the sliding window, calculate the window mean and standard deviation for the current time step. and window standard deviation The expressions are as follows: , , Among them, S k is the image-level anomaly score corresponding to the k-th input image within the sliding window, and t is time; Step 7: Generate a dynamic sampling threshold based on the window mean, window standard deviation, fluctuation compensation term, and safety margin, including: A dynamic sampling threshold is constructed based on the window mean, window standard deviation, fluctuation compensation term, and safety margin. This allows the dynamic sampling threshold to adaptively adjust to changes in data distribution during industrial production. The dynamic sampling threshold T t The expression is: , in, The fluctuation compensation term is represented by γ, the compensation coefficient, and Δ, which is the safety margin. The safety margin Δ is related to the window standard deviation. The proportional setting is expressed as follows: , Where c is a preset constant, and the expression for the compensation coefficient γ is: , Where λ is the compression coefficient, ε is a minimal constant to prevent the denominator from being zero, and tanh() is the hyperbolic tangent function; Step 8: Compare the image-level anomaly score with the dynamic sampling threshold and decide whether to upload; Step 9: As industrial time-series images continue to be input, repeat steps 1-8 and recursively update window statistics to upload images with high anomaly risk.

2. The dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection according to claim 1, characterized in that, Step 2 includes: For the current input image, a pre-trained feature extraction network is used to extract multi-layer feature representations. The multi-layer feature representations correspond to information at different scales and semantic levels. For each spatial location in the feature map of each layer, local context information within a preset neighborhood is aggregated with that spatial location as the center to obtain an enhanced local feature representation. Then, the enhanced feature maps of each layer are uniformly adjusted to the same spatial size and spliced ​​along the channel dimension to obtain a fused feature map.

3. The dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection according to claim 1, characterized in that, Step 3 includes: The feature vectors corresponding to each spatial location in the fused feature map are similarly matched with the prototype vectors in a pre-built and stored multi-scale normal feature prototype library. Based on the matching results, pixel-level initial anomaly scores are calculated for each spatial location to characterize the degree of deviation of the current input image from the normal pattern at different spatial locations. The multi-scale normal feature prototype library is constructed from normal sample images after feature extraction via a pre-trained feature extraction network, and is used to describe the typical feature distribution of normal industrial objects at different scales. The pixel-level initial anomaly score s at any spatial location in the current input image is... ij Calculated using the following formula: , Where P is a multi-scale normal feature prototype library, f ij The feature vector at spatial location (i,j) of the fused feature map is p, which is the prototype vector in the multi-scale normal feature prototype library, and max() is the maximum value function.

4. The dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection according to claim 1, characterized in that, Step 4 includes: The initial pixel-level anomaly score is input into the lightweight discriminator to obtain the pixel-level anomaly score map corresponding to the current input image. Then, spatial dimension maximum aggregation is performed on the pixel-level anomaly score map to obtain the image-level anomaly score corresponding to the current input image. The image-level anomaly score S... t The expression is: , in, Let be the anomaly response value of the pixel-level anomaly score map at spatial location (i,j), where i and j are spatial location indices. This means taking the maximum value across all spatial locations in the pixel-level anomaly score map.

5. The dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection according to claim 1, characterized in that, Step 5 includes: A sliding window of length W is established in the edge device to store the image-level anomaly scores corresponding to the most recent W input images. When a new image-level anomaly score is obtained, the new image-level anomaly score is written into the sliding window, and the anomaly score that entered the sliding window earliest is removed.

6. The dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection according to claim 1, characterized in that, Step 8 includes: The image-level anomaly score S corresponding to the current input image. t With dynamic sampling threshold T t Compare; when the image-level anomaly score S t Greater than the dynamic sampling threshold T t When the current input image is identified as an abnormal sample to be uploaded, it is uploaded to the cloud server; when the image-level anomaly score S... t Not greater than the dynamic sampling threshold T t When this happens, the current input image is determined to be a locally retained sample and is not uploaded.

7. The dynamic anomaly perception sampling method for cloud-edge collaborative industrial visual inspection according to claim 1, characterized in that, Step 9 includes: As industrial image sequences are continuously input, steps 1 through 8 are repeated. The window mean is updated recursively, and its expression is: , Among them, S t S is the image-level anomaly score corresponding to the current input image. t-W The earliest image-level anomaly score removed from the sliding window.

Citation Information

Patent Citations

  • Industrial product anomaly detection method based on self-supervised puzzle module

    CN115861306A

  • Power anomaly detection method and system

    CN120123937A

  • Industrial product online visual inspection method based on cloud collaboration

    CN121280329A