A method and system for identifying features in two-dimensional engineering drawings based on dynamic query-guided consistent projection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BEIJING INST OF ARCHITECTURAL DESIGN
- Filing Date
- 2025-12-26
- Publication Date
- 2026-05-26
Smart Images

Figure CN122090480A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and artificial intelligence, and in particular to a method and system for identifying two-dimensional engineering drawing elements based on dynamic query-guided consistency projection. This method combines a dynamic query mechanism, dynamic context generation, and consistency diffusion model to achieve efficient and accurate identification of drawing elements in a single sampling. Background Technology
[0002] Automated identification of drawing elements is a key component of digital processes in the architecture, engineering, and manufacturing (AEC) industry. The challenge of identification tasks lies in the fact that engineering drawings contain a wide variety of elements, which vary greatly in scale, have high similarity in appearance, are densely arranged, and often overlap.
[0003] Generative detection methods based on diffusion models have been proposed in recent years, treating feature detection as a reverse generation process from noise to a deterministic state. These methods demonstrate good performance in handling uncertain scenarios such as blurriness and occlusion. However, their main bottleneck in practical applications lies in inference speed. Standard diffusion models require hundreds to thousands of iterative sampling steps to obtain high-quality output, making them unsuitable for applications with high real-time requirements.
[0004] To accelerate the inference process of diffusion models, researchers have proposed one-step or few-step sampling techniques, such as progressive distillation or the construction of consistency models. These techniques aim to train a neural network capable of directly mapping from noise to a final, clear result. However, current one-step generative models typically employ a statically structured network (such as U-Net) as its core functional unit. This means that regardless of the noise state or image content of the input, the model uses the same fixed set of parameters to perform the mapping from noise to result. For drawing feature recognition tasks requiring fine discrimination and contextual understanding, this static inference path limits the model's adaptability and the final achievable accuracy. It cannot simulate the analytical process of human experts dynamically adjusting subsequent points of interest based on initial observations.
[0005] In addition, while dynamic query-based detection models (such as DETR and its variants) introduce query adaptability, their cross-attention modules in the decoder typically operate on a statically encoded image context (fixed key and value), limiting the model's flexibility in utilizing image features at different inference stages.
[0006] Therefore, how to effectively combine the adaptability of dynamic queries with the efficiency and theoretical advantages of one-step generative models is a technical problem with significant research value and application prospects.
[0007] The information disclosed in this background section is intended only to enhance the understanding of the general background of the invention and should not be construed as an admission or in any way implying that the information constitutes prior art known to those skilled in the art. Summary of the Invention
[0008] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a method and system for identifying two-dimensional engineering drawing elements based on dynamic query-guided consistent projection. This aims to achieve recognition quality comparable to multi-step diffusion models while maintaining the inference efficiency of a single forward propagation. Its core is the deep integration of dynamic querying, dynamic context generation, and consistent model theory.
[0009] To achieve the above objectives, the present invention adopts the following technical solution:
[0010] This invention provides a method for identifying features in two-dimensional engineering drawings based on dynamic query-guided consistent projection, including acquiring an image of the drawing to be identified and extracting an image feature map using a feature extraction network. Initialize one or more initial state vectors that follow a predetermined noise distribution. ; the initial state vector With the image feature map Both inputs are fed into a dynamically query-guided consistent projection decoder: DQ-CPD. Through a single forward propagation of this decoder, one or more predicted deterministic feature state vectors are directly output. The DQ-CPD consists of at least two cascaded refining layers, and its internal processing includes:
[0011] a. The dynamic query vector output from the previous layer As the current layer Input;
[0012] b. In the current layer In, based on the dynamic query vector The image feature map is dynamically generated by a hypernetic network controller. At least one set of context projection parameters, the parameters including key projection parameters Sum projection parameters ;
[0013] c. Using dynamically generated key projection parameters Sum projection parameters The image feature map Transformed into dynamic bond features specific to this layer. and dynamic value characteristics ;
[0014] d. Based on the dynamic query vector Generate query features and in the dynamic bond feature and dynamic value characteristics Above, perform a cross-attention operation to generate an updated dynamic query vector. ;
[0015] e. The dynamic query vector output by the last refining layer. The predicted deterministic feature state vector is obtained through an output transformation layer. .
[0016] Furthermore, the hypernetic controller in step b It is a multilayer perceptron, whose input is a dynamic query vector. The output is the context projection parameters, and this process is represented as:
[0017] ; This indicates that the nonlinear mapping function defined by the multilayer perceptron maps the input dynamic query vector to the parameters required to generate key and value features;
[0018] in, Includes the weight matrix of the linear projection layer used to generate key features. and bias vector , Includes the weight matrix of the linear projection layer used to generate value features. and bias vector .
[0019] Furthermore, the training process of the DQ-CPD is based on the consistency model theory, and its loss function is... The aim is to minimize the noise states at different time points on the same diffusion trajectory. and The difference between the outputs after the decoder is represented by the loss function in the following form:
[0020] ;
[0021] in, It is a function parameterized by the DQ-CPD, and its parameters are: ; Is with The structures are the same but the parameters are The teacher network function of exponential moving average; It is a distance metric function; It is the actual element state vector; It is noise sampled from a standard normal distribution; and These are two different time steps; and It is based on and At time step and The generated noise state; where, It is a set of indexes from a predefined discrete time step sequence. Integer indices from uniform sampling are used to determine two adjacent time points in the current training step. and ,in This represents the total number of discretization time steps.
[0022] Furthermore, the distance metric function The distance is selected from L1 distance or L2 distance; the L1 distance refers to the sum of the absolute values of the differences between corresponding elements of two vectors, and the L2 distance refers to the Euclidean norm or its square form of the differences between corresponding elements of two vectors.
[0023] Furthermore, the refining layer in step d Internally, before performing the cross-attention operation, the system includes a self-attention module, which is used to process a set of dynamic query vectors as input. To exchange information.
[0024] Furthermore, the initial state vector It is from a standard Gaussian distribution A random vector sampled from the middle, where It is an identity matrix.
[0025] Furthermore, the element state vector It contains one class component and one geometric component, denoted as , where category components Geometric components are represented by a vector derived from a learnable class embedding matrix. Represented by normalized bounding box coordinates.
[0026] A two-dimensional engineering drawing feature recognition system based on dynamic query-guided consistent projection includes: a feature extraction module configured to extract image feature maps from an input drawing image; and a dynamic query-guided consistent projection decoder (DQ-CPD) configured to receive a random noise vector and the image feature maps, and directly output a predicted feature state vector through a single forward propagation. The decoder internally includes: multiple cascaded refinement layers, each including a hypernetwork controller for dynamically generating context projection parameters based on the input query.
[0027] By adopting the above technical solution, the present invention has the following beneficial effects:
[0028] 1. High inference efficiency: The time-consuming multi-step iterative sampling process is compressed into a single network forward propagation, making real-time drawing recognition possible.
[0029] 2. Strong Adaptability: Through a dynamic key-value generation mechanism controlled by dynamic query, the model can adaptively adjust its feature extraction method for each element to be identified at each micro-stage of reasoning, significantly enhancing its ability to identify complex, multi-scale elements.
[0030] 3. Unified system framework: It integrates dynamic query, dynamic context and one-step generation theory into an end-to-end decoder architecture, avoiding the complexity of multi-stage training. Attached Figure Description
[0031] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0032] Figure 1 This is a flowchart of the method for identifying two-dimensional engineering drawing elements based on dynamic query-guided consistent projection provided in this application.
[0033] Figure 2 This is a schematic diagram of the internal structure of the Dynamic Query Guided Consistent Projection Decoder (DQ-CPD) provided in this application.
[0034] Figure 3 This is a system block diagram of the two-dimensional engineering drawing feature recognition system based on dynamic query-guided consistent projection provided in this application. Detailed Implementation
[0035] The technical solution of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0036] The specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0037] This application provides a method and system for identifying two-dimensional engineering drawing elements based on dynamic query-guided consistent projection. The technical solution of this invention can be summarized as follows:
[0038] 1) Consistency Model: This method constructs a consistency function. The goal of this function is to find any point on the diffusion process trajectory defined in the feature state space. (Given image features) Under the given conditions, all of them are mapped back to the starting point of the trajectory, i.e., the noise-free state of the real elements. The DQ-CPD network proposed in this invention That is, the consistency function. A neural network implementation.
[0039] 2) DQ-CPD Architecture: Macroscopic Single-Step, Microscopic Multi-Step. DQ-CPD manifests as a single decoder module at the external interface. During inference, it receives a set of random vectors sampled from a standard Gaussian distribution (representing...). (initial state of the hypothetical elements) and image features Through one forward propagation, the output is directly obtained. A predicted, deterministic vector of element states. Internally, it consists of... It consists of cascaded refinement layers, forming a microscopic, high-speed iterative processing flow that simulates the information refinement process from uncertainty to certainty.
[0040] 3) Dynamic querying serves as the inference controller and dynamic context generation. This is the core mechanism of this invention:
[0041] The initial random noise vector is used as the dynamic query for layer 0. .
[0042] In each refining layer ( In the input dynamic query vector It has a dual function:
[0043] Information carrier: It encodes all inferred information about a certain element up to the previous layer.
[0044] Inference controller: It is fed into a lightweight "contextualized hypernetwork". The hypernetwork is based on the query vector. The current state, providing real-time updates for the current layer. The cross-attention module generates custom context projection parameters. Specifically, these are the parameters used to generate the linear projection matrix of the key and value.
[0045] Using dynamically generated projection parameters, global image features Transform into key features tailored to the current query. Sum value characteristics .
[0046] by Generate queries based on this, in a dynamic manner. Perform cross-attention operations on top.
[0047] By using residual connections and feedforward networks, an updated and more refined query vector is obtained. .
[0048] This process allows the model to dynamically adjust its focus on the image based on the evolution of the query. For example, in the initial layer, the query is close to pure noise, and the hypernetwork... This might generate a set of K / V projection parameters that tend to extract global, low-frequency information. As the layer depth increases, the query may already contain preliminary information about the location or shape of features. It will generate a set of K / V projection parameters that are more focused on extracting high-frequency details such as local edges and corners.
[0049] 4) Training and Reasoning:
[0050] Training: A consistency model distillation training strategy is employed. In each training step, noise states at two different time points are sampled from the same diffusion trajectory. They are then fed into DQ-CPD (a process that uses the current weights). A teacher weight updated using momentum The training objective is to minimize the distance between the two outputs. This strategy forces the DQ-CPD to learn to project any point on the trajectory to the same deterministic endpoint.
[0051] Reasoning: The reasoning process is efficient. It involves sampling a set of random noise vectors. , with image features They are fed into the pre-trained DQ-CPD. After one forward propagation, the final element state prediction is obtained directly. .
[0052] Combination Figure 1-3 As shown, the detailed implementation process of the two-dimensional engineering drawing element recognition method and system based on dynamic query-guided consistent projection of the present invention is as follows:
[0053] S100: Feature Extraction and State Space Definition, 1) Feature Extraction: Input a drawing image Multi-scale feature maps are extracted using a convolutional neural network (CNN) backbone (e.g., ResNet-50) and a feature pyramid network (FPN). For simplicity, we select feature maps at one scale. As a condition for subsequent image processing. The height and width of the feature map, 1) Number of channels. 2) State space definition: Define a... A dimensional element state space. A vector in this space. A complete description of a feature instance. This vector can be formed by concatenating two parts:
[0054] .
[0055] in It is a category component, which is derived from a learnable category embedding matrix. The vector found in, where It represents the total number of element categories. These are geometric components, representing the normalized bounding box coordinates of the feature, such as (cx, cy, w, h), which represent the x-coordinate of the center point, the y-coordinate of the center point, the width, and the height, respectively.
[0056] S200: Training Phase: Learning based on uniform distillation. The goal of this phase is to learn the DQ-CPD network. parameters This process also maintains a parameter as follows: Teacher network .
[0057] 1. Definition of forward diffusion process: A process from real data... To noise The forward diffusion process is defined by the following equation:
[0058] ;
[0059] in, It is a continuous-time variable. It is a predefined, monotonically decreasing noise scheduling function from 1 to 0. It is an identity matrix.
[0060] 2. Training Loop: In each training iteration, perform the following steps:
[0061] a. Randomly sample a batch of real feature states from the training set. and their corresponding image features .
[0062] b. Randomly sample a time step index for this batch of data. ,in It represents the total number of discretization steps during training.
[0063] c. Schedule according to a preset time step (e.g., ), calculate two adjacent time points and .in and It's a hyperparameter.
[0064] d. From the standard normal distribution Sample a noise vector .
[0065] e. Generate noise samples at the two time points mentioned above:
[0066] ;
[0067] f. Input these two noise samples into the student network respectively. Teacher Network :
[0068] ;
[0069] g. Calculate consistency loss This loss function is designed to force the student network to... The prediction results are close to those of the teacher network. Prediction results:
[0070] ;
[0071] in, Denotes the square of the L2 norm. The operation blocks the gradient from flowing to the teacher network, ensuring that the teacher network's parameters are updated only through the exponential moving average (EMA).
[0072] h. Calculate the loss function with respect to the parameters using the backpropagation algorithm. The gradient is calculated, and the parameters of the student network are updated using an optimizer (such as AdamW). .
[0073] i. Update the parameters of the teacher network using an exponential moving average: .in It is the momentum coefficient, which is usually taken to be close to 1 (such as 0.999).
[0074] S300: Detailed Explanation of DQ-CPD Core Architecture and DQ-CPD Network Receive a group ( (Number) noise vectors and an image feature map As input, the output is a set of predicted clean state vectors. .
[0075] 1. Input embedding: The input noise state vector First, a linear layer is used to map the internal working dimension of the decoder. The initial dynamic query vector is obtained. .
[0076] 2. Refining Layer ( Each layer is based on the set of input query vectors. Processing and refining.
[0077] a. Self-Attention Module: To facilitate information exchange between different feature hypotheses (e.g., suppressing duplicate detection, utilizing relative positional relationships), a multi-head self-attention operation is first performed on the input query vector set:
[0078] ;
[0079] b. Contextualized Hypernetwork For each query vector output by the self-attention module Through a hypernet Generate its own context projection parameters. It is typically a small multilayer perceptron (MLP).
[0080] ;
[0081] in, This means flattening the matrix into a vector. and They are respectively the first The weights and biases of the key projection matrix dynamically generated by each query. and These are the corresponding projection parameters. and It is the dimension of keys and values.
[0082] c. Dynamic Cross-Attention Module:
[0083] 1) Query generation: Query vector The query vector is generated after passing through a fixed linear projection layer: ,in These are the learnable parameters shared by this layer.
[0084] 2) Dynamic Key / Value Generation: Using the dynamically generated parameters from step b, the global image feature map is generated. This transforms the data into dynamic keys and values relevant to the query. This operation is equivalent to performing an independent 1x1 convolution on each query: in Representing convolution operations, the reshape operation flattens the spatial dimensions into a sequence.
[0085] 3) Attention Calculation: Perform standard scaled dot product attention:
[0086] ;
[0087] d. Feed-Forward Network (FFN) and Updates: Updating the query vector via residual connections and the FFN: Finally, we obtain a more refined query vector output by this layer. .
[0088] 3. Output Projection: After passing through After layer refinement, the dynamic query vector output by the last layer It is fed into an output MLP, which is then processed from the working dimension. Mapping back to the element state space dimension :
[0089] ;
[0090] Received That is, for the first The final deterministic state prediction of each element.
[0091] S400: The reasoning process in the reasoning stage is greatly simplified, resulting in high timeliness.
[0092] 1. Obtain the drawing image to be recognized. Feature maps are obtained through a feature extraction network. .
[0093] 2. From the standard Gaussian distribution Medium sampling random vectors As the initial state.
[0094] 3. Perform a single forward propagation: .in This is the trained DQ-CPD network. 4. Regarding the output results... Perform decoding. For each prediction... By embedding a learnable category matrix The nearest neighbor search is used to determine its category, and then directly uses... As the coordinates of the predicted bounding box.
[0095] Through the above implementation methods, this application constructs a feature recognition framework that is highly efficient and accurate in terms of performance. It effectively solves the core contradictions in existing technologies by injecting the adaptive concept of dynamic querying into the one-step generated model framework and implementing it through a micro-level dynamic iterative refinement process.
[0096] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application, such as changes to the hypernetwork, are not permitted. The specific structure, the introduction of a dynamic parameter generation mechanism in FFN, or the application of this DQ-CPD framework to other computer vision tasks should all be included within the scope of protection of this application.
Claims
1. A method for identifying features in two-dimensional engineering drawings based on dynamic query-guided consistent projection, characterized in that, This includes acquiring the image of the drawing to be identified and using a feature extraction network to extract an image feature map. Initialize one or more initial state vectors that follow a predetermined noise distribution. ; the initial state vector With the image feature map Both inputs are fed into a dynamically query-guided consistent projection decoder: DQ-CPD. Through a single forward propagation of this decoder, one or more predicted deterministic feature state vectors are directly output. The DQ-CPD consists of at least two cascaded refining layers, and its internal processing includes: a. The dynamic query vector output from the previous layer As the current layer Input; b. In the current layer In, based on the dynamic query vector The image feature map is dynamically generated by a hypernetic network controller. At least one set of context projection parameters, the parameters including key projection parameters Sum projection parameters ; c. Using dynamically generated key projection parameters Sum projection parameters The image feature map Transformed into dynamic bond features specific to this layer. and dynamic value characteristics ; d. Based on the dynamic query vector Generate query features and in the dynamic bond feature and dynamic value characteristics Above, perform a cross-attention operation to generate an updated dynamic query vector. ; e. The dynamic query vector output by the last refining layer. The predicted deterministic feature state vector is obtained through an output transformation layer. .
2. The method for identifying elements in two-dimensional engineering drawings according to claim 1, characterized in that, Hypernet controller in step b It is a multilayer perceptron, whose input is a dynamic query vector. The output is the context projection parameters, and this process is represented as: ; This indicates that the nonlinear mapping function defined by the multilayer perceptron maps the input dynamic query vector to the parameters required to generate key and value features; in, Includes the weight matrix of the linear projection layer used to generate key features. and bias vector , Includes the weight matrix of the linear projection layer used to generate value features. and bias vector .
3. The method for identifying elements in two-dimensional engineering drawings according to claim 1, characterized in that, The training process of the DQ-CPD is based on the consistency model theory, and its loss function is... The aim is to minimize the noise states at different time points on the same diffusion trajectory. and The difference between the outputs after the decoder is represented by the loss function in the following form: ; in, It is a function parameterized by the DQ-CPD, and its parameters are: ; Is with The structures are the same but the parameters are The teacher network function of exponential moving average; It is a distance metric function; It is the actual element state vector; It is noise sampled from a standard normal distribution; and These are two different time steps; and It is based on and At time step and The generated noise state; where, It is a set of indexes from a predefined discrete time step sequence. Integer indices from uniform sampling are used to determine two adjacent time points in the current training step. and ,in This represents the total number of discretization time steps.
4. The method for identifying elements in two-dimensional engineering drawings according to claim 3, characterized in that, The distance metric function The distance is selected from L1 distance or L2 distance; the L1 distance refers to the sum of the absolute values of the differences between corresponding elements of two vectors, and the L2 distance refers to the Euclidean norm or its square form of the differences between corresponding elements of two vectors.
5. The method for identifying elements in two-dimensional engineering drawings according to claim 1, characterized in that, Refining layer in step d Internally, before performing the cross-attention operation, the system includes a self-attention module, which is used to process a set of dynamic query vectors as input. To exchange information.
6. The method for identifying elements in two-dimensional engineering drawings according to claim 1, characterized in that, The initial state vector It is from a standard Gaussian distribution A random vector sampled from the middle, where It is an identity matrix.
7. The method for identifying elements in two-dimensional engineering drawings according to claim 1, characterized in that, Element state vector It contains one class component and one geometric component, denoted as , where category components Geometric components are represented by a vector derived from a learnable class embedding matrix. Represented by normalized bounding box coordinates.
8. A system for identifying two-dimensional engineering drawing elements based on dynamic query-guided consistent projection as described in any one of claims 1-7, characterized in that, include: The feature extraction module is configured to extract image feature maps from the input drawing image; A Dynamic Query Guided Consistent Projection Decoder (DQ-CPD) configured to receive a random noise vector and the image feature map, and to directly output a predicted feature state vector via a single forward propagation as described in any one of claims 1 to 7, wherein the decoder internally comprises: multiple cascaded refinement layers, each including a hypernetwork controller for dynamically generating context projection parameters based on the input query.