Target detection method and system based on prompt project and regional text description

By introducing prompt engineering and image text generation decoder into the target detection model, fine-grained features are extracted and text descriptions are generated, which solves the problem of reduced model performance and category attribute judgment caused by subdivision classification, and improves the accuracy of target detection in smart cities. and event judgment ability.

CN118609149AActive Publication Date: 2024-09-06CHENGDU ZHIHUI HENENG CITY TECHNOLOGY CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410648143.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-09-06
Estimated Expiration
2044-05-23

AI Technical Summary

Technical Problem

Existing target detection methods based on subdivisions lead to feature conflicts, resulting in reduced model performance, and are unable to provide attribute descriptions of target areas, and cannot effectively distinguish category attributes and event judgments in smart cities.

Method used

Design a target detection model with regional attribute description. By introducing hint engineering and image text generation decoder, fine-grained features of the detection target are extracted, and the Transformer structure is used for text description generation, combined with the adaptive regional feature extraction module and text generation. Decoding module to build a new target detection architecture.

Benefits of technology

It improves the average accuracy of target detection tasks, provides text descriptions of target areas, solves the problem of reduced model performance and category attribute judgment caused by subdivision, and enhances the ability to judge urban management events.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118609149A
    Figure CN118609149A
Patent Text Reader

Abstract

The invention discloses a target detection method and system based on prompt engineering and regional text description, and the method comprises the steps: constructing an annotated data set which comprises a plurality of annotated images; constructing a target detection model with region attribute description, wherein the target detection model with the region attribute description is a new model formed by adding an adaptive region feature extraction module and a text generation decoding module on the basis of an RTDetr model structure; based on the labeled data set, performing model training on the target detection model with the region attribute description to obtain a trained target detection model with the region attribute description; and obtaining a to-be-detected image, and performing target detection on the to-be-detected image by adopting the trained target detection model with the region attribute description to obtain a target prediction frame, a prediction category and the region attribute description. The problems that target detection fine classification affects model performance reduction and category attribute judgment are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target detection, and in particular to a target detection method and system based on prompt engineering and regional text description. Background Art

[0002] The smart city vehicle-mounted edge AI detection system realizes target detection through the target detection model. Usually, the edge device will use the CNN-based YOLO series model or the Transformer-based end-to-end target detection DETR series model to realize the detection of city-related objects with the help of sub-classification data, and use its corresponding category or add some logic to judge the event. It is difficult to solve the two types of problems of smart city category attribute distinction by relying only on a large amount of data and a single target detection model: first, the sub-classification conflict problem, which is manifested as a category conflict with extremely similar features (such as sedans and large sedans SUVs), resulting in reduced model accuracy and even missed detection; second, the category attribute event problem, the detection model can only give the category without additional attribute prompts, such as the detection model cannot distinguish whether the car category is parked on the sidewalk or lane, and still cannot distinguish the city management event (sidewalk and lane cars are different events). Of course, the existing methods also use multiple identical target detection models, each target detection model is responsible for a certain number of category detections, and relies on scene logic combination to realize urban management sub-classification and event judgment. This can improve the performance of the detection model to a certain extent, but it cannot fundamentally solve the problem of urban management, but instead increases the resource consumption of edge devices. At the same time, existing methods use detailed classification for target detection, which causes model feature conflicts and insufficient feature expression, loss of model performance, and lack of text-related descriptions, making it impossible to judge urban management events for category-attached attributes.

[0003] Therefore, the smart city vehicle-mounted edge AI detection system relies on a large amount of data and subdivided categories, uses a single or multiple identical target detection models, and relies on scene logic combination to achieve smart city object category and event judgment. However, the above existing target detection methods are based on subdivision, which will lead to feature conflicts and thus reduce model performance, and cannot provide category attribute assignment for urban management event judgment. Summary of the invention

[0004] The technical problem to be solved by the present invention is that the existing target detection method based on fine classification will lead to feature conflicts and thus reduce the model performance, and cannot provide the problem of target area attribute description judgment. The purpose of the present invention is to provide a target detection method and system based on prompt engineering and regional text description. The present invention focuses on designing a new architecture of a target detection model: a target detection model with regional attribute description, specifically introducing prompt engineering prompt and image text generation decoder decoder into the existing target detection model, with the help of prompt engineering prompt, the prediction box obtained by the existing detection model is embedded and encoded as a precise feature extraction query vector Q, the features extracted by the existing detection model are used as key vectors K and numerical vectors V, and the fine-grained features of the detection target area are extracted, and then the fine-grained features are used to obtain the corresponding prediction box target attribute text description using the image text generation decoder decoder. The present invention solves the problem that the target detection fine classification affects the performance degradation of the model and the regional attribute judgment.

[0005] The present invention is achieved through the following technical solutions:

[0006] In a first aspect, the present invention provides a target detection method based on prompt engineering and regional text description, the method comprising:

[0007] Construct a labeled data set, which includes multiple labeled image target detection annotations and labeled image target area text descriptions; the labeled image target detection annotations are based on scene target detection category annotations and position annotations, and category annotations are based on superclass (i.e., major categories) for annotation; the labeled image target area text description is a short text description of the area corresponding to the detection target, including a regional category attribute text description and a regional event attribute text description, which are integrated to construct a text description; the regional category attribute text description is a subdivided subclass content description of the corresponding detection target area superclass; the regional event attribute text description is a content description of the corresponding detection target area event;

