Perimeter rule generation method and electronic equipment
By obtaining the scene image and rule prompt text, performing feature extraction and fusion processing, and using the pre-trained model to generate perimeter rules, the problem of high cost of configuring perimeter prevention rules in the existing technology is solved, and automated and accurate perimeter rules are realized. generate.
Patent Information
- Application Number
- CN202411032133.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-07-30
AI Technical Summary
In the existing technology, the configuration of perimeter prevention rules requires a large labor cost, and unreasonable configuration will affect the algorithm effect, resulting in high technical requirements for configuration personnel.
By obtaining the scene image and rule prompt text, image feature extraction and text feature extraction are performed, the features are fused for decoding processing, and the perimeter rules of the target scene are generated, and the perimeter rules are automatically configured using the pre-trained perimeter rule generation model.
On the premise of ensuring the accuracy of perimeter rule generation, the cost of perimeter rule configuration is reduced, and perimeter rules are automatically generated for various target scenarios.
Smart Images

Figure CN118552912A
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a perimeter rule generation method and electronic device. Background Art
[0002] With the rapid development of image analysis technology, some perimeter alarm methods based on image analysis have been applied. They mainly achieve the function of perimeter protection by intelligently analyzing the collected scene images. In the implementation process, in order to better simulate perimeter protection methods such as electronic pulses, corresponding rules will be drawn in areas such as walls in the video image, such as tripwires, double tripwires, areas, etc., to detect whether there are alarm events.
[0003] Whether the configuration of perimeter defense rules is reasonable has a relatively large impact on the final algorithm effect, so it puts forward higher technical requirements for rule configuration personnel, resulting in higher labor costs for configuring perimeter defense rules. Summary of the invention
[0004] In order to solve the above technical problems, the present application at least provides a perimeter rule generation method and an electronic device.
[0005] The first aspect of the present application provides a perimeter rule generation method, which includes: obtaining a scene image obtained by performing image acquisition on a target scene and a rule prompt text corresponding to the scene image; wherein the rule prompt text is used to describe relevant information of the perimeter rule to be generated; performing image feature extraction on the scene image to obtain scene image features, and performing text feature extraction on the rule prompt text to obtain prompt text features; fusing the scene image features and the prompt text features to obtain fused features, decoding the fused features to obtain a mask area in the scene image that matches the rule prompt text; and using the contour information of the mask area to generate the perimeter rule corresponding to the target scene.
[0006] In one embodiment, before using the contour information of the mask area to generate the perimeter rule corresponding to the target scene, it also includes: extracting contour points corresponding to the mask area; generating a line segment table based on the contour points, and using the line segment table as the contour information corresponding to the mask area.
[0007] In one embodiment, contour information of the mask area is used to generate perimeter rules corresponding to the target scene, including: performing text classification processing on prompt text features to obtain a rule type corresponding to the rule prompt text; obtaining a rule generation strategy that matches the rule type, and performing rule generation processing on the line segment table according to the rule generation strategy to obtain the perimeter rules corresponding to the target scene.
[0008] In one embodiment, the fusion of scene image features and prompt text features to obtain fused features includes: performing feature alignment processing on the scene image features and the prompt text features; based on the attention mechanism, fusing the scene image features and the prompt text features after feature alignment to obtain fused features.
[0009] In one embodiment, the fused features are decoded to obtain a mask area in the scene image that matches the rule prompt text, including: decoding the fused features to obtain a region division probability value corresponding to each pixel in the scene image, the region division probability value representing the probability that the pixel belongs to the mask area; obtaining a probability threshold corresponding to the scene image; and obtaining a mask area from the scene image based on the probability threshold and the region division probability value corresponding to each pixel in the scene image.
[0010] In one embodiment, obtaining a probability threshold corresponding to a scene image includes: determining a scene type corresponding to a target scene and / or a scene image quality of a scene image pair and / or a rule level of a perimeter rule to be generated; and calculating a probability threshold corresponding to the scene type based on the scene type and / or the scene image quality and / or the rule level.
[0011] In one embodiment, there are multiple scene images; using the contour information of the mask area, the perimeter rules corresponding to the target scene are generated, including: using the contour information of the mask area in each scene image that matches the rule prompt text to generate the initial perimeter rules corresponding to each scene image respectively; fusing each initial perimeter rule and using the fusion result as the perimeter rule corresponding to the target scene.
[0012] In one embodiment, a perimeter rule generation model is pre-trained, and the perimeter rule generation model includes an image feature extraction network, a text feature extraction network, a feature fusion network, a feature decoding network and a text classification network; the scene image is input into the image feature extraction network to obtain the scene image features output by the image feature extraction network; and the rule prompt text is input into the text feature extraction network to obtain the prompt text features output by the text feature extraction network; the scene image features and the prompt text features are input into the feature fusion network to obtain the fused features output by the feature fusion network; the fused features are input into the feature decoding network to obtain the probability map output by the feature decoding network, and the probability map contains the region division probability values corresponding to each pixel in the scene image; the scene image is region-divided based on the probability map to obtain the mask region in the scene image that matches the rule prompt text; the prompt text features are input into the text classification network to obtain the rule type corresponding to the rule prompt text output by the text classification network; a rule generation strategy matching the rule type is obtained, and the contour information of the mask region is subjected to rule generation processing according to the rule generation strategy to obtain the perimeter rule corresponding to the target scene.
[0013] In one embodiment, the training steps of the perimeter rule generation model include: obtaining a sample scene image, the sample scene image is correspondingly marked with an expected mask area, the expected mask area is correspondingly marked with a sample rule prompt text and an expected rule type corresponding to the sample rule prompt text; inputting the sample scene image and the sample rule prompt text into a pre-trained perimeter rule generation model to obtain a probability map and a rule type output by the pre-trained perimeter rule generation model; calculating a region division loss based on the probability map and the expected mask area output by the pre-trained perimeter rule generation model; and calculating a text classification loss based on the rule type and the expected rule type output by the pre-trained perimeter rule generation model; adjusting the model parameters of the pre-trained perimeter rule generation model in combination with the region division loss and the text classification loss to obtain a trained perimeter rule generation model.
[0014] The second aspect of the present application provides a perimeter rule generation device, which includes: a data acquisition module, which is used to obtain a scene image obtained by performing image acquisition on a target scene and a rule prompt text corresponding to the scene image; wherein the rule prompt text is used to describe the relevant information of the perimeter rule to be generated; a feature extraction module, which is used to perform image feature extraction on the scene image to obtain scene image features, and to perform text feature extraction on the rule prompt text to obtain prompt text features; a feature fusion module, which is used to fuse the scene image features and the prompt text features to obtain fused features, and to decode the fused features to obtain a mask area in the scene image that matches the rule prompt text; and a rule generation module, which is used to generate the perimeter rule corresponding to the target scene using the contour information of the mask area.
[0015] A third aspect of the present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned perimeter rule generation method.
[0016] A fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, which implement the above-mentioned perimeter rule generation method when the program instructions are executed by a processor.
[0017] The above scheme obtains a scene image obtained by performing image acquisition on the target scene and a rule prompt text corresponding to the scene image; performs image feature extraction on the scene image to obtain scene image features, and performs text feature extraction on the rule prompt text to obtain prompt text features; fuses the scene image features and the prompt text features to obtain fused features, and decodes the fused features to obtain a mask area in the scene image that matches the rule prompt text; utilizes the contour information of the mask area to generate the perimeter rules corresponding to the target scene, and can automatically generate perimeter rules for various target scenes, thereby reducing the configuration cost required for perimeter rule configuration while ensuring the accuracy of perimeter rule generation.
[0018] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.
[0020] Figure 1 It is a schematic diagram of an implementation environment of a solution provided by an embodiment of the present application; Figure 2 is a flow chart of a perimeter rule generation method shown in an exemplary embodiment of the present application; Figure 3 is a schematic diagram of generating perimeter rules according to an exemplary embodiment of the present application; Figure 4 is a schematic diagram of a perimeter rule generation model shown in an exemplary embodiment of the present application; Figure 5 is a schematic diagram of a training perimeter rule generation model shown in an exemplary embodiment of the present application; Figure 6 is a block diagram of a perimeter rule generating device shown in an exemplary embodiment of the present application; Figure 7 is a schematic structural diagram of an electronic device shown in an exemplary embodiment of the present application; Figure 8 It is a schematic diagram of the structure of a computer-readable storage medium shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0021] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.
[0022] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.
[0023] The term "and / or" in this article is only an association information describing the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the previous and next associated objects are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.
[0024] The following is a description of the perimeter rule generation method provided in an embodiment of the present application.
[0025] Please refer to Figure 1 , which shows a schematic diagram of a solution implementation environment provided by an embodiment of the present application. The solution implementation environment may include a terminal 110 and a server 120, and the terminal 110 and the server 120 are connected to each other in communication.
[0026] The number of the terminal 110 may be one or more. The terminal 110 may be a camera, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart watch, etc., but is not limited thereto.
[0027] Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), as well as big data and artificial intelligence platforms.
[0028] In one example, the server 120 may generate perimeter rules based on the scene image and rule prompt text obtained from the terminal 110 to obtain the perimeter rules corresponding to the target scene. The server 120 may perform alarm detection on subsequent scene images of the target scene based on the perimeter rules corresponding to the target scene. Of course, the server 120 may transmit the perimeter rules corresponding to the target scene back to the terminal 110 or transmit them to other alarm detection terminals, so that the terminal 110 or other alarm detection terminals may perform alarm detection on subsequent scene images of the target scene.
[0029] In one example, a client running a target application is installed in the terminal 110, and the target application may be an application that provides a perimeter rule generation function. The server 120 may be a background server of the target application, and is used to provide background services for the client of the target application, so that the terminal 110 can directly generate perimeter rules for the acquired scene image and rule prompt text.
[0030] In the perimeter rule generation method provided in the embodiment of the present application, the execution subject of each step can be the terminal 110, such as the client of the target application installed and running in the terminal 110, or the server 120, or the terminal 110 and the server 120 interact and cooperate to execute, that is, part of the steps of the method are executed by the terminal 110 and the other part of the steps are executed by the server 120.
[0031] See also Figure 2 , Figure 2 is a flowchart of a perimeter rule generation method shown in an exemplary embodiment of the present application. The perimeter rule generation method can be applied to Figure 1 It should be understood that the method can also be applied to other exemplary implementation environments and be specifically executed by devices in other implementation environments, and this embodiment does not limit the implementation environment to which the method is applicable.
[0032] like Figure 2 As shown, the perimeter rule generation method includes at least steps S210 to S240, which are described in detail as follows: Step S210: Acquire a scene image obtained by performing image acquisition on a target scene and a rule prompt text corresponding to the scene image; wherein the rule prompt text is used to describe relevant information of the perimeter rule that is expected to be generated.
[0033] Among them, the target scene refers to the scene that requires perimeter protection, such as the entrances and exits of buildings, walls, etc.
[0034] The scene image is obtained by performing image acquisition on the target scene. For example, a camera is deployed in the target scene, and the image of the target scene is acquired by the camera.
[0035] Further, a rule prompt text corresponding to the scene image is obtained, and the rule prompt text is used to describe the relevant information of the perimeter rule to be generated. For example, the rule prompt text may be "No vehicles are allowed to enter from Gate 1", "No vehicles are allowed to enter the lawn", etc.
[0036] The rule prompt text may be pre-stored in the server, or the terminal may send the rule prompt text to the server after obtaining the input rule prompt text in response to the rule input operation. This application does not limit this.
[0037] Step S220: extracting image features from the scene image to obtain scene image features, and extracting text features from the rule prompt text to obtain prompt text features.
[0038] Image features are extracted from the scene image to obtain scene image features, wherein the image features include but are not limited to color features, texture features, depth features, etc.
[0039] Extract text features from the rule prompt text to obtain prompt text features. For example, the rule prompt text is segmented into sentences, words, and characters to extract character vectors, word vectors, and sentence vectors respectively, and the prompt text features of the rule prompt text are obtained by combining the above vectors.
[0040] Step S230: fuse the scene image feature and the prompt text feature to obtain a fused feature, and decode the fused feature to obtain a mask area in the scene image that matches the rule prompt text.
[0041] By fusing scene image features and prompt text features, richer and more accurate fusion features can be obtained.
[0042] Exemplarily, feature fusion can be achieved in the following ways: 1. Stitching and fusion: directly stitch the scene image features and prompt text features together to obtain fused features.
[0043] 2. Weighted fusion: Add the scene image features and prompt text features according to their corresponding fusion weights to obtain the fusion features.
[0044] Among them, the fusion weights corresponding to the scene image features and the prompt text features can be obtained based on the attention mechanism.
[0045] It is also possible to classify the target scene and / or classify the rule prompt text, and determine the fusion weights corresponding to the scene image features and the prompt text features according to the scene type and / or rule type obtained by classification. The association between the scene type and / or rule type and the fusion weight can be learned by training a preset neural network model, so that the fusion weight can be determined by the trained neural network model; the association between the scene type and / or rule type and the fusion weight can also be pre-stored.
[0046] For example, the scene level corresponding to the target scene and / or the rule level corresponding to the rule prompt text are obtained. The higher the scene level, the higher the fusion weight of the scene image features, and the higher the rule level, the higher the fusion weight of the prompt text features. The emphasis in the feature fusion process is determined according to the scene type and / or rule type to obtain a fusion feature that is more in line with the current perimeter rule scene.
[0047] The scene level corresponding to the target scene can be determined according to the scene type of the target scene, the area of the target scene, the number of moving objects in the target scene, etc.; the rule level can be determined according to the rule type of the rule prompt text.
[0048] Optionally, in order to ensure the accuracy of the fused features, the values of the fusion weights of the scene image features and the prompt text features are within a preset weight range.
[0049] More accurate fusion features can be obtained through weighted fusion, which can further improve the accuracy of the mask area obtained by subsequent decoding.
[0050] 3. Feature selection after fusion: fuse the scene image features and the prompt text features to obtain the initial fusion features, and then perform feature selection on the initial fusion features to select the most valuable features and obtain the final fusion features.
[0051] Furthermore, the fused features are decoded to obtain a mask region in the scene image that matches the rule prompt text, that is, the mask region is used to indicate an image region that matches the perimeter rule that is expected to be generated.
[0052] Step S240: Generate a perimeter rule corresponding to the target scene using the contour information of the mask area.
[0053] After obtaining the mask area, the perimeter rule corresponding to the target scene is generated according to the contour information of the mask area.
[0054] Exemplarily, edge contour extraction can be performed on the mask area to obtain contour information of the mask area; contour point extraction can also be performed on the mask area, and a line segment table can be generated based on the contour points, and the line segment table can be used as the contour information corresponding to the mask area. This application does not limit this.
[0055] Exemplarily, the rule type may be determined according to the rule prompt text, such as the rule types include tripwire, double tripwire, area, multiple rule combinations (a combination of at least two of the tripwire, double tripwire, and area), etc., based on the rule type, a perimeter rule generation strategy is determined, and the contour information is processed according to the perimeter rule generation strategy to generate perimeter rules corresponding to the target scene.
[0056] Of course, there may also be a preset rule type, and a corresponding perimeter rule may be generated according to the preset rule type and contour information.
[0057] For example, see Figure 3 , Figure 3 This is a schematic diagram of generating perimeter rules shown in an exemplary embodiment of the present application, as shown in FIG. Figure 3 As shown, assuming that the rule prompt text is "Do not approach the display window", the rule type obtained by text classification of the rule prompt text is a tripwire, and the mask area is obtained by combining the scene image and the scene image. According to the contour information of the mask area, the perimeter alarm tripwire is drawn, and the perimeter rule corresponding to the target scene is generated: if a moving object is detected entering the perimeter alarm area, an alarm message is generated.
[0058] Next, some embodiments of the present application are described in further detail.
[0059] In some embodiments, the step S230 of fusing the scene image features and the prompt text features to obtain the fused features includes: performing feature alignment processing on the scene image features and the prompt text features; and based on the attention mechanism, fusing the scene image features and the prompt text features after feature alignment to obtain the fused features.
[0060] Specifically, feature space transformation is performed on the scene image features or the prompt text features so that the feature space and feature dimension between the scene image features and the prompt text features are aligned.
[0061] Then, based on the attention mechanism, the scene image features and prompt text features after feature alignment are weighted fused to obtain the fused features.
[0062] In some embodiments, in step S230, the fused features are decoded to obtain a mask area in the scene image that matches the rule prompt text, including: decoding the fused features to obtain a region division probability value corresponding to each pixel in the scene image, the region division probability value representing the probability that the pixel belongs to the mask area; obtaining a probability threshold corresponding to the scene image; and obtaining a mask area from the scene image based on the probability threshold and the region division probability value corresponding to each pixel in the scene image.
[0063] The probability threshold may be a preset value or a value flexibly calculated according to an actual application scenario.
[0064] Exemplarily, obtaining the probability threshold corresponding to the scene image includes: detecting the scene type corresponding to the target scene; querying the scene threshold mapping table, and using the threshold obtained from the query as the probability threshold corresponding to the scene type; wherein the scene threshold association table is used to store the mapping relationship between each scene type and the threshold.
[0065] It can be by performing scene classification on the scene image to obtain the scene type corresponding to the target scene; it can also be by combining the scene image and the scene audio of the target scene to perform scene classification on the target scene to obtain the scene type corresponding to the target scene; it can also be by obtaining the scene type input operation of the terminal to obtain the scene type corresponding to the target scene, which is not limited in this application.
[0066] Among them, scene types include but are not limited to first-class company entrances and exits, second-class company entrances and exits, community walls, etc. Different scene types correspond to different scene thresholds.
[0067] For example, different scene types can be divided into different scene levels. For example, if the alert requirement of the first type of company is higher than that of the second type of company, then the scene level of the entrance and exit of the first type of company is higher than that of the entrance and exit of the second type of company. The scene threshold mapping table stores thresholds corresponding to different scene levels. After obtaining the scene level to which the scene type corresponding to the current target scene belongs, the scene threshold mapping table is queried to obtain the threshold associated with the scene level, and the probability threshold is obtained. For example, the higher the scene level, the smaller the probability threshold, so as to ensure that the perimeter rule finally generated meets the alert requirement of the target scene.
[0068] By setting different probability thresholds for different scene types, the flexibility and accuracy of probability threshold selection can be improved.
[0069] Of course, in addition to considering the scene type corresponding to the target scene to determine the probability threshold, other influencing factors may also be considered to determine the probability threshold.
[0070] For example, the quality of the scene image can be detected to obtain the scene image quality, and the probability threshold is determined according to the scene image quality. If the scene image quality is higher, the probability threshold is higher to avoid invalid areas being divided into mask areas, and vice versa, if the scene image quality is lower, the probability threshold is lower to avoid valid areas not being divided into mask areas, wherein the valid area refers to the image area that matches the expected generated perimeter rule, and the invalid area refers to the image area that does not match the expected generated perimeter rule.
[0071] For another example, the rule level of the pre-generated perimeter rule can also be determined, and the probability threshold can be determined according to the rule level. For example, the lower the rule level, the higher the probability threshold, so as to avoid invalid areas being divided into mask areas. On the contrary, the higher the rule level, the lower the probability threshold, so as to avoid valid areas not being divided into mask areas, so as to meet the alert requirements of perimeter prevention as much as possible.
[0072] For another example, the probability threshold may be calculated based on the scene type and / or the scene image quality and / or the rule level.
[0073] Optionally, a threshold range corresponding to the probability threshold may be set, and the probability threshold may be adjusted within the threshold range, that is, the flexibly determined probability threshold may not be greater than a maximum value of the threshold range, nor less than a minimum value of the threshold range.
[0074] In some embodiments, before using the contour information of the mask area to generate the perimeter rules corresponding to the target scene, it also includes: extracting contour points corresponding to the mask area; generating a line segment table based on the contour points, and using the line segment table as the contour information corresponding to the mask area.
[0075] There are two commonly used methods for region representation, namely contour representation and line segment representation. The contour representation method uses the connectivity of the region contour to record each contour point, and finally goes around a circle back to the starting point, which obtains a chain code table; while the line segment representation method uses the rule of pixel arrangement to record the contour points in each row of the region image in sequence, which obtains a line segment table.
[0076] Among them, the line segment table is used to describe the contour information. The mask area can be represented as a set of horizontal line segments composed of a series of pixels. Each line segment can be represented by its two endpoints (contour points). The line segment table can be obtained by storing the endpoints of the line segments constituting the area in order.
[0077] Of course, a chain code table may also be used to represent the contour information corresponding to the mask area, and this application does not limit this.
[0078] Taking the line segment table as an example, the generation process of the perimeter rule is illustrated as follows: text classification processing is performed on the prompt text features to obtain the rule type corresponding to the rule prompt text; a rule generation strategy matching the rule type is obtained, and rule generation processing is performed on the line segment table according to the rule generation strategy to obtain the perimeter rule corresponding to the target scene.
[0079] For example, if the rule type corresponding to the rule prompt text is region, the rule generation strategy is to connect the contour points at both ends of the line segment table into a region, draw it into the target scene, use the obtained region as the perimeter alarm region, and generate the perimeter rule corresponding to the target scene as follows: if a moving object is detected to enter the perimeter alarm area, an alarm message is generated. If the rule type corresponding to the rule prompt text is tripwire, the rule generation strategy is to connect the center points corresponding to the line segment table into a straight line, draw it into the target scene, use the obtained straight line as the perimeter alarm tripwire, and generate the perimeter rule corresponding to the target scene as follows: if a moving object is detected to cross the perimeter alarm tripwire from the first direction, an alarm message is generated.
[0080] In some embodiments, there are multiple scene images; using the contour information of the mask area, generating the perimeter rules corresponding to the target scene, including: using the contour information of the mask area in each scene image that matches the rule prompt text to generate the initial perimeter rules corresponding to each scene image; fusing each initial perimeter rule and using the fusion result as the perimeter rule corresponding to the target scene.
[0081] Among them, multiple scene images can be taken at different times, such as scene images taken during the day, and scene images taken at night; multiple scene images can also be taken from different perspectives, such as scene images obtained by a first image acquisition device photographing the target scene from a first perspective, and scene images obtained by a second image acquisition device photographing the target scene from a second perspective. The present application does not limit this.
[0082] An initial perimeter rule is generated for each scene image, and the specific generation method can refer to the above embodiment. Then, each initial perimeter rule is combined and the fusion result is used as the perimeter rule corresponding to the target scene.
[0083] For example, the mean of the rule drawing results (area, tripwire, double tripwire, etc.) corresponding to each initial perimeter rule can be calculated, and the mean calculation result can be used as the fusion result. For example, the mean of the area corresponding to each initial perimeter rule is calculated, and the area mean is used as the perimeter alarm area corresponding to the final perimeter rule. Among them, the rule drawing results can be converted into the world coordinate system for fusion calculation.
[0084] For another example, the accuracy of the rule drawing result corresponding to each initial perimeter rule may be determined, and a weighted average calculation is performed on multiple rule drawing results according to the accuracy, and the weighted average calculation result is used as the fusion result. The accuracy may be determined according to the image quality of the scene image.
[0085] By fusing the initial perimeter rules corresponding to multiple scene images, the final perimeter rules generated are more robust and accurate.
[0086] In some embodiments, a perimeter rule generation model is pre-trained, see Figure 4 , Figure 4 FIG. 1 is a schematic diagram of a perimeter rule generation model shown in an exemplary embodiment of the present application. Figure 4 As shown, the perimeter rule generation model includes an image feature extraction network, a text feature extraction network, a feature fusion network, a feature decoding network and a text classification network.
[0087] The scene image is input into an image feature extraction network to obtain scene image features output by the image feature extraction network; and the rule prompt text is input into a text feature extraction network to obtain prompt text features output by the text feature extraction network; the scene image features and prompt text features are input into a feature fusion network to obtain fused features output by the feature fusion network; the fused features are input into a feature decoding network to obtain a probability map output by the feature decoding network, the probability map containing region division probability values corresponding to each pixel in the scene image; the scene image is region-divided based on the probability map to obtain a mask region in the scene image that matches the rule prompt text; the prompt text features are input into a text classification network to obtain a rule type corresponding to the rule prompt text output by the text classification network; a rule generation strategy matching the rule type is obtained, and the contour information of the mask region is subjected to rule generation processing according to the rule generation strategy to obtain a perimeter rule corresponding to the target scene.
[0088] Among them, the image feature extraction network can be implemented based on the VIT (Vision Transformer) network, convolutional neural network (CNN), etc.; the text feature extraction network can be implemented based on the Transformer network, long short-term memory network (LSTM, Long Short-Term Memory), etc.; the feature fusion network can be implemented based on the Tranformer Attention network; the feature decoding network is used to decode the fused features, which contains an activation function, and outputs a probability map through the activation function, specifically outputting a floating point number between 0 and 1, which represents the regional division probability value corresponding to each pixel in the scene image.
[0089] It should be noted that the specific network architecture of the perimeter rule generation model can be flexibly adjusted according to the actual application scenario, and this application does not limit this.
[0090] Optionally, continue to see Figure 4 The perimeter rule generation model may also include an image preprocessing network. Before extracting image features from the scene image, the scene image may be preprocessed by the image preprocessing network, such as image cropping, resizing, etc. The perimeter rule generation model may also include a feature alignment network. The feature alignment network is used to perform feature space conversion and feature dimension alignment processing on the prompt text features, and the output prompt text features are input into the feature fusion network.
[0091] By inputting the scene image and the rule prompt text corresponding to the scene image into the pre-trained perimeter rule generation model, the area division probability value and rule type output by the perimeter rule generation model are obtained, and the mask area matching the rule prompt text is determined according to the area division probability value, and the corresponding perimeter rule is drawn for the mask area according to the rule type.
[0092] In some embodiments, see Figure 5 , Figure 5 FIG. 1 is a schematic diagram of a training perimeter rule generation model shown in an exemplary embodiment of the present application, as shown in FIG. Figure 5As shown, a sample scene image is obtained, the sample scene image is marked with an expected mask area, and the expected mask area is marked with a sample rule prompt text and an expected rule type corresponding to the sample rule prompt text; the sample scene image and the sample rule prompt text are input into a pre-trained perimeter rule generation model to obtain a probability map and a rule type output by the pre-trained perimeter rule generation model; based on the probability map and the expected mask area output by the pre-trained perimeter rule generation model, the region division loss is calculated; and based on the rule type and the expected rule type output by the pre-trained perimeter rule generation model, the text classification loss is calculated; in combination with the region division loss and the text classification loss, the model parameters of the pre-trained perimeter rule generation model are adjusted to obtain a trained perimeter rule generation model.
[0093] Specifically, based on the probability map and expected mask area output by the pre-trained perimeter rule generation model, the relevant formula for calculating the area segmentation loss loss1 can be expressed as the following formula 1: (Formula 1) in, is the region division probability value of pixel i, which is a floating point number between 0 and 1; is the region division result of pixel i in the desired mask area, with a value of 0 or 1; N is the total number of pixels.
[0094] Based on the rule type and expected rule type output by the pre-trained perimeter rule generation model, the relevant formula for calculating the text classification loss loss2 can be expressed as the following formula 2: (Formula 2) Where m is the number of desired mask regions in the sample scene image; The rule type obtained by text classification corresponding to the sample rule prompt text marked for the jth expected mask area, such as area, tripwire, double tripwire, etc.; The expected rule type for labeling the jth expected mask region.
[0095] The model parameters of the pre-trained perimeter rule generation model are adjusted according to the region division loss and the text classification loss, such as adjusting the network parameters of the image feature extraction network, the text feature extraction network, the feature alignment network, the feature fusion network and the feature decoding network according to the region division loss, and adjusting the network parameters of the text classification network according to the text classification loss; or adjusting the network parameters of the image feature extraction network, the feature fusion network and the feature decoding network according to the region division loss, adjusting the network parameters of the text classification network according to the text classification loss, performing weighted calculation on the region division loss and the text classification loss, and adjusting the text feature extraction network according to the weighted calculation result, which is not limited in this application.
[0096] In response to the convergence of the region division loss and the text classification loss, or the number of model training iterations reaches a preset number, the current perimeter rule generation model is used as the trained perimeter rule generation model.
[0097] The perimeter rule generation method provided in the present application obtains a scene image obtained by performing image acquisition on a target scene and a rule prompt text corresponding to the scene image; performs image feature extraction on the scene image to obtain scene image features, and performs text feature extraction on the rule prompt text to obtain prompt text features; fuses the scene image features and the prompt text features to obtain fused features, and decodes the fused features to obtain a mask area in the scene image that matches the rule prompt text; utilizes contour information of the mask area to generate a perimeter rule corresponding to the target scene, and can automatically generate perimeter rules for various target scenes, thereby reducing the configuration cost required for perimeter rule configuration while ensuring the accuracy of perimeter rule generation.
[0098] Figure 6 FIG. 1 is a block diagram of a perimeter rule generating device shown in an exemplary embodiment of the present application. Figure 6 As shown, the exemplary perimeter rule generating device 600 includes: a data acquisition module 610, a feature extraction module 620, a feature fusion module 630 and a rule generating module 640. Specifically: The data acquisition module 610 is used to acquire a scene image obtained by performing image acquisition on a target scene and a rule prompt text corresponding to the scene image; wherein the rule prompt text is used to describe relevant information of the perimeter rule to be generated; The feature extraction module 620 is used to extract image features from the scene image to obtain scene image features, and to extract text features from the rule prompt text to obtain prompt text features; A feature fusion module 630 is used to fuse the scene image feature and the prompt text feature to obtain a fused feature, and decode the fused feature to obtain a mask area in the scene image that matches the rule prompt text; The rule generation module 640 is used to generate a perimeter rule corresponding to the target scene using the contour information of the mask area.
[0099] It should be noted that the perimeter rule generation device provided in the above embodiment and the perimeter rule generation method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs operations has been described in detail in the method embodiment, and will not be repeated here. In practical applications, the perimeter rule generation device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0100] See also Figure 7 , Figure 7 7 is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 700 includes a memory 701 and a processor 702, and the processor 702 is used to execute program instructions stored in the memory 701 to implement the steps in any of the above-mentioned boundary rule generation method embodiments. In a specific implementation scenario, the electronic device 700 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 700 may also include a mobile device such as a laptop computer and a tablet computer, which is not limited here.
[0101] Specifically, the processor 702 is used to control itself and the memory 701 to implement the steps in any of the above-mentioned boundary rule generation method embodiments. The processor 702 can also be called a central processing unit (CPU). The processor 702 may be an integrated circuit chip with signal processing capabilities. The processor 702 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 702 can be implemented by an integrated circuit chip.
[0102] See also Figure 8 , Figure 8 The computer-readable storage medium 800 stores program instructions 810 that can be executed by a processor, and the program instructions 810 are used to implement the steps in any of the above-mentioned boundary rule generation method embodiments.
[0103] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0104] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.
[0105] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0106] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or part of the contribution to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program code.
Claims
1. A perimeter rule generation method, It is characterized in that include: Acquire a scene image obtained by performing image acquisition on a target scene and a rule prompt text corresponding to the scene image; wherein the rule prompt text is used to describe relevant information of the perimeter rule to be generated; Performing image feature extraction on the scene image to obtain scene image features, and performing text feature extraction on the rule prompt text to obtain prompt text features; The scene image feature and the prompt text feature are fused to obtain a fused feature, and the fused feature is decoded to obtain a mask area in the scene image that matches the rule prompt text; The contour information of the mask area is used to generate a perimeter rule corresponding to the target scene.
2. The method according to claim 1, It is characterized in that Before using the contour information of the mask area to generate the perimeter rule corresponding to the target scene, the method further includes: Extracting contour points corresponding to the mask area; A line segment table is generated based on the contour points, and the line segment table is used as contour information corresponding to the mask area.
3. The method according to claim 2, It is characterized in that The step of using the contour information of the mask area to generate a perimeter rule corresponding to the target scene includes: Performing text classification processing on the prompt text features to obtain the rule type corresponding to the rule prompt text; A rule generation strategy matching the rule type is acquired, and rule generation processing is performed on the line segment table according to the rule generation strategy to obtain a perimeter rule corresponding to the target scene.
4. The method according to claim 1, It is characterized in that The fusing the scene image feature and the prompt text feature to obtain a fused feature includes: Performing feature alignment processing on the scene image features and the prompt text features; Based on the attention mechanism, the scene image features and the prompt text features after feature alignment are fused to obtain fused features.
5. The method according to claim 1, It is characterized in that The decoding process of the fusion feature to obtain a mask area in the scene image that matches the rule prompt text includes: Decoding the fused features to obtain a region division probability value corresponding to each pixel in the scene image, wherein the region division probability value represents a probability that the pixel belongs to a mask region; Obtaining a probability threshold corresponding to the scene image; Based on the probability threshold and the region division probability value corresponding to each pixel in the scene image, a mask region is obtained by dividing the scene image.
6. The method according to claim 5, It is characterized in that The obtaining a probability threshold corresponding to the scene image includes: Determining a scene type corresponding to the target scene and / or a scene image quality of the scene image pair and / or a rule level of the perimeter rule that is desired to be generated; Based on the scene type and / or the scene image quality and / or the rule level, a probability threshold corresponding to the scene type is calculated.
7. The method according to claim 1, It is characterized in that The number of the scene images is multiple; the use of the contour information of the mask area to generate the perimeter rule corresponding to the target scene includes: Using the contour information of the mask area matching the rule prompt text in each scene image, respectively generate the initial perimeter rule corresponding to each scene image; Each initial perimeter rule is fused, and the fusion result is used as the perimeter rule corresponding to the target scene.
8. The method according to claim 1, It is characterized in that A perimeter rule generation model is pre-trained, wherein the perimeter rule generation model includes an image feature extraction network, a text feature extraction network, a feature fusion network, a feature decoding network, and a text classification network; Inputting the scene image into the image feature extraction network to obtain scene image features output by the image feature extraction network; and inputting the rule prompt text into the text feature extraction network to obtain prompt text features output by the text feature extraction network; Inputting the scene image features and the prompt text features into the feature fusion network to obtain fusion features output by the feature fusion network; Inputting the fused features into the feature decoding network to obtain a probability map output by the feature decoding network, wherein the probability map contains a region division probability value corresponding to each pixel in the scene image; Based on the probability map, the scene image is divided into regions to obtain a mask region in the scene image that matches the rule prompt text; Inputting the prompt text feature into the text classification network to obtain the rule type corresponding to the rule prompt text output by the text classification network; A rule generation strategy matching the rule type is acquired, and rule generation processing is performed on the contour information of the mask area according to the rule generation strategy to obtain a perimeter rule corresponding to the target scene.
9. The method according to claim 8, It is characterized in that The training steps of the perimeter rule generation model include: Acquire a sample scene image, wherein the sample scene image is correspondingly marked with an expected mask area, and the expected mask area is correspondingly marked with a sample rule prompt text and an expected rule type corresponding to the sample rule prompt text; Inputting the sample scene image and the sample rule prompt text into a pre-trained perimeter rule generation model to obtain a probability map and a rule type output by the pre-trained perimeter rule generation model; Calculating a region partition loss based on a probability map output by the pre-trained perimeter rule generation model and the expected mask region; and calculating a text classification loss based on a rule type output by the pre-trained perimeter rule generation model and the expected rule type; In combination with the region division loss and the text classification loss, the model parameters of the pre-trained perimeter rule generation model are adjusted to obtain a trained perimeter rule generation model.
10. An electronic device, It is characterized in that The electronic device comprises a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the steps in the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Pedestrian mask and three-dimensional scene fusion display method, terminal and storage medium
CN111563516A
Automatic lineation perimeter alarm method, computer equipment and storage device
CN111582060A
Data processing method and device, electronic equipment and storage medium
CN115115913A
Target object recognition method and device, training method and device and storage medium
CN116246287A
Text-based scene picture editing method and system
CN116524070A
Cited By
Behavior specification supervision large model system cooperatively defined by natural language and picture
CN120705641A
