Small target multi-stage detection programming method based on cluster computing system
By using the task allocation and scheduling mechanism under the Manager-Worker model, the complexity of programming for multi-stage detection of small targets in a cluster computing system is solved, achieving the effects of simplifying programming and improving efficiency.
Patent Information
- Application Number
- CN202211481152.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-24
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-11-24
AI Technical Summary
In a cluster computing system, programming for multi-stage detection of small targets is complex and difficult. In particular, the parallel computing aspects such as data segmentation, task allocation and scheduling in a multi-node environment make it very difficult for developers in the field of target detection to write correct and efficient programs.
The cluster computing system adopts the Manager-Worker pattern, where the Manager is responsible for task allocation and scheduling, and the Worker is responsible for task execution. By splitting data, allocating ROI and small target detection tasks, and introducing task scheduling, fault tolerance mechanism and node detection mechanism, the programming process is simplified.
While ensuring system scalability, fault tolerance, and efficiency, the programming process for multi-stage detection of small targets has been simplified, improving programming efficiency and accuracy.
Smart Images

Figure CN115830433B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of small target multi-stage detection, parallel programming model and cluster system, in particular to a small target multi-stage detection programming method based on cluster computing system. BACKGROUND
[0002] Target detection is one of the core problems of computer vision, and the main task is to predict the category and location of objects in image or video data. Small target detection in video data, as an important part of target detection, is widely used in marine rescue, forest fire alarm, safety production, unmanned aerial vehicle search and other scenes. Due to the small size, few features and difficult to identify of small targets, small target detection is still a difficult problem to be solved. Existing solutions can be divided into two categories: one is to optimize the small target detection model according to the data or scene; the other is to use a multi-stage detection method, which first applies a model to detect the object on which the small target depends (ROI detection stage), and then uses a high-precision model to detect the small target (small target detection stage). The former belongs to single-stage model optimization, and there is still a contradiction between precision and speed: high-precision models run slowly and take a long time to detect; lightweight models are prone to misidentification and have low detection accuracy. The latter has attracted widespread attention from scholars due to its strong universality, detection effect not dependent on the dataset, etc.
[0003] Multi-stage detection method can greatly reduce the search range of the target in the video frame and exclude potential recognition interference; it can also effectively reduce the amount of data input to the high-precision model and reduce the overall running time of the model, so it can effectively improve the accuracy and speed of target detection. At present, the multi-stage detection method of small targets has been widely applied, and is very common in car plate detection, industrial meter reading detection, and pedestrian face detection scenes. The programming of small target multi-stage detection method in a multi-node cluster environment is complex, and it is necessary to distribute video data to multiple computing nodes for processing, which involves data cutting and integration, task allocation and scheduling, error detection and recovery, and many other parallel computing contents, making it very difficult for developers in the field of target detection to write correct and efficient programs. Since the small target multi-stage detection process has universality, only the model needs to be changed in different application scenarios, so it is of great significance to encapsulate the complex parallel computing process and realize a small target multi-stage detection programming model and system for simplifying programming. SUMMARY
[0004] In view of the problem that small target multi-stage detection programming is complex and difficult under the cluster computing system, the present application provides a small target multi-stage detection programming model and system based on cluster computing system, which can achieve the purpose of simplifying programming while ensuring the scalability, fault tolerance and efficiency of the system.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] A programming method for multi-stage detection of small targets based on a cluster computing system is disclosed, employing the master-slave Manager-Worker model within the cluster computing system. The Manager is the master node, responsible for task allocation and scheduling; the Worker is the worker node, responsible for task execution. The programming method for multi-stage detection of small targets based on a cluster computing system includes the following steps:
[0007] Step S1: The Manager cuts the input data, encapsulates it into several ROI detection tasks, and assigns them to idle Workers for ROI target detection;
[0008] Step S2: The Worker executes the ROI detection task assigned by the Manager to generate an ROI screenshot, which is then packaged into a small target detection task and saved to a temporary directory specified by the system.
[0009] Step S3: The Manager assigns the small target detection task to an idle Worker;
[0010] Step S4: The Worker executes the small target detection task assigned by the Manager and generates small target detection results;
[0011] Step S5: The Manager sorts and reorganizes the small target detection results, and saves the final detection results to the disk path specified by the user.
[0012] Preferably, in step S1, the Manager determines the type of the input data: if it is a video data type, the FFmpeg tool is used to cut the video data into equal segments; if it is an image set, the image set is evenly distributed into several different folders; otherwise, the system throws an exception and stops running; after the Manager completes the segmentation of the input data, it encapsulates it into ROI detection tasks and records the ID of each ROI detection task and the path of the corresponding data.
[0013] Preferably, in step S2, the Worker labels the ROI detection screenshot with the following format: "Frame number - ROI number - ROI top left corner x-axis coordinate - ROI top left corner y-axis coordinate - ROI width - ROI height".
[0014] Preferably, in the steps S1 and S3, the Manager allocates and schedules the ROI detection task or the small target detection task according to a task scheduling algorithm, specifically: when all tasks have not been completed, the Manager traverses each available Worker, checks the running state of the Worker; if the Worker is idle, the Worker is allocated a new task; if the Worker is busy, the Worker is not allocated a new task, i.e. no operation is performed.
[0015] Preferably, the steps S1, S2 and S3 further comprise a phase transition algorithm, comprising the following steps:
[0016] S51: initializing the worker_stage attribute value of each Worker as ROI_STAGE, indicating that the ROI detection task needs to be processed when the multi-stage detection process starts;
[0017] S52: the Manager starts a new thread listenStage to listen to the worker_stage change of each Worker;
[0018] S53: the Manager directly modifies the worker_stage attribute of the Worker as TARGET_STAGE if the Manager finds that the ROI phase has an empty task queue and the Worker is idle;
[0019] S54: the listenStage starts the small target detection process to allocate the existing small target detection task as soon as the listenStage finds that the worker_stage of the Worker changes.
[0020] Preferably, the small target multi-stage detection programming method based on the cluster computing system further comprises an execution node detection mechanism, comprising the following steps:
[0021] S61: all Workers periodically send heartbeat data to the Manager at an interval of interval, and the heartbeat data comprises the running state of the Worker, the work execution state of the Worker and the sending data time information;
[0022] S62: the Manager receives the heartbeat data, performs timeout judgment on each Worker: if the Manager finds that a Worker is in timeout, the step S63 is performed; otherwise, the step S61 is performed;
[0023] S63: Manager sends three status requests to the timeout worker at the frequency of interval, once the manager gets the status data from the worker within the specified time, the system continues to run normally; if the manager does not receive a response during the three requests, it is determined that the worker cannot continue to work, at this time the manager will update the available worker list of the current system and reassign the tasks that the worker has not completed.
[0024] Preferably, the small target multi-stage detection programming method based on the cluster computing system further comprises a task fault tolerance mechanism, including the following steps:
[0025] S71: Manager extracts the first task in the task queue, assigns the task to the worker with normal running state and idle according to the latest worker detection result, and saves the task assignment in the worker array;
[0026] S72: After each idle worker receives the task information assigned by the manager, it obtains the related data from the file system and executes the ROI detection task or the small target detection task;
[0027] S73: Manager regularly scans the task execution of each worker in the worker array to detect whether the task is timed out or executed incorrectly;
[0028] S74: If the worker actively sends a data processing exception message to the manager or the manager finds that the status information of a worker is timed out, the manager will modify the status identifier of the corresponding worker in the worker array, and will not assign tasks to it in the future, and execute step S77;
[0029] S75: After the worker completes the task, it puts the processed data into the specified storage directory;
[0030] S76: The worker notifies the manager that the executed task has been completed, and the manager modifies the related information of the corresponding worker in the worker array after receiving the message;
[0031] S77: Manager obtains the failed task from the worker array and adds it to the tail of the task queue.
[0032] Preferably, in step S2, the Worker calls the ROIDetection function specified by the developer to perform the ROI detection task assigned by the Manager.
[0033] Preferably, in step S4, the Worker calls the TargetDetection function specified by the developer to perform the small target detection task assigned by the Manager.
[0034] The small target multi-stage detection programming method based on the cluster computing system according to the present application solves the problem of complex and difficult small target multi-stage detection programming under the cluster computing system, and can achieve the purpose of simplifying programming under the premise of ensuring the scalability, fault tolerance and high efficiency of the system. BRIEF DESCRIPTION OF DRAWINGS
[0035] Figure 1 is an implementation process diagram of the ROIDetection function and the TargetDetection function;
[0036] Figure 2 is a step diagram of the small target multi-stage detection programming method based on the cluster computing system;
[0037] Figure 3 is a data processing flowchart of the small target multi-stage detection programming method based on the cluster computing system;
[0038] Figure 4 is a phase transition algorithm flowchart of the small target multi-stage detection programming method based on the cluster computing system;
[0039] Figure 5 is a node detection mechanism flowchart of the small target multi-stage detection programming method based on the cluster computing system;
[0040] Figure 6 is a task fault tolerance mechanism flowchart of the small target multi-stage detection programming method based on the cluster computing system. DETAILED DESCRIPTION
[0041] The technical solutions of the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0042] When the developer uses the small target multi-stage detection programming method in the present application, only needs to realize the ROIDetection function and the TargetDetection function according to the use requirements, and then calls the functions to perform the ROI detection and small target detection tasks. Figure 1The illustrated ROIDetection function and TargetDetection function can complete the small target multi-stage detection task in a cluster environment. In the ROIDetection function, the user needs to input the video or image set path, the weight file path of the ROI detection model, and the storage path of the ROI model detection result, and then create the ROI detection model, use a for loop to predict each frame of image, and use the saveIntermediateResult function to save the ROI detection result. Similarly, in the TargetDetection function, the user needs to input the ROI detection result path, the weight file path of the small target detection model, and the storage path of the small target model detection result, and then create the ROI detection model, use a for loop to predict each ROI region, and use the saveFinalResult function to save the small target detection result.
[0043] Reference Figure 2 and Figure 3 When the small target multi-stage detection system starts, the following steps are performed:
[0044] Step S1: The Manager cuts the video data or video frame set input to the system, uniformly processes different formats of data, obtains the cut sub-video or sub-set, encapsulates it as an ROI detection task, and assigns it to an idle Worker for ROI target detection.
[0045] In step S1, the Manager judges the type of input data: if it is a video data type, the video data is equally cut using the FFmpeg tool; if it is an image set, the image set is equally distributed to several different folders; otherwise, the system throws an exception and stops running; when the Manager completes the cutting of the input data, it encapsulates it into an ROI detection task and records the ID of each ROI detection task and the path of the corresponding data.
[0046] In step S1, the Manager will distribute and schedule the ROI detection task or small target detection task according to the task scheduling algorithm, specifically: when all tasks have not been completed, the Manager iterates through each available Worker, checks the running state of the Worker; if the Worker is idle, assign a new task to the Worker; if the Worker is busy, do not assign a new task to the Worker, i.e. do nothing.
[0047] In step S1, the following steps are performed simultaneously: Figure 4The stage transition algorithm of the small target multi-stage detection method based on the cluster computing system includes the following steps:
[0048] S11: initializing the worker_stage attribute value of each Worker as ROI_STAGE, indicating that the ROI detection task needs to be processed when the multi-stage detection starts;
[0049] S12: the Manager starts a new thread listenStage to listen to the worker_stage change of each Worker;
[0050] S13: if the Manager finds that the ROI stage has no task to be executed and a Worker is idle, the worker_stage attribute of the Worker is directly modified as TARGET_STAGE;
[0051] S14: the listenStage starts the small target detection process as soon as the worker_stage of a Worker changes, and assigns the existing small target detection task.
[0052] Step S2: the Worker executes the ROI detection task assigned by the Manager to generate an ROI screenshot, which is encapsulated as a small target detection task and saved to a temporary directory specified by the system;
[0053] Specifically, in step S2, the Worker calls the ROI detection function specified by the developer to execute the ROI detection task assigned by the Manager;
[0054] In step S2, the Worker labels the name of the ROI detection result, and the specific format is “frame number-ROI number-left upper corner x-axis coordinate of ROI-left upper corner y-axis coordinate of ROI-ROI width-ROI height”.
[0055] Step S3: the Manager assigns the generated small target detection task to an idle Worker;
[0056] In step S3, the same stage transition algorithm as in step S1 is executed.
[0057] Step S4: the Worker executes the small target detection task assigned by the Manager to generate a small target detection result;
[0058] In step S4, the Worker calls the TargetDetection function specified by the developer to execute the small target detection task assigned by the Manager;
[0059] In step S4, the same task scheduling algorithm and phase transition algorithm as in steps S1 or S2 are performed.
[0060] Step S5: The Manager sorts and recombines the small target detection results to generate final detection results and save the final detection results to a disk path specified by a user.
[0061] As shown in Figure 5 The present application includes a node detection mechanism flowchart of a small target multi-phase detection programming method based on a cluster computing system, and includes the following steps:
[0062] 101: All Workers periodically send heartbeat data to the Manager at an interval of time, and the heartbeat data includes a running state of the Worker, a work execution state of the Worker, and sending data time information;
[0063] 102: The Manager listens to and receives state information of each Worker, and performs timeout judgment on each Worker: if the Manager finds that a certain Worker is in timeout, step 103 is performed; otherwise, step 101 is performed.
[0064] 103: The Manager sends three state requests to the Worker at an interval of time, and if state data from the Worker is obtained within a specified time, the system continues to normally operate; if there is still no response during the three requests, it is determined that the Worker cannot continue to work; at this time, the Manager updates a list of available Workers of the current system, and reassigns tasks that have not been completed by the Worker.
[0065] As shown in Figure 6 The present application also includes a task fault tolerance mechanism flowchart of a small target multi-phase detection programming method based on a cluster computing system, and includes the following steps:
[0066] 201: The Manager extracts a first task in a task queue, assigns the task to a Worker in a normal running state and idle state according to a latest detection result of the Worker, and saves the task assignment in a Worker Array.
[0067] 202: Each idle Worker receives task information assigned by the Manager, obtains related data from a file system, and performs an ROI detection task or a small target detection task.
[0068] 203: The Manager periodically scans a task execution state of each Worker in the Worker Array to detect whether a task is in timeout or an error is generated in execution.
[0069] 204: If the Worker initiatively sends a data processing exception message to the Manager, or the Manager finds that the state information of a certain Worker is out of time, the Manager will modify the state identifier of the corresponding Worker in the Worker Array, and will not allocate tasks to it in the future, and will execute step 207.
[0070] 205: After the Worker completes the task, the processed data is placed in the designated storage directory.
[0071] 206: The Worker notifies the Manager that the executed task has been completed, and the Manager modifies the relevant information of the corresponding Worker in the Worker Array after receiving the message.
[0072] 207: The Manager obtains the failed tasks from the Worker Array and adds them to the tail of the task queue.
[0073] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think of changes or replacements within the technical scope disclosed by the present application, which should be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A programming method for multi-stage detection of small targets based on a cluster computing system, employing the master-slave Manager-Worker pattern in the cluster computing system; wherein, The Manager is the master node, responsible for task allocation and scheduling; the Worker is the worker node, responsible for task execution; the method for multi-stage detection of small targets based on a cluster computing system includes the following steps: Step S1: The Manager cuts the input data, encapsulates it into several ROI detection tasks, and assigns them to idle Workers for ROI target detection; Step S2: The Worker executes the ROI detection task assigned by the Manager to generate an ROI screenshot, which is then packaged into a small target detection task and saved to a temporary directory specified by the system. Step S3: The Manager assigns the small target detection task to an idle Worker; Step S4: The Worker executes the small target detection task assigned by the Manager and generates small target detection results; Step S5: The Manager sorts and reorganizes the small target detection results, and saves the final detection results to the disk path specified by the user.
2. The small target multi-stage detection programming method based on a cluster computing system according to claim 1, characterized in that, In step S1, the Manager determines the type of the input data: if it is a video data type, the FFmpeg tool is used to cut the video data into equal parts; if it is an image collection, the image collection is evenly distributed into several different folders; otherwise, the system throws an exception and stops running; after the Manager completes the cutting of the input data, it encapsulates it into ROI detection tasks and records the ID of each ROI detection task and the path of the corresponding data.
3. The small target multi-stage detection programming method based on a cluster computing system according to claim 1, characterized in that, In step S2, the Worker labels the ROI detection screenshots with the following format: "Frame number - ROI number - ROI top left corner x-axis coordinate - ROI top left corner y-axis coordinate - ROI width - ROI height".
4. The small target multi-stage detection programming method based on a cluster computing system according to claim 1, characterized in that, In steps S1 and S3, the Manager will allocate and schedule ROI detection tasks or small target detection tasks according to the task scheduling algorithm. Specifically, when all tasks have not been completed, the Manager will iterate through each available Worker and check the running status of the Worker; if the Worker is idle, a new task will be assigned to the Worker. If a Worker is busy, no new tasks will be assigned to that Worker, meaning no operations will be performed on it.
5. The programming method for multi-stage detection of small targets based on a cluster computing system according to claim 1, characterized in that, Steps S1, S2, and S3 further include an execution phase transition algorithm, comprising the following steps: S51: Initialize the worker_stage attribute of each Worker to ROI_STAGE, indicating that ROI detection tasks need to be processed at the start of the multi-stage detection process; S52: The Manager starts a new thread, listenStage, to monitor changes in the worker_stage of each Worker; S53: If the Manager finds that the queue of tasks to be executed in the ROI phase is empty and a certain Worker is idle, it directly modifies the worker_stage attribute of that Worker to TARGET_STAGE; S54: listenStage will start the small target detection process and allocate existing small target detection tasks whenever it detects a change in the worker_stage of a certain worker.
6. The programming method for multi-stage detection of small targets based on a cluster computing system according to claim 1, characterized in that, The small target multi-stage detection programming method based on cluster computing system also includes an execution node detection mechanism, comprising the following steps: S61: All Workers periodically send heartbeat data to the Manager at intervals. The heartbeat data includes the Worker's running status, the Worker's work execution status, and the time information when the data was sent. S62: The Manager receives the heartbeat data and performs a timeout check on each Worker: if the Manager finds that a Worker has timed out, then proceed to step S63; otherwise, proceed to step S61. S63: The Manager sends three status requests to the timed-out Worker at intervals. Once the Manager obtains the status data from the Worker within the specified time, the system continues to operate normally. If the Manager does not receive a response during these three requests, it is determined that the Worker cannot continue to work. At this time, the Manager will update the list of available Workers in the current system and reassign the unfinished tasks of the Worker.
7. The programming method for multi-stage detection of small targets based on a cluster computing system according to claim 1, characterized in that, The small target multi-stage detection programming method based on cluster computing system also includes a task fault tolerance mechanism, including the following steps: S71: The Manager extracts the head task from the task queue, assigns tasks to workers that are running normally and idle based on the most recent Worker detection results, and saves the task assignment information in the Worker Array. S72: After each idle Worker receives the task information assigned by the Manager, it retrieves the relevant data from the file system and executes the ROI detection task or the small target detection task. S73: The Manager periodically scans the task execution status of each Worker in the Worker Array to detect whether a task has timed out or encountered an error. S74: If a Worker actively sends a data processing exception message to the Manager, or if the Manager finds that the status information of a Worker has timed out, the Manager will modify the status flag of the corresponding Worker in the Worker Array, and will no longer assign tasks to it, and will execute step S77. S75: After the Worker completes the task, it places the processed data into the specified storage directory; S76: The Worker notifies the Manager that the task has been completed. After receiving the message, the Manager modifies the relevant information of the corresponding Worker in the Worker Array. S77: The Manager retrieves the failed tasks from the Worker Array and adds them back to the end of the task queue.
8. The programming method for multi-stage detection of small targets based on a cluster computing system according to claim 1, characterized in that, In step S2, the Worker calls the ROIDetection function specified by the developer to execute the ROI detection task assigned by the Manager; in step S4, the Worker calls the TargetDetection function specified by the developer to execute the small target detection task assigned by the Manager.
Citation Information
Patent Citations
Task processing method and device, computer readable storage medium and server
CN112231108A
Real-time spatial and group monitoring and optimization
US20210019528A1