[0008] Constructing a target detection model with regional attribute description. The target detection model with regional attribute description is a new model with a text description branch structure by adding an adaptive regional feature extraction module and a text generation decoding module without changing the RTDetr detection model structure.

[0009] Based on the labeled data set, the RTDetr detection model is trained for detection tasks using the labeled image target detection annotations as the first stage model training; the target detection model with regional attribute description is trained for regional short text description tasks using the labeled image target region text descriptions as the second stage model training, where the second stage RTDetr detection model uses the weights obtained from the first stage training and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute descriptions;

[0010] Obtain the image to be detected, use the trained target detection model with regional attribute description to perform target detection on the image to be detected, and obtain the target prediction box, prediction category and regional attribute description.

[0011] Furthermore, the superclass is to merge the subcategories with high feature similarity into one large category.

[0012] Furthermore, the target detection model with regional attribute description is based on the RTDetr model, and the added adaptive regional feature extraction module APF, the text generation decoding module TGD and the RTDetr model are integrated to construct a new model for regional description target detection based on prompt engineering prompt and image description caption;

[0013] The adaptive regional feature extraction module APF converts the regional coordinate information of the target prediction box into a vector expression based on the features extracted by the backbone network module (backbone) in the RTDetr model and the target prediction box output by the prediction module (Head). It further extracts the features of the RTDetr model according to the vector expression to obtain the regional related feature expression.

[0014] The text generation and decoding module TGD uses the Transformer structure to decode the region-related feature expressions based on the region-related feature expressions to obtain the region attribute description.

[0015] Furthermore, the regional coordinate information of the target prediction box is converted into a vector expression, and the features of the RTDetr model are further extracted according to the vector expression to obtain the regional related feature expression, including:

[0016] Based on the prompt engineering prompt, the regional coordinate information of the target prediction box is converted into a vector expression X b ;

[0017] Express the vector X b As the query vector Q of the Transformer structure, the features of the RTDetr model are used as the key vector K and the numerical vector V of the Transformer structure; the Transformer structure is used to first express the vector X bThe self-attention mechanism is encoded, and then the features of the RTDetr model are encoded using the cross-attention mechanism. The FFN structure is then repeated n times to achieve region-related feature expression extraction.

[0018] Furthermore, the extracted region-related feature expression formula is:

[0019] F p =f n f ca (f sa (F t ,X b ))

[0020] Among them, f sa represents the self-attention mechanism structure, f ca represents the cross attention mechanism structure, f n is the FFN structure, F t is the characteristic of RTDetr model, X b The region coordinate information of the target prediction box is converted into a vector expression.

[0021] Furthermore, the region attribute description is based on the text attribute data of the prediction box.

[0022] Further, based on the labeled data set, the labeled image target detection annotation is used to perform the first stage model training on the RTDetr detection model; the labeled image target region text description is used to perform the second stage model training on the target detection model with regional attribute description, wherein the second stage RTDetrr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description, including:

[0023] The first training stage: Based on the super-class data, the RTDetr model is trained to obtain the predicted category and box prediction task of the RTDetr model, and the weight W of the RTDetr model is saved. r ; The superclass data does not contain the corresponding event attribute data description;

[0024] Second training stage: The weight W saved in the first stage training r Assign the corresponding weights to the target detection model with regional attribute description, and freeze its corresponding RTDetr model structure; train the target detection model with regional attribute description based on the labeled data set and only train the adaptive regional feature extraction module APF and the text generation decoding module TGD, update the weights of the adaptive regional feature extraction module APF and the text generation decoding module TGD, so as to maintain the target detection capability of the original RTDetr model and obtain the regional attribute description;

[0025] After the training is completed, the optimal weight of the target detection model with regional attribute description is saved to obtain the trained target detection model with regional attribute description.

[0026] In a second aspect, the present invention further provides a target detection system based on prompt engineering and regional text description, the system using the above-mentioned target detection method based on prompt engineering and regional text description; the system comprises:

[0027] A data set construction unit is used to construct a labeled data set, wherein the labeled data set includes a plurality of labeled image target detection annotations and labeled image target area text descriptions; the labeled image target detection annotations are detection category annotations and position annotations based on scene targets, and the category annotations are annotated based on superclasses; the labeled image target area text descriptions are short text descriptions of the area corresponding to the detection target, including area category attribute text descriptions and area event attribute text descriptions; the area category attribute text descriptions are subdivided subclass content descriptions of the corresponding detection target area superclass; the area event attribute text descriptions are content descriptions of the corresponding detection target area events;

[0028] A model building unit, used for building a target detection model with regional attribute description, wherein the target detection model with regional attribute description is a new model with a text description branch structure by adding an adaptive regional feature extraction module APF and a text generation decoding module TGD on the basis of not changing the RTDetr detection model structure;

[0029] A model training unit is used to perform detection task training on the RTDetr detection model based on the labeled data set using the labeled image target detection annotations as the first stage model training; and perform regional short text description task training on the target detection model with regional attribute description using the labeled image target region text description as the second stage model training, wherein the second stage RTDetrr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description;

[0030] The target detection unit is used to obtain the image to be detected, use the trained target detection model with regional attribute description to perform target detection on the image to be detected, and obtain the target prediction box, prediction category and regional attribute description.

[0031] Furthermore, the target detection model with regional attribute description is based on the RTDetr model, and the added adaptive regional feature extraction module APF, the text generation decoding module TGD and the RTDetr model are integrated to construct a new model for regional description target detection based on prompt engineering prompt and image description caption;

[0032] The adaptive regional feature extraction module APF is used to convert the regional coordinate information of the target prediction box into a vector expression based on the features extracted by the backbone network module (backbone) in the RTDetr model and the target prediction box output by the prediction module (Head), and further extract the features of the RTDetr model based on the vector expression to obtain the regional related feature expression;

[0033] The text generation and decoding module TGD is used to decode the region-related feature expressions using the Transformer structure to obtain the region attribute description.

[0034] In a third aspect, the present invention further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned target detection method based on prompt engineering and regional text description is implemented.

[0035] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0036] 1. The present invention is based on a target detection method and system based on prompt engineering and regional text description. The present invention focuses on designing a new architecture of a target detection model: a target detection model with regional attribute description; the present invention introduces prompt engineering prompt and image text generation decoder decoder into the existing target detection model, and embeds the prediction box obtained by the existing detection model with the help of prompt engineering prompt as an accurate feature extraction query vector Q. The features extracted by the existing detection model are used as key vectors K and numerical vectors V to extract the fine-grained features Fc of the detection target, and then the fine-grained features Fc are used to obtain the corresponding prediction box target attribute text description using the image text generation decoder decoder. The present invention solves the problem that the sub-classification of target detection affects the performance reduction of the model and the judgment of category attributes.

[0037] 2. The object detection method and system based on prompt engineering and regional text description of the present invention is divided into two stages for the training of the object detection model PG-RTDetr with regional attribute description. The first training stage is to train the RTDetr model based on superclass data; the second training stage is to train the weights W saved in the first stage training. rAssign the corresponding weights to the PG-RTDetr model and freeze the corresponding RTDetr model structure; then train the PG-RTDetr model based on the labeled data set and only train the adaptive regional feature extraction module APF and the text generation decoding module TGD. The above training strategy not only enhances the target detection task capability of the original RTDetr model, but also adds additional text descriptions of the target area, effectively improving the mean average accuracy (mAP) of the target detection task, and also provides the description content of the target area, effectively solving the problems of sub-classification and event judgment. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The drawings described herein are used to provide a further understanding of the embodiments of the present invention, constitute a part of this application, and do not constitute a limitation of the embodiments of the present invention. In the drawings:

[0039] Figure 1 It is a flow chart of the target detection method based on prompt engineering and regional text description of the present invention;

[0040] Figure 2 This is a schematic diagram of the Transformer structure of the present invention;

[0041] Figure 3 A schematic diagram of the structure of the target detection model with regional attribute description of the present invention;

[0042] Figure 4 A schematic diagram of a target detection model structure training mode with regional attribute description of the present invention;

[0043] Figure 5 A schematic diagram of a structural reasoning mode of an object detection model with regional attribute description of the present invention;

[0044] Figure 6 This is a schematic diagram of target area detection in Example 1 of the present invention;

[0045] Figure 7 This is a structural block diagram of the target detection system based on prompt engineering and regional text description of the present invention. DETAILED DESCRIPTION

[0046] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.

[0047] At present, the smart city vehicle-mounted edge AI detection system relies on a large amount of data and subdivided categories, uses a single or multiple identical target detection models, and relies on scene logic combination to realize smart city object category and event judgment. However, the existing target detection method based on subdivided classification will lead to feature conflicts and thus reduce model performance, and cannot provide category attribute assignment for urban management event judgment.

[0048] Based on the above problems, in order to solve the problem that target detection subclassification will cause feature conflicts and thus affect the degradation of model performance and the problem of target area attribute description judgment, the basic existing methods do not provide a target detection model with regional text description, let alone an end-to-end detection model that reduces resources. Therefore, the present invention designs and constructs a target detection model with regional attribute description.

[0049] How to build such a model? We face two problems. First, how to extract regional features in the target detection model? To solve this problem, the present invention proposes a target region fine-grained feature module (APF) structure. Second, how to implement text description attributes for regional features? To solve this problem, the present invention proposes a target feature attribute description module (TGD) structure to build a new model architecture for regional attributes.

[0050] The specific design idea is: the present invention does not consider the introduction of a text model with a larger number of parameters (BERT), nor does it consider the use of a multimodal structure model (CLIP). The present invention considers the use of image description (image caption) content to achieve target region attribute description. However, the image description model will only describe the entire image content and cannot accurately achieve regional target region attribute description (corresponding to the target region). Based on this, the present invention draws on the prompt project (prompt) of the Segment Everything Model (SAM) feature. The project includes point, box, and text prompts to segment the target. Similar to our detection box, we directly draw on the embedding method of the box to complete the target region feature extraction, as an image description encoding feature expression, and then use the text decoding of the image description to achieve regional target attribute description. At the same time, the target region fine-grained feature module (APF) and the target feature attribute description module (TGD) both need to use the Transformer structure to achieve regional feature extraction and text description respectively. We naturally introduce the Transformer structure detection model to achieve a new architecture model for regional attribute description. Finally, the present invention takes the RTDetr target detection model as the baseline, introduces the target area fine-grained feature module (APF) and the target feature attribute description module (TGD), and constructs a target detection model with regional attribute description (PG-RTDetr model), which effectively solves the problem of model performance and regional attribute judgment in urban management events.

[0051] Example 1

[0052] like Figure 1 As shown, the target detection method based on prompt engineering and regional text description of the present invention relies on the following hardware parts: (1) high-definition camera, parameters: 2 million pixel (1920*1080) high-definition camera, the distance between the deployment detection area and the camera is less than 10 meters and greater than 1 meter, and IPX6 waterproof.

[0053] (2) Computing platform, parameters: Nvidia NX, TX edge computing device, memory and video memory of not less than 4G, processor frequency of not less than 2.3GHz.

[0054] The method of the present invention comprises:

[0055] Step 1, construct a labeled data set, the labeled data set includes multiple labeled image target detection annotations and labeled image target area text descriptions; the labeled image target detection annotations are detection category annotations and position annotations based on scene targets, and category annotations are annotated based on superclasses (i.e., major categories); the labeled image target area text description is a short text description of the area corresponding to the detection target, including a regional category attribute text description and a regional event attribute text description, which are integrated to construct a text description; the regional category attribute text description is a subdivided subclass content description of the corresponding detection target area superclass; the regional event attribute text description is a content description of the corresponding detection target area event; for example, the superclass description is a car, the regional event attribute text description is a sidewalk, and the constructed text description is a sidewalk car;

[0056] Step 2, constructing a target detection model with regional attribute description. The target detection model with regional attribute description is a new model with a text description branch structure that is constructed by adding an adaptive regional feature extraction module and a text generation decoding module without changing the RTDetr detection model structure;

[0057] Step 3: Based on the labeled data set, the labeled image target detection annotation is used to train the RTDetr detection model for detection tasks as the first stage model training; the labeled image target region text description is used to train the target detection model with regional attribute description for regional short text description tasks as the second stage model training, wherein the second stage RTDetrr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description;

[0058] Step 4: Obtain the image to be detected, use the trained target detection model with regional attribute description to perform target detection on the image to be detected, and obtain the target prediction box, prediction category and regional attribute description.

[0059] The target detection model PG-RTDetr with regional attribute description constructed by the present invention solves the problem of reduced model performance and urban management event judgment caused by fine classification. The model can realize fine classification detection tasks and urban management event judgment tasks in the mobile scene of the vehicle-mounted edge terminal device and the arm edge computing platform. The present invention proposes to integrate the prompt method of regional precise feature extraction and feature text generation method based on the existing target detection model RTDetr to construct a detection model PG-RTDetr with regional (category) attribute description. The present invention improves the existing target detection model structure and proposes a new architecture for target detection with regional description. The improved part of the structure mainly includes two parts. The first part is the adaptive regional feature extraction module APF, which is composed of the prompt conversion of the prediction box and multiple Transformer structures; the second part is the text generation decoding module TGD, which is also composed of multiple Transformers. Next, the present invention will introduce the basic structure of Transformer, the overall architecture of the PG-RTDetr model, the APF feature extraction structure, the TGD text generation structure, the loss loss structure and other technical details.

[0060] (1) Transformer basic structure

[0061] The present invention uses the prompt of the prediction box as the query vector Q (query) to further encode the encoder to extract the precise features of the region using the Transformer structure. The text generation encoding decoder also uses the description caption as the query and uses the Transformer structure to realize text description content generation (region attribute description).

[0062] The existing Transformer structure comes from Ashish Vaswani et al., who proposed that attention is all you need. The model proposed an encoder-decoder structure such as Figure 2 As shown, the underlying structure uses Transformer and neural network structure (FFN structure).

[0063] The Transformer structure consists of three input representation vectors (query vector Q, key vector K, and numerical vector V). The query vector Q, key vector K, and numerical vector V are implemented using conventional linear convolution. Finally, the following formula can be used to implement the transformer structure. The calculation formula is as follows:

[0064]

[0065] Among them, d k Represents the feature expression dimension.

[0066] The FFN structure consists of two linear convolutions and a ReLU activation function, and its calculation formula is as follows:

[0067] FFN(x)=max(0,xW+b)W2+b2(2)

[0068] Among them, x is the input feature, W1 is the one-dimensional convolution kernel weight, b1 is the one-dimensional convolution corresponding bias, b2 is the one-dimensional convolution kernel weight, and w2 is the one-dimensional convolution corresponding bias.

[0069] (2) PG-RTDetr architecture of target detection model with regional attribute description

[0070] The target detection model PG-RTDetr (such as Figure 3 ), the PG-RTDetr model is based on the RTDetr model, and integrates the added adaptive regional feature extraction module APF, the text generation decoding module TGD and the RTDetr model to construct a new model PG-RTDetr for regional description target detection based on prompt engineering prompt and image description caption.

[0071] The PG-RTDetr model of the present invention maintains the original target detection structure RTDetr (such as Figure 3 Yellow part); add adaptive feature extraction module (such as Figure 3 blue part); use prompt engineering prompt to process RTDetr features, further refine regional feature extraction Fp, and also add text generation decoding module (such as Figure 3 Green part), using the superposition decoding structure to process Fp, to achieve text generation description Hc. In this way, the model proposed by the present invention can not only improve the detection ability of the original RTDetr model, but also provide attribute description for the region (category) to solve the problem of urban management sub-classification and event.

[0072] During the training phase, Figure 4 As shown in the figure, the training strategy adopted by the present invention for the model, and its experiments show that our training strategy can effectively improve the mean average accuracy (mAP) of the detection model. The present invention first trains the original RTDetr model with super-class data (merging subdivided categories with high feature similarity into one large category, such as merging sedans and large sedans SUV into cars), obtains the category prediction and prediction box prediction tasks of the detection model, and uses the loss loss of the original RTDetr model to implement training. Then freeze the entire RTDetr detection model (such as Figure 3The yellow part) trains the adaptive regional feature extraction module APF and the text generation decoding module TGD, and uses the Hc description output to perform cross entropy loss with the text attribute description of the annotated text gt (such as the lane car). Figure 5 ), the PG-RTDetr model maintains the original RTDetr prediction task and realizes the prediction task of target category and regional prediction box. The adaptive regional feature extraction module APF and the text generation decoding module TGD use the features of RTDetr to further process and realize the description of the prediction box area attributes.

[0073] Specifically, the adaptive regional feature extraction module APF is mainly based on the features extracted by the backbone network module (backbone) in the RTDetr model and the target prediction box output by the prediction module (Head), converts the regional coordinate information of the target prediction box into a vector expression, and further extracts the Ft feature of the RTDetr model based on the vector expression to obtain the regional related feature expression Fp. This module mainly consists of two parts. The first is to convert the prompt project of the prediction box into a query vector Q (query), mainly using the prompt method of the SAM model prediction box; the second is to build an n-layer feature extraction encoding module based on Transformer.

[0074] First, the prompt encoding of the prediction box:

[0075] Based on the prompt engineering prompt, the prompt method of the SAM model prediction box is used to convert the coordinates of the regional prediction box [x1, y1, x2, y2] into a d-dimensional vector expression X b ; It can be expressed as the following formula:

[0076] X b =f([x1,y1,x2,y2])(3)

[0077] Among them, the f() function uses the SAM model to draw on the calculation method proposed by Matthew Tancik and others.

[0078] Second, Prompt adaptive feature encoding:

[0079] The present invention expresses the vector X b As the query vector Q of the Transformer structure, the features of the RTDetr model are used as the key vector K and the numerical vector V of the Transformer structure; the Transformer structure is used to first express the vector X bPerform self-attention encoding, then perform cross-attention encoding on the features of the RTDetr model, and then use the FFN structure to repeat n times to extract the regional related feature expression. The expression formula for the extracted regional related features is:

[0080] F p =f n f ca (f sa (F t ,X b ))(4)

[0081] Among them, f sa represents the self-attention mechanism structure, f ca represents the cross attention mechanism structure, f n is the FFN structure, F t is the characteristic of RTDetr model, X b The region coordinate information of the target prediction box is converted into a vector expression.

[0082] Specifically, the text generation and decoding module TGD is mainly based on the region-related feature expression obtained by the adaptive region feature extraction module APF, and also uses the Transformer structure to decode the region-related feature expression to obtain the region attribute description.

[0083] The text generation decoding module TGD also uses formula (4) for decoding, using a linear convolution to obtain the vocabulary corresponding to the vocabulary description. In the training stage, the input of the text generation decoding module TGD is F p The text tag token is used to calculate the text loss using cross entropy. In the prediction stage, the text generation decoding module TGD input is F p With the starting vocabulary cls as the text label token, the model is used to predict each word one by one and superimposed as the new text label token input to obtain the final region description text.

[0084] like Figure 6 As shown, an example of target area detection is given below:

[0085] Assumptions: ①, feature-similar subcategories have been merged into supercategories (such as sedans and large bridge vehicles SUVs are merged into cars); ②, text attribute data of existing regions or categories; ③, the RTDetr model has been trained using images and corresponding labels; ④, only the APF and TGD modules need to be trained, which are the structures added by the present invention.

[0086] Specific process:

[0087] ①, Freeze RTDetr model weights (such as Figure 6 Green box), the trained RTDetr model can be used to predict the superclass car and the corresponding position prediction box (4 coordinate points), which are called the predicted category pred_class and the predicted box pred_box;

[0088] ② The predicted box pred_box coordinates are sent to the adaptive regional feature extraction module APF to be converted into the embedding of the prompt engineering prompt, and the embedding is used as the query vector (query). The above Transformer structure is used to further extract more region-related features from the Ft feature, called Fp;

[0089] ③. The obtained Fp features are passed through the text generation and decoding module TGD to decode the Fp features into simple description content, that is, the region or category text description;

[0090] ④. Describe the event or sub-classification by describing the lane car and RTDetr predicting the category car.

[0091] The description above is "lane car" and the predicted category is "car". Figure 6 The car is a "sedan parked in the lane". The present invention uses category attribute description to provide a method to solve the problem of feature conflict caused by sub-categories (regions) and reduce model performance (such as: sedans, SUVs); in addition, the use of category attributes provides a solution to the problem of category attributes assisting smart city event judgment.

[0092] As a further implementation, based on the labeled data set, the labeled image target detection annotation is used to perform the first stage model training on the RTDetr detection model; the labeled image target region text description is used to perform the second stage model training on the target detection model with regional attribute description, wherein the second stage RTDetrr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description, including:

[0093] The first training stage: Based on the super-class data, the RTDetr model is trained to obtain the predicted category and box prediction task of the RTDetr model, and the weight W of the RTDetr model is saved. r ; The superclass data does not contain the corresponding event attribute data description;

[0094] Second training stage: The weight W saved in the first stage training rAssign the corresponding weights to the target detection model with regional attribute description, and freeze its corresponding RTDetr model structure; train the target detection model with regional attribute description based on the labeled data set and only train the adaptive regional feature extraction module APF and the text generation decoding module TGD, update the weights of the adaptive regional feature extraction module APF and the text generation decoding module TGD, so as to maintain the target detection capability of the original RTDetr model and obtain the regional attribute description;

[0095] After the training is completed, the optimal weight of the target detection model with regional attribute description is saved to obtain the trained target detection model with regional attribute description.

[0096] The above technical solution adopts an inseparable two-stage training method. Through experiments, the new model of the present invention (PG-RTDetr architecture of target detection model with regional attribute description) is trained once to realize end-to-end detection task and regional attribute description task training. Here, the prediction box of prompt is changed to the real gt box. Affected by the loss of text description task, it does not have the outstanding effect of the two-stage training method of the present invention (first detection task training and then regional attribute text description task training). The present invention believes that this situation is affected by the branch task characteristics and the RTDetr detection task. In addition, we use the prediction box box trained in the first stage of RTDert in prompt to provide more information than the real box box, which helps the branch task to better provide feature information.

[0097] The present invention performs target detection in a smart city scenario, and the specific implementation is as follows:

[0098] 1. Construct regional (category) attribute description data, describe the data according to the urban scene and industry nature, and describe the super-class vehicle data: one is the feature class description (such as describing large sedans, SUVs and small sedans), and the other is the event attribute data description (such as describing lane cars and road vehicles);

[0099] 2. Construct the code of the adaptive regional feature extraction module APF and the text generation and decoding module TGD, and at the same time construct the code of the text loss module. Select the RTDetr target detection model as the baseline, integrate the APF module, TGD module and the base model to construct a new model PG-RTDetr for target detection based on prompt engineering and regional text description;

[0100] 3. Use superclass (large class with similar small classes merged) data without corresponding text description to train an original RTDetr object detection model and save its weight W r ;

[0101] 4. Save step 3 as W rAssign the corresponding weights to the PG-RTDetr model and freeze the corresponding RTDetr model structure (such as Figure 3 Yellow part);

[0102] 5. Use the data set constructed in step 1 (including attribute description) to train the PG-RTDetr model obtained in step 4, update the weights of the APF module and the TGD module, and achieve the original target detection capability and obtain the regional attribute description;

[0103] 6. After step 5 training, save the best weight W of PG-RTDetr best (including detection model, APF, TGD weight);

[0104] 7. Deploy the PG-RTDetr model to the arm edge device and load the weight W in step 6 best ;

[0105] 8. Perform smart city target detection and attribute description, combine urban management standards with model prediction categories and descriptions, and realize category task or event judgment content output.

[0106] The present invention uses the prediction box as a prompt engineering prompt on the basis of the existing target detection model RTDetr to obtain the precise feature expression of the prediction box area (also the corresponding category), and then uses a decoding structure similar to the description caption to obtain the precise features of the area to achieve regional attribute description. The new model PG-RTDetr of the present invention solves the problem of subclassification conflict and industry event judgment with brief attributes. The new model PG-RTDetr of the present invention uses the prompt engineering prompt to accurately extract features and integrate regional description modules to achieve detection and text description content. It can replace multiple models to achieve the same effect, reduce the edge arm device resources and reasoning time to a certain extent, and also provide ideas for integrating regional attributes into the detection model.

[0107] Example 2

[0108] like Figure 7 As shown, the difference between this embodiment and embodiment 1 is that this embodiment provides a target detection system based on prompt engineering and regional text description, and the system uses the target detection method based on prompt engineering and regional text description in embodiment 1; the system includes:

[0109] A data set construction unit is used to construct a labeled data set, wherein the labeled data set includes a plurality of labeled image target detection annotations and labeled image target area text descriptions; the labeled image target detection annotations are detection category annotations and position annotations based on scene targets, and the category annotations are annotated based on superclasses; the labeled image target area text descriptions are short text descriptions of the area corresponding to the detection target, including area category attribute text descriptions and area event attribute text descriptions; the area category attribute text descriptions are subdivided subclass content descriptions of the corresponding detection target area superclass; the area event attribute text descriptions are content descriptions of the corresponding detection target area events;

[0110] A model building unit, used for building a target detection model with regional attribute description, wherein the target detection model with regional attribute description is a new model with a text description branch structure by adding an adaptive regional feature extraction module APF and a text generation decoding module TGD on the basis of not changing the RTDetr detection model structure;

[0111] A model training unit is used to perform detection task training on the RTDetr detection model based on the labeled data set using the labeled image target detection annotations as the first stage model training; and perform regional short text description task training on the target detection model with regional attribute description using the labeled image target region text description as the second stage model training, wherein the second stage RTDetrr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description;

[0112] The target detection unit is used to obtain the image to be detected, use the trained target detection model with regional attribute description to perform target detection on the image to be detected, and obtain the target prediction box, prediction category and regional attribute description.

[0113] As a further implementation, the target detection model with regional attribute description is based on the RTDetr model, and the added adaptive regional feature extraction module APF, text generation decoding module TGD and RTDetr model are integrated to construct a new model PG-RTDetr for regional description target detection based on prompt engineering prompt and image description caption;

[0114] The adaptive regional feature extraction module APF is used to convert the regional coordinate information of the target prediction box into a vector expression based on the features extracted by the backbone network module (backbone) in the RTDetr model and the target prediction box output by the prediction module (Head), and further extract the features of the RTDetr model based on the vector expression to obtain the regional related feature expression;

[0115] The text generation and decoding module TGD is used to decode the region-related feature expressions using the Transformer structure to obtain the region attribute description.

[0116] Among them, the execution process of each unit can be executed according to the process steps of the target detection method based on prompt engineering and regional text description in Example 1, and will not be repeated one by one in this embodiment.

[0117] The present invention is based on a target detection method and system based on prompt engineering and regional text description. The present invention focuses on designing a new architecture of a target detection model: a target detection model with regional attribute description. The present invention introduces prompt engineering prompt and image text generation decoder decoder into the existing target detection model. With the help of prompt engineering prompt, the prediction box obtained by the existing detection model is embedded and encoded as a precise feature extraction query vector Q. The features extracted by the existing detection model are used as key vectors K and numerical vectors V to extract the fine-grained features Fc of the detection target, and then the fine-grained features Fc are used to obtain the corresponding prediction box target attribute text description using the image text generation decoder decoder. The present invention solves the problem of target detection sub-classification affecting the performance degradation of the model and the judgment of category attributes.

[0118] The present invention only adds a small amount of prompt encoder structure and text decoder structure to the original target detection model to realize local fine-grained feature extraction and brief attribute description of the prediction box. At the same time, the present invention integrates the subdivided categories with high feature similarity into a superclass at the data level, and does not change the target detection model structure, so as to improve the detection model performance. Finally, the present invention selects the RTDetr model as the target detection model benchmark, maintains the original RTDetr model detection structure, and adds the prompt engineering prompt method to accurately extract the target fine-grained feature module (i.e., the adaptive regional feature extraction module, called Adapter Prompter extract Feature, APF) and the target feature attribute description module (i.e., the text generation decoding module is called Text Generation Decoder, TGD), and integrates the APF, TGD module and the RTDetr model to propose a new target detection model (PG-RTDetr) with category (region) attribute description. The present invention aims to add a small amount of parameters to integrate the detection model, obtain category attributes, and realize category attribute assisted city detection tasks in the smart city edge vehicle-mounted AI system.

[0119] At the same time, the present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned target detection method based on prompt engineering and regional text description is implemented.

[0120] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.

[0121] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0122] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0123] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0124] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.

Claims

1. The object detection method based on prompt engineering and regional text description is characterized by: The method includes: Constructing a labeled data set, the labeled data set includes a plurality of labeled image target detection annotations and labeled image target region text descriptions; the labeled image target detection annotations are detection category annotations and position annotations based on scene targets, and the category annotations are annotated based on superclasses; the labeled image target region text descriptions are region short text descriptions corresponding to the detection target, including region category attribute text descriptions and region event attribute text descriptions; the region category attribute text descriptions are subdivided subclass content descriptions of the corresponding detection target region superclass; the region event attribute text descriptions are content descriptions of the corresponding detection target region events; Constructing a target detection model with regional attribute description, wherein the target detection model with regional attribute description is a new model with a text description branch structure by adding an adaptive regional feature extraction module and a text generation decoding module without changing the RTDetr detection model structure; Based on the labeled data set, the labeled image target detection annotation is used to perform detection task training on the RTDetr detection model as the first stage model training; the labeled image target region text description is used to perform regional short text description task training on the target detection model with regional attribute description as the second stage model training, wherein the second stage RTDetr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description; An image to be detected is obtained, and a trained target detection model with regional attribute description is used to perform target detection on the image to be detected, so as to obtain a target prediction box, a prediction category and a regional attribute description.

2. The target detection method based on prompt engineering and regional text description according to claim 1, characterized in that: The superclass is to merge subcategories with high feature similarity into one large category.

3. The object detection method based on prompt engineering and regional text description according to claim 1, characterized in that: The target detection model with regional attribute description is based on the RTDetr detection model, and the added adaptive regional feature extraction module, the text generation and decoding module and the RTDetr model are integrated to form a new model for regional description target detection based on prompt engineering and image description; The adaptive regional feature extraction module converts the regional coordinate information of the target prediction box into a vector expression based on the features extracted by the backbone network module in the RTDetr model and the target prediction box output by the prediction module, and further extracts the features of the RTDetr model according to the vector expression to obtain the regional related feature expression; The text generation and decoding module, based on the region-related feature expression, uses a Transformer structure to decode the region-related feature expression to obtain a region attribute description.

4. The target detection method based on prompt engineering and regional text description according to claim 3 is characterized in that: Converting the region coordinate information of the target prediction box into a vector expression, further extracting the features of the RTDetr model according to the vector expression, and obtaining the region-related feature expression, including: Based on the prompt engineering, the regional coordinate information of the target prediction box is converted into a vector expression; The vector expression is used as the query vector of the Transformer structure, and the features of the RTDetr model are used as the key vector and numerical vector of the Transformer structure; the Transformer structure is used to first encode the vector expression through a self-attention mechanism, and then the features of the RTDetr model are encoded through a cross-attention mechanism, and then the FFN structure is used to repeat n times to realize the extraction of region-related feature expressions.

5. The target detection method based on prompt engineering and regional text description according to claim 4 is characterized in that: The expression formula of the extracted regional related features is: F p =f n f ca (f sa (F t ,X b )) Among them, f sa represents the self-attention mechanism structure, f ca represents the cross attention mechanism structure, f n is the FFN structure, F t is the characteristic of the RTDetr model, X b The region coordinate information of the target prediction box is converted into a vector expression.

6. The object detection method based on prompt engineering and regional text description according to claim 3 is characterized in that: The region attribute description is based on text attribute data of the prediction box.

7. The object detection method based on prompt engineering and regional text description according to claim 1 is characterized in that: Based on the labeled data set, the first stage model training is performed on the RTDetr detection model using the labeled image target detection annotations; the second stage model training is performed on the target detection model with regional attribute description using the labeled image target region text description, wherein the second stage RTDetr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description, including: The first training stage: Based on the superclass data, the RTDetr model is trained to obtain the prediction category and prediction box task of the RTDetr model, and the weight W of the RTDetr model is saved. r ; The superclass data does not contain the corresponding event attribute data description; Second training stage: The weight W saved in the first stage training r Assigning corresponding weights to the target detection model with regional attribute description, and freezing its corresponding RTDetr model structure; training the target detection model with regional attribute description based on the labeled data set and only training the adaptive regional feature extraction module and the text generation decoding module, updating the weights of the adaptive regional feature extraction module and the text generation decoding module, so as to maintain the target detection capability of the original RTDetr model and obtain the regional attribute description; After the training is completed, the optimal weight of the target detection model with regional attribute description is saved to obtain a trained target detection model with regional attribute description.

8. Object detection system based on prompt engineering and regional text description, characterized in that: The system includes: A data set construction unit is used to construct a labeled data set, wherein the labeled data set includes a plurality of labeled image target detection annotations and labeled image target area text descriptions; the labeled image target detection annotations are detection category annotations and position annotations based on scene targets, and the category annotations are annotated based on superclasses; the labeled image target area text descriptions are short text descriptions of the area corresponding to the detection target, including area category attribute text descriptions and area event attribute text descriptions; the area category attribute text descriptions are subdivided subclass content descriptions of the corresponding detection target area superclass; the area event attribute text descriptions are content descriptions of the corresponding detection target area events; A model building unit, used to build a target detection model with regional attribute description, wherein the target detection model with regional attribute description is a new model with a text description branch structure by adding an adaptive regional feature extraction module and a text generation decoding module on the basis of not changing the RTDetr detection model structure; A model training unit is used to perform detection task training on the RTDetr detection model based on the labeled data set using the labeled image target detection annotations as the first stage model training; and perform regional short text description task training on the target detection model with regional attribute description using the labeled image target region text description as the second stage model training, wherein the second stage RTDetrr detection model uses the weights obtained by the first stage training, and freezes the RTDetr detection model structure to obtain a trained target detection model with regional attribute description; The target detection unit is used to obtain an image to be detected, use a trained target detection model with regional attribute description to perform target detection on the image to be detected, and obtain a target prediction box, a prediction category and a regional attribute description.

9. The object detection system based on prompt engineering and regional text description according to claim 8, characterized in that: The target detection model with regional attribute description is based on the RTDetr model, and the added adaptive regional feature extraction module, the text generation and decoding module and the RTDetr model are integrated to form a new model for regional description target detection based on prompt engineering and image description; The adaptive regional feature extraction module is used to convert the regional coordinate information of the target prediction box into a vector expression according to the features extracted by the backbone network module in the RTDetr model and the target prediction box output by the prediction module, and further extract the features of the RTDetr model according to the vector expression to obtain the regional related feature expression; The text generation and decoding module is used to decode the region-related feature expression using a Transformer structure according to the region-related feature expression to obtain a region attribute description.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the target detection method based on prompt engineering and regional text description as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Cross-modal knowledge-guided small sample neural network target detection method

    CN116051943A

  • Multi-scale crack segmentation method based on Transform network

    CN117593521A

  • Improved chip multi-defect detection method and system based on fusion of SwinIR and RT-DETR

    CN117934420A

  • Open vocabulary target detection method, system and device and medium

    CN118673465A

  • Target detection model training method and apparatus, and target detection method and apparatus

    WO2023116507A1