An edge-cloud collaborative industrial quality inspection method, system, device and medium

By employing an edge-cloud collaborative architecture, a lightweight small model and an early-retirement router are used for preliminary quality inspection. Deep reinforcement learning is then combined to dynamically adjust the segmentation position and resource allocation of the large model, solving the problem of balancing detection accuracy, latency, and energy consumption in existing technologies. This results in a highly efficient and adaptive industrial quality inspection system.

CN122132162APending Publication Date: 2026-06-02DONGGUAN UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
DONGGUAN UNIV OF TECH
Filing Date
2026-01-28
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

Existing industrial quality inspection systems struggle to balance high detection accuracy with low latency and low energy consumption. Furthermore, they lack effective multi-stage knowledge distillation methods and dynamic sample routing strategies, resulting in rigid model segmentation locations and resource allocation that cannot adapt to dynamic changes in operating conditions.

Method used

By adopting an edge-cloud collaborative architecture, preliminary inference is performed by deploying lightweight small models and early-retreat routers on the edge side. Combined with deep reinforcement learning, the segmentation position of the large model and the allocation of cloud resources are dynamically adjusted to achieve multi-stage knowledge distillation and confidence-aware sample routing.

Benefits of technology

It significantly reduces end-to-end inference latency and system energy consumption, improves the real-time performance and energy efficiency of the quality inspection system, enables adaptive deployment and operation under different working conditions, and improves detection accuracy and resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122132162A_ABST
    Figure CN122132162A_ABST
Patent Text Reader

Abstract

This application provides an edge-cloud collaborative industrial quality inspection method, system, device, and medium, relating to the field of industrial quality inspection technology. The method deploys a lightweight small model on the edge side and combines it with an early-retirement router to quickly screen inspection images, uploading only problematic samples with insufficient confidence to the edge side, effectively reducing unnecessary data transmission and cloud load. Furthermore, a deep reinforcement learning method with inference latency and energy consumption as joint optimization objectives is introduced to dynamically adjust the segmentation position of the large model and the allocation of cloud resources. Simultaneously, an edge-cloud collaborative segmentation-based large model architecture is used, allowing the edge side to handle medium-complexity inference while the cloud side focuses on high-difficulty inference, balancing accuracy and efficiency. This enables adaptive deployment and operation of the system under different working conditions, significantly reducing overall inference latency and energy consumption while ensuring high detection accuracy, thereby improving the real-time performance, energy efficiency ratio, and resource utilization of the industrial quality inspection system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial quality inspection technology, and in particular to an edge-cloud collaborative industrial quality inspection method, system, equipment and medium. Background Technology

[0002] In industrial intelligent manufacturing scenarios, industrial quality inspection is crucial; however, the high precision, low latency, and low energy consumption required for industrial quality inspection are difficult to achieve simultaneously. Existing cloud-based large-model solutions, while offering high accuracy, suffer from high transmission latency and energy consumption due to reliance on remote computing, failing to meet the real-time requirements of production lines. On the other hand, lightweight edge-based small models, while offering fast inference and low power consumption, are limited by capacity and lack the ability to identify complex or abnormal defects. Existing collaborative methods mostly employ static deployment, lacking both effective multi-stage knowledge distillation methods to enhance the small model's ability to inherit multi-level features from the large model and dynamic routing strategies based on sample confidence, failing to adaptively adjust the inference path according to network conditions, device load, and sample difficulty. Furthermore, model segmentation locations and cloud resource allocation are typically fixed, without joint optimization considering inference latency and energy consumption, resulting in overall system inefficiency and making it difficult to achieve optimal synergy between accuracy, speed, and energy efficiency. Summary of the Invention

[0003] This application provides an edge-cloud collaborative industrial quality inspection method, system, device, and medium to solve one or more technical problems existing in the prior art, and at least provides a beneficial option or creates conditions that can reduce end-to-end inference latency and system energy consumption while ensuring high detection accuracy, and realize dynamic adaptive optimization of model deployment and resource allocation.

[0004] On the one hand, this application provides an edge-cloud collaborative industrial quality inspection method, which is collaboratively executed by industrial equipment on the edge side, servers on the edge side, and data centers on the cloud side, including:

[0005] A lightweight small model is deployed on the edge to perform preliminary inference on industrial inspection images and calculate a confidence score based on an early termination router. If the confidence score is higher than a preset confidence threshold, the corresponding quality inspection result is output; otherwise, the industrial inspection image is uploaded to the edge as a low-confidence sample. The large-scale segmented model is deployed collaboratively on the edge and cloud sides, wherein the shallow part of the large-scale model is run on the edge side and the deep part is run on the cloud side. Specifically, it includes: based on deep reinforcement learning methods, with inference latency and energy consumption as joint optimization objectives, dynamically determining the segmentation position of the large-scale model and the cloud side resource allocation strategy, and adjusting the deployment configuration of the edge and cloud sides accordingly. The edge performs shallow forward inference of the large model on the low-confidence samples. If the accuracy requirements are met, the corresponding quality inspection result is output. Otherwise, the intermediate features of the shallow forward inference are transmitted to the cloud side to complete the deep forward inference of the large model and the corresponding quality inspection result is output.

[0006] Furthermore, the lightweight small model is obtained through multi-stage logical knowledge distillation based on the large model, including the following steps: Obtain a training dataset containing industrial inspection images and their corresponding ground truth labels; Deploy replicas of the large model and the small model on the cloud side, and perform forward inference on the training dataset to obtain the output layer logical confidence vector of the large model, the intermediate layer logical confidence vectors of multiple large models, and the output layer logical confidence vector of the small model. Calculate the KL divergence between the output layer logic confidence vector of the large model and the output layer logic confidence vector of the small model, and use it as the output layer distillation loss; Calculate the cross-entropy loss between the output layer logistic confidence vector of the small model and the true label, and use it as the hard label loss; For each of the aforementioned large model intermediate layer logical confidence vectors, calculate the cross-entropy loss between it and the true label, and then obtain the corresponding intermediate layer allocation weights based on the cross-entropy loss through a normalization formula. Based on the intermediate layer allocation weights corresponding to the intermediate layer logical confidence vectors of each of the large models, the KL divergence between the intermediate layer logical confidence vectors of each of the large models and the output layer logical confidence vectors of the small models is calculated by weighted summation, and the multi-stage intermediate layer logical distillation loss is obtained. The output layer distillation loss, hard label loss, and multi-stage intermediate layer logic distillation loss are weighted and summed to form the overall loss, and the parameters of the small model are updated based on minimizing the overall loss.

[0007] Furthermore, the early retirement router is obtained through knowledge distillation training, including the following steps: During the training phase, the small model on the edge is used as the teacher model and its network parameters are frozen. Inference is performed on the training samples to generate intermediate layer features and corresponding teacher logical confidence vectors. Using the early departure router as a student model and the intermediate layer features as input, a student logical confidence vector is generated. A distillation loss is constructed based on the teacher's logical confidence vector and the student's logical confidence vector; A cross-entropy loss is constructed based on the true labels of the samples and the logical confidence vectors of the students. The distillation loss and cross-entropy loss are weighted and summed to form the overall loss. The training of the early-retreat router is completed by minimizing the overall loss. During the inference phase, the trained early-retreat router is embedded into the intermediate layer of the edge-side small model to output a confidence score based on the real-time generated intermediate layer features. The confidence score is then compared with a preset confidence threshold to determine whether to continue inferring the industrial inspection image and output the corresponding quality inspection result, or to upload the industrial inspection image to the edge. The preset confidence threshold is an adaptive threshold dynamically determined based on the confidence distribution of small model inference on the validation set.

[0008] Furthermore, the large model is characterized by having Early exit point and A deep neural network with 1 logical layer, where each early exit point corresponds to a potential inference early exit location; the segmentation location of the large model corresponds to the 1st logical layer. A logical layer, specifically including: the side-side deployment from the input layer to the first... The logical layer sub-network, the cloud-side data center deployment from the first The sub-network from the logic layer to the final output layer, where Let be a positive integer dynamically determined based on the optimization results of the Markov decision process, and satisfy . .

[0009] Furthermore, the method based on deep reinforcement learning, using inference latency and energy consumption as joint optimization objectives, dynamically determines the segmentation position of the large model and the cloud-side resource allocation strategy, and adjusts the deployment configuration of the edge and cloud sides accordingly, including the following steps: Construct a discrete Markov decision process, where the state space includes the computing resources, network bandwidth, and early exit point structure information of the edge server and cloud devices, and the action space includes the segmentation location. The reward function is the weighted negative of the average inference latency and average energy consumption of low-confidence samples across all terminal devices, in relation to the cloud computing resource allocation ratio. The Markov decision process is trained using a multi-agent deep reinforcement learning algorithm to obtain the optimal policy; Based on the aforementioned optimal strategy, the current optimal segmentation position is dynamically output during runtime. The cloud-side resource allocation scheme is used to update the model deployment and resource configuration on both the edge and cloud sides.

[0010] Furthermore, the average inference latency includes end-side inference latency, edge-side inference latency, and cloud-side inference latency; The edge-side inference latency includes: the computation latency of the edge-side small model performing preliminary inference on the industrial inspection image, the judgment latency of the early-retreat router generating confidence scores, and the transmission latency of uploading low-confidence samples from the edge to the side. The side-side inference latency includes: the computational latency of performing shallow partial forward inference of the large model on the low-confidence samples, and the transmission latency of transmitting intermediate features of the shallow partial forward inference to the cloud side. The cloud-side inference latency includes: the computational latency of performing deep forward inference of the large model; The total energy consumption includes: the computing energy consumption of the end-side industrial equipment, the energy consumption of the end-side industrial equipment in transmitting industrial quality inspection images, the computing power consumption of the edge server, the energy consumption of the edge server in transmitting intermediate feature data, and the computing power consumption of the cloud-side data center.

[0011] Furthermore, the step of training the Markov decision process using a multi-agent deep reinforcement learning algorithm to obtain the optimal policy includes the following steps: Each large model is configured with an agent, and each agent constructs a state representation based on environmental observations and independently selects actions; Each agent stores the experience generated during the interaction process in the form of a four-tuple in the experience replay buffer; the four-tuple includes state, action, reward and next state. During the training phase, batch experience data is sampled from the experience replay buffer, the current action value is calculated using the main training network, and the target action value is calculated using the target network with parameter delay updates. Based on the temporal difference error between the current action value and the target action value, the parameters of the main training network are updated, while the parameters of the target network are synchronized from the main training network through periodic replication. Repeat the above process until the strategy converges to obtain the optimal strategy for dynamically outputting the segmentation location and cloud-side resource allocation scheme.

[0012] On the other hand, this application provides an edge-cloud collaborative industrial quality inspection system, deployed on the edge of industrial equipment, the edge of servers, and the cloud of data centers, including the following modules: The small model inference module is configured to: deploy a lightweight small model on the edge side, perform preliminary inference on the industrial inspection image, and calculate a confidence score based on the early termination router; if the confidence score is higher than a preset confidence threshold, output the corresponding quality inspection result; otherwise, upload the industrial inspection image as a low-confidence sample to the edge side. The large model segmentation module is configured to: collaboratively deploy segmented large models on the edge and cloud sides, wherein the shallow part of the large model is run on the edge side and the deep part is run on the cloud side. Specifically, it includes: based on deep reinforcement learning methods, taking inference latency and energy consumption as joint optimization objectives, dynamically determining the segmentation position of the large model and the cloud side resource allocation strategy, and adjusting the deployment configuration of the edge and cloud sides accordingly. The large model inference module is configured as follows: the edge performs shallow forward inference of the large model on the low confidence samples. If the accuracy requirements are met, the corresponding quality inspection result is output. Otherwise, the intermediate features of the shallow forward inference are transmitted to the cloud side to complete the deep forward inference of the large model and the corresponding quality inspection result is output.

[0013] On the other hand, this application provides an electronic device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the aforementioned edge-cloud collaborative industrial quality inspection method.

[0014] On the other hand, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned edge-cloud collaborative industrial quality inspection method.

[0015] On the other hand, this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the aforementioned edge-cloud collaborative industrial quality inspection method.

[0016] The beneficial effects of this application are as follows: This application provides an edge-cloud collaborative industrial quality inspection method. This method deploys a lightweight small model on the edge side and combines it with an early-retirement router to quickly screen detection images, uploading only problematic samples with insufficient confidence to the edge side, effectively reducing unnecessary data transmission and cloud load. Furthermore, a deep reinforcement learning method with inference latency and energy consumption as joint optimization objectives is introduced to dynamically adjust the segmentation position of the large model and the allocation of cloud resources. Simultaneously, utilizing an edge-cloud collaborative segmentation-based large model architecture, the edge side handles medium-complexity inference while the cloud side focuses on high-difficulty inference, balancing accuracy and efficiency. Therefore, the system achieves adaptive deployment and operation under different working conditions, significantly reducing overall inference latency and energy consumption while ensuring high detection accuracy, thus improving the real-time performance, energy efficiency ratio, and resource utilization of the industrial quality inspection system. This application also provides corresponding systems, devices, and media. The beneficial effects of the systems, devices, and media are similar to those of the method and will not be elaborated further here.

[0017] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the description, claims and drawings. Attached Figure Description

[0018] The accompanying drawings are provided to further understand the technical solutions of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the technical solutions of the present invention, and do not constitute a limitation on the technical solutions of the present invention.

[0019] Figure 1 This is a flowchart of the edge-cloud collaborative industrial quality inspection method provided in this application; Figure 2 This is a schematic diagram of the edge-cloud collaborative industrial quality inspection method provided in this application; Figure 3 This is a structural diagram of the edge-cloud collaborative industrial quality inspection system provided in this application. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0021] The present application will be further described below with reference to the accompanying drawings and specific embodiments. The described embodiments should not be considered as limitations on the present application, and all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of the present application.

[0022] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0024] In industrial intelligent manufacturing scenarios, industrial quality inspection equipment, as a key sensing terminal, is widely connected to the Industrial Internet of Things (IIoT) to collect real-time images of product appearance, 3D contours, dimensional parameters, and multi-dimensional sensor data, providing high-quality input for intelligent quality inspection systems. These devices can be flexibly configured according to actual production needs, and typical types include high-speed industrial cameras, 3D laser scanners, intelligent sensing and detection terminals, online dimensional measuring instruments, and defect visual inspection equipment. High-speed industrial cameras can continuously capture images of products on the production line and, combined with edge computing modules, initially screen for suspected defects; 3D laser scanners acquire 3D contours to accurately identify dimensional deviations and surface irregularities; intelligent sensing and detection terminals integrate sensors for temperature, pressure, and vibration to assist in assessing assembly accuracy and operational stability; online dimensional measuring instruments utilize optical principles to monitor in real-time whether key dimensions meet process standards; and defect visual inspection equipment focuses on the high-sensitivity identification of surface defects such as scratches, stains, and cracks.

[0025] Leveraging the convergence of industrial IoT communication, edge computing, and big data analytics capabilities, the aforementioned quality inspection equipment is efficiently interconnected with production equipment and management platforms, constructing a distributed intelligent quality inspection system covering "device-edge-cloud." This system employs a large-scale model collaboration technology, where a lightweight small model on the device side quickly processes routine samples, while a large model deployed collaboratively on the edge and cloud sides performs in-depth analysis of complex defects, forming a hierarchical reasoning method. This architecture not only outputs high-precision quality inspection results and defect cause analysis but also supports advanced applications such as batch quality inspection, defect tracing, and production process optimization, significantly improving production line quality inspection efficiency, reducing manual omission rates, and providing reliable data support for continuous improvement of the manufacturing process.

[0026] However, existing industrial quality inspection systems still face severe challenges. While centralized cloud-based large-scale model solutions offer high accuracy, their reliance on remote transmission introduces significant latency, high bandwidth consumption, and data privacy risks, making it difficult to meet the real-time requirements of high-speed production lines. Pure edge-based lightweight solutions offer low latency and low power consumption, but are limited by model capacity and lack generalization ability when facing out-of-distribution, small, or complex defects, easily leading to missed detections and misjudgments. Some preliminary edge-edge collaborative solutions attempt hierarchical processing, but their initial screening methods often use fixed thresholds, lacking fine-grained perception of sample difficulty. Furthermore, there is no structural collaboration between edge-based models and cloud-based large-scale models, and resource allocation is statically preset, failing to adapt to dynamic operating conditions and limiting overall performance.

[0027] In summary, current technologies generally suffer from three core shortcomings: First, the lack of efficient multi-level knowledge distillation methods makes it difficult for small models to fully inherit the deep semantic representation capabilities of large models; second, the lack of a confidence-aware dynamic sample routing strategy prevents the intelligent triage of high-confidence samples for rapid local detection and low-confidence samples for progressive, precise judgment; and third, the absence of adaptive resource scheduling capabilities with inference latency and system energy consumption as joint optimization objectives, resulting in rigid model segmentation points and computational resource allocation. These bottlenecks severely restrict the large-scale deployment and overall performance of AI quality inspection systems in complex industrial environments, necessitating a novel collaborative quality inspection architecture that deeply integrates edge, cloud, and endpoint resources to achieve synergistic optimization of accuracy, speed, and energy efficiency.

[0028] To address the aforementioned issues, this application proposes an edge-cloud collaborative industrial quality inspection method, system, equipment, and medium. This scheme constructs a three-level intelligent collaborative reasoning architecture. By deploying a lightweight small model trained based on multi-stage logical knowledge distillation and an early-retreat router on the edge side, it achieves efficient initial screening and confidence-aware decision-making for industrial inspection images, uploading only low-confidence samples to the edge side. A dynamically segmentable large model structure is adopted between the edge and cloud sides. The edge side performs the front-end reasoning of the large model to handle medium-complexity reasoning, only uploading samples or intermediate features to the cloud side for subsequent reasoning when accuracy requirements are not met, thus avoiding unnecessary cloud load. Simultaneously, an optimization model based on deep reinforcement learning is introduced, using inference latency and system energy consumption as joint optimization objectives. A Markov decision process is constructed to dynamically determine the optimal segmentation position of the large model and the cloud-side resource allocation strategy in real time, adaptively adjusting the edge-cloud deployment configuration accordingly. Ultimately, while ensuring high detection accuracy, end-to-end latency and overall energy consumption are significantly reduced, achieving optimal synergy in accuracy, real-time performance, and energy efficiency for the industrial quality inspection system.

[0029] First, the edge-cloud collaborative industrial quality inspection method provided in this application will be described in detail below with reference to the accompanying drawings. It is executed collaboratively by industrial equipment on the edge side, servers on the edge side, and data centers on the cloud side. It can also be software, firmware, or combinations thereof running on the aforementioned equipment or servers.

[0030] Edge devices can be dedicated industrial quality inspection terminals such as industrial cameras, intelligent sensing and detection terminals, 3D laser scanners, and online dimensional measuring instruments, or embedded devices and industrial control computers equipped with industrial quality inspection modules, but are not limited to these. Edge servers can be independent edge computing nodes, industrial gateway servers, distributed computing clusters composed of multiple edge devices, or fog computing nodes with edge computing capabilities, providing basic edge services such as model deployment, local inference, and data forwarding. Cloud-side data centers can be independent physical cloud servers, cloud server clusters composed of multiple physical servers, or distributed cloud systems that support the deployment and efficient inference of large models. They can also be cloud platforms that provide services such as artificial intelligence model training, large-scale computing power scheduling, and massive data storage and analysis, but are not limited to these.

[0031] Reference Figure 1 The implementation process of the edge-cloud collaborative industrial quality inspection method provided in this application embodiment includes, but is not limited to, the following steps.

[0032] Step S110: Deploy a lightweight small model on the edge to perform preliminary inference on the industrial inspection image and calculate the confidence score based on the early termination router; if the confidence score is higher than the preset confidence threshold, output the corresponding quality inspection result; otherwise, upload the industrial inspection image as a low confidence sample to the edge.

[0033] In step S110, rapid initial screening and intelligent routing of detection tasks are implemented. By running a compressed and optimized small model on resource-constrained edge devices, the vast majority of high-confidence samples can be instantly identified locally, avoiding uploading all data to the network side, thereby significantly reducing communication overhead and system response latency. The introduction of early-retirement routers makes confidence assessment more accurate and reliable, ensuring that only those difficult samples that the small model cannot accurately identify are marked as low-confidence samples and uploaded to the edge, effectively balancing edge processing efficiency and overall detection reliability.

[0034] Step S120 involves co-deploying a segmented large model on the edge and cloud sides, wherein the shallow part of the large model is run on the edge side and the deep part is run on the cloud side. Specifically, this includes: based on a deep reinforcement learning method, with inference latency and energy consumption as joint optimization objectives, dynamically determining the segmentation position of the large model and the cloud side resource allocation strategy, and adjusting the deployment configuration of the edge and cloud sides accordingly.

[0035] In step S120, the entire quality inspection system is endowed with adaptive optimization capabilities, enabling it to dynamically adjust its architecture parameters based on the real-time operating environment. By modeling the selection of partitioning locations and resource allocation as a Markov decision process, and using a weighted negative value of average inference latency and average energy consumption as a reward signal, the agent can learn the optimal strategy and automatically determine, under different operating conditions, which logical layer the large model should be partitioned into edge and cloud, and how much computing resources should be allocated to the cloud side. This dynamic configuration method breaks through the limitations of traditional static deployment, enabling the system to maintain high efficiency under scenarios such as network bandwidth fluctuations, changes in equipment load, or differences in the complexity of quality inspection tasks, achieving global collaborative optimization of performance and energy efficiency.

[0036] Step S130: The side performs shallow forward inference of the large model on the low confidence samples. If the accuracy requirement is met, the corresponding quality inspection result is output. Otherwise, the intermediate features of the shallow forward inference are transmitted to the cloud side to complete the deep forward inference of the large model and the corresponding quality inspection result is output.

[0037] In step S130, a hierarchical and progressive precision judgment method is constructed, making full use of the strong computing power of the edge side and the computing power of the cloud side. The edge side first uses the front-end structure of the large model to perform more in-depth feature extraction and preliminary analysis on low-confidence samples from the edge side. If the required accuracy standard has been achieved at this point, the result is directly output, avoiding further uploading. Only when the edge side inference is still insufficient to meet the accuracy requirements is the original image or intermediate features with more semantic information transmitted to the cloud side, where the remaining high-complexity inference is completed. This two-level collaborative approach not only improves the processing capability of difficult samples but also minimizes the dependence on cloud resources and the burden of network transmission.

[0038] Therefore, this application embodiment achieves this by enabling small models to learn more knowledge from the intermediate layers of large models through collaboration between large and small models, based on a multi-stage logical knowledge distillation method. This enhances the generalization ability of small models, allowing more computational tasks to be completed on the edge and reducing the number of calls to the large model. Secondly, by collaborating between small and large models, confidence assessment of the intermediate feature data of small models is performed based on an early-retreat confidence routing method, selecting a more suitable inference path for the sample data from both large and small models. This fully utilizes the advantages of both large and small models, improving the accuracy of detection results. Furthermore, by collaborating between large models and the cloud, large models are partitioned and computing power is allocated based on deep reinforcement learning methods, fully utilizing cloud and edge computing resources. This improves the utilization rate of computing resources and reduces overall inference latency and energy consumption.

[0039] In some embodiments of this application, lightweight small models are obtained through a multi-stage logical knowledge distillation method based on large models, including the following steps.

[0040] Step S210: Obtain a training dataset containing industrial inspection images and corresponding real labels.

[0041] In step S210, a training dataset containing industrial inspection images and corresponding ground truth labels is acquired, providing basic supervised information and learning materials for the knowledge distillation training of the small model. The industrial inspection images reflect various product states that may occur on the actual production line, while the ground truth labels explicitly indicate whether defects exist in each image and their category or location. Together, they constitute the input-output pair necessary for supervised learning. A high-quality, comprehensive training dataset is a prerequisite for ensuring that the subsequent distillation process effectively transfers the knowledge of the large model while preserving the semantic accuracy of the task, and it is also the data foundation for the small model to ultimately possess reliable quality inspection capabilities.

[0042] Step S220: Deploy replicas of the large model and the small model on the cloud side, and perform forward inference on the training dataset to obtain the output layer logical confidence vector of the large model, the intermediate layer logical confidence vectors of multiple large models, and the output layer logical confidence vector of the small model.

[0043] In step S220, response features of copies of the large and small models under the same input are extracted simultaneously, providing an aligned signal source for subsequent loss calculation. The large model, as a knowledge source, contains high-precision category discrimination information in its output layer logical confidence vector, while multiple intermediate layer logical confidence vectors capture multi-level semantic representations from shallow to deep layers; the small model's output layer logical confidence vector represents its prediction distribution in its current learning state. By performing forward inference in parallel on the same training samples, and normalization through the softmax function, input consistency in feature alignment between teachers and students during the distillation process is ensured, laying the foundation for multi-stage knowledge transfer.

[0044] Step S230: Calculate the KL divergence between the output layer logic confidence vector of the large model and the output layer logic confidence vector of the small model, and use it as the output layer distillation loss.

[0045] In step S230, the soft label information contained in the final decision layer of the large model is effectively transferred to the small model. Compared to hard labels, the logistic confidence vector output by the large model, after temperature scaling, can reflect the similarity and uncertainty between categories and contains richer supervision signals. By minimizing the KL divergence between the two, the output distribution of the small model is made to approximate the output distribution of the large model, thereby inheriting its stronger generalization ability and ability to distinguish difficult samples, and improving the robustness and accuracy of the small model in industrial quality inspection tasks.

[0046] Step S240: Calculate the cross-entropy loss between the logistic confidence vector of the small model output layer and the true label, and use it as the hard label loss.

[0047] Step S240 aims to ensure that the smaller model, while learning from the larger model, does not deviate from the fundamental objective of the original quality control task. Cross-entropy loss directly measures the difference between the smaller model's predictions and the true labels, and is the most basic optimization objective in supervised learning. Retaining hard label loss prevents the distillation process from overfitting the teacher model's output and ignoring the supervision of the true labels. This is especially helpful when the larger model has misclassifications or label noise, helping to maintain the smaller model's learning direction towards the correct semantics and ensuring its reliability in practical applications.

[0048] Step S250: For the logical confidence vectors of the intermediate layers of each model, calculate the cross-entropy loss between them and the true labels, and then obtain the corresponding intermediate layer allocation weights based on the cross-entropy loss through the normalization formula.

[0049] In step S250, differentiated importance weights are assigned to the knowledge of different intermediate layers. Not all intermediate layers contribute equally to the final task; some layers may focus more on low-level features such as texture and edges, while others encode more discriminative high-level semantics. By calculating the cross-entropy loss between the logistic confidence vector of each intermediate layer and the true label when used individually for classification, the effectiveness of the layer's features for the task objective can be quantified. The lower the cross-entropy, the more discriminative the layer's features are, and the higher the weight should be assigned. This dynamic weighting method based on task performance makes the distillation process more targeted and efficient.

[0050] Step S260: Based on the intermediate layer assignment weights corresponding to the intermediate layer logical confidence vectors of each model, calculate the KL divergence between the intermediate layer logical confidence vectors of each model and the output layer logical confidence vector of the small model by weighted summation, and obtain the multi-stage intermediate layer logical distillation loss.

[0051] In step S260, selective transfer of multi-level feature knowledge from the large model is implemented. By weighted fusion of the KL divergence between each intermediate layer and the output layer of the small model according to their assigned weights, a loss term that comprehensively reflects the degree of semantic alignment across multiple levels is constructed. This design enables the small model not only to mimic the final output of the large model, but also to implicitly absorb structured knowledge from multiple intermediate layers in its output layer. This is particularly helpful in improving its spatial perception and contextual understanding of complex defects, thereby enhancing the model's expressive power.

[0052] Step S270: The output layer distillation loss, hard label loss and multi-stage intermediate layer distillation loss are weighted and summed to form the overall loss, and the parameters of the small model are updated based on minimizing the overall loss.

[0053] In step S270, by jointly optimizing three complementary loss terms, the small model is simultaneously supervised by the direct supervision of the real labels, the soft supervision of the final output of the large model, and the indirect guidance of multi-layer intermediate features during training. This allows it to approximate the performance of the large model to the maximum extent possible with limited capacity. The weighted combination of the overall loss function can adjust the importance of each term according to task requirements, ensuring that the small model maintains lightweight design while possessing high accuracy, strong generalization, and good task alignment, providing a reliable model foundation for efficient edge quality inspection.

[0054] In some embodiments of this application, by collaborating from a large model to a small model, and based on a multi-stage logical knowledge distillation method, the small model can learn more knowledge from the intermediate layers of the large model. This enhances the generalization ability of the small model, enabling more computational tasks to be completed on the edge and reducing the number of times the large model is called.

[0055] Specifically, the network structure replicas of the large model and the small model are deployed on the cloud side, so that the small model can absorb the multi-stage knowledge of the large model through a multi-stage logical knowledge distillation method.

[0056] Assume the industrial quality inspection dataset contains One sample, ,in Represents an image, They represent The true label, and These are the width and height of the image, respectively. This represents the total number of categories in the dataset. For the input sample... Large model and small models The sample can be processed separately and a prediction logistic vector can be generated. and . Logical confidence vectors can be used with distillation temperature of The softmax function is obtained by further transforming the prediction logistic vector and is defined by the following formula (1): (1); in and They are and The Each element.

[0057] Because knowledge distillation aims to narrow and The difference between them, and the KL divergence loss is mainly used to measure the difference between them. and The degree of closeness between the large and small models, therefore the classical distillation loss between the large and small models, is defined by the following formula (2): (2); In addition, to fully learn the supervised information in the dataset, the cross-entropy loss is used to measure the closeness between the final logistic confidence vector of the small model and the true label, and is defined by the following formula (3): (3); in It is the true label distribution, it is Unique hot tags.

[0058] To effectively aggregate the multi-stage intermediate layer logistic confidence vectors of a large model, the cross-entropy loss between the intermediate layer logistic confidence vectors and the true labels is calculated, and the first layer representing the sample-level confidence is... The weight allocation of the intermediate layer logical confidence vectors is given by the following formula (4): (4); in, It represents the total number of intermediate layer prediction logistic vectors generated in the large model. It is the first Intermediate prediction logic vectors yes The first in One element, yes The logical confidence vector. The smaller, The larger it is.

[0059] By assigning weights, all intermediate logic distillation losses are obtained. It can be aggregated into a multi-stage intermediate logical loss. , is defined as follows (5): (5); Therefore, the overall loss function of multi-stage logical knowledge distillation can be defined as the following formula (6): (6); in and It is a distillation parameter used to balance the effects of knowledge distillation loss and standard cross-entropy loss.

[0060] Based on the above definition, by minimizing the overall loss The small model can effectively absorb the multi-stage knowledge of the large model, use the generated network weight parameters to update the small model, and deploy the updated small model on the edge to perform inference on industrial inspection images.

[0061] In some embodiments of this application, the early termination router is trained through knowledge distillation, including the following steps.

[0062] Step S310: During the training phase, the small model on the edge is used as the teacher model and its network parameters are frozen. Inference is performed on the training samples to generate intermediate layer features and corresponding teacher logical confidence vectors.

[0063] In step S310, a reliable and stable source of supervision signal is provided for the training of the early-retirement router. Since the small model has fully learned the discriminative ability of the large model during the multi-stage knowledge distillation process, its output logical confidence vector can effectively reflect the recognition reliability of the current input sample. By freezing its parameters, the teacher's behavior is kept consistent throughout the router training process, avoiding supervision signal drift caused by small model parameter updates. Simultaneously, its internal intermediate layer features are extracted as input to the subsequent student model, enabling early-retirement decisions to be based on feature representations completely consistent with the actual reasoning process, ensuring consistency between training and deployment.

[0064] Step S320: Using the early departure router as the student model and the intermediate layer features as input, generate the student logical confidence vector.

[0065] In step S320, a lightweight and efficient confidence predictor is constructed. Its function is to quickly estimate the confidence level of the current inference result from the feature representation of the intermediate layer of the small model. Early termination routers typically employ minimalist structures such as single-layer perceptrons or small MLPs to ensure that their computational overhead is negligible. By directly using the intermediate layer features as input, the router can generate confidence assessments in real time during inference without repeating the computation of the backbone network, providing a basis for whether to terminate early. This design deeply integrates confidence judgment with the main model inference, achieving low-latency, high-precision early termination decisions.

[0066] Step S330: Construct distillation loss based on teacher logical confidence vector and student logical confidence vector, construct cross-entropy loss based on sample true label and student logical confidence vector, and sum the distillation loss and cross-entropy loss by weight to form the overall loss. By minimizing the overall loss, the training of the early-retirement router is completed.

[0067] In step S330, the implicit confidence judgment ability of the small model is transferred to the early departure router through knowledge distillation. The teacher's logical confidence vector represents the small model's intrinsic confidence in its own predictions, while the student's logical confidence vector is the router's independent estimate of the same input. By constructing a loss function between the two (such as KL divergence) as the distillation loss, the router parameters can be optimized so that its output approximates the teacher's true confidence as closely as possible. Furthermore, a cross-entropy loss is constructed based on the sample's true label and the student's logical confidence vector, and the distillation loss and cross-entropy loss are weighted and summed to form the overall loss. By minimizing the overall loss, the early departure router is trained. This supervised approach avoids relying on true labels to define a rigid rule of "whether to leave early," instead learning the model's own uncertainty expression, making the early departure strategy more adaptable and robust.

[0068] In step S340, during the inference phase, the trained early-retreat router is embedded into the intermediate layer of the edge-side small model to output a confidence score based on the real-time generated intermediate layer features. The confidence score is then compared with a preset confidence threshold to determine whether to continue inferring the industrial inspection image and output the corresponding quality inspection result, or to upload the industrial inspection image to the edge.

[0069] The preset confidence threshold is an adaptive threshold dynamically determined based on the confidence distribution of small model inference on the validation set.

[0070] Step S340 implements the integration and application of the early termination method in actual operation. The router is activated during the forward inference process of the small model, instantly generating a confidence assessment using the intermediate features already calculated at the current layer, without requiring additional data transmission or delays. If the confidence score is higher than the threshold, the system immediately adopts the current output of the small model as the final quality inspection result, completing a rapid response; otherwise, it is judged as a difficult sample, triggering the upload process. This method significantly improves the processing efficiency of high-confidence samples while ensuring that low-confidence samples receive a higher level of review opportunity, optimizing overall resource allocation.

[0071] Furthermore, the preset confidence threshold is an adaptive threshold dynamically determined based on the confidence distribution of the small model's inference on the validation set, ensuring that the threshold for early termination decisions is both environmentally adaptable and task-oriented. Fixed thresholds are insufficient to handle confidence distribution shifts caused by different production lines, different defect types, or model aging. By statistically analyzing the confidence distribution of the small model's output on the validation set, an adaptive threshold that covers high-precision regions can be set, for example, selecting the lowest confidence value that ensures the validation set accuracy does not fall below a certain level.

[0072] In some embodiments of this application, the confidence threshold of the early termination router can be adjusted using an adaptive method: after the end-side device completes inference for a batch of data samples, it retains the confidence distribution information of the batch of data samples; the end-side device dynamically updates the decision threshold of the early termination router based on this information—for example, if the end-side device resolves a large number of data samples with high confidence, it adjusts the early termination confidence threshold to reduce unnecessary uploads, and conversely, it lowers the threshold to avoid missed detections.

[0073] In some embodiments of this application, by collaborating between a small model and a large model, the confidence level of the intermediate feature data of the small model is evaluated based on the early termination confidence routing method, and a more suitable inference path for the sample data is selected from the large and small models. In this way, the advantages of each model can be fully utilized to improve the accuracy of the detection results.

[0074] Specifically, in the early-retreat confidence routing, an early-retreat router based on a deep neural network (DNN) is inserted into the intermediate layer of the small end-model to process intermediate feature data and generate a prediction confidence score. The prediction confidence score is used to evaluate the sample reasoning ability of the small model.

[0075] By training the early-leave router The output can be used with the softmax function to define a logical confidence vector. ,in , It is a predicted logistic vector, and These are intermediate feature data generated from the intermediate layers of the small model. In a specific dimension, a larger value indicates that the smaller model has a stronger confidence in the inference of the corresponding sample.

[0076] If the sample's prediction confidence score Above the defined confidence threshold If the condition is met, the sample will continue to be processed by the edge-side small model. Otherwise, the inference process of the edge-side small model will be interrupted, and the sample will be transferred to the cloud-side large model for processing.

[0077] In the training of the early-retirement router, a standardized knowledge distillation method was employed, in which the edge-side small model acts as the teacher model, and the early-retirement router acts as the student model. During training, the small model freezes itself to generate stable intermediate feature data and prediction logistic vectors. Furthermore, the early exit router processes intermediate feature data to generate intermediate prediction logical vectors. .

[0078] To improve the performance of distillation training, and Standardization is performed using standard normalization methods. Defined as the input logical confidence vector, the normalization process is expressed as the following formula (7): (7); in It is the standard deviation function. Yes The mean. Therefore, the distillation loss between the small model and the early-retreat router is defined by the following formula (8): (8); in These are the distillation weights. They are minimized during the distillation training of the early-retreat router. The generalization ability of the early-retreat router after training can be closer to that of the small model.

[0079] Based on the above definition, for datasets End-side small model generate And pause the inference process in progress. Early departure router deal with And generate prediction confidence scores. .if Higher than The end-side small model will continue to be processed. To complete the reasoning. Otherwise, It will be uploaded to a large model for inference.

[0080] In some embodiments of this application, the large model is having Early exit point and In a deep neural network with 1 logical layer, each early exit point corresponds to a potential inference early exit location. The segmentation location of the large model corresponds to the 1st logical layer. There are several logical layers, specifically including: edge deployment from the input layer to the first... The sub-network of the logical layer, cloud-side data center deployment from the first... Each logical layer leads to a sub-network of the final output layer, where... Let be a positive integer dynamically determined based on the optimization results of the Markov decision process, and satisfy . .

[0081] Specifically, the large model is constructed to have Early exit point and A deep neural network with multiple logical layers, where each early exit point corresponds to a potential inference early exit location. This structural design enables the model to have multi-level intermediate output capabilities, allowing the system to flexibly terminate or hand over the inference process at different depths based on task requirements or resource conditions. This provides a divisible and interruptible model foundation for edge-cloud collaboration, thereby supporting a progressive and phased intelligent quality inspection process.

[0082] The segmentation position of the large model corresponds to the first There are 1 logical layers, with side-side deployments extending from the input layer to the 1st layer. The logical layer sub-network, while the cloud-side data center deploys from the first... The sub-network extends from the logical layer to the final output layer. This partitioning method ensures that the edge can utilize local computing power to perform in-depth but incomplete reasoning on low-confidence samples. If the accuracy requirements are met, the results can be directly output. Only when the edge processing is still insufficient to guarantee the reliability of the discrimination will the intermediate feature data be transmitted to the cloud side, which will then complete the remaining high-complexity calculations, thus achieving a reasonable distribution of computing load and effective control of communication overhead.

[0083] in, Let be a positive integer dynamically determined based on the optimization results of the Markov decision process, and satisfy . This constraint ensures that the edge undertakes the substantial computational task. ), while ensuring that the cloud side retains sufficient model depth to complete the final accurate judgment ( More importantly, The value is not a fixed configuration, but an optimized variable that is adjusted in real time according to the system's operating status, enabling the model segmentation to adapt to dynamic factors such as network bandwidth, device load, and sample difficulty, thereby continuously optimizing the overall inference latency and energy consumption while ensuring the accuracy of quality inspection.

[0084] In some embodiments of this application, step S130 involves dynamically determining the segmentation location of the large model and the cloud-side resource allocation strategy based on a deep reinforcement learning method, with inference latency and energy consumption as joint optimization objectives, and adjusting the deployment configuration of the edge and cloud sides accordingly, including the following steps.

[0085] Step S410: Construct a Discrete Markov Decision Process, where the state space includes the computational load, network bandwidth, and early exit point structure information of each edge server and cloud device, and the action space includes the segmentation location. The reward function is the weighted negative of the average inference latency and average energy consumption of low-confidence samples across all terminal devices, relative to the cloud computing resource allocation ratio.

[0086] In step S410, the dynamic resource allocation problem in the edge-cloud collaborative quality inspection system is formalized into a learnable sequential decision problem. By clearly defining states, actions, and rewards, the system can mathematically characterize the relationship between the current operating environment (e.g., whether devices are busy, whether the network is congested, and the model structure) and decision-making behaviors (e.g., where to partition the model and how much cloud resources to allocate), using the combined performance of inference latency and energy consumption as the optimization guide. Setting the reward as a weighted negative value of the two makes the goal of reinforcement learning naturally transform into minimizing latency and energy consumption, thus providing a clear and quantifiable optimization objective for subsequent policy learning.

[0087] Step S420: The Markov decision process is trained using a multi-agent deep reinforcement learning algorithm to obtain the optimal policy.

[0088] In step S420, a distributed agent collaborative learning method is used to efficiently solve the joint optimization strategy in complex environments. Since industrial quality inspection systems typically contain multiple terminal devices, each facing different local states, a single agent cannot fully perceive the global picture and make optimal decisions. By assigning an agent to each large model, each agent independently selects actions based on environmental observations, while collaboratively optimizing overall performance through shared experience or centralized training methods. This preserves the distributed nature of decision-making and achieves consistency in the global objective. The multi-agent architecture effectively improves the adaptability and convergence efficiency of the strategy in heterogeneous and dynamic industrial environments, ultimately outputting a policy function that can map any system state to the optimal partitioning position and resource allocation ratio.

[0089] Step S430: Based on the optimal strategy, dynamically output the current optimal segmentation position at runtime. The cloud-side resource allocation scheme is used to update the model deployment and resource configuration on both the edge and cloud sides.

[0090] In step S430, the intelligent strategy obtained from offline training is applied to the actual operation phase to achieve online adaptive control of the system. Whenever the system state changes (such as increased load due to increased production line speed, or network fluctuations affecting transmission efficiency), the strategy can evaluate the current situation in real time and output the most suitable model segmentation point. The system then automatically adjusts the sub-network range loaded on the edge and the number of compute instances allocated on the cloud, completing a dynamic reconfiguration of the deployment configuration. This closed-loop control method enables the entire quality inspection system to continuously optimize, allowing it to operate with near-optimal resource configurations without service interruption, maximizing overall energy efficiency and response efficiency.

[0091] In some embodiments of this application, the average inference latency includes edge-side inference latency, side-side inference latency, and cloud-side inference latency, specifically including the following: (1) Edge-side inference latency includes: the computational latency generated by the small model on the edge performing preliminary inference on the industrial inspection image, reflecting the time required for the lightweight model to complete forward propagation on the local device; the judgment latency introduced by the early-retreat router generating confidence scores based on the intermediate layer features of the small model, reflecting the additional processing overhead of the confidence assessment module; and the transmission latency experienced when uploading low-confidence samples from the edge device to the edge server when the confidence is insufficient, which is directly limited by the network bandwidth and link quality between the edge and the device. These three factors together constitute the complete time cost required for the edge to process an inspection request, which is an important indicator for measuring the real-time performance of the system.

[0092] (2) Edge inference latency includes: first, the computational latency caused by the edge server performing shallow forward inference of the large model on low-confidence samples from the end side, which depends on the size of the sub-network deployed on the edge and its hardware computing power; second, the transmission latency caused by further transmitting the intermediate features obtained from the shallow forward inference to the cloud side when the edge inference results still do not meet the accuracy requirements, which is affected by the network conditions between the edge and the cloud. Edge inference latency reflects the system's response efficiency in the medium-complexity task processing stage, and its optimization helps to reduce dependence on cloud resources and accelerate the overall decision-making process.

[0093] (3) Cloud-side inference latency includes the computational latency of performing forward inference of the deep parts of large models. This part is only triggered when the edge cannot complete high-precision discrimination, representing the final computational time of the system in processing the most complex and difficult samples. Since the cloud side is usually equipped with high-performance GPU clusters, its single inference speed is relatively fast, but if it is called frequently, it will accumulate significant latency. Therefore, although cloud-side inference latency is the last link in the three-level architecture, it is a key link to ensure the overall quality inspection accuracy. Its frequency and duration directly reflect the effectiveness of the system's intelligent traffic diversion method.

[0094] In some embodiments of this application, the total energy consumption includes: the computing energy consumption of the end-side industrial equipment, the energy consumption of the end-side industrial equipment in transmitting industrial quality inspection images, the computing power consumption of the edge server, the energy consumption of the edge server in transmitting intermediate feature data, and the computing power consumption of the cloud-side data center.

[0095] Specifically, edge computing energy consumption originates from the computation process of small models and early-retrieval routers on embedded devices or industrial cameras, typically at the milliwatt level, but has a cumulative effect due to the large number of devices. Edge image transmission energy consumption comes from the real-time uploading process of industrial quality inspection images, affected by the transmission frame rate and wireless communication link bandwidth. Although the transmission power consumption of a single device is lower than the computing power consumption, it will result in significant energy consumption overhead when massive devices transmit in parallel. Edge computing energy consumption refers to the power consumed by edge servers in performing forward inference of the shallow part of large models. Edge feature data transmission energy consumption is the energy consumed by edge servers in transmitting processed intermediate feature data to the cloud. Cloud computing power consumption comes from the high-density energy consumption generated by GPU instances in data centers running the back-end inference of large models. Although the energy efficiency of a single task is relatively high, the overall carbon footprint is significant under large-scale concurrency. Incorporating all three into the total energy consumption consideration allows the system optimization goal to take into account both local energy efficiency and global sustainability, supporting the implementation needs of green and intelligent manufacturing.

[0096] In some embodiments of this application, step S420 involves training the Markov decision process using a multi-agent deep reinforcement learning algorithm to obtain the optimal policy, including the following steps.

[0097] Step S510: Configure an agent for each large model. Each agent constructs a state representation based on environmental observations and independently selects actions.

[0098] In step S510, a distributed decision-making architecture is established, enabling each agent to autonomously perceive the system state based on its local environment (such as local computing load, network conditions, etc.) and independently determine its corresponding actions, such as suggesting model segmentation locations or requesting resources. This multi-agent design avoids the communication bottlenecks and scalability limitations caused by relying on a single central controller to obtain global information. It also better suits the actual characteristics of widely distributed and heterogeneous terminal devices in industrial settings, laying the foundation for efficient and scalable collaborative optimization.

[0099] In step S520, each agent stores the experience generated during the interaction into a local experience replay buffer in the form of a four-tuple. The four-tuple includes state, action, reward, and next state.

[0100] In step S520, the historical trajectory of the agent's interaction with the environment is recorded to provide training data for subsequent policy learning. By structurally storing the state transitions and immediate feedback during each decision-making process, the experience replay method breaks the temporal correlation of data, improves sample utilization efficiency, and supports offline or batch training. The local cache design also reduces the dependence on central storage, enhances the robustness and privacy of the system, and provides data support for multi-agent learning under asynchronous or non-synchronous conditions.

[0101] Step S530: During the training phase, sample batch experience data from the experience replay buffer, calculate the current action value using the main training network, and calculate the target action value using the target network with parameter delay updates.

[0102] In step S530, a dual-network architecture is implemented in the deep Q-network to stabilize the reinforcement learning training process. The main training network is responsible for evaluating the value of the selected action according to the current policy, while the target network provides a relatively stable reference benchmark for calculating the expected reward. By separating these two functions, the training oscillation problem caused by frequent changes in the target value in traditional Q-learning is effectively alleviated. Batch sampling further improves the stability and convergence speed of gradient estimation, providing reliable technical support for the learning of complex Markov decision processes.

[0103] In step S540, based on the temporal difference error between the current action value and the target action value, the parameters of the main training network are updated, while the parameters of the target network are synchronized from the main training network through periodic replication.

[0104] In step S540, the policy is iteratively optimized by minimizing the temporal difference error, enabling the agent to gradually learn to predict actions with higher long-term cumulative rewards. The parameter updates of the main network directly drive policy improvement, while the target network employs a delayed synchronization method (such as hard copying every few steps) to ensure the target value remains stable in the short term, thereby improving training convergence and numerical stability. This parameter update method is a key technical aspect of the successful application of deep reinforcement learning algorithms in high-dimensional, dynamic environments.

[0105] Step S550: Repeat the above process S510 to S540 until the strategy converges, and obtain the optimal strategy for dynamically outputting the segmentation location and cloud-side resource allocation scheme.

[0106] In step S550, the closed-loop training process of the entire multi-agent reinforcement learning is completed. Through continuous environmental interaction, experience accumulation, network updates, and policy iterations, each agent eventually learns a stable mapping relationship: it can output the optimal segmentation position based on any given system state. Combined with cloud-side resource allocation ratios. Policy convergence means that after repeated trial and error and learning, the agent has found a decision rule that can minimize the weighted sum of average inference latency and average energy consumption in long-term operation, providing a reliable policy foundation for the system to achieve adaptive and intelligent resource allocation in actual deployment.

[0107] In some embodiments of this application, large-scale models are divided and computing power is allocated based on deep reinforcement learning methods through edge-cloud collaboration, making full use of computing resources on the cloud and edge sides. This improves the utilization rate of computing resources and reduces overall inference latency and energy consumption.

[0108] Specifically, on the cloud side, there are deployed A large model with multiple exits To collaboratively perform inference in edge-cloud collaboration, [the system will have]... Exit points and Each logical layer It is divided into a shallow layer and a deep layer, with the former deployed on the side server. The latter is deployed in a cloud data center. For sample inference on the terminal device, if it is determined to be of low confidence through early-retreat confidence routing, the early-retreat router will forward the inference to the edge. If it is deployed on the edge server... If the shallow part of the inference achieves the expected accuracy, the inference result is returned to the terminal device. Otherwise, the inference is forwarded to the cloud.

[0109] For edge-side inference, on the terminal device On it, a configuration with Each logic layer consists of a pre-trained small model. Each logic layer consists of a pair of tuples. Characterization, in which , This is the amount of computation required. This refers to the size of the output data.

[0110] Using the early-retreat confidence routing method described above, if in the... If an early-retreat router is inserted into a logical layer, then in The computation delay at that point can be defined by the following formula (9): (9); in This is the total computational cost of inserting early-exit routers. yes computing power It is the confidence score predicted by the early exit router.

[0111] if Then the data size is Low confidence samples Forward to edge server To reason. from Transmit to The delay can be defined as ,in It refers to the data transmission rate. It's bandwidth. It is transmission power. It is channel gain. It is the noise spectral density.

[0112] Therefore, for low-confidence samples, in The inference delay caused by the location can be defined by the following formula (10): (10); For side-by-side inference, the shallow part of the large model is deployed in Due to the uncertainty of the exit point when inferring samples, the computational complexity required to process samples is uncertain.

[0113] Since the exit probability quantifies the adaptability of an exit to sample inference, offline inference on the validation set is used to obtain the expected exit probability for each exit. A defined confidence threshold is used. If the predicted logistic vector of an exit is higher than the value after processing by the softmax function... If the inference fails, the sample inference will exit prematurely at this exit point. Therefore, inference is performed on all validation samples from the input layer to all exit points, and the number of samples that exit prematurely is recorded. ,in yes The The number of early exit samples at each exit point. Correspondingly, the exit probability can be defined as... ,in It is the first The probability of exiting at each exit point This is the total number of validation samples. Therefore, by iterating through the... The exit probabilities of all exit points before the nth exit point can be used to determine the exit probability of the nth exit point. The probability of calculating each exit point is defined by the following formula (11): (11); also, In the main branch The computational probability of a logical layer can be defined as follows: ,in yes In the main branch The sequence index of the adjacent exit point after each logical layer.

[0114] By combining the computational overhead of each logic layer and each exit, in The expected computational overhead is defined by the following formula (12): (12); yes computing power It is The decision segment is divided into shallow and deep parts. If Then the first logical layer will be connected to the second logical layer. The logical layers are combined into a shallow layer and deployed in... . It represents the number of exit points in the shallow model. yes In the main branch The computational cost of each logical layer yes The Middle The calculation amount for each exit point.

[0115] Will Defined as the deep portion deployed on the cloud side from Layer transmission to The size of intermediate data in the layer, from transmission The expected latency to the cloud can be defined as ,in It refers to the data transmission rate. It is transmission power. It's bandwidth. It is the noise spectral density. It is co-channel interference. It is the channel power gain. It is the path loss constant. It is the power gain of the small-scale fading channel. From Euclidean distance to the cloud side This is a reference distance. It is a large-scale path loss factor.

[0116] Therefore, in The expected inference delay in the shallow part caused by the location can be defined by the following formula (13): (13); For cloud-side inference, Defined as the computing power of a cloud data center, Defined as The resource allocation ratio in the deep layer, and the expected inference delay in the deep layer caused by the cloud side, can be defined by the following formula (14): (14); During the above process, the relevant entities also consume energy. Terminal devices. It is equipped with a system-on-a-chip. The energy consumption for low-confidence samples is defined as... , among which yes The power consumption. Meanwhile, the edge server is also equipped with a system-on-a-chip (SoC), and the expected power consumption of the edge server is defined as... ,in yes Power consumption.

[0117] Since cloud data centers are equipped with CPUs and GPUs, the power consumption on the cloud side is defined as... ,in The energy coefficient is determined by the chip structure. This refers to the clock frequency. Therefore, the expected energy consumption of a cloud data center can be defined by formula (15): (15); Regarding the above process, You can request any Inference is performed on low-confidence samples. According to the above definition, from... The average inference delay of low-confidence samples can be defined by the following formula (16): (16); Similarly, by The average energy consumption caused by inferring low-confidence samples can be defined by the following formula (17): (17); Based on the above process, it is necessary to... Divided into shallow and deep layers, and on the cloud side... The deeper layers allocate resources to complete inference on low-confidence samples on terminal devices. Therefore, a method for large models needs to be found. Model partitioning strategy and cloud-side resource allocation strategies This is to ensure the system operates optimally. For and ,Depend on The average cost of inferring low-confidence samples can be defined as ,in and These are weighting coefficients used to balance the relative importance of inference latency and energy consumption in inference cost. Therefore, the optimization problem can be expressed as the following formula (18):

[0118]

[0119]

[0120] (18); in, Used to limit the total number of model partitions at the logical layer. Inside, Used to restrict The resource allocation ratio in the deeper layers, This is used to ensure that the total allocated computing power equals the total computing power of the cloud data center.

[0121] The optimization problem described above can be transformed into a discrete Markov decision process (MDP). To achieve the optimal decision, each... Actions are executed in a discrete sequential decision-making pattern based on the current state. The action used in each decision round is an exploratory model split point in the current state. and resource allocation ratio . and All of them exhibit discrete characteristics. After the action is performed, A reward will be received that measures the effectiveness of the current action in jointly optimizing average inference latency and energy consumption, and the current state will be updated. Based on the newly updated state, In the next round of decision-making, we will continue to implement new exploratory actions. The state observed in each decision round includes time-varying and discrete factors, such as the available computing power of heterogeneous devices, achievable wireless transmission rates, and... The probability of exiting is uncertain, and the state is updated only at each discrete time step as the decision-making process progresses. Furthermore, in this decision-making process, for In each decision round, the actions of the tentative model in dividing points and allocating resource ratios depend only on the current state and are independent of historical states, satisfying the Markov property.

[0122] The above discrete Markov decision process can be derived from... It means that, among them It is the number of intelligent agents. It is a state space. It is the action space. It is the set of rewards obtained by all agents in a round of decision-making. This refers to the state transition probability. The definitions involved in the above discrete Markov decision process are as follows: 1) State space: in In each round of decision-making, In the The state observed at each time step It mainly contains three types of information: Calculation information, Resource information and cloud data center resource information. It can be defined as follows:

[0123] in, , , and .

[0124] 2) Action Space: To optimize the process for low-confidence samples across all terminal devices, minimizing average inference latency and energy consumption. We need to find suitable model split points in the current state. and resource allocation ratio .therefore, In the Actions taken at each time step Defined as .

[0125] 3) Reward Function: In each decision round, the efficiency of the action taken is represented by the reward received. The reward function for each time step can be defined by the following formula (19): (19); in, and These are the positive weights that balance the relative importance of inference delay and energy consumption.

[0126] For the aforementioned Discrete Markov Decision Process, a multi-agent dual-deep Q-network algorithm based on Gaussian exploration is used to rationally partition the cloud data center. And the allocation of resources.

[0127] For the above algorithm, we have There are [number] training rounds. At the beginning of each training round, the environment is observed as [condition]. Initialize the current state .for Using Gaussian exploration strategy Choose an action to explore more possibilities; the selected action can be defined by the following formula (20): (20); implement back, Receive corresponding rewards ,and Transition to the next state .

[0128] In each training round, There is an experience relay memory buffer To store data including the current state The state of action taken Rewards received And the next state For from Randomly selected experience sub-batch Experience replay data in the middle, target network and training network Couple the predicted values ​​with the target values ​​to reduce the correlation. From training network Obtain, and from the target network The goal achieved It is defined as follows (21): (twenty one); in, It is a discount factor.

[0129] In supervised learning, It needs to be fixed and updated by minimizing the loss function. In order to weaken and The correlation between them Fixed, and Every Updated once per training epoch. Accordingly, the temporal difference error is defined as... loss function It is defined as follows (22): (twenty two); Furthermore, the gradient of the loss function is defined by the following formula (23): (twenty three); Accordingly, It can be based on the learning rate , Update using stochastic gradient descent.

[0130] In some embodiments of this application, reference is made to Figure 2The process described presents a collaborative industrial quality inspection method involving edge, cloud, and endpoint devices. Its core lies in constructing a collaborative inference architecture based on a large model and a lightweight small model. In industrial intelligent manufacturing scenarios, several edge-side industrial devices (such as high-speed industrial cameras and intelligent sensing terminals), multiple edge-side servers, and a cloud-side data center are connected to the Industrial Internet of Things (IIoT). Each edge-side device deploys a small model trained through multi-stage logical knowledge distillation and an early-retreat router, enabling it to absorb multi-level knowledge from the large model. The edge and cloud sides collaboratively deploy a segmented large model, with the edge running the shallow part of the large model and the cloud running the deep part. When an industrial inspection image is input, the edge-side small model performs preliminary inference and calculates a confidence score using the early-retreat router. If the score is higher than a preset confidence threshold, the quality inspection result is directly output for rapid response; otherwise, the low-confidence sample is uploaded to the edge. The edge performs forward inference on the sample using the shallow part of the large model. If the accuracy requirement is met, the result is output; otherwise, the intermediate feature data is transmitted to the cloud, where the deep part of the large model completes high-precision inference and outputs the final result. Meanwhile, based on deep reinforcement learning, the system dynamically determines the segmentation position of the large model and the cloud-side resource allocation strategy with inference latency and energy consumption as joint optimization objectives, and adjusts the edge-cloud deployment configuration in real time. This effectively balances latency and energy consumption while ensuring detection accuracy, thus building an efficient and adaptive edge-cloud collaborative industrial quality inspection system.

[0131] Secondly, refer to Figure 3 This application provides an edge-cloud collaborative industrial quality inspection system, deployed on industrial equipment on the edge, servers on the edge, and data centers on the cloud, including a small model inference module, a large model segmentation module, and a large model inference module.

[0132] The small model inference module is configured to: deploy a lightweight small model on the edge side to perform preliminary inference on industrial inspection images and calculate a confidence score based on an early-retirement router; if the confidence score is higher than a preset confidence threshold, the corresponding quality inspection result is output; otherwise, the industrial inspection image is uploaded to the edge side as a low-confidence sample. This method effectively filters high-deterministic samples, significantly reduces unnecessary data transmission and upper-level computational burden, and improves the overall system response speed and energy efficiency.

[0133] The large model segmentation module is configured to collaboratively deploy segmented large models on both the edge and cloud sides. The edge side runs the shallow part of the large model, while the cloud side runs its deep part. Specifically, it includes: using deep reinforcement learning methods, with inference latency and energy consumption as joint optimization objectives, dynamically determining the segmentation position of the large model and the cloud side resource allocation strategy, and adjusting the deployment configuration of the edge and cloud sides accordingly. By continuously sensing environmental changes such as device load and network status, this module enables the entire quality inspection system to automatically maintain a near-optimal operating state under different working conditions, thereby maximizing the system's energy efficiency ratio and response performance while ensuring inspection quality.

[0134] The large model inference module is configured as follows: On the edge, shallow forward inference of the large model is performed on the low-confidence samples. If the accuracy requirements are met, the corresponding quality control result is output; otherwise, the intermediate features of the shallow forward inference are transmitted to the cloud to complete the deep forward inference of the large model, and the corresponding quality control result is output. This phased, hierarchical collaborative architecture fully utilizes the strong local computing power of the edge while retaining the discrimination capabilities of the cloud, ensuring high-precision processing of difficult samples, and avoiding excessive reliance on cloud resources, thus achieving a balance between accuracy and efficiency.

[0135] Furthermore, embodiments of this application provide an electronic device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the aforementioned end-edge-cloud collaborative industrial quality inspection method.

[0136] Furthermore, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the aforementioned edge-cloud collaborative industrial quality inspection method.

[0137] In summary, the edge-cloud collaborative industrial quality inspection method, system, equipment, and medium provided in this application have the following technical effects.

[0138] This solution achieves rapid local decision-making for high-confidence samples by deploying lightweight small models and early-retire routers on the edge, significantly reducing communication overhead and response latency. Through an edge-cloud collaborative segmentation architecture, low-confidence samples undergo moderately complex inference on the edge, while only difficult samples are refined on the cloud, effectively balancing detection accuracy and system efficiency. By introducing a deep reinforcement learning method with inference latency and energy consumption as joint optimization objectives, the solution dynamically determines the segmentation position of the large model and the cloud resource allocation strategy, enabling adaptive adjustments to deployment configuration. The overall solution ensures high-precision quality inspection capabilities while significantly reducing end-to-end inference latency and end-to-end energy consumption, improving the real-time performance, energy efficiency, and resource utilization efficiency of industrial quality inspection systems in complex and variable production line environments. It provides a scalable, adaptive, efficient, and reliable new paradigm for AI quality inspection in intelligent manufacturing scenarios.

[0139] It should be noted that in all specific embodiments of this application, all data processing activities related to user identity or personal characteristics, such as user information, user behavior data, historical data, and location information, will be conducted in accordance with the principles of legality, legitimacy, and necessity. All data collection, use, storage, and processing will be subject to compliance with applicable national and regional laws, regulations, and industry standards, and informed consent from users will be obtained in a clear and explicit manner before processing. For the processing of sensitive personal information, separate consent from users will be obtained through prominent means such as pop-up prompts and independent confirmation pages. If any processing conflicts with laws and regulations, the laws and regulations will prevail, and necessary data processing will only be carried out within the scope permitted by laws and regulations, ensuring that all data-based applications, analyses, and technical implementations are conducted within the scope permitted by laws and regulations.

[0140] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this application are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.

[0141] Furthermore, although this application is described in the context of functional modules, it should be understood that, unless otherwise stated, one or more of the functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding this application. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of ordinary skill of an engineer. Therefore, those skilled in the art can implement the application set forth in the claims using ordinary skill. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of this application, which is determined by the full scope of the appended claims and their equivalents.

[0142] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several programs to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0143] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequential list of executable programs for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, a program execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can retrieve and execute a program from or in conjunction with such a program execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can mean any means that can contain, store, communicate, propagate, or transmit a program for use by or in conjunction with a program execution system, apparatus, or device.

[0144] More specific examples (a non-exhaustive list) of computer-readable media include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Additionally, computer-readable media can even be paper or other suitable media on which programs can be printed, for example, by optically scanning the paper or other media, then editing, interpreting, or, if necessary, processing it in a suitable manner to obtain the program electronically, and then storing it in computer memory.

[0145] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable program execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0146] In the foregoing description of this specification, the reference to terms such as "one embodiment / implementation," "another embodiment / implementation," or "certain embodiments / implementations," etc., indicates that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in an embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0147] Although embodiments of the invention have been shown and described, those skilled in the art will understand 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 claims and their equivalents.

[0148] The above is a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of the present invention.

Claims

1. An industrial quality inspection method with edge-cloud collaboration, characterized in that, This is executed collaboratively by industrial equipment on the edge, servers on the edge, and data centers on the cloud, including: A lightweight small model is deployed on the edge to perform preliminary inference on industrial inspection images and calculate a confidence score based on an early termination router. If the confidence score is higher than a preset confidence threshold, the corresponding quality inspection result is output; otherwise, the industrial inspection image is uploaded to the edge as a low-confidence sample. The large-scale segmented model is deployed collaboratively on the edge and cloud sides, wherein the shallow part of the large-scale model is run on the edge side and the deep part is run on the cloud side. Specifically, it includes: based on deep reinforcement learning methods, with inference latency and energy consumption as joint optimization objectives, dynamically determining the segmentation position of the large-scale model and the cloud side resource allocation strategy, and adjusting the deployment configuration of the edge and cloud sides accordingly. The edge performs shallow forward inference of the large model on the low-confidence samples. If the accuracy requirements are met, the corresponding quality inspection result is output. Otherwise, the intermediate features of the shallow forward inference are transmitted to the cloud side to complete the deep forward inference of the large model and the corresponding quality inspection result is output.

2. The industrial quality inspection method for edge-cloud collaboration according to claim 1, characterized in that, The lightweight small model is obtained through multi-stage logical knowledge distillation based on the large model, including the following steps: Obtain a training dataset containing industrial inspection images and their corresponding ground truth labels; Deploy replicas of the large model and the small model on the cloud side, and perform forward inference on the training dataset to obtain the output layer logical confidence vector of the large model, the intermediate layer logical confidence vectors of multiple large models, and the output layer logical confidence vector of the small model. Calculate the KL divergence between the output layer logic confidence vector of the large model and the output layer logic confidence vector of the small model, and use it as the output layer distillation loss; Calculate the cross-entropy loss between the output layer logistic confidence vector of the small model and the true label, and use it as the hard label loss; For each of the aforementioned large model intermediate layer logical confidence vectors, calculate the cross-entropy loss between it and the true label, and then obtain the corresponding intermediate layer allocation weights based on the cross-entropy loss through a normalization formula. Based on the intermediate layer allocation weights corresponding to the intermediate layer logical confidence vectors of each of the large models, the KL divergence between the intermediate layer logical confidence vectors of each of the large models and the output layer logical confidence vectors of the small models is calculated by weighted summation, and the multi-stage intermediate layer logical distillation loss is obtained. The output layer distillation loss, hard label loss, and multi-stage intermediate layer logic distillation loss are weighted and summed to form the overall loss, and the parameters of the small model are updated based on minimizing the overall loss.

3. The industrial quality inspection method for edge-cloud collaboration according to claim 1, characterized in that, The early termination router is obtained through knowledge distillation training, including the following steps: During the training phase, the small model on the edge is used as the teacher model and its network parameters are frozen. Inference is performed on the training samples to generate intermediate layer features and corresponding teacher logical confidence vectors. Using the early departure router as a student model and the intermediate layer features as input, a student logical confidence vector is generated. A distillation loss is constructed based on the teacher's logical confidence vector and the student's logical confidence vector; Construct a cross-entropy loss based on the true labels of the samples and the logical confidence vectors of the students; The distillation loss and cross-entropy loss are weighted and summed to form the overall loss. The training of the early-retreat router is completed by minimizing the overall loss. During the inference phase, the trained early-retreat router is embedded into the intermediate layer of the edge-side small model to output a confidence score based on the real-time generated intermediate layer features. The confidence score is then compared with a preset confidence threshold to determine whether to continue inferring the industrial inspection image and output the corresponding quality inspection result, or to upload the industrial inspection image to the edge. The preset confidence threshold is an adaptive threshold dynamically determined based on the confidence distribution of small model inference on the validation set.

4. The industrial quality inspection method for edge-cloud collaboration according to claim 1, characterized in that, The large model is characterized by having Early exit point and A deep neural network with 1 logical layer, where each early exit point corresponds to a potential inference early exit location; the segmentation location of the large model corresponds to the 1st logical layer. A logical layer, specifically including: the side-side deployment from the input layer to the first... The logical layer sub-network, the cloud-side data center deployment from the first The sub-network from the logic layer to the final output layer, where Let be a positive integer dynamically determined based on the optimization results of the Markov decision process, and satisfy . .

5. The industrial quality inspection method for edge-cloud collaboration according to claim 4, characterized in that, The deep reinforcement learning-based method, with inference latency and energy consumption as joint optimization objectives, dynamically determines the segmentation position and cloud-side resource allocation strategy of the large model, and adjusts the deployment configuration of the edge and cloud sides accordingly, including the following steps: Construct a discrete Markov decision process, where the state space includes the computing resources, network bandwidth, and early exit point structure information of the edge server and cloud devices, and the action space includes the segmentation location. The reward function is the weighted negative of the average inference latency and average energy consumption of low-confidence samples across all terminal devices, in relation to the cloud computing resource allocation ratio. The Markov decision process is trained using a multi-agent deep reinforcement learning algorithm to obtain the optimal policy; Based on the aforementioned optimal strategy, the current optimal segmentation position is dynamically output during runtime. The cloud-side resource allocation scheme is used to update the model deployment and resource configuration on both the edge and cloud sides.

6. The industrial quality inspection method for edge-cloud collaboration according to claim 5, characterized in that, The average inference latency includes edge-side inference latency, side-side inference latency, and cloud-side inference latency; The edge-side inference latency includes: the computation latency of the edge-side small model performing preliminary inference on the industrial inspection image, the judgment latency of the early-retreat router generating confidence scores, and the transmission latency of uploading low-confidence samples from the edge to the side. The side-side inference latency includes: the computational latency of performing shallow partial forward inference of the large model on the low-confidence samples, and the transmission latency of transmitting intermediate features of the shallow partial forward inference to the cloud side. The cloud-side inference latency includes: the computational latency of performing deep forward inference of the large model; The total energy consumption includes: the computing energy consumption of the end-side industrial equipment, the energy consumption of the end-side industrial equipment in transmitting industrial quality inspection images, the computing power consumption of the edge server, the energy consumption of the edge server in transmitting intermediate feature data, and the computing power consumption of the cloud-side data center.

7. The industrial quality inspection method for edge-cloud collaboration according to claim 5, characterized in that, The step of training the Markov decision process using a multi-agent deep reinforcement learning algorithm to obtain the optimal policy includes the following steps: Each large model is configured with an agent, and each agent constructs a state representation based on environmental observations and independently selects actions; Each agent stores the experience generated during the interaction process in the form of a four-tuple in the experience replay buffer; the four-tuple includes state, action, reward and next state. During the training phase, batch experience data is sampled from the experience replay buffer, the current action value is calculated using the main training network, and the target action value is calculated using the target network with parameter delay updates. Based on the temporal difference error between the current action value and the target action value, the parameters of the main training network are updated, while the parameters of the target network are synchronized from the main training network through periodic replication. Repeat the above process until the strategy converges to obtain the optimal strategy for dynamically outputting the segmentation location and cloud-side resource allocation scheme.

8. An edge-cloud collaborative industrial quality inspection system, characterized in that, The industrial equipment deployed on the edge, the servers on the edge, and the data center on the cloud include the following modules: The small model inference module is configured to: deploy a lightweight small model on the edge side, perform preliminary inference on the industrial inspection image, and calculate a confidence score based on the early termination router; if the confidence score is higher than a preset confidence threshold, output the corresponding quality inspection result; otherwise, upload the industrial inspection image as a low-confidence sample to the edge side. The large model segmentation module is configured to: collaboratively deploy segmented large models on the edge and cloud sides, wherein the shallow part of the large model is run on the edge side and the deep part is run on the cloud side. Specifically, it includes: based on deep reinforcement learning methods, taking inference latency and energy consumption as joint optimization objectives, dynamically determining the segmentation position of the large model and the cloud side resource allocation strategy, and adjusting the deployment configuration of the edge and cloud sides accordingly. The large model inference module is configured as follows: the edge performs shallow forward inference of the large model on the low confidence samples. If the accuracy requirements are met, the corresponding quality inspection result is output. Otherwise, the intermediate features of the shallow forward inference are transmitted to the cloud side to complete the deep forward inference of the large model and the corresponding quality inspection result is output.

9. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the edge-cloud collaborative industrial quality inspection method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The device contains a computer program that, when executed by a processor, implements the edge-cloud collaborative industrial quality inspection method as described in any one of claims 1 to 7.