CAD model generation method and device, storage medium and electronic equipment
Through the forward and reverse diffusion subnet processing of the diffusion model, a diversified CAD model under partial constraints is generated, which solves the problem of difficult to control the CAD model type, size and position relationship in the prior art, and realizes that under specified conditions efficient CAD model generation.
Patent Information
- Application Number
- CN202411353436.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-27
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing CAD model generation methods are difficult to randomly generate CAD models of specified categories under partial constraints, and cannot effectively control the type, size and position relationship of the CAD model.
Using the diffusion model, the CAD command sequence is converted into a sample embedding vector through the forward diffusion subnet and added noise. The reverse diffusion subnet performs noise reduction processing, trains the model according to the differences, generates the target CAD model, and realizes under partial constraints. random generation and control of specified positional relationships.
It realizes the generation of different types of CAD models under partial constraints, and can control the type or size of the CAD model separately. By adding constraint relationships through the denoising stage, ensuring that the generated model conforms to the specified positional relationship, solving the difficulty of random generation in traditional methods. Technical issues with specifying category CAD models.
Smart Images

Figure CN119203285A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a CAD model generation method, device, storage medium and electronic device. Background Art
[0002] Computer-Aided Design (CAD) is a design process that uses computer software to allow designers to use computers to create, modify, analyze and optimize various designs. Today, CAD models have become key to modern engineering and manufacturing, driving the design of a variety of products.
[0003] Typically, designers use sketches and extrusion operations to build CAD models, starting with 2D curves to define the outline and then converting it into a 3D model. If a deep learning model is used to learn the designer's CAD sequence modeling capabilities and use this model to assist the designer's work, a lot of labor costs can be reduced. In the early stages of work, minor errors in parametric CAD models can be corrected, and the generation of CAD models of the same category can be achieved by changing fewer parameters.
[0004] However, these construction methods do not incorporate the expertise of professional designers. In the process of CAD model construction, the size and position constraints of the geometric structure of the CAD model are crucial to the generation of the CAD model, but the existing generation methods can only randomly sample the information in the codebook and cannot explicitly control these fine-grained variables and constraint relationships.
[0005] Therefore, how to use neural network models to randomly generate CAD models under partial constraints is an urgent problem to be solved. Summary of the invention
[0006] The present specification provides a CAD model generation method, device, storage medium and electronic device to at least partially solve the above-mentioned problems existing in the prior art.
[0007] This manual adopts the following technical solutions:
[0008] This specification provides a CAD model generation method, including:
[0009] Obtain a computer-aided design (CAD) command sequence as a sample CAD sequence;
[0010] Inputting the sample CAD sequence into a diffusion model to be trained, wherein the diffusion model comprises a forward diffusion subnet and a reverse diffusion subnet;
[0011] The sample CAD sequence is converted into a sample embedding vector by the forward diffusion subnet, and noise is added to the sample embedding vector to obtain a sample diffusion vector;
[0012] Performing denoising processing on the sample diffusion vector through the reverse diffusion subnet to obtain a prediction vector to be optimized, and determining a prediction sequence to be optimized according to the prediction vector to be optimized;
[0013] Training the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector;
[0014] The inverse diffusion subnet included in the trained diffusion model is used as a target model, and the target model is used to generate a CAD model.
[0015] Optionally, the forward diffusion subnet includes at least a conversion layer and a noise addition layer;
[0016] The sample CAD sequence is converted into a sample embedding vector by the forward diffusion subnet, and noise is added to the sample embedding vector to obtain a sample diffusion vector, which specifically includes:
[0017] The sample CAD sequence is converted into a sample embedding vector by using a pre-designed embedding function through the conversion layer;
[0018] Noise is added to the sample embedding vector through the noise adding layer to obtain a sample diffusion vector.
[0019] Optionally, the CAD command sequence includes command types and parameters, and the embedded function includes a type embedded function and a parameter embedded function;
[0020] The sample CAD sequence is converted into a sample embedding vector by using a pre-designed embedding function through the conversion layer, specifically including:
[0021] The conversion layer uses a pre-designed type embedding function to convert the command type included in the sample CAD sequence into a sample type vector, and uses a pre-designed parameter embedding function to convert the parameters included in the sample CAD sequence into a sample parameter vector;
[0022] The sample type vector and the sample parameter vector are concatenated to obtain a sample embedding vector.
[0023] Optionally, adding noise to the sample embedding vector specifically includes:
[0024] Determine the specified step size according to a preset rule;
[0025] Add noise of the specified step size to the sample embedding vector to obtain a sample diffusion vector.
[0026] Optionally, the reverse diffusion subnet includes at least a noise reduction layer and a restoration layer;
[0027] The sample diffusion vector is subjected to denoising by the reverse diffusion subnet to obtain a prediction vector to be optimized, and a prediction sequence to be optimized is determined according to the prediction vector to be optimized, specifically including:
[0028] Performing denoising processing on the sample diffusion vector through the denoising layer to obtain a prediction vector to be optimized;
[0029] The prediction sequence to be optimized is determined according to the prediction vector to be optimized through the restoration layer.
[0030] Optionally, training the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector specifically includes:
[0031] Inputting the sample embedding vector into the reduction layer to obtain a reduction sequence to be optimized output by the reduction layer;
[0032] The diffusion model is trained according to the difference between the prediction vector to be optimized and the sample embedding vector, and the difference between the restored sequence to be optimized and the sample CAD sequence.
[0033] Optionally, using the target model to generate a CAD model specifically includes:
[0034] Acquire a CAD command sequence input by a user as a target CAD sequence, wherein the target CAD sequence includes one of the command type and the parameter;
[0035] When the target CAD sequence includes the command type, the command type included in the target CAD sequence is converted into a target type vector using the type embedding function, random noise is generated as a target parameter vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector;
[0036] When the target CAD sequence includes the parameters, the parameter embedding function is used to convert the parameters included in the target CAD sequence into a target parameter vector, and random noise is generated as a target type vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector;
[0037] The target sample embedding vector is input into the target model to obtain a target sequence output by the target model, and a target CAD model is generated according to the target sequence.
[0038] This specification provides a CAD model generation device, the device comprising:
[0039] An acquisition module is used to acquire a computer-aided design (CAD) command sequence as a sample CAD sequence;
[0040] An input module, used for inputting the sample CAD sequence into a diffusion model to be trained, wherein the diffusion model comprises a forward diffusion subnet and a reverse diffusion subnet;
[0041] A noise adding module, used for converting the sample CAD sequence into a sample embedding vector through the forward diffusion subnet, and adding noise to the sample embedding vector to obtain a sample diffusion vector;
[0042] A denoising module, configured to perform denoising processing on the sample diffusion vector through the reverse diffusion subnet to obtain a prediction vector to be optimized, and determine a prediction sequence to be optimized according to the prediction vector to be optimized;
[0043] A training module, used for training the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector;
[0044] The generation module is used to use the inverse diffusion subnet included in the trained diffusion model as a target model and use the target model to generate a CAD model.
[0045] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned CAD model generation method is implemented.
[0046] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned CAD model generation method when executing the program.
[0047] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0048] In the CAD model generation method provided in the present specification, a computer-aided design CAD command sequence is obtained as a sample CAD sequence; the sample CAD sequence is input into a diffusion model to be trained, and the diffusion model includes a forward diffusion subnet and a reverse diffusion subnet; the sample CAD sequence is converted into a sample embedding vector through the forward diffusion subnet, and noise is added to the sample embedding vector to obtain a sample diffusion vector; the sample diffusion vector is denoised through the reverse diffusion subnet to obtain a prediction vector to be optimized, and a prediction sequence to be optimized is determined based on the prediction vector to be optimized; the diffusion model is trained based on the difference between the prediction vector to be optimized and the sample embedding vector; the reverse diffusion subnet included in the trained diffusion model is used as a target model, and the target model is used to generate a CAD model.
[0049] When this method is used to randomly generate CAD models under partial constraints, the reverse diffusion process in the diffusion model can be used to achieve random generation of different CAD models under specified categories. This method can not only control the type or size of the CAD model individually when generating the CAD model, but also achieve the specified position relationship of the CAD model by adding additional constraints in the denoising stage. Compared with traditional methods, it effectively solves the technical problem of difficulty in randomly generating CAD models of specified categories. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The drawings described herein are used to provide a further understanding of this specification and constitute a part of this specification. The illustrative embodiments and descriptions of this specification are used to explain this specification and do not constitute an improper limitation on this specification. In the drawings:
[0051] Figure 1 A schematic diagram of a CAD model generation method in this specification;
[0052] Figure 2 A schematic diagram of a specific embodiment of a CAD command sequence provided in this specification;
[0053] Figure 3 A schematic diagram of the model structure of a diffusion model provided in this specification;
[0054] Figure 4 A schematic diagram of a process for generating a CAD model without a classifier provided in this specification;
[0055] Figure 5 A schematic diagram for comparing a CAD model generated under controllable command type provided in this specification with a model randomly generated by a traditional method;
[0056] Figure 6 A schematic diagram for comparing a CAD model generated under controllable parameters provided in this specification with a model randomly generated by a traditional method;
[0057] Figure 7 A schematic diagram of a CAD model generated under structural control provided in this specification;
[0058] Figure 8 A schematic diagram of a CAD model generated under the guidance of a classifier provided in this specification;
[0059] Fig. 9 A schematic diagram of a CAD model generation device provided in this specification;
[0060] Fig.10 The corresponding Figure 1 Schematic diagram of electronic equipment. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0062] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0063] Figure 1 The following is a flow chart of a CAD model generation method in this specification, which specifically includes the following steps:
[0064] S100: Acquire a computer-aided design (CAD) command sequence as a sample CAD sequence.
[0065] All steps in the CAD model generation method provided in this specification can be implemented by any electronic device with computing functions, such as terminals, servers and other devices.
[0066] This method is mainly used to generate diversified CAD models by using a neural network model while satisfying some constraints, so as to quickly provide users with a variety of different choices or inspirations. Based on the above ideas, in this method, it is first necessary to build and train a neural network model with corresponding functions, which is the target model used in this method.
[0067] The target model for generating CAD models finally obtained in this method is based on the diffusion model. Diffusion models are a generation model based on probability theory. The core idea is to simulate a gradual "diffusion" process from data distribution to simple noise distribution, and then reconstruct high-quality data samples from noise by learning the inverse process. Generally speaking, the diffusion model includes two processes: forward diffusion and reverse diffusion. The forward diffusion process starts from the original data and gradually adds noise to it, making the data gradually blurred and finally close to the Gaussian noise distribution. This process can be regarded as a Markov chain, that is, the state at each moment is only related to the state at the previous moment. The forward diffusion process helps to simplify the data structure, facilitates storage and transmission, and plays a cornerstone role in the training of the generation model. The reverse diffusion process is to learn how to recover the original data from the noise based on the forward diffusion process. This is the core of the diffusion model and the key to generating images or data. The reverse diffusion process gradually removes noise and gradually restores the data to its original state.
[0068] In this method, the denoising diffusion probative model (DDPM), that is, the inverse diffusion part of the diffusion model, is used as the target model to output a variety of user-controllable CAD models.
[0069] In this step, training samples for training the diffusion model can be first obtained. The CAD model can be described as a series of operations in which the user iteratively adds sketches and stretching instructions to create entities in the CAD software. These operations are regarded as CAD command sequences. Each CAD command sequence has a different number of elements, and the element type may also be a continuous value or a discrete value. In order to make the CAD command sequence more suitable as the input of the neural network, this method defines a command sequence S = (C1, C2, ... C NC ). Where C i Is a single command in a sequence. Command C i =(t i ,p i ) by command type t i and the corresponding parameter p i constitute. Figure 2 A specific implementation example of a CAD command sequence is given, such as Figure 2 As shown, it shows some commands in a CAD command sequence. Each row of data is a CAD command, where the first column of data is the command type (Command Types), the second column of data is the parameters (Parameters), and the third column of data is the description of the command (Description). The main purpose of the command description is to introduce the function of the command and will not be included in the CAD command.
[0070] In order to make the number of parameters in each command consistent, this method stacks the data of each command into a fixed-length vector. The length of the vector can be set according to specific needs, such as 19×1, etc., and this manual does not impose specific restrictions on this. The positions of unused elements in the vector are set to -1. The length of the command sequence for each CAD model is also set to a fixed length N. C , N C The length of is also set according to specific needs, for example, N C =60. In order to efficiently process data in parallel, this method quantizes the continuous values to 256 levels to unify the data expression in order to solve the problem of mixing discrete and continuous values in commands.
[0071] Under the above rules, a CAD command sequence can be obtained in this step as a sample CAD sequence for subsequent training of the diffusion model. The CAD command sequence can be obtained from historical data or input by the user, and this specification does not impose any specific restrictions on this.
[0072] S102: Inputting the sample CAD sequence into a diffusion model to be trained, wherein the diffusion model comprises a forward diffusion subnet and a reverse diffusion subnet.
[0073] After obtaining the sample CAD sequence for training the diffusion model in step S100, the sample CAD sequence can be input into the diffusion model in this step to start training the diffusion model. In this method, the diffusion model can include a forward diffusion subnet and a reverse diffusion subnet, whose functions correspond to the forward diffusion process and the reverse diffusion process in the diffusion model respectively.
[0074] S104: Convert the sample CAD sequence into a sample embedding vector through the forward diffusion subnet, and add noise to the sample embedding vector to obtain a sample diffusion vector.
[0075] In this step, the sample CAD sequence input to the diffusion model first enters the forward diffusion subnet. In this method, the forward diffusion subnet is mainly used to perform two tasks: one is to convert the received sample CAD sequence into a sample embedding vector, and the other is to add noise to the converted sample embedding vector to obtain the noisy sample diffusion vector.
[0076] In order to better realize the above functions, in this method, the forward diffusion subnet can be designed as a structure that at least includes a conversion layer and a noise adding layer. On this basis, the forward diffusion subnet can specifically convert the sample CAD sequence into a sample embedding vector by using a pre-designed embedding function through the conversion layer; and add noise to the sample embedding vector through the noise adding layer to obtain a sample diffusion vector.
[0077] As introduced in step S100, a CAD command sequence can generally be composed of two parts: a command type and a parameter. Correspondingly, the embedding function used by the present method when converting a sample CAD sequence into a sample embedding vector also includes two parts, namely, a type embedding function corresponding to the command type and a parameter embedding function corresponding to the parameter. When performing the conversion, specifically, the command type contained in the sample CAD sequence can be converted into a sample type vector by using a pre-designed type embedding function through the conversion layer, and the parameters contained in the sample CAD sequence can be converted into a sample parameter vector by using a pre-designed parameter embedding function; the sample type vector and the sample parameter vector are concatenated to obtain a sample embedding vector.
[0078] In order to apply the continuous diffusion model to discrete CAD sequences, this method defines different embedding functions EMB for command types and parameters in CAD command sequences. t (t i ),EMB p (p i), so as to convert the CAD command sequence into a CAD vector. The sample embedding vector of the CAD command sequence S with a length of N is defined as:
[0079]
[0080] Among them, concat represents the operation of vector concatenation. represents the sample embedding vector corresponding to the CAD command sequence at the initial time 0 (without noise), It is the sample embedding vector corresponding to the nth CAD command in the CAD command sequence at the initial time 0.
[0081] Through the above formula, the sample CAD sequence can be converted into a sample embedding vector.
[0082] On the other hand, when adding noise to the obtained sample embedding vector, noise of different sizes and types can also be added to the sample embedding vector according to different specific needs. This method is mainly described by adding Gaussian noise as an example. Specifically, the specified step size can be determined according to a preset rule; the noise of the specified step size number of times is added to the sample embedding vector to obtain a sample diffusion vector.
[0083] Embedding vector into samples In the process of adding Gaussian noise, there may be many preset rules for determining the specified step size. For example, time t may be randomly sampled from the interval [1, T] as the direction The specified step size for adding noise. Adding noise will embed the samples into the vector Convert to sample diffusion vector Its noise distribution is:
[0084]
[0085] where β t is a hyperparameter that controls the diffusion rate. After adding the forward noise, Input to the linear projection layer To increase the data dimension. The randomly sampled time t is input into the time embedding layer to generate t emb . emb and Add and then input to the position encoding layer to get The purpose of the position encoding layer is to provide a i Provides index.
[0086] S106: performing noise reduction processing on the sample diffusion vector through the reverse diffusion subnet to obtain a prediction vector to be optimized, and determining a prediction sequence to be optimized according to the prediction vector to be optimized.
[0087] After completing the forward diffusion process in the diffusion model in step S104, the subsequent reverse diffusion process can be further completed in this step, that is, the denoising of the sample diffusion vector is completed through the reverse diffusion subnet in the diffusion model, and the prediction sequence to be optimized is determined based on the prediction vector to be optimized obtained by denoising.
[0088] Similar to the forward diffusion subnet, in order to enable the reverse diffusion subnet to better realize the corresponding function, the reverse diffusion subnet may include at least a noise reduction layer and a restoration layer. At this time, the reverse diffusion subnet may specifically perform noise reduction processing on the sample diffusion vector through the noise reduction layer to obtain the prediction vector to be optimized; and determine the prediction sequence to be optimized according to the prediction vector to be optimized through the restoration layer.
[0089] The goal of generating the prediction vector to be optimized is to model the inverse diffusion process. By performing step-by-step denoising, the prediction vector to be optimized can be predicted without adding noise.
[0090]
[0091] Where N is a Bert-based encoder used to implement the denoising function in reverse diffusion.
[0092] Furthermore, the method designs a linear layer for restoring the command type and parameters contained in the CAD command as a recovery step, that is, the reduction layer contained in the reverse diffusion subnet, which maps the vector back to the CAD command sequence. The reduction layer processes the prediction vector to be optimized, and finally obtains the prediction sequence to be optimized.
[0093] Figure 3 This is a schematic diagram of the model structure of a diffusion model provided in this specification. Figure 3 As shown in the figure, the left half is the forward diffusion subnet of the diffusion model, which realizes the function of CAD command sequence to its corresponding noisy vector (CADSequences to CAD Vectors); the right half is the reverse diffusion subnet of the diffusion model, which realizes the function of predicting the CAD command sequence according to the noisy vector (Noised CAD Vectors to CAD Sequences). Among them, the Restoration Step (RS) corresponds to the restoration layer in the diffusion model.
[0094] S108: Training the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector.
[0095] Finally, the diffusion model can be trained according to the output of the reverse diffusion subnetwork in step S106. Since the process of converting from the sample CAD sequence to the sample embedding vector is implemented by a designed function, the training process does not need to include the process of converting the CAD command sequence to the embedding vector. That is, the diffusion model can be trained directly according to the difference between the prediction vector to be optimized and the sample embedding vector. Specifically, it can be expressed as:
[0096]
[0097] Among them, l diff is the loss between the prediction vector to be optimized and the sample embedding vector.
[0098] Furthermore, in the diffusion model, its ability to predict the CAD command sequence based on the vector can be additionally trained. Based on this, when training the diffusion model, the sample embedding vector can be specifically input into the reduction layer to obtain the reduction sequence to be optimized output by the reduction layer; the diffusion model is trained based on the difference between the prediction vector to be optimized and the sample embedding vector, and the difference between the reduction sequence to be optimized and the sample CAD sequence.
[0099] In order to ensure the training effect, the loss here does not directly use the prediction sequence to be optimized obtained according to the prediction vector to be optimized, but uses the method of inputting the sample embedding vector into the reduction layer to obtain the restored sequence to be optimized to train the diffusion model. Since the sample embedding vector is directly converted from the sample CAD sequence, and the prediction vector to be optimized is obtained after the sample embedding vector is subjected to the denoising and denoising process, the use of the restored sequence to be optimized obtained according to the sample embedding vector can help the diffusion model learn more accurate prediction capabilities. The loss between the restored sequence to be optimized and the sample CAD sequence can be determined as follows:
[0100]
[0101] Among them, l res represents the loss between the restored sequence to be optimized and the sample CAD sequence, C represents the standard cross entropy, rs represents the reduction layer in the reverse diffusion subnetwork, and S is the sample CAD sequence.
[0102] The above method can complete the training of the diffusion model and obtain a complete and excellent diffusion model.
[0103] S110: taking the inverse diffusion subnet included in the trained diffusion model as a target model, and using the target model to generate a CAD model.
[0104] Finally, the inverse diffusion subnet in the trained diffusion model can be used as the target model to realize the generation of CAD models of specified categories under partial constraints.
[0105] Specifically, a CAD command sequence input by a user can be obtained as a target CAD sequence, wherein the target CAD sequence includes one of the command type and the parameters; when the target CAD sequence includes the command type, the type embedding function is used to convert the command type included in the target CAD sequence into a target type vector, and random noise is generated as a target parameter vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector; when the target CAD sequence includes the parameters, the parameter embedding function is used to convert the parameters included in the target CAD sequence into a target parameter vector, and random noise is generated as a target type vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector; the target sample embedding vector is input into the target model to obtain a target sequence output by the target model, and a target CAD model is generated according to the target sequence.
[0106] A complete CAD command includes two parts: command type and parameters. Under a complete set of CAD commands, that is, a complete CAD command sequence, the generated CAD model is fixed. This process can be regarded as generating a CAD model under full constraints. When the CAD command sequence is incomplete, for example, it only contains command types but not parameters, or only contains parameters but not command types, the CAD model is generated under partial constraints.
[0107] When generating a CAD model under partial constraints, the CAD command sequence input by the user, that is, the target CAD sequence, will only include one of the command type and parameter, and the other will be empty. For ease of representation, the one included in the target CAD sequence is called a known item, and the one not included is called an empty item. It can be imagined that the user's purpose is to obtain multiple CAD models by freely filling in the empty items under the condition that the known items are fixed, that is, multiple CAD models with some of the same parts.
[0108] Based on this, for known items, this method can directly convert them into corresponding embedding vectors through pre-designed embedding functions; for empty items, fixed values such as -1 or random initialization can be used to fill them as embedding vectors. Subsequently, the embedding vectors corresponding to the known items can be fixed unchanged, and the embedding vectors of the empty items can be randomly noised. There are many ways to add noise, but in order to ensure the best generation effect, the noise layer trained in the diffusion model can be directly used to add noise to the embedding vectors of the empty items.
[0109] The target embedding vector for input into the target model is obtained by concatenating the embedding vector converted from the known items and the embedding vector obtained by adding noise to the empty items. After the target embedding vector is input into the target model, the target model will denoise the noisy part of the embedding vector to obtain the target prediction vector, and finally determine the target sequence based on the target prediction vector. The target sequence can be executed to generate the target CAD model.
[0110] It should be noted that the word "model" in this specification has different meanings in different words. In the words "diffusion model" and "target model", the meaning of "model" is a neural network model; while in the word "CAD model", the meaning of "model" is a model designed in computer software.
[0111] Additionally, when a plurality of different CAD models need to be generated, this step may be repeated for multiple times, or a plurality of different CAD models may be generated by denoising with different step lengths during one execution of this step.
[0112] After random noise data is given, different CAD models are randomly generated after denoising at different time steps. Furthermore, the CAD model can be generated without a classifier and with the help of a classifier. Figure 4 A schematic diagram of a process for generating a CAD model without a classifier provided in this specification, such as Figure 4 As shown in the figure, the classifier-free method can complete a variety of controllable tasks by controlling the noise or CAD sequence in the iterative process, that is, after each denoising step in the multi-step denoising process, a CAD command sequence can be determined according to the vector in the current step, and the generation direction of the subsequent CAD model can be controlled by adjusting the CAD command sequence. The generation method without a classifier can mainly include three different control types.
[0113] The first is command type controllable CAD model generation. For command type control tasks, such as Figure 4 As shown in part (a) of the figure, the command type in the target CAD sequence is fixed and then input into the command type embedding function EMB t Get the embedding vector e corresponding to the command type ct , the embedding vector corresponding to the parameter is the noise e noise In the denoising stage, the target model will generate parameters corresponding to the input command type.
[0114] Figure 5The figure is a comparison diagram of the CAD model generated under controllable command type and the model randomly generated by traditional methods. In part (a), Diffusion-CAD represents the target model, and SkexGen in part (b) is the traditional codebook generation method for CAD models. Given a user-specified target CAD sequence, the target model can generate CAD models with different parameters under the same command type. SkexGen generates models of the same command type by sampling decoupled codebooks. However, since the expression of the codebook is not explicit, the model generated by each sampling is not controllable. This method can be more helpful to users in designing CAD models. Figure 5 As shown in FIG. 1 , for the target CAD sequence input by the user, the target model can accurately generate the corresponding model and also ensure diversity. However, the comparison method cannot generate the model according to the user's instructions.
[0115] The second is the generation of CAD models with controllable parameters. In layman's terms, the parameters in the CAD command sequence can generally be considered to represent the size of the generated CAD model. The CAD model size control method is similar to the command type control method. Figure 4 As shown in (b), the parameters of the CAD command sequence are fixed and then input into the parameter embedding function EMB p Then, the embedding vector corresponding to the parameter part is obtained. In this method, the size control may at least include the position of the point, the radius of the circle and the angle of the arc.
[0116] Figure 6 This is a schematic diagram comparing the CAD model generated under parameter control and the model randomly generated by traditional methods. In this category of control, users can manipulate three parameters such as Figure 6 shown. Figure 6 In part (a), the first row is the coordinates of the control points of this method to generate different CAD models with the same positional relationship; the second row is the CAD model generated by controlling the coordinates of the points and the radius of the four circles at the same time; the third row is the CAD model generated by limiting the coordinates of the points and the arc angle of a certain arc to 90°. The above results show that the target model has flexible parameter control capabilities and can generate a variety of CAD models with precise sizes specified by the user. However, in contrast, the traditional method SkexGen can only randomly sample from the geometric codebook to generate models with roughly the same geometric positions. This method cannot accurately control any size information.
[0117] The third is the generation of structurally controllable CAD models. This type of constraint is a geometric control without direct assignment of CAD command sequences. It can be used in conjunction with the first two types. The structures that can be realized include: coincidence, parallelism, verticality, and symmetry. Figure 4As shown in part (c), at time T in the inference process, the command type vector and the noise corresponding to the parameters are used as input. We predict a CAD command sequence after each denoising step, and add constraint relationship formulas after the predicted CAD command sequence to control the geometric structure to denoise according to the user's specified requirements. At time T-1, the constraint relationship vector at time T is used as input. The process is repeated until time 1 (the transformation of time in the denoising process is from T to 1), at which time the output is a CAD command sequence that satisfies the structural constraints.
[0118] Figure 7 is a schematic diagram of the CAD model generated under structural control. Figure 7 As shown in the figure, it shows the CAD models generated under various given geometric constraint relationships. In the first row of vertical relationships, the command type is set to 2 arcs, 2 straight lines and 1 hollow circle, and the structural constraint is that the angle between the center point of the circle and the line connecting the two ends of any straight line is 90 degrees. The constraint relationship achieved by the second row of results is parallel and symmetrical. The given command instructions are 4 straight lines and 2 hollow circles, and the structural constraint is that the straight lines where the two circle centers are located are parallel to the two sides of the quadrilateral and are the symmetry axes of the quadrilateral. Figure 7 The generated results in show that this method can not only accurately complete the constraint relationship but also meet the needs of diverse design.
[0119] The classifier-guided approach enables category-guided CAD model generation. Specifically, a classifier can be trained using architectures such as GPT-2. The architecture is given a vector with noise added Then, the trained classifier and target model are used to generate the CAD model of the specified category. In the iterative generation stage, Input to the classifier and run gradient update on the latent space To guide the model to achieve category control.
[0120] Figure 8 is a schematic diagram of the CAD model generated under the guidance of the classifier. Figure 8 As shown in the figure, a random category label is given, and the trained target model and classifier are used to collaborate to generate a CAD model of the corresponding category. The experimental results show that this method can generate diverse results under the specified category.
[0121] When this method is used to randomly generate CAD models under partial constraints, the reverse diffusion process in the diffusion model can be used to achieve random generation of different CAD models under specified categories. This method can not only control the type or size of the CAD model individually when generating the CAD model, but also achieve the specified position relationship of the CAD model by adding additional constraints in the denoising stage. Compared with traditional methods, it effectively solves the technical problem of difficulty in randomly generating CAD models of specified categories.
[0122] The above is the CAD model generation method provided in this specification. Based on the same idea, this specification also provides a corresponding CAD model generation device, such as Fig. 9 shown.
[0123] Fig. 9 A schematic diagram of a CAD model generation device provided in this specification specifically includes:
[0124] An acquisition module 200 is used to acquire a computer-aided design (CAD) command sequence as a sample CAD sequence;
[0125] An input module 202, used for inputting the sample CAD sequence into a diffusion model to be trained, wherein the diffusion model comprises a forward diffusion subnet and a reverse diffusion subnet;
[0126] A noise adding module 204, configured to convert the sample CAD sequence into a sample embedding vector through the forward diffusion subnet, and add noise to the sample embedding vector to obtain a sample diffusion vector;
[0127] A denoising module 206, configured to perform denoising processing on the sample diffusion vector through the reverse diffusion subnet to obtain a prediction vector to be optimized, and determine a prediction sequence to be optimized according to the prediction vector to be optimized;
[0128] A training module 208, configured to train the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector;
[0129] The generating module 210 is used to use the inverse diffusion subnet included in the trained diffusion model as a target model, and use the target model to generate a CAD model.
[0130] Optionally, the forward diffusion subnet includes at least a conversion layer and a noise addition layer;
[0131] The noise adding module 204 is specifically used to convert the sample CAD sequence into a sample embedding vector by using a pre-designed embedding function through the conversion layer; and add noise to the sample embedding vector by using the noise adding layer to obtain a sample diffusion vector.
[0132] Optionally, the CAD command sequence includes command types and parameters, and the embedded function includes a type embedded function and a parameter embedded function;
[0133] The noise adding module 204 is specifically used to convert the command type contained in the sample CAD sequence into a sample type vector by using a pre-designed type embedding function through the conversion layer, and to convert the parameters contained in the sample CAD sequence into a sample parameter vector by using a pre-designed parameter embedding function; and to concatenate the sample type vector and the sample parameter vector to obtain a sample embedding vector.
[0134] Optionally, the noise adding module 204 is specifically configured to determine a specified step length according to a preset rule; and add noise of the specified step length times to the sample embedding vector to obtain a sample diffusion vector.
[0135] Optionally, the reverse diffusion subnet includes at least a noise reduction layer and a restoration layer;
[0136] The denoising module 206 is specifically configured to perform denoising processing on the sample diffusion vector through the denoising layer to obtain a prediction vector to be optimized; and determine a prediction sequence to be optimized according to the prediction vector to be optimized through the restoration layer.
[0137] Optionally, the training module 208 is specifically used to input the sample embedding vector into the reduction layer to obtain the reduction sequence to be optimized output by the reduction layer; and train the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector, and the difference between the reduction sequence to be optimized and the sample CAD sequence.
[0138] Optionally, the generating module 210 is specifically configured to obtain a CAD command sequence input by a user as a target CAD sequence, wherein the target CAD sequence includes one of the command type and the parameter;
[0139] When the target CAD sequence contains the command type, the type embedding function is used to convert the command type contained in the target CAD sequence into a target type vector, and random noise is generated as a target parameter vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector; when the target CAD sequence contains the parameter, the parameter embedding function is used to convert the parameter contained in the target CAD sequence into a target parameter vector, and random noise is generated as a target type vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector; the target sample embedding vector is input into the target model to obtain a target sequence output by the target model, and a target CAD model is generated according to the target sequence.
[0140] This specification also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A CAD model generation method is provided.
[0141] This manual also provides Fig.10 The schematic structure diagram of the electronic device shown in FIG. Fig.10 As mentioned above, at the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Of course, in addition to the software implementation, this specification does not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0142] For the improvement of a technology, it can be clearly distinguished whether it is a hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or a software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0143] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.
[0144] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0145] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0146] 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.
[0147] 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.
[0148] 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.
[0149] 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.
[0150] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0151] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0152] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0153] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0154] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0155] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0156] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0157] The above description is only an embodiment of this specification and is not intended to limit this specification. For those skilled in the art, this specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of this specification should be included in the scope of the claims of this application.
Claims
1. A CAD model generation method, characterized in that: include: Obtain a computer-aided design (CAD) command sequence as a sample CAD sequence; Inputting the sample CAD sequence into a diffusion model to be trained, wherein the diffusion model comprises a forward diffusion subnet and a reverse diffusion subnet; The sample CAD sequence is converted into a sample embedding vector by the forward diffusion subnet, and noise is added to the sample embedding vector to obtain a sample diffusion vector; Performing denoising processing on the sample diffusion vector through the reverse diffusion subnet to obtain a prediction vector to be optimized, and determining a prediction sequence to be optimized according to the prediction vector to be optimized; Training the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector; The inverse diffusion subnet included in the trained diffusion model is used as a target model, and the target model is used to generate a CAD model.
2. The method according to claim 1, characterized in that The forward diffusion subnet at least includes a conversion layer and a noise addition layer; The sample CAD sequence is converted into a sample embedding vector by the forward diffusion subnet, and noise is added to the sample embedding vector to obtain a sample diffusion vector, which specifically includes: The sample CAD sequence is converted into a sample embedding vector by using a pre-designed embedding function through the conversion layer; Noise is added to the sample embedding vector through the noise adding layer to obtain a sample diffusion vector.
3. The method according to claim 2, characterized in that The CAD command sequence includes command types and parameters, and the embedded function includes a type embedded function and a parameter embedded function; The sample CAD sequence is converted into a sample embedding vector by using a pre-designed embedding function through the conversion layer, specifically including: The conversion layer uses a pre-designed type embedding function to convert the command type included in the sample CAD sequence into a sample type vector, and uses a pre-designed parameter embedding function to convert the parameters included in the sample CAD sequence into a sample parameter vector; The sample type vector and the sample parameter vector are concatenated to obtain a sample embedding vector.
4. The method according to claim 1, characterized in that Adding noise to the sample embedding vector specifically includes: Determine the specified step size according to a preset rule; Add noise of the specified step size to the sample embedding vector to obtain a sample diffusion vector.
5. The method according to claim 1, characterized in that The reverse diffusion subnet at least includes a noise reduction layer and a restoration layer; The sample diffusion vector is subjected to denoising by the reverse diffusion subnet to obtain a prediction vector to be optimized, and a prediction sequence to be optimized is determined according to the prediction vector to be optimized, specifically including: Performing denoising processing on the sample diffusion vector through the denoising layer to obtain a prediction vector to be optimized; The prediction sequence to be optimized is determined according to the prediction vector to be optimized through the restoration layer.
6. The method according to claim 5, characterized in that The diffusion model is trained according to the difference between the prediction vector to be optimized and the sample embedding vector, specifically comprising: Inputting the sample embedding vector into the reduction layer to obtain a reduction sequence to be optimized output by the reduction layer; The diffusion model is trained according to the difference between the prediction vector to be optimized and the sample embedding vector, and the difference between the restored sequence to be optimized and the sample CAD sequence.
7. The method according to claim 3, characterized in that The target model is used to generate a CAD model, specifically comprising: Acquire a CAD command sequence input by a user as a target CAD sequence, wherein the target CAD sequence includes one of the command type and the parameter; When the target CAD sequence includes the command type, the command type included in the target CAD sequence is converted into a target type vector using the type embedding function, random noise is generated as a target parameter vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector; When the target CAD sequence contains the parameters, the parameter embedding function is used to convert the parameters contained in the target CAD sequence into a target parameter vector, and random noise is generated as a target type vector, and the target type vector and the target parameter vector are concatenated to obtain a target sample embedding vector; The target sample embedding vector is input into the target model to obtain a target sequence output by the target model, and a target CAD model is generated according to the target sequence.
8. A CAD model generating device, characterized in that: include: An acquisition module is used to acquire a computer-aided design (CAD) command sequence as a sample CAD sequence; An input module, used for inputting the sample CAD sequence into a diffusion model to be trained, wherein the diffusion model comprises a forward diffusion subnet and a reverse diffusion subnet; A noise adding module, used for converting the sample CAD sequence into a sample embedding vector through the forward diffusion subnet, and adding noise to the sample embedding vector to obtain a sample diffusion vector; A denoising module, configured to perform denoising processing on the sample diffusion vector through the reverse diffusion subnet to obtain a prediction vector to be optimized, and determine a prediction sequence to be optimized according to the prediction vector to be optimized; A training module, used for training the diffusion model according to the difference between the prediction vector to be optimized and the sample embedding vector; The generation module is used to use the inverse diffusion subnet included in the trained diffusion model as a target model and use the target model to generate a CAD model.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Rapid model generation method based on diffusion model
CN115935817A
Three-dimensional object generation method based on diffusion model and semantic guidance
CN116721200A
Workpiece surface topography generation method and device based on multi-modal image generation
CN116977652A
Training method of sketch generation model, sketch generation method, terminal and medium
CN117935291A