Scheduling method and device of detection algorithm, computer equipment and storage medium
By obtaining and updating the running instances of the detection algorithm and judging the operation status according to the number of devices, the problem of low efficiency in smart camera algorithm scheduling is solved, and flexible and efficient detection algorithm scheduling is achieved.
Patent Information
- Application Number
- CN202510822921.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-17
- Publication Date
- 2025-10-17
AI Technical Summary
In the existing technology, the algorithm scheduling efficiency of smart cameras is low, and configuration errors and repeated debugging problems are prone to occur, resulting in low scheduling efficiency of the detection algorithm.
By obtaining the current running instance of the target detection algorithm, the number of devices it can support is determined. According to the cached range of supported devices and the current number of supported devices, the instance operation status is judged and the instance is updated to ensure that the target device can call the target detection algorithm in time.
The scheduling flexibility and efficiency of the detection algorithm are improved, ensuring that the detection algorithm supports device calls at any time, avoiding the inaccuracy of hardware resource expansion or reduction in traditional methods, and improving the scheduling efficiency of the detection algorithm.
Smart Images

Figure CN120803630A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, in particular to a detection algorithm scheduling method and device, computer equipment and storage medium. BACKGROUND
[0002] With the development of artificial intelligence technology, the popularity of intelligent cameras is increasingly high, and various intelligent cameras carrying different algorithm capabilities are covered in different application scenarios, such as public transportation scenarios, commercial shopping scenarios, medical scenarios, etc. The increasing number of intelligent cameras also brings the problem of time-consuming and laborious camera algorithm scheduling. Currently, the operation of algorithm scheduling mainly adopts manual scheduling, and different algorithms are deployed for different cameras to adapt to application scenarios.
[0003] However, for multifunctional intelligent cameras, different detection algorithms need to be scheduled to realize various detection functions. Obviously, using manual scheduling method is prone to a series of problems such as configuration error, repeated debugging and repeated work, resulting in low scheduling efficiency of detection algorithms. SUMMARY
[0004] Therefore, it is necessary to provide a detection algorithm scheduling method, device, computer equipment, storage medium and computer program product to improve the scheduling efficiency of detection algorithms.
[0005] In a first aspect, the present application provides a detection algorithm scheduling method, comprising:
[0006] obtaining a current running instance corresponding to a target detection algorithm;
[0007] determining a current supportable device quantity corresponding to the target detection algorithm based on the current running instance;
[0008] determining an instance operation state corresponding to the target detection algorithm based on a cache supportable device quantity range corresponding to the target detection algorithm and the current supportable device quantity;
[0009] updating the current running instance based on the instance operation state to obtain an updated running instance; the updated running instance is used to support a target device calling the target detection algorithm.
[0010] In a second aspect, the present application provides a detection algorithm scheduling device, comprising:
[0011] an obtaining module configured to obtain a current running instance corresponding to a target detection algorithm;
[0012] a determining module configured to determine a current supportable device quantity corresponding to the target detection algorithm based on the current running instance;
[0013] a judging module, configured to determine an instance operation state corresponding to the target detection algorithm based on the current supportable device quantity and the cache supportable device quantity range corresponding to the target detection algorithm;
[0014] an updating module, configured to update the current running instance based on the instance operation state to obtain an updated running instance; the updated running instance is used to support the target device to call the target detection algorithm.
[0015] In a third aspect, a computer device is provided, which includes a memory and a processor. The memory stores a computer program. When the processor executes the computer program, the steps in the method described above are implemented.
[0016] In a fourth aspect, a computer readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps in the method described above are implemented.
[0017] In a fifth aspect, a computer program product is provided, which includes a computer program. When the computer program is executed by a processor, the steps in the method described above are implemented.
[0018] The scheduling method and device of the detection algorithm, the computer device, the computer readable storage medium and the computer program product described above can determine the current supportable device quantity of the target detection algorithm according to the current running instance corresponding to the target detection algorithm when the target detection algorithm needs to be scheduled, and then determine the instance operation state corresponding to the target detection algorithm according to the current supportable device quantity and the cache supportable device quantity range corresponding to the target detection algorithm. Then, the current supportable device quantity of the target detection algorithm can intuitively and specifically reflect whether the target detection algorithm can support the algorithm calling condition of the device calling currently, and further accurately determine the instance operation state of the current running instance. Then, the current running instance is updated according to the instance operation state to obtain an updated running instance, which can timely meet the scheduling demand of the target device on the target detection algorithm, realize the scheduling flexibility of the target detection algorithm, and improve the scheduling efficiency of the target detection algorithm.
[0019] Further, compared with the traditional method of expanding or shrinking the hardware resources of the server or terminal according to the hardware performance indicators of the server or terminal (such as memory, energy consumption, etc.), the instance processing operation of the detection algorithm cannot be accurately locked to support the timely calling of the corresponding device. For example, in the case of sufficient hardware resources of the server or terminal, it cannot accurately reflect whether the instance of each detection algorithm supports the device calling. The present application determines the instance operation state of the target detection algorithm by determining the current number of devices that can be supported by the target detection algorithm, ensures that the target detection algorithm supports the device calling at any time, and thus improves the scheduling efficiency of the detection algorithm. BRIEF DESCRIPTION OF DRAWINGS
[0020] Figure 1 An application environment diagram of a detection algorithm scheduling method provided by an embodiment of the present application is shown in FIG. 1.
[0021] Figure 2 A flowchart of a detection algorithm scheduling method provided by an embodiment of the present application is shown in FIG. 2.
[0022] Figure 3 A detection algorithm scheduling diagram provided by an embodiment of the present application is shown in FIG. 3.
[0023] Figure 4 A system architecture diagram of a system for automatically managing the detection algorithm of the device provided by an embodiment of the present application is shown in FIG. 4.
[0024] Figure 5 A camera service skill diagram provided by an embodiment of the present application is shown in FIG. 5.
[0025] Figure 6 A structural block diagram of a detection algorithm scheduling device provided by an embodiment of the present application is shown in FIG. 6.
[0026] Figure 7 An internal structure diagram of a computer device provided by an embodiment of the present application is shown in FIG. 7.
[0027] Figure 8 Another internal structure diagram of a computer device provided by an embodiment of the present application is shown in FIG. 8.
[0028] Figure 9 An internal structure diagram of a computer readable storage medium provided by an embodiment of the present application is shown in FIG. 9. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.
[0030] The scheduling method of the detection algorithm provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through a communication network. The data storage system can store data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers.
[0031] like Figure 2 As shown, the embodiment of the present application provides a scheduling method for a detection algorithm, which is applied to Figure 1 The terminal 102 or server 104 in the example is used for explanation. It is understood that the computer device may include at least one of a terminal and a server. The method includes the following steps:
[0032] S202: Obtain the current running instance corresponding to the target detection algorithm.
[0033] S204: Based on the current running instance, determine the number of devices currently supported by the target detection algorithm.
[0034] The target detection algorithm refers to the detection algorithm currently being invoked by the target device. This refers to the detection algorithm that the target device needs to run to implement the corresponding detection function, such as an image recognition algorithm or a debris detection algorithm. The target device can be a device that provides input data to run the target detection algorithm, such as a camera or sensor. The currently running instance refers to the instance of the target detection algorithm currently in operation. An instance refers to the object to which the algorithm is applied. For example, in a sorting algorithm, the set of numbers to be sorted [3, 1, 4, 2] is an instance. This means that the target detection algorithm implements the corresponding detection function by running the currently running instance.
[0035] The current supportable device quantity corresponding to the target detection algorithm refers to the quantity of devices that can call the target detection algorithm, and indicates the quantity of devices that can be configured for the target detection algorithm. The current supportable device quantity corresponding to the target detection algorithm can include the quantity of devices that can be configured when no other device calls the target detection algorithm, or the quantity of devices that can be configured when other devices call the target detection algorithm. The current supportable device quantity corresponding to the target detection algorithm can be obtained according to the current supportable device quantity corresponding to the current running instance in the target detection algorithm. The current supportable device quantity corresponding to the current running instance refers to the quantity of devices that can be processed by the idle resources of the current running instance, which can be simplified as the quantity of devices that can be processed by the current running instance.
[0036] For example, a target device triggers a detection task at a current time, determines a target detection algorithm according to the detection task, generates an algorithm calling request for the target detection algorithm, and sends the algorithm calling request to a server. The server responds to the algorithm calling request, obtains an algorithm scheduling table corresponding to the target detection algorithm, finds at least one current running instance corresponding to the target detection algorithm from the algorithm scheduling table, and obtains the current supportable device quantity corresponding to each current running instance. The server counts the current supportable device quantity corresponding to each current running instance, and determines the current supportable device quantity corresponding to the target detection algorithm. For example, the target detection algorithm A corresponds to three running instances, and the current supportable device quantity corresponding to each running instance is 1, 3, and 4, respectively. Therefore, the current supportable device quantity corresponding to the target detection algorithm A is 8.
[0037] In some embodiments, the single-instance supportable device quantity of each current running instance corresponding to the target detection algorithm is pre-configured in the algorithm scheduling table. The single-instance supportable device quantity refers to the total quantity of devices that can process the input data provided by multiple devices when starting one current running instance. The single-instance supportable device quantity corresponding to each current running instance can be the same or different. After the target detection algorithm is called by other devices in a historical time period, the server updates the supported device quantity corresponding to each current running instance in the algorithm scheduling table in real time. The supported device quantity refers to the quantity of devices being processed by each current running instance.
[0038] The server can determine the current supportable device quantity corresponding to the target detection algorithm in the algorithm scheduling table corresponding to the target detection algorithm according to the difference between the single-instance supportable device quantity and the supported device quantity of each current running instance, and then count the current supportable device quantity corresponding to each current running instance to obtain the current supportable device quantity corresponding to the target detection algorithm.
[0039] S206, determining an instance operation state corresponding to the target detection algorithm based on the cache supportable device quantity range and the current supportable device quantity corresponding to the target detection algorithm.
[0040] The cache supportable device quantity range refers to a threshold range pre-set for judging whether the running instance of the target detection algorithm needs to be processed, and can be understood as a necessary reserved device processing quantity range for the target detection algorithm. The instance operation state refers to an operation state in which the current running instance of the target detection algorithm needs to be processed, such as an instance expansion state or an instance shrinkage state.
[0041] For example, when the current supportable device quantity is within the cache supportable device quantity range, it indicates that the device quantity that the target detection algorithm can currently process meets the calling demand, and the instance operation state corresponding to the target detection algorithm is an instance maintenance state, which is used to indicate that the server does not update the current running instance of the target detection algorithm, and then the server notifies the target device that the target detection algorithm can be called through the current running instance.
[0042] When the current supportable device quantity is outside the cache supportable device quantity range, it indicates that the device quantity that the target detection algorithm can currently process does not meet the calling demand, and the instance operation state corresponding to the target detection algorithm is an instance change state, which is used to indicate that the server updates the current running instance of the target detection algorithm.
[0043] S208, updating the current running instance based on the instance operation state to obtain an updated running instance; the updated running instance is used to support the target device to call the target detection algorithm.
[0044] Exemplarily, the server updates the current running instances according to the instance operation state. When the instance operation state is the instance expansion state, one or more instances are added according to the instance parameters of the current running instances, and the updated running instances corresponding to the target detection algorithm are obtained according to the added current running instances. When the instance operation state is the instance shrinkage state, one or more instances are deleted from the current running instances, and the updated running instances corresponding to the target detection algorithm are obtained according to the deleted current running instances. Before the processing of deleting one or more current running instances, the devices being processed by the current running instances to be deleted are transferred to the current running instances that are not deleted. Then the server informs the target device that the target detection algorithm can be called through the updated running instances, and after detecting that the target device successfully calls the target detection algorithm, the current supportable device quantity corresponding to the target detection algorithm is updated according to the updated running instances.
[0045] In some embodiments, the algorithm calling request can include the target device quantity that needs to call the target detection algorithm. After obtaining the current supportable device quantity corresponding to the target detection algorithm, the server updates the current supportable device quantity corresponding to the target detection algorithm according to the target device quantity corresponding to the received algorithm calling request. Generally, the current supportable device quantity corresponding to the target detection algorithm is decremented according to the target device quantity to obtain the updated supportable device quantity.
[0046] Then the server takes the updated supportable device quantity as the current supportable device quantity corresponding to the target detection algorithm, and enters the step of determining the instance operation state corresponding to the target detection algorithm based on the cache supportable device quantity range and the current supportable device quantity corresponding to the target detection algorithm, which can ensure that the latest current supportable device quantity corresponding to the target detection algorithm still meets the calling demand corresponding to the cache supportable device quantity range after the target device calls the target detection algorithm, and can quickly respond to new algorithm calling requests.
[0047] It can be seen that in the embodiments of the present application, when the target detection algorithm needs to be scheduled, the current supportable device quantity corresponding to the target detection algorithm is determined according to the current running instance of the target detection algorithm, then the instance operation state corresponding to the target detection algorithm is determined according to the current supportable device quantity and the cache supportable device quantity range corresponding to the target detection algorithm, and then the current supportable device quantity of the target detection algorithm can intuitively and specifically reflect whether the target detection algorithm can support the algorithm calling of the device at present, and further the instance operation state of the current running instance can be accurately judged. Then the current running instance is updated according to the instance operation state to obtain an updated running instance, which can timely meet the scheduling demand of the target device for the target detection algorithm, realize the scheduling flexibility of the target detection algorithm, and improve the scheduling efficiency of the target detection algorithm.
[0048] Further, compared with the traditional method of expanding or shrinking the hardware resources of the server or terminal according to the hardware performance indicators of the server or terminal (such as memory, energy consumption, etc.), it cannot accurately lock the instance expansion or instance shrinkage operation of a certain detection algorithm to support the timely calling of the corresponding device. For example, in the case where the hardware resources of the server or terminal are sufficient, it cannot accurately reflect whether the instances of each detection algorithm support the device calling. The present application determines the instance operation state corresponding to the target detection algorithm by the current supportable device quantity of the target detection algorithm, ensures that the target detection algorithm supports the device calling at any time, and thus improves the scheduling efficiency of the detection algorithm.
[0049] In some embodiments, obtaining the current running instance corresponding to the target detection algorithm comprises:
[0050] Obtaining the current device scene corresponding to the target device;
[0051] Generating a detection task corresponding to the target device based on the current device scene, and sending the detection task to the target device, so that the target device determines the target detection algorithm based on the detection task;
[0052] In response to the algorithm calling request of the target device for the target detection algorithm, obtaining the current running instance corresponding to the target detection algorithm.
[0053] The current device scene refers to the environment scene in which the target device is currently located, for example, the current device scene corresponding to the camera device installed in the cinema is the cinema scene. The detection task is a detection task for meeting the detection demand associated with the current device scene.
[0054] Exemplarily, the server acquires a current device scene corresponding to the target device, determines a detection requirement associated with the current device scene according to the current device scene and a current time point, generates a detection task according to the detection requirement, and sends the detection task to the target device. The server acquires a current running instance corresponding to the target detection algorithm in response to an algorithm calling request of the target detection algorithm by the target device. For example, in a laboratory scene, a student makes an appointment to use an experimental table, and the server determines that the detection requirement associated with the laboratory scene is to detect the arrangement state of the items in the experimental table area (such as the equipment not being returned to the original position or the desktop being cluttered, etc.) after detecting that the appointment time is over. Then, the server generates a detection task of detecting specified items, and the camera device installed in the laboratory needs to call an image recognition algorithm as the target detection algorithm. The algorithm type of the target detection algorithm that needs to be called by the target device can be determined according to the business type corresponding to the current device scene of the target device. For example, for the security monitoring business, the detection algorithm of the camera device installed in the personnel passage can be personnel intrusion detection, passage litter detection, etc.
[0055] It can be seen that in the embodiment, by determining the target detection algorithm that needs to be called by the target device according to the current device scene of the target device, flexible scheduling between the target device and the target detection algorithm can be achieved.
[0056] In some embodiments, the instance operation state corresponding to the target detection algorithm is determined based on the range of the cache supportable device quantity corresponding to the target detection algorithm and the current supportable device quantity, including:
[0057] When the current supportable device quantity is less than the lower limit value of the range of the cache supportable device quantity corresponding to the target detection algorithm, the instance operation state corresponding to the target detection algorithm is determined as an instance expansion state; or,
[0058] When the current supportable device quantity is greater than the upper limit value of the range of the cache supportable device quantity corresponding to the target detection algorithm, the instance operation state corresponding to the target detection algorithm is determined as an instance contraction state.
[0059] The instance expansion state refers to an operation state in which a new instance of the target detection algorithm needs to be added. The instance contraction state refers to an operation state in which the instances of the target detection algorithm need to be reduced.
[0060] Exemplarily, the server determines, according to the comparison result, that the instance operation state corresponding to the target detection algorithm is an instance variation state when the current supportable device quantity is located outside the cached supportable device quantity range. The instance variation state includes an instance expansion state and an instance contraction state. Specifically, when the current supportable device quantity is less than the lower limit value of the cached supportable device quantity range, it indicates that the target detection algorithm currently has insufficient processing capacity, and the instance operation state corresponding to the target detection algorithm is determined to be the instance expansion state, and the target detection algorithm needs to be expanded in instances, which can be to add a running instance of the target detection algorithm. When the current supportable device quantity is greater than the upper limit value of the cached supportable device quantity range, it indicates that the target detection algorithm currently has excessive processing capacity, and the instance operation state corresponding to the target detection algorithm is determined to be the instance contraction state, and the target detection algorithm needs to be contracted in instances, which can be to reduce the current running instance of the target detection algorithm.
[0061] In this embodiment, by comparing the current supportable device quantity with the upper and lower limit values of the cached supportable device quantity range, the corresponding instance operation state is determined, the running instance of the target detection algorithm can be effectively controlled, and the running resources of the target detection algorithm are saved.
[0062] In some embodiments, based on the instance operation state, the current running instance is updated to obtain an updated running instance, including:
[0063] Based on the instance contraction state, device load information corresponding to each current running instance is obtained.
[0064] Based on the device load information, a contraction running instance and a target load device corresponding to the contraction running instance are determined from each current running instance.
[0065] The calling relationship between the contraction running instance and the target load device is deleted, and the target load device is allocated to other running instances except the contraction running instance.
[0066] The contraction running instance is closed, and an updated running instance is determined based on the other running instances.
[0067] The device load information indicates the device information being processed by the current running instance, including the number of devices being processed by the current running instance (i.e., the supported device quantity of the current running instance), device identifiers, etc. The contraction running instance refers to the current running instance that needs to be deleted. The target load device refers to the device being processed by the contraction running instance.
[0068] Exemplarily, the server can acquire the number of supported devices corresponding to each current running instance respectively according to the device load information, take the current running instance with the smallest number of supported devices as the shrinkage running instance, and determine the target load device being processed by the shrinkage running instance according to the algorithm scheduling table. Then the server deletes the calling relationship between the shrinkage running instance and the target load device, which can be deleting the device identifier of the target load device corresponding to the shrinkage running instance in the algorithm scheduling table.
[0069] Then the server allocates the target load device to other running instances except the shrinkage running instance, which can be adding the device identifier of the corresponding target load device to other running instances in the algorithm scheduling table. The allocation of the target load device can be allocating the target load device to other running instances evenly, or determining the corresponding allocation number according to the current number of supported devices of other running instances, and allocating the target load device according to the corresponding allocation number of other running instances. After the allocation of the target load device is completed, the server closes the shrinkage running instance, and takes other running instances as the updated running instance corresponding to the target detection algorithm. Then the server updates the current number of supported devices of the target detection algorithm according to the current number of supported devices of the updated running instance.
[0070] In this embodiment, by performing instance shrinkage operation on the target detection algorithm, and transferring the target load device of the shrinkage running instance to other running instances, the normal calling of the target load device to the target detection algorithm is ensured, and the dynamic adjustment of the instance of the target detection algorithm is realized, and the algorithm running resources are saved.
[0071] In some embodiments, the scheduling method of the detection algorithm further includes:
[0072] In response to an algorithm switching request of switching the target device from other detection algorithms to the target detection algorithm, deleting the calling relationship between the target device and other detection algorithms in the algorithm scheduling table, and performing the step of acquiring the current running instance corresponding to the target detection algorithm until the updated running instance is obtained.
[0073] Based on the updated running instance, determining the target running instance;
[0074] Adding the calling relationship between the target device and the target running instance in the algorithm scheduling table.
[0075] The target running instance refers to the running instance in the updated running instance for processing the target device.
[0076] Exemplarily, when the server detects the algorithm switching trigger condition for the target device, the algorithm switching trigger condition can be an event time point of a specific event, the associated target detection algorithm is determined according to other detection algorithms historically called by the target device, the algorithm switching task of switching from the other detection algorithm to the target detection algorithm is sent to the target device, and the algorithm switching request returned by the target device is received. For example, in a cinema scenario, the camera device installed in the auditorium needs to perform behavior detection on the audience before the movie ends, and needs to perform residual object detection on the audience seat area after the movie ends. When the server detects that the current time point is the end time point of the movie event, the algorithm switching trigger condition of the camera device is reached, the algorithm switching task of switching from the behavior detection algorithm to the residual object detection algorithm is sent to the camera device, and the algorithm switching request returned by the camera device is received.
[0077] The server can select the update running instance with the smallest number of supported devices as the target running instance corresponding to the target device according to the number of supported devices corresponding to each update running instance.
[0078] In this embodiment, the calling relationship between each device and detection algorithm can be effectively configured by configuring the algorithm scheduling table, and the scheduling efficiency of the detection algorithm is improved.
[0079] In some embodiments, the resource capacity of each server, the start and stop strategy of the detection algorithm, and the current number of supported devices of the detection algorithm and the like are defined in advance in the table of the database as the algorithm scheduling rules of the corresponding detection algorithm.
[0080] The algorithm scheduling table is shown in Table 1, which includes a server table, a detection algorithm table, a running instance table of the detection algorithm, a scheduling table of the device and the detection algorithm, and a device table.
[0081] Table 1
[0082]
[0083] The parameters corresponding to the server table, the detection algorithm table, the running instance table of the detection algorithm, the scheduling table of the device and the detection algorithm, and the device table are defined as follows:
[0084] 1. Server table (resource definition of server):
[0085] Server ID: unique identifier of the server.
[0086] Used memory / maximum available memory: the available memory of the server can be obtained by subtracting the used memory from the maximum available memory.
[0087] Available video memory per graphics card / maximum available video memory: the available video memory of each graphics card can be obtained by subtracting the used video memory from the maximum available video memory.
[0088] 2. Detection algorithm table (definition of detection algorithm):
[0089] Algorithm name: Define the identity of the algorithm, and each algorithm has a unique name.
[0090] Deployment yaml template: The content of the Deployment type yaml, based on which the instance is started.
[0091] Detection call path template: The RestAPI path that calls the algorithm, based on which the call path is determined when the instance is started.
[0092] Memory and GPU consumed by a single instance: Define the server memory and GPU that need to be consumed when starting an instance.
[0093] Current number of supported devices: Indicates how many devices that call this detection algorithm can be configured.
[0094] Number of devices supported by a single instance: Indicates the total number of devices that can be processed by starting an algorithm instance.
[0095] Lower limit of the number of devices supported by the cache: Indicates that there are at least how many idle device processing quantities for this detection algorithm, which is used as a judgment condition when scaling out the instance.
[0096] Upper limit of the number of devices supported by the cache: Indicates that there are at most how many idle device processing quantities for this detection algorithm, which is used as a judgment condition when scaling in the instance.
[0097] 3. Running instance table of detection algorithm (algorithm started instance):
[0098] Algorithm name: To associate with the detection algorithm name.
[0099] Running instance Deployment name: The instance name defined when starting the instance based on the deployment yaml template, used when shutting down the instance.
[0100] Server ID: Associated with the specific deployed server. When shutting down the instance, the server's resources need to be released.
[0101] Detection path: Based on the detection call path template of this detection algorithm, the specific camera calls the instance.
[0102] Deployed GPU location: describes which GPU on the server this instance is executed on. When the instance is closed, the specific GPU can be located to release resources.
[0103] 4. Device and detection algorithm scheduling table (definition of device calling detection algorithm):
[0104] Camera ID: in order to associate with the camera.
[0105] Running instance Deployment name: represents that the camera calls the detection algorithm instance.
[0106] 5. Device table:
[0107] Device ID: unique identification of the device.
[0108] In some embodiments, the system business logic layer can interact with the web front end through the RestAPI to realize the dynamic opening and closing of the detection algorithm. For example, the opening and closing of the detection algorithm can be received through human-computer interaction of the web front end; the detection algorithm can also be started and stopped by using Kubernetes to interact with the server. When the opening of the detection algorithm is detected, the instance expansion or instance shrinkage operation of the detection algorithm needs to be performed according to the current supportable device quantity of the detection algorithm. The automatic expansion and shrinkage of the detection algorithm instance can also be realized through the timing task mechanism.
[0109] In some embodiments, before determining the instance operation state corresponding to the target detection algorithm based on the cache supportable device quantity range and the current supportable device quantity corresponding to the target detection algorithm, the scheduling method of the detection algorithm further includes:
[0110] Obtaining the single-instance supportable device quantity corresponding to the target detection algorithm;
[0111] Determining the cache supportable device quantity range corresponding to the target detection algorithm based on the single-instance supportable device quantity.
[0112] Exemplarily, the single-instance supportable device quantity of the target detection algorithm is taken as the upper limit value of the cache supportable device quantity range, and the lower limit value of the cache supportable device quantity range can be set to 1, to obtain the cache supportable device quantity range corresponding to the target detection algorithm.
[0113] In some embodiments, as shown in Figure 3 , a scheduling diagram of the detection algorithm is provided. The scheduling of the detection algorithm can include automatic expansion and shrinkage of the detection algorithm instance based on the timing task mechanism, and the flowchart is as shown in Figure 3 .
[0114] When the timing task triggers, loop through each detection algorithm to determine whether it needs to be scaled up or scaled down. If the lower limit value of the cache supported device quantity range of each detection algorithm and the current supported device quantity are used to determine whether scaling up is needed, if yes, the corresponding scaling up logic is executed (using detection algorithm A as an example): all servers are traversed, and the servers that meet the deployment conditions are selected for deployment of algorithm instances according to the memory and video memory consumed by a single instance of detection algorithm A. If no resource sufficient available node is found after traversing all servers (i.e., all servers have reached the resource upper limit), the corresponding log information is recorded and the administrator is notified for subsequent audit and operation and maintenance troubleshooting, and the subsequent steps of the current scaling up process are skipped. According to the yaml template of detection algorithm A deployment, the detection call path template generates a running instance L of detection algorithm A, and starts running instance L through Kubernetes. The current supported device quantity N of detection algorithm A is increased according to the single instance supported device quantity N of detection algorithm A, and the memory and video memory of the server used by the instance are consumed according to the memory and video memory consumed by a single instance of detection algorithm A.
[0115] If the upper limit value of the cache supported device quantity range of each detection algorithm and the current supported device quantity are used to determine whether scaling down is needed, if yes, the corresponding scaling down logic is executed (using detection algorithm A as an example): the running instance L of detection algorithm A that currently processes the least number of devices is selected according to the scheduling table of devices and detection algorithms. The scheduling table of devices and detection algorithms is maintained, the devices processed by the running instance L of detection algorithm A are transferred to other running instances of detection algorithm A, and then the running instance L of detection algorithm A is closed through Kubernetes. The current supported device processing quantity N of detection algorithm A is reduced according to the single instance supported device quantity N of detection algorithm A, and the memory and video memory of the server used by the instance are released according to the memory and video memory consumed by a single instance of detection algorithm A as defined.
[0116] The scheduling of detection algorithms can include detection algorithm switching scheduling for devices, which can operate on a real-time page to modify the opening or closing of detection algorithms for devices, and a flowchart thereof is shown in FIG. 8B. Figure 3 The detection algorithm switching scheduling process is described by taking the example of closing detection algorithm A and opening detection algorithm B for device T:
[0117] First, the logic of closing detection algorithm A is executed: the scheduling table of devices and detection algorithms is maintained, the relationship between device T and detection algorithm A is removed, and the current supported device quantity of detection algorithm A is increased by 1.
[0118] Then the logic of starting detection algorithm B is executed: it is judged whether the current supportable device quantity of detection algorithm B is greater than 0, if yes, according to the supportable device quantity of a single instance of detection algorithm B, an operating instance L of the detection algorithm B which is not full is selected in the detection algorithm table. If the current timing task is executing the dynamic automatic expansion / shrinking of the detection algorithm, it is waited to be executed, and then it is judged again whether the current supportable device quantity of detection algorithm B is greater than 0, if yes, according to the supportable device quantity of a single instance of detection algorithm B, an operating instance L of the detection algorithm B which is not full is selected in the detection algorithm table, otherwise the device dynamic automatic expansion operation is executed. The scheduling table of device and detection algorithm is maintained, the relationship between device T and detection algorithm B operating instance L is added, and the current supportable device quantity of detection algorithm B is reduced by 1.
[0119] In some embodiments, as shown in Figure 4 A system architecture diagram for automatically managing detection algorithms of devices is provided. The system includes an algorithm detection layer, a service layer, and a display layer. The target device can be a camera.
[0120] The algorithm detection layer is configured to provide detection algorithm services to the service layer, and to timely detect whether the algorithm detection result based on the current frame of the camera needs to be alarmed, and to return to the service layer.
[0121] The service layer is configured to process business logic, including matters related to the dynamic automatic management of the detection algorithms of the camera.
[0122] The display layer is the configuration of the camera and the detection algorithm, and is configured to display the algorithm detection result.
[0123] In addition to the main part of the system, DevOps (a combination of Development and Operations) technology can be used to maintain the system. Kubernetes is used for containerized management and deployment of services; CI / CD is completed based on Jenkins (an open source automation server), that is, continuous integration (CI) and continuous deployment (CD) of services are implemented; and the state of the services is monitored using Prometheus, which can automatically and timely notify the maintenance personnel to handle the system exception. As shown in Figure 5 The camera business skill diagram shows that the business skills (configured detection algorithms, each configured detection algorithm can have a corresponding priority) that can be implemented by the camera A include electronic fence (personnel intrusion detection, channel debris detection, etc.), compliance identification (wearing compliance detection, chest card wearing detection, etc.), and fire identification (flame and smoke detection, etc.).
[0124] It should be understood that although each step in the flowchart involved in each of the above embodiments is shown in sequence according to the arrow, these steps are not necessarily executed in the order indicated by the arrow. Unless otherwise specified herein, there is no strict order limitation for the execution of these steps, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in each of the above embodiments can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps.
[0125] Based on the same inventive concept, the embodiments of the present application also provide a detection algorithm scheduling device. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more detection algorithm scheduling device embodiments provided below can refer to the limitations of the detection algorithm scheduling method in the above text, which will not be repeated here.
[0126] As shown in Figure 6 The embodiments of the present application provide a detection algorithm scheduling device 600, which comprises:
[0127] The acquisition module 602 is configured to acquire a current running instance corresponding to a target detection algorithm.
[0128] The determination module 604 is configured to determine a current supportable device quantity corresponding to the target detection algorithm based on the current running instance.
[0129] The judgment module 606 is configured to determine an instance operation state corresponding to the target detection algorithm based on a cache supportable device quantity range corresponding to the target detection algorithm and the current supportable device quantity.
[0130] The update module 608 is configured to update the current running instance based on the instance operation state to obtain an updated running instance; the updated running instance is used to support a target device calling the target detection algorithm.
[0131] In some embodiments, in terms of acquiring the current running instance corresponding to the target detection algorithm, the acquisition module 602 is specifically configured to:
[0132] Acquire a current device scene corresponding to the target device;
[0133] Generate a detection task corresponding to the target device based on the current device scene, and send the detection task to the target device, so that the target device determines the target detection algorithm based on the detection task.
[0134] In response to the algorithm invocation request of the target device for the target detection algorithm, the current running instance corresponding to the target detection algorithm is acquired.
[0135] In some embodiments, in determining the instance operation state corresponding to the target detection algorithm based on the cache supportable device quantity range corresponding to the target detection algorithm and the current supportable device quantity, the determining module 606 is specifically configured to:
[0136] when the current supportable device quantity is less than the lower limit value of the cache supportable device quantity range corresponding to the target detection algorithm, determining that the instance operation state corresponding to the target detection algorithm is an instance expansion state; or,
[0137] when the current supportable device quantity is greater than the upper limit value of the cache supportable device quantity range corresponding to the target detection algorithm, determining that the instance operation state corresponding to the target detection algorithm is an instance shrinkage state.
[0138] In some embodiments, in updating the current running instance based on the instance operation state to obtain an updated running instance, the updating module 608 is specifically configured to:
[0139] based on the instance shrinkage state, acquiring device load information corresponding to each current running instance respectively;
[0140] based on the device load information, determining a shrinkage running instance and a target load device corresponding to the shrinkage running instance from each current running instance;
[0141] deleting the invocation relationship between the shrinkage running instance and the target load device, and assigning the target load device to other running instances except the shrinkage running instance in each current running instance;
[0142] closing the shrinkage running instance, and determining an updated running instance based on the other running instances.
[0143] In some embodiments, the scheduling apparatus 600 of the detection algorithm further includes an adding module, which is configured to:
[0144] in response to an algorithm switching request of the target device from other detection algorithms to the target detection algorithm, deleting the invocation relationship between the target device and the other detection algorithms in the algorithm scheduling table, and performing the step of acquiring the current running instance corresponding to the target detection algorithm until an updated running instance is obtained; based on the updated running instance, determining a target running instance; and adding the invocation relationship between the target device and the target running instance in the algorithm scheduling table.
[0145] In some embodiments, the determining module 604 is further configured to:
[0146] Obtain the number of devices supported by a single instance of the target detection algorithm. Based on the number of devices supported by a single instance, determine the range of devices supported by the cache corresponding to the target detection algorithm.
[0147] Each module in the scheduling device of the above-mentioned detection algorithm can be implemented in whole or in part through software, hardware, or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of the processor of the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of each of the above modules.
[0148] In some embodiments, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, abbreviated as I / O) and a communication interface. The processor, memory and input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store data related to the scheduling detection algorithm. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, the steps in the scheduling method of the above-mentioned detection algorithm are implemented.
[0149] In some embodiments, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through the system bus, the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control ability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program in the non-volatile storage medium to run. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with the external terminal in a wired or wireless manner. The wireless manner can be realized through WIFI, mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by the processor to realize the steps in the scheduling method of the detection algorithm described above. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen; The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0150] Those skilled in the art can understand that, Figure 7 or Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0151] In some embodiments, a computer device is provided, which includes a memory and a processor, the memory stores a computer program, and the processor executes the computer program to realize the steps in the above method embodiments.
[0152] In some embodiments, as Figure 9 A block diagram of the internal structure of a computer readable storage medium is provided, which stores a computer program. The computer program is executed by the processor to realize the steps in the above method embodiments.
[0153] In some embodiments, a computer program product is provided, which includes a computer program. The computer program is executed by the processor to realize the steps in the above method embodiments.
[0154] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of the country and region.
[0155] It can be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing related hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, it can include the processes of the above-mentioned embodiments of each method. Any reference to memory, database or other medium used in the embodiments provided by the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided by the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided by the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0156] The technical features of the above embodiments can be combined in any way. In order to make the description concise, not all possible combinations of the technical features in the above embodiments are described, but as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.
[0157] The above embodiments only express several implementation ways of the present application, and the description is specific and detailed, but it should not be understood as a limitation to the patent scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A scheduling method for a detection algorithm, characterized in that: include: Get the currently running instance of the target detection algorithm; Determining the number of devices currently supported by the target detection algorithm based on the current running instance; Determining an instance operation state corresponding to the target detection algorithm based on a range of the number of devices supported by the cache corresponding to the target detection algorithm and the current number of supported devices; Based on the instance operation state, the current running instance is updated to obtain an updated running instance; the updated running instance is used to support the target device to call the target detection algorithm.
2. The method according to claim 1, characterized in that The obtaining of the current running instance corresponding to the target detection algorithm includes: Obtaining the current device scene corresponding to the target device; generating a detection task corresponding to the target device based on the current device scenario, and sending the detection task to the target device so that the target device determines a target detection algorithm based on the detection task; In response to an algorithm call request from the target device for the target detection algorithm, a current running instance corresponding to the target detection algorithm is obtained.
3. The method according to claim 1, characterized in that The determining, based on the range of the number of devices supported by the cache corresponding to the target detection algorithm and the number of currently supported devices, the instance operation state corresponding to the target detection algorithm includes: When the current number of supported devices is less than a lower limit of a range of the number of supported devices of the cache corresponding to the target detection algorithm, determining that the instance operation state corresponding to the target detection algorithm is an instance expansion state; or When the current number of supported devices is greater than an upper limit value of a range of the number of supported devices of the cache corresponding to the target detection algorithm, it is determined that the instance operation state corresponding to the target detection algorithm is an instance scaling-down state.
4. The method according to claim 3, characterized in that The updating of the current running instance based on the instance operation state to obtain an updated running instance includes: Based on the instance scaling status, obtaining device load information corresponding to each currently running instance; Based on the device load information, determining a scaled-down running instance and a target load device corresponding to the scaled-down running instance from each of the current running instances; Deleting the calling relationship between the scaled-down running instance and the target load device, and allocating the target load device to other running instances among the current running instances except the scaled-down running instance; The scaled-down running instance is closed, and an updated running instance is determined based on the other running instances.
5. The method according to claim 1, wherein The method further comprises: In response to an algorithm switching request from the target device to switch from another detection algorithm to the target detection algorithm, deleting a calling relationship between the target device and the other detection algorithm in the algorithm scheduling table, and executing the step of obtaining a current running instance corresponding to the target detection algorithm until the updated running instance is obtained; Determining a target running instance based on the updated running instance; A calling relationship between the target device and the target running instance is added to the algorithm scheduling table.
6. The method according to claim 1, characterized in that Before determining the instance operation state corresponding to the target detection algorithm based on the range of the number of devices supported by the cache corresponding to the target detection algorithm and the current number of supported devices, the method further includes: Obtain the number of devices supported by a single instance of the target detection algorithm; Based on the number of devices that can be supported by the single instance, a range of the number of devices that can be supported by the cache corresponding to the target detection algorithm is determined.
7. A scheduling device for a detection algorithm, characterized in that: include: The acquisition module is used to obtain the current running instance corresponding to the target detection algorithm; A determination module, configured to determine the number of currently supported devices corresponding to the target detection algorithm based on the currently running instance; a determination module, configured to determine an instance operation state corresponding to the target detection algorithm based on a range of the number of devices supported by the cache corresponding to the target detection algorithm and the number of currently supported devices; An updating module is used to update the current running instance based on the instance operation state to obtain an updated running instance; the updated running instance is used to support the target device to call the target detection algorithm.
8. The device according to claim 7, characterized in that In terms of obtaining the current running instance corresponding to the target detection algorithm, the acquisition module is specifically used to: Obtaining the current device scene corresponding to the target device; generating a detection task corresponding to the target device based on the current device scenario, and sending the detection task to the target device so that the target device determines a target detection algorithm based on the detection task; In response to an algorithm call request from the target device for the target detection algorithm, a current running instance corresponding to the target detection algorithm is obtained.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.