YOLOv8 edge deployment and multi-thread collaborative optimization method for power monitoring
By constructing a heterogeneous parallel processing architecture and the H-PSO dynamic resource scheduling algorithm, the problems of low efficiency and uneven resource utilization in existing edge deployment schemes in power monitoring are solved, achieving efficient multi-threaded collaborative optimization and improving system throughput and real-time performance.
Patent Information
- Application Number
- CN202512000342.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-03-20
AI Technical Summary
Existing edge deployment solutions for power monitoring suffer from problems such as inefficient processing architecture, rigid resource scheduling, insufficient hardware resource utilization, high system latency, and inability to adapt to dynamic fluctuations in load from multiple video streams, thus failing to meet the business requirements for high real-time performance and high throughput.
A heterogeneous parallel processing architecture is constructed, employing multi-level buffer queues and multi-threaded collaborative optimization methods, combined with a dynamic resource scheduling algorithm based on H-PSO, to achieve collaborative work between the central processing unit and the graphics processing unit, and to optimize resource utilization through real-time performance monitoring and task migration.
It improved system throughput, reduced end-to-end latency, enhanced the resource utilization of the graphics processor, and ensured the stability and high real-time performance of the power monitoring system under complex operating conditions.
Smart Images

Figure CN121705031A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of edge computing, intelligent power monitoring, and computer vision, specifically to a YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring. Background Technology
[0002] Edge intelligent analysis systems for power monitoring have become a research hotspot in the industry, and using target detection models such as the YOLO series to perform real-time inspection tasks on edge devices is the current mainstream technical approach. However, in practical applications, existing edge deployment solutions often face technical bottlenecks such as low processing architecture efficiency, rigid resource scheduling mechanisms, and insufficient hardware resource utilization.
[0003] Existing deployment solutions mostly employ single-threaded serial processing architectures or simple multi-threaded parallel modes, failing to achieve deep decoupling of the data processing flow. This approach results in inefficient collaboration between the CPU and GPU, with low overlap between data input / output latency and computation time, leading to high system latency during concurrent processing of multiple video streams and limiting overall system throughput. Furthermore, existing general-purpose edge deployment solutions lack systematic optimization for the multi-camera concurrency, small target detection, and high real-time requirements of power monitoring scenarios. This often results in low GPU utilization, CPU underload, and excessively high end-to-end response latency on real edge computing platforms, making it difficult to support millisecond-level response time requirements.
[0004] In terms of resource scheduling, existing technical solutions mostly adopt static task allocation strategies or fixed thread pool modes. This rigid scheduling mechanism cannot adapt to the dynamic fluctuation characteristics of multi-channel video stream load in power monitoring scenarios. When the complexity of the video stream changes abruptly or the number of access channels changes, the static scheduling strategy struggles to achieve dynamic migration and reallocation of tasks among heterogeneous computing resources, easily leading to uneven resource utilization and unstable response latency. The lack of adaptive scheduling mechanisms prevents edge devices from achieving a balance between low latency, high throughput, and low energy consumption when facing complex and ever-changing power inspection tasks, thus hindering the progress of intelligent upgrades to power monitoring systems.
[0005] Therefore, this invention proposes a YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring to address the shortcomings of existing technologies. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this invention provides a YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring. This method solves the problems of data processing flow blockage, low efficiency of CPU and GPU collaboration, and excessive end-to-end latency caused by the use of serial or simple parallel processing architectures in existing edge deployment schemes. It also solves the problems that static resource scheduling mechanisms cannot adapt to the dynamic fluctuations of load in multiple video streams in power monitoring scenarios, the difficulty in achieving automatic task migration and load balancing between heterogeneous resources, and the insufficient utilization of GPU resources under multi-channel concurrent conditions.
[0007] To achieve the above objectives, the present invention provides the following technical solution: This invention provides a YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring, comprising the following steps: S1. Construct a heterogeneous parallel processing architecture based on edge computing devices. The heterogeneous parallel processing architecture includes a central processing unit and a graphics processing unit as heterogeneous computing nodes, and constructs a multi-level buffer queue including multiple first-level buffer queues and a shared inference task queue in the memory of the edge computing devices. S2. The video stream reading and decoding thread and the preprocessing thread are run by the central processing unit to convert the video stream data collected by the power monitoring camera into tensor data to be inferred and store it in the shared inference task queue. Multiple model inference threads in the inference resource pool are run by the graphics processor to obtain the tensor data to be inferred from the shared inference task queue and perform model inference calculation. S3. Quantify the processing capabilities of the heterogeneous computing nodes based on the resource capacity model, and collect the operating status data of the central processing unit and the graphics processing unit using a real-time performance monitoring and triggering mechanism. S4. When the running status data meets the preset triggering conditions, the H-PSO-based dynamic resource scheduling algorithm is started. The H-PSO-based dynamic resource scheduling algorithm searches for the globally optimal position containing the number of model inference threads, the capacity of the first-level buffer queue, and the capacity of the shared inference task queue through iterative search. S5. Based on the globally optimal position, perform task migration and load balancing operations, adjust the number of model inference threads in the inference resource pool, and reallocate the storage space size of the first-level buffer queue and the shared inference task queue.
[0008] Furthermore, in step S2, the video stream reading and decoding thread establishes a one-to-one binding relationship with the power monitoring camera. This one-to-one binding relationship ensures obstacle isolation and an independent data path. The video stream reading and decoding thread performs hardware decoding operations on the video stream data to generate raw frame images, and writes the raw frame images into the first-level buffer queue corresponding to the video stream reading and decoding thread.
[0009] The primary buffer queue is configured as a circular buffer structure and stores the original frame images according to the first-in-first-out principle. The circular buffer structure can smooth the difference between the video stream data input rate and the data processing rate.
[0010] Further, in step S2, the preprocessing thread retrieves the original frame image from the first-level buffer queue, performs an image transformation operation on the original frame image, and generates the tensor data to be inferred. The preprocessing thread performs a data encapsulation operation to construct a structure object containing the tensor data to be inferred, a channel identifier ID identifying the source of the original frame image, and timestamp information, and stores the structure object in the shared inference task queue.
[0011] The data encapsulation operation ensures that, during asynchronous processing, the source information and timing information of each frame of image remain associated with the image data.
[0012] Furthermore, in step S2, the model inference thread uses a preemptive strategy to obtain the structure object from the shared inference task queue and performs a dynamic batch processing operation, which can improve the parallel computing efficiency of the graphics processor.
[0013] The model inference thread calls the YOLOv8 object detection model to perform forward inference computation on the tensor data to be inferred, generates intermediate inference results, and writes the intermediate inference results into a shared result queue. The central processing unit runs a post-processing thread, reads the intermediate inference results from the shared result queue, performs non-maximum suppression operation, and distributes the final detection results according to the channel identifier ID, realizing pipelined parallelism of computation tasks between the central processing unit and the graphics processing unit.
[0014] Furthermore, in step S3, the resource capacity model determines the effective processing capacity of the heterogeneous computing node based on the basic capacity, efficiency factor, and load factor of the heterogeneous computing node. The effective processing capacity reflects the actual computing potential of the heterogeneous computing node in the current environment.
[0015] Based on the effective processing capacity and the amount of task data, the edge computing device uses a task processing time estimation function to predict the execution time of computing tasks on the heterogeneous computing nodes, providing a quantitative basis for subsequent scheduling decisions.
[0016] Further, in step S4, the H-PSO-based dynamic resource scheduling algorithm initializes a particle swarm containing multiple particles, each particle representing a resource allocation scheme. During iteration, the H-PSO-based dynamic resource scheduling algorithm updates the velocity vector of each particle based on inertia weight, individual learning factor, social learning factor, individual historical best position, and global best position of the population, and updates the position vector of the particle based on the updated velocity vector.
[0017] The position vector corresponds to the number of model inference threads, the capacity of the first-level buffer queue, and the capacity of the shared inference task queue, thereby searching for optimal resource configuration parameters in the multidimensional solution space.
[0018] Furthermore, in step S4, the H-PSO-based dynamic resource scheduling algorithm evaluates the fitness value of the particles using a multi-objective fitness function. This multi-objective fitness function comprehensively considers load balancing metrics, system average latency metrics, system reciprocal throughput metrics, and edge device energy consumption metrics to achieve a balance between performance and energy consumption.
[0019] The H-PSO-based dynamic resource scheduling algorithm uses an adaptive strategy to dynamically adjust the inertia weight. The adaptive strategy causes the inertia weight to decrease as the number of iterations increases, thereby maintaining global exploration capability in the early stage of the algorithm and improving local convergence accuracy in the later stage of the algorithm.
[0020] Further, in step S4, the H-PSO-based dynamic resource scheduling algorithm executes a particle hybridization and offspring evolution mechanism after completing the position vector update. This mechanism selects two parent particles from the particle swarm to perform a position crossover operation, generating offspring particles, and calculates the fitness value of the offspring particles.
[0021] When the fitness value of the offspring particle is better than that of the parent particle, the parent particle is replaced by the offspring particle. The particle hybridization and offspring evolution mechanism can effectively prevent the algorithm from getting stuck in a local optimum.
[0022] Furthermore, in step S3, the real-time performance monitoring and triggering mechanism uses hardware counters and operating system interfaces to collect load data and task processing time data, and calculates resource utilization indicators, average latency indicators, and load imbalance values.
[0023] In step S4, the preset triggering conditions include the load imbalance value exceeding the load imbalance threshold, the average latency index exceeding the latency alarm threshold, or the resource utilization index being lower than the minimum utilization threshold. The preset triggering conditions ensure that rescheduling is triggered only when the system operating state deviates from the expected range, thereby reducing system overhead.
[0024] Further, in step S5, the edge computing device performs a state locking operation during the task migration and load balancing operation, temporarily suspending the write and read permissions of the shared inference task queue. This state locking operation prevents data contention or loss during resource reconfiguration. The edge computing device compares the number of target model inference threads in the globally optimal location with the number of currently active model inference threads. When the number of target model inference threads exceeds the number of currently active model inference threads, a thread expansion operation is performed to create new model inference threads. When the number of target model inference threads is less than the number of currently active model inference threads, a thread shrinking operation is performed to destroy the specified model inference threads, thereby achieving elastic scaling of computing resources.
[0025] This invention provides a YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring. It offers the following advantages: 1. This invention constructs a heterogeneous parallel processing architecture, utilizing multi-level buffer queues to completely decouple the video stream reading, preprocessing, and model inference processes, achieving pipelined parallel computing through collaborative work between the central processing unit and the graphics processing unit. This heterogeneous parallel processing architecture eliminates the waiting and computational blocking phenomena in traditional serial processing architectures, reducing end-to-end system latency while ensuring data integrity, and improving the system throughput of edge devices in scenarios with multiple concurrent video streams.
[0026] 2. This invention introduces a dynamic resource scheduling algorithm based on H-PSO, which, combined with a resource capacity model and a real-time performance monitoring mechanism, can dynamically find the globally optimal position for the number of model inference threads and the buffer queue capacity based on load fluctuations. The H-PSO-based dynamic resource scheduling algorithm solves the load imbalance problem between heterogeneous computing nodes through a multi-objective optimization strategy, realizing the allocation of tasks between the central processing unit and the graphics processing unit, and improving the resource utilization of the graphics processing unit and the overall system energy efficiency.
[0027] 3. This invention employs a shared inference task queue and a dynamic batch processing mechanism, combined with state locking operations and thread scaling strategies, to achieve refined management and elastic scheduling of edge computing resources. This resource management mechanism supports real-time access to large-scale video streams while reducing system memory consumption, ensuring the operational stability of the power monitoring system under complex conditions, and meeting the high real-time and high reliability requirements of intelligent power equipment inspection. Attached Figure Description
[0028] Figure 1 This is a flowchart of the method of the present invention; Figure 2 This is a flowchart of the dynamic resource scheduling algorithm based on H-PSO of the present invention. Detailed Implementation
[0029] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0030] See attached document Figure 1 This invention provides a YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring, comprising the following steps: S1. Construct a heterogeneous parallel processing architecture based on edge computing devices. The heterogeneous parallel processing architecture includes a central processing unit and a graphics processing unit as heterogeneous computing nodes, and constructs a multi-level buffer queue including multiple first-level buffer queues and a shared inference task queue in the memory of the edge computing devices. S2. The video stream reading and decoding thread and the preprocessing thread are run by the central processing unit to convert the video stream data collected by the power monitoring camera into tensor data to be inferred and store it in the shared inference task queue. Multiple model inference threads in the inference resource pool are run by the graphics processor to obtain tensor data to be inferred from the shared inference task queue and perform model inference calculation. S3. Quantify the processing capabilities of heterogeneous computing nodes based on the resource capacity model, and collect the operating status data of the central processing unit and graphics processing unit using real-time performance monitoring and triggering mechanisms. S4. When the running status data meets the preset triggering conditions, the H-PSO-based dynamic resource scheduling algorithm is started. The H-PSO-based dynamic resource scheduling algorithm searches for the globally optimal position that includes the number of model inference threads, the capacity of the first-level buffer queue, and the capacity of the shared inference task queue through iterative search. S5. Perform task migration and load balancing operations based on the globally optimal location, adjust the number of model inference threads in the inference resource pool, and reallocate the storage space size of the primary buffer queue and the shared inference task queue.
[0031] The edge computing system of this invention operates on an edge computing device containing heterogeneous computing resources. The edge computing device includes a central processing unit (CPU) and a graphics processing unit (GPU) as heterogeneous computing nodes. The CPU and GPU are connected via a high-speed bus for data exchange. The edge computing device also includes a memory for storing instructions, image data, and a buffer queue.
[0032] Edge computing devices connect to multiple power monitoring cameras via network interfaces. These cameras are used to acquire real-time monitoring video streams of power equipment. They are deployed at key monitoring points in substations or transmission lines. The edge computing devices operate on a multi-threaded heterogeneous parallel processing architecture. This architecture is logically divided into a data input stage, a data preprocessing stage, a model inference stage, and a post-processing stage. The central processing unit (CPU) is responsible for executing the computational tasks in the data input, preprocessing, and post-processing stages. The graphics processing unit (GPU) is responsible for executing the computational tasks in the model inference stage.
[0033] In the operating environment of edge computing devices, to achieve precise scheduling of heterogeneous computing resources, this invention abstracts the central processing unit (CPU) and graphics processing unit (GPU) as heterogeneous computing nodes and establishes a resource capacity model. The resource capacity model is used to quantify the processing capacity of heterogeneous computing nodes at a specific time.
[0034] Based on the resource capacity model, edge computing devices use a task processing time estimation function to calculate the expected time for a specific task on a specific resource. The task processing time estimation function is expressed as: ; In the above formula, Indicates the first The computational task in the th ... Processing time on heterogeneous computing nodes; Indicates the first The task size of each computation task is determined by the image resolution and the data batch size. Indicates the first Processing rate of heterogeneous computing nodes, processing rate and processing capacity Positive correlation; Indicates the first The computational task in the th ... The overhead on heterogeneous computing nodes includes data transmission latency and context switching time.
[0035] Edge computing devices allocate independent storage space in memory to construct multi-level buffer queues. These multi-level buffer queues include multiple primary buffer queues corresponding to multiple power monitoring cameras, and a shared inference task queue connecting the data preprocessing stage and the model inference stage. The multiple primary buffer queues isolate the video stream inputs from different power monitoring cameras. The shared inference task queue aggregates the preprocessed image data. The shared inference task queue manages the image data using a first-in, first-out (FIFO) strategy. The edge computing device calculates its processing capacity by monitoring the stack length of the primary buffer queues and the shared inference task queue, combined with a resource capacity model. This provides status input for subsequent dynamic resource scheduling.
[0036] See attached document Figure 1 The system software architecture of this invention is based on a multi-stage decoupled parallel processing pipeline constructed using heterogeneous computing resources. The parallel processing pipeline logically and strictly divides the deep learning object detection task into a data input stage, a data preprocessing stage, a model inference stage, and a post-processing stage. These stages are connected via a first-in, first-out (FIFO) buffer queue.
[0037] During the data input phase, the edge computing device utilizes its central processing unit (CPU) to allocate an independent video stream reading and decoding thread to each connected power monitoring camera. The video stream reading and decoding thread continuously acquires real-time video stream data from the corresponding power monitoring camera. It then performs hardware decoding on the real-time video stream data to generate raw frame images. Finally, the video stream reading and decoding thread stores the generated raw frame images into a primary buffer queue corresponding to each power monitoring camera. This primary buffer queue is used to cache the raw frame images generated during the data input phase, preventing data loss due to network fluctuations.
[0038] During the data preprocessing stage, the edge computing device utilizes the CPU to run multiple preprocessing threads. The preprocessing threads retrieve raw frame images from the primary buffer queue. They perform resizing, color space conversion, and pixel normalization on the raw frame images, generating tensor data to be inferred that conforms to the YOLOv8 model input standard. The preprocessing threads then store the tensor data to be inferred, along with the source channel identifier and timestamp information of the raw frame images, into a shared inference task queue. This shared inference task queue, serving as the sole data channel connecting the CPU and GPU, aggregates the data to be processed from all power monitoring cameras.
[0039] During the model inference phase, the edge computing device establishes an inference resource pool on the GPU containing multiple model inference threads. The model inference threads in the resource pool use a preemptive strategy to acquire tensor data to be inferred from a shared inference task queue. The model inference threads call the YOLOv8 object detection model to perform forward inference computation on the tensor data to be inferred. The forward inference computation outputs intermediate inference results containing object category indices, confidence scores, and bounding box regression coordinates. The model inference threads write the intermediate inference results to a shared results queue.
[0040] In the post-processing stage, the edge computing device utilizes the central processing unit (CPU) to run a post-processing thread. The post-processing thread reads intermediate inference results from a shared result queue. It performs non-maximum suppression on these intermediate results, filtering out redundant detection boxes with overlap exceeding a preset threshold and retaining the optimal detection results. The post-processing thread also reads the source channel identifier associated with the intermediate inference results. Based on the source channel identifier, it distributes the optimal detection results to the corresponding display channel or alarm interface. This multi-stage decoupled parallel processing pipeline ensures that the data input stage, data preprocessing stage, model inference stage, and post-processing stage can operate independently and in parallel.
[0041] See attached document Figure 1 In the data input and preprocessing stages of this invention, the multi-core parallel computing capability of the central processing unit (CPU) is utilized to construct an independent channel access and unified data encapsulation process for multiple video streams. During system initialization, the edge computing device determines the data based on the total number of connected power monitoring cameras. ,create Each video stream read and decode thread is independent of the others. Each video stream read and decode thread is bound to a specific power monitoring camera. Each video stream read and decode thread is responsible for maintaining the network connection and data stream for only one specific power monitoring camera.
[0042] The video stream reading and decoding thread continuously receives compressed video streams from the attached power monitoring camera via RTSP or ONVIF protocols. The thread then invokes the CPU's hardware decoding instruction set to perform decoding operations on the compressed video stream. The decoding operation restores the compressed video stream to original frame images in RGB or YUV format. After decoding each frame, the thread immediately writes the original frame image to the corresponding first-level buffer queue. This first-level buffer queue is allocated as a circular buffer structure in physical memory. It strictly adheres to a first-in, first-out (FIFO) principle when storing the original frame images. The primary buffer queues are isolated from each other in the memory address space, ensuring that network latency or data congestion of any power monitoring camera will not affect the data paths of other power monitoring cameras.
[0043] During the data preprocessing stage, the edge computing device initiates multiple preprocessing threads. These threads retrieve raw frame images from a primary buffer queue. They then perform a series of image transformation operations on the raw frame images to adapt them to the input tensor requirements of the YOLOv8 object detection model. These image transformation operations include image resizing, pixel value normalization, and channel dimension rearrangement. The image resizing operation uses bilinear interpolation to adjust the resolution of the raw frame images to the input resolution specified by the model. Pixel value normalization maps the grayscale values of pixels to floating-point numbers between 0 and 1. Channel dimension rearrangement transforms the image data from a height, width, and channels (HWC) layout to a channel, height, and width (CHW) layout.
[0044] To ensure that the inference results processed by the GPU can be accurately traced back to the corresponding power monitoring cameras, the preprocessing thread performs a data encapsulation operation. This operation constructs a structure object containing metadata about the inference task. The structure object contains three key fields: the tensor data to be inferred generated after image transformation, the channel identifier ID identifying the source of the original frame image, and the timestamp recording the acquisition time of the original frame image. The preprocessing thread stores the completed structure object in a shared inference task queue. This shared inference task queue, as the sole convergence point connecting the data preprocessing stage and the subsequent model inference stage, shields the complexity caused by the varying number of front-end power monitoring cameras and provides a unified standard data input interface for subsequent heterogeneous resource pooling inference.
[0045] See attached document Figure 1 The multi-level buffer queue mechanism of this invention constructs a hierarchical data temporary storage and flow control structure in the memory space of the edge computing device. The multi-level buffer queue mechanism includes a structure located between the data input stage and the data preprocessing stage. The system consists of a primary buffer queue and a shared inference task queue located between the data preprocessing stage and the model inference stage. The multi-level buffer queue mechanism strictly follows the first-in-first-out (FIFO) principle to manage the timing of the data flow.
[0046] The primary buffer queue is configured as a circular buffer structure. Each primary buffer queue independently serves the video data stream from one power monitoring camera. The primary buffer queue is used to smooth the impact of network transmission jitter on subsequent processing. When the data generation rate of a specific power monitoring camera exceeds the processing rate of the corresponding preprocessing thread, the primary buffer queue is responsible for temporarily storing the backlog of raw frame images. To ensure real-time performance in power monitoring scenarios, the primary buffer queue is configured with a timestamp-based discarding policy. When the number of raw frame images stored in the primary buffer queue reaches the preset capacity limit, the video stream reading and decoding threads automatically overwrite the earliest stored raw frame image in the primary buffer queue. The discarding policy ensures that the data entering the subsequent processing flow is always the latest monitoring footage.
[0047] The shared inference task queue is configured as a thread-safe blocking queue. It aggregates struct objects generated by all preprocessing threads. This queue achieves complete decoupling between the CPU and GPU. Complete decoupling means that the CPU's data production process and the GPU's data consumption process do not block each other in time. After completing data encapsulation, the preprocessing thread pushes the struct object to the tail of the shared inference task queue. The GPU's model inference thread retrieves the struct object from the head of the queue.
[0048] The multi-level buffer queue mechanism supports dynamic capacity configuration. The capacity limits of the first-level buffer queue and the shared inference task queue are not fixed constants, but rather serve as control variables for system scheduling. Edge computing devices adjust the length parameters of the first-level buffer queue and the shared inference task queue in real time based on feedback from the heterogeneous particle swarm optimization algorithm. Increasing the capacity limit can improve system throughput and reduce data dropout, but it increases end-to-end processing latency. Decreasing the capacity limit can reduce processing latency, but it may lead to data loss under high load fluctuations. The multi-level buffer queue mechanism provides a physical basis for balancing system latency and throughput by offering adjustable buffer depth.
[0049] See attached document Figure 1 The dynamic resource pooling model inference stage of this invention constructs a scalable parallel computing environment on a graphics processing unit (GPU). The edge computing device loads the network weight parameters and computation graph structure of the YOLOv8 object detection model into the GPU's memory. The edge computing device initializes a set of model inference threads to form an inference resource pool. The model inference threads in the inference resource pool share the GPU's memory context and computation units. The number of active model inference threads in the inference resource pool is denoted as... .quantity It is not a fixed value, but rather a controlled variable that is dynamically adjusted according to the output instructions of the heterogeneous particle swarm optimization algorithm.
[0050] The model inference thread executes looping task processing logic during runtime. In each processing loop, the model inference thread accesses the shared inference task queue. The model inference thread attempts to retrieve struct objects to be processed from the shared inference task queue. To improve the parallel computing efficiency of the graphics processing unit (GPU), the model inference thread performs dynamic batch processing. When the amount of accumulated data in the shared inference task queue meets a preset condition, the model inference thread extracts multiple sets of struct objects from the shared inference task queue at once. The model inference thread then concatenates the tensor data to be inferred contained in the extracted multiple sets of struct objects along the batch processing dimension, combining them into a high-dimensional input tensor.
[0051] The model inference thread calls the YOLOv8 object detection model's inference engine to perform forward propagation computation on the high-dimensional input tensor. The forward propagation computation utilizes the CUDA cores or Tensor cores of the GPU to perform parallel matrix multiplication and convolution operations. The forward propagation computation generates an output tensor containing object detection information. The output tensor's data includes the detected object's position coordinates in the image coordinate system, the object's class probability distribution, and the object's confidence score.
[0052] After completing the forward propagation computation, the model inference thread logically decomposes the output tensor, restoring the batch processing results into single-frame inference results that correspond one-to-one with the original structure objects. The model inference thread then re-associates the single-frame inference results with the source channel identifier and timestamp carried in the structure object, ensuring data traceability. Subsequently, the model inference thread writes the associated result data to a shared result queue. This shared result queue serves as a buffer between the model inference and post-processing stages, aggregating the computational outputs from all model inference threads.
[0053] The inference resource pool changes the number of model inference threads in real time. This mechanism adapts to varying computational loads. When the system receives a scheduling instruction to increase resources, the edge computing device activates dormant standby threads or creates new model inference threads to join the inference resource pool, thereby increasing the concurrency of data retrieval from the shared inference task queue. When the system receives a scheduling instruction to decrease resources, the edge computing device suspends or destroys a specified number of model inference threads, thus freeing up the computing resources of the graphics processing unit (GPU). This dynamic resource pooling mechanism ensures that the GPU's computing power allocation precisely matches the current video stream input pressure.
[0054] See attached document Figure 1In the post-processing and result distribution stage of this invention, the central processing unit (CPU) parses and logically filters the raw detection data output from the model inference stage. An edge computing device runs one or more post-processing threads. These threads continuously monitor a shared result queue. The shared result queue stores single-frame inference results generated by the graphics processing unit (GPU). At this point, the single-frame inference results still exist in the form of an associated metadata structure.
[0055] The post-processing thread reads single-frame inference results from the shared result queue. First, it performs a confidence threshold filtering operation on the single-frame inference results. This operation removes candidate detection boxes with confidence scores below a preset safety threshold. After initial filtering, the post-processing thread performs non-maximum suppression (NMS) on the remaining candidate detection boxes. NMS calculates the intersection-over-union (IoU) ratio between different candidate detection boxes. When the IoU ratio of two candidate detection boxes exceeds a preset overlap threshold, NMS retains the candidate detection box with the higher confidence score and discards the one with the lower score. NMS eliminates redundant detection boxes targeting the same power equipment, ensuring the uniqueness of the final output.
[0056] After completing the above logical operations, the post-processing thread parses the source channel identifier carried in the structure object. The source channel identifier is written during the data preprocessing stage and remains unchanged after the model inference stage. Based on the source channel identifier, the post-processing thread maps the filtered final detection result back to the corresponding data path of the power monitoring camera. The final detection result includes the target category label, the target confidence score, and the target's coordinate position information in the image.
[0057] The post-processing thread distributes the final detection results to the output interface corresponding to the source channel identifier. The output interface performs a visualization rendering operation. The visualization rendering operation overlays the final detection results onto the original frame image as rectangles and text labels. For power equipment targets identified as having potential anomalies, the post-processing thread sends the anomaly information to the monitoring center's management platform by triggering an alarm signal. The completion of the post-processing and result distribution stages marks the end of the lifecycle of a single frame image data in the multi-stage decoupled parallel processing pipeline.
[0058] See attached document Figure 2 The H-PSO-based dynamic resource scheduling algorithm of this invention first establishes a heterogeneous resource modeling and quantification mechanism. This mechanism abstracts the CPU and GPU in edge computing devices into heterogeneous computing nodes with different computing characteristics. The edge computing device then uses a resource capacity model to evaluate the actual data processing capability of each heterogeneous computing node at a specific time.
[0059] The resource capacity model is defined by the following formula: ; In the above formula, Indicates the first The effective processing capacity of a heterogeneous computing node. Effective processing capacity reflects the number of floating-point operations or logical operations that a heterogeneous computing node can complete per unit of time. Indicates the first The base capacity of a heterogeneous computing node. The base capacity is a static theoretical peak determined by the hardware specifications of the heterogeneous computing node. For a central processing unit (CPU), the base capacity depends on the number of physical cores and the clock speed; for a graphics processing unit (GPU), the base capacity depends on the number of stream processors and the memory bandwidth. Indicates the first The efficiency factor of a heterogeneous computing node. The efficiency factor is a dimensionless coefficient between 0 and 1, used to characterize the current instruction pipeline execution efficiency and the impact of cache hit rate on performance. Indicates the first The load factor of each heterogeneous computing node. The load factor is used to dynamically reflect the resource consumption of the heterogeneous computing nodes by background processes and other tasks in the system at the current moment.
[0060] Based on the resource capacity model, edge computing devices utilize a task processing time estimation function to predict the execution time of a specific computing task on a specific heterogeneous computing node. The task processing time estimation function is defined as follows: ; In the above formula, Indicates the first The computational task in the th ... Estimated processing time on each heterogeneous computing node. Indicates the first The size of the data for each computational task. In object detection scenarios, the size of the data is typically determined by the resolution of the input image, the number of color channels, and the batch size. Indicates the first The actual processing rate of each heterogeneous computing node. The actual processing rate is compared to the effective processing capacity calculated in the aforementioned formula. They show a positive correlation and are calibrated using benchmark test data. Indicates the first The computing task was scheduled to the first The additional overhead time incurred by heterogeneous computing nodes includes PCIe bus transfer latency for transferring image data from system memory to video memory, thread context switching latency, and kernel startup latency. The heterogeneous resource modeling and quantization mechanism provides a precise mathematical basis for subsequent particle swarm optimization scheduling.
[0061] See attached document Figure 2 The core process of the H-PSO algorithm of this invention is executed at the control layer of the edge computing device, aiming to find the globally optimal resource configuration parameters through iterative search. The resource configuration parameters are mapped to particle position vectors in the algorithm. Each particle position vector corresponds to the number of control variables to be optimized, including the number of model threads on the GPU, the upper limit of the first-level buffer queue, and the upper limit of the shared inference task queue.
[0062] The edge computing device first initializes the particle swarm. The particle swarm contains multiple particles. Each particle... The state at each iteration is described by both the position vector and the velocity vector. During each iteration, the edge computing device calculates the particle's velocity at the next moment according to the following velocity update formula: ; In the above formula, Indicates the first The particle in the first The speed of each iteration. This represents the inertial weight, which is used to adjust the degree to which a particle maintains its previous velocity. Indicates the first The particle in the first The speed of each iteration. This represents the individual learning factor, which controls the step size by which a particle moves toward its historical best position. This represents the first random number, which follows a uniform distribution between 0 and 1. Indicates the first The particle reached the [number]th [number]. The individual's historical best position experienced in each iteration. Indicates the first The particle in the first The position of the next iteration. This represents the social learning factor, which is used to control the step size by which particles move toward the global optimal position of the population. This represents the second random number, which follows a uniform distribution between 0 and 1. This indicates that the entire particle swarm has reached the [number]th [stage / phase]. The globally optimal position found in the next iteration.
[0063] Based on the calculated new velocity, the edge computing device calculates the particle's position in the next moment according to the following position update formula: ; In the above formula, Indicates the first The particle in the first The position of the next iteration. After rounding and boundary constraint processing, it directly corresponds to the actual resource configuration parameters of the system in the next moment; Indicates the first The particle in the first The current position at the next iteration; Indicates the first The particle in the first Speed during the next iteration.
[0064] To balance the global search capability and local exploitation capability of the H-PSO algorithm, edge computing devices employ an adaptive strategy to dynamically adjust inertia weights. Inertia weight The variation with the number of iterations is defined by the following formula: ; In the above formula, This represents the maximum value of the inertia weight, which is usually set to 0.9. This represents the minimum value of the inertia weight, which is usually set to 0.4. This indicates the current iteration number. This indicates the maximum number of iterations preset by the algorithm. The adaptive strategy ensures that the algorithm has high performance in the early stages of iteration. To explore the solution space, and to have a smaller solution space in the later stages of iteration. The optimal solution is found through a meticulous search.
[0065] Edge computing devices utilize a multi-objective fitness function to evaluate the merits of the resource allocation scheme represented by each particle. The multi-objective fitness function comprehensively considers load balancing, system latency, system throughput, and device energy consumption. The multi-objective fitness function is defined as follows: ; In the above formula, This represents the fitness value of a particle; a smaller fitness value indicates a better resource allocation scheme. This represents the load balancing index after normalization. This represents the normalized average system latency metric. This represents the normalized reciprocal of the system throughput metric. This represents the normalized energy consumption index of edge devices. , , and These represent the load balancing weighting coefficient, latency weighting coefficient, throughput weighting coefficient, and energy consumption weighting coefficient, respectively. The sum of these four weighting coefficients equals 1. In power monitoring scenarios, edge computing devices are typically configured with relatively large weighting coefficients. The algorithm prioritizes low-latency performance. The H-PSO algorithm iteratively updates the particle state until the maximum number of iterations is reached. The final output makes the fitness value The smallest globally optimal position is used as the optimal resource scheduling strategy.
[0066] The particle hybridization and offspring evolution mechanism of this invention is embedded in the iterative loop of the heterogeneous particle swarm optimization algorithm, aiming to solve the technical defect of the standard particle swarm optimization algorithm that is prone to getting trapped in local optima when searching in multidimensional discrete space. After completing the particle velocity update and position update operations in each round, the edge computing device executes the particle hybridization and offspring evolution mechanism.
[0067] The particle hybridization and offspring evolution mechanism first performs a particle pairing selection operation. Edge computing devices select particles based on their fitness values. The particle swarm is sorted based on its quality. The edge computing device randomly selects two different particles from the sorted swarm as parent particle A and parent particle B. Parent particle A and parent particle B each have independent position vectors. The position vector represents two different resource scheduling schemes at the current moment.
[0068] Subsequently, the edge computing device performs a position crossover operation on parent particle A and parent particle B to generate a child particle. This position crossover operation simulates the gene recombination process in biological evolution. The edge computing device performs a linear combination calculation on the position components of each dimension of parent particle A and the corresponding position components of parent particle B. This linear combination calculation generates a new position vector, which is then assigned to the child particle. The child particle's position vector represents a novel resource scheduling scheme that integrates features from both parents. For example, the child particle might inherit the GPU model thread count configuration from parent particle A, while simultaneously inheriting the buffer queue capacity configuration from parent particle B.
[0069] After generating offspring particles, the edge computing device uses the aforementioned multi-objective fitness function to calculate the fitness value of the offspring particles. Edge computing devices employ a greedy selection strategy to perform offspring competition and population update operations. The edge computing device will assign fitness values to offspring particles... Fitness value of parent particle A and the fitness value of parent particle B Compare them. If the fitness value of the offspring particles... A fitness value that is better than (i.e., less than) that of parent particle A or parent particle B Edge computing devices will use offspring particles to directly replace the parent particle with the poorest fitness value.
[0070] The particle hybridization and offspring evolution mechanism artificially increases the diversity of the particle swarm by introducing random crossover and survival-of-the-fittest logic. When all particles tend to converge towards the same local extremum, the hybridization operation can generate new particles located in different regions of the solution space, thus giving the algorithm the ability to escape local optima. This mechanism ensures that edge computing devices can continuously search for better resource allocation parameters when facing complex power monitoring load fluctuations, rather than remaining in a suboptimal configuration state.
[0071] The real-time performance monitoring and triggering mechanism of this invention is embedded in the system kernel or daemon process of the edge computing device. This mechanism samples the system's operating status periodically. The edge computing device utilizes hardware counters and operating system interfaces to collect real-time load data and task processing time data of the CPU and GPU.
[0072] To quantify the current efficiency of heterogeneous resource utilization, edge computing devices use collected data to calculate resource utilization rate. The calculation of resource utilization rate follows the formula: ; In the above formula, This indicates the current overall resource utilization rate of the system. Indicates the first The active working time of each computing node within the sampling period. Active working time refers to the actual time that the computing node spends executing instructions, excluding idle waiting time. Indicates the first The total running time of each computing node within the sampling period. This indicates a summation operation performed on all monitored heterogeneous computing nodes within the system.
[0073] To evaluate the real-time performance of the system processing video streams, edge computing devices calculate an average latency metric. The average latency metric reflects the end-to-end time it takes for data to travel from input to the completion of inference. The average latency metric is calculated using the following formula: ; In the above formula, This represents the average delay within the current sampling period. Indicates the first End-to-end processing latency of a frame image. End-to-end processing latency is defined as the latency from the first frame... The time difference between when a frame image is decoded and when the corresponding inference result is output. This indicates the total number of image frames processed within the current sampling period.
[0074] Edge computing devices construct a logical trigger mechanism based on calculated performance metrics. This mechanism determines whether to initiate the H-PSO algorithm for resource reallocation. The output of the logical trigger mechanism is determined by the following formula: ; In the above formula, This indicates that an output signal has been triggered. When... When the logical value is true, the edge computing device activates the H-PSO dynamic resource scheduling algorithm; when When the logical value is false, the system maintains the current resource configuration. This represents the current load imbalance value, which is obtained by calculating the standard deviation of the load factors between different computing nodes. This indicates the preset load imbalance threshold. Represents the logical OR operator. This represents the current real-time latency value of the system, which is taken from the average latency calculated by the aforementioned formula. . This indicates the preset delay alarm threshold, which is set according to the real-time requirements of power monitoring services. This represents the current real-time utilization rate of the system, which is derived from the resource utilization rate calculated using the aforementioned formula. . This represents the preset minimum utilization threshold. The triggering mechanism ensures that scheduling optimization is only performed when the system experiences load imbalance, latency violations, or resource idleness, avoiding the performance overhead caused by frequent scheduling.
[0075] See attached document Figure 2 In this invention, the task migration and load balancing execution phase occurs after the H-PSO algorithm outputs the globally optimal position. The edge computing device uses the control parameters contained in the globally optimal position to reconstruct the underlying system resources. The globally optimal position is a multi-dimensional vector containing the number of model inference threads on the GPU side, the capacity of the first-level buffer queue, and the capacity of the shared inference task queue. The task migration and load balancing execution phase aims to transform this multi-dimensional vector into a physical-level resource allocation state.
[0076] The edge computing device first performs a state locking operation. This operation temporarily suspends write and read permissions for the shared inference task queue. State locking ensures data consistency during resource reconfiguration and prevents memory address conflicts caused by concurrent reads and writes. After completing the state locking operation, the edge computing device reads the number of target model inference threads at the globally optimal location.
[0077] The edge computing device compares the number of target model inference threads with the number of currently running active model inference threads. When the number of target model inference threads exceeds the number of active model inference threads, the edge computing device performs a thread expansion operation. This operation calls the Compute Unified Device Architecture (CUDA) interface of the graphics processing unit (GPU) to create a new number of model inference threads equal to the number of target model inference threads minus the number of active model inference threads. The new model inference threads load the YOLOv8 model weights and are registered to the inference resource pool.
[0078] When the number of target model inference threads is less than the number of active model inference threads, the edge computing device performs a thread shrinking operation. This operation sends termination signals to a specified number of model inference threads (the number of active model inference threads minus the target number of model inference threads). After completing the computation of the tensor data to be inferred, each specified model inference thread releases its memory context and exits execution. Thread expansion and shrinking operations directly alter the data throughput during the model inference phase.
[0079] Subsequently, the edge computing device adjusts memory allocation based on the queue capacity parameters at the globally optimal location. The edge computing device utilizes a dynamic memory management mechanism to reallocate the storage space size of the primary buffer queue and the shared inference task queue. After completing all parameter adjustments, the edge computing device unlocks the shared inference task queue.
[0080] Through the steps described above, edge computing devices achieve dynamic matching between task processing speed and heterogeneous computing resource capabilities. This dynamic matching directly optimizes the multi-objective fitness function. Specifically, adjusting the number of model inference threads changes the load factor of the graphics processing unit (GPU), and adjusting the buffer queue capacity changes the waiting time of tasks in the queue. By periodically executing this process, edge computing devices ensure that the load balance between the central processing unit (CPU) and the graphics processing unit (GPU) remains within the optimal range even when the power monitoring video stream load fluctuates, thereby avoiding system crashes or data backlogs caused by single-point resource bottlenecks.
Claims
1. A YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring, characterized in that, Includes the following steps: S1. Construct a heterogeneous parallel processing architecture based on edge computing devices. The heterogeneous parallel processing architecture includes a central processing unit and a graphics processing unit as heterogeneous computing nodes, and constructs a multi-level buffer queue including multiple first-level buffer queues and a shared inference task queue in the memory of the edge computing devices. S2. The video stream reading and decoding thread and the preprocessing thread are run by the central processing unit to convert the video stream data collected by the power monitoring camera into tensor data to be inferred and store it in the shared inference task queue. Multiple model inference threads in the inference resource pool are run by the graphics processor to obtain the tensor data to be inferred from the shared inference task queue and perform model inference calculation. S3. Quantify the processing capabilities of the heterogeneous computing nodes based on the resource capacity model, and collect the operating status data of the central processing unit and the graphics processing unit using a real-time performance monitoring and triggering mechanism. S4. When the running status data meets the preset triggering conditions, the H-PSO-based dynamic resource scheduling algorithm is started. The H-PSO-based dynamic resource scheduling algorithm searches for the globally optimal position containing the number of model inference threads, the capacity of the first-level buffer queue, and the capacity of the shared inference task queue through iterative search. S5. Based on the globally optimal position, perform task migration and load balancing operations, adjust the number of model inference threads in the inference resource pool, and reallocate the storage space size of the first-level buffer queue and the shared inference task queue.
2. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 1, characterized in that, In step S2, the video stream reading and decoding thread establishes a one-to-one binding relationship with the power monitoring camera; The video stream reading and decoding thread performs hardware decoding operations on the video stream data to generate raw frame images, and writes the raw frame images into the first-level buffer queue corresponding to the video stream reading and decoding thread; The primary buffer queue is configured as a circular buffer structure and stores the original frame images according to the first-in-first-out principle.
3. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 2, characterized in that, In step S2, the preprocessing thread retrieves the original frame image from the first-level buffer queue, performs image transformation operations on the original frame image, and generates the tensor data to be inferred. The preprocessing thread performs a data encapsulation operation, constructs a structure object containing the tensor data to be inferred, a channel identifier ID identifying the source of the original frame image, and timestamp information, and stores the structure object in the shared inference task queue.
4. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 3, characterized in that, In step S2, the model inference thread uses a preemptive strategy to obtain the structure object from the shared inference task queue and performs dynamic batch processing. The model inference thread calls the YOLOv8 object detection model to perform forward inference calculations on the tensor data to be inferred, generates intermediate inference results, and writes the intermediate inference results into the shared result queue. The central processing unit runs a post-processing thread, reads the inference intermediate results from the shared result queue, performs non-maximum suppression operation, and distributes the final detection results according to the channel identifier ID.
5. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 1, characterized in that, In step S3, the resource capacity model determines the effective processing capacity of the heterogeneous computing node based on the basic capacity, efficiency factor, and load factor of the heterogeneous computing node. The edge computing device predicts the execution time of computing tasks on the heterogeneous computing nodes based on the effective processing capacity and the amount of task data using a task processing time estimation function.
6. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 1, characterized in that, In step S4, the H-PSO-based dynamic resource scheduling algorithm initializes a particle swarm containing multiple particles, each of which represents a resource allocation scheme. During the iteration process, the dynamic resource scheduling algorithm based on H-PSO updates the velocity vector of the particle according to the inertia weight, individual learning factor, social learning factor, individual historical best position and population global best position, and updates the position vector of the particle according to the updated velocity vector. The position vector corresponds to the number of model inference threads, the capacity of the first-level buffer queue, and the capacity of the shared inference task queue.
7. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 6, characterized in that, In step S4, the H-PSO-based dynamic resource scheduling algorithm uses a multi-objective fitness function to evaluate the fitness value of the particle. The multi-objective fitness function comprehensively considers load balancing index, system average latency index, system reciprocal throughput index, and edge device energy consumption index. The H-PSO-based dynamic resource scheduling algorithm uses an adaptive strategy to dynamically adjust the inertia weight, which causes the inertia weight to decrease as the number of iterations increases.
8. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 7, characterized in that, In step S4, the H-PSO-based dynamic resource scheduling algorithm executes a particle hybridization and offspring evolution mechanism after completing the position vector update. The particle hybridization and offspring evolution mechanism selects two parent particles from the particle swarm to perform a positional crossover operation, generates offspring particles, and calculates the fitness value of the offspring particles. When the fitness value of the offspring particle is better than that of the parent particle, the offspring particle replaces the parent particle.
9. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 1, characterized in that, In step S3, the real-time performance monitoring and triggering mechanism uses hardware counters and operating system interfaces to collect load data and task processing time data, and calculates resource utilization index, average latency index and load imbalance value. In step S4, the preset triggering conditions include the load imbalance value exceeding the load imbalance threshold, the average latency index exceeding the latency alarm threshold, or the resource utilization index being lower than the minimum utilization threshold.
10. The YOLOv8 edge deployment and multi-threaded collaborative optimization method for power monitoring according to claim 1, characterized in that, In step S5, the edge computing device performs a state locking operation when performing the task migration and load balancing operation, temporarily suspending the write and read permissions of the shared inference task queue. The edge computing device compares the number of target model inference threads in the globally optimal location with the number of currently active model inference threads. When the number of target model inference threads exceeds the number of currently active model inference threads, a thread expansion operation is performed to create new model inference threads. When the number of target model inference threads is less than the number of currently active model inference threads, a thread shrinking operation is performed to destroy the specified model inference threads.