A sketch-driven stress distribution generation method based on latent space flow matching
By combining Gaussian heatmap encoding and mask predictor with latent spatial flow matching, the problems of coarse stress point encoding and insufficient structural priors in stress distribution generation are solved, achieving efficient and accurate stress distribution generation, which is suitable for mechanical structure design and industrial product simulation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA UNIV OF PETROLEUM (EAST CHINA)
- Filing Date
- 2026-04-13
- Publication Date
- 2026-06-09
Smart Images

Figure FT_1 
Figure SMS_12 
Figure SMS_14
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of deep learning, computer vision and structural mechanics simulation, and specifically relates to a sketch-driven stress distribution generation method based on latent spatial flow matching. Technical Background
[0002] In mechanical structure design, lightweight design of industrial products, and mechanical performance evaluation, stress distribution simulation is a core component for ensuring the safety, reliability, and optimized design of components. Traditional stress analysis relies on finite element analysis, which requires 3D modeling, mesh generation, boundary condition setting, material parameter configuration, and iterative solution. This approach suffers from drawbacks such as cumbersome modeling processes, long computation times, high hardware costs, and heavy reliance on professional personnel, making it difficult to meet the needs of rapid design iteration, real-time visualization, and lightweight interactive design.
[0003] With the development of deep learning and image generation technologies, data-driven stress field prediction has become a research hotspot. Existing technologies can be mainly divided into the following three categories:
[0004] 1. Direct stress prediction method based on convolutional regression: This type of method is based on convolutional neural networks (CNN) and directly maps component images to stress distribution images. Although it achieves end-to-end prediction, the models are mostly simple encoder-decoder structures, lacking the ability to model long-range dependencies. They have poor ability to reproduce stress transfer, stress concentration and boundary effects of complex components, and the generated results are vague and have low physical consistency.
[0005] 2. Stress Map Generation Methods Based on GANs and Diffusion Models: Generative Adversarial Networks (GANs) and diffusion models are used to generate stress field visualizations, improving image details. However, these methods are trained directly in high-resolution pixel space, resulting in high computational cost, high memory usage, unstable training, and slow convergence. Furthermore, most methods only use a single sketch as a condition, without introducing the location of stress points as explicit constraints, leading to significant deviations between the generated results and the actual stress state. Sketch2stress, for example, uses a GAN-based generation method to achieve sketch-driven stress distribution generation.
[0006] 3. Image modeling methods based on latent space generation: Variational autoencoders (VAEs) can compress high-dimensional images into low-dimensional latent spaces, significantly reducing computational cost. Existing technologies mostly use them for natural images, faces, and texture generation, but rarely for mechanical stress field generation; moreover, existing latent space generation frameworks do not design weighted losses for stress regions, and cannot distinguish between effective stress regions and invalid background regions, resulting in the loss of key details such as stress edges and gradients.
[0007] However, existing technologies have significant shortcomings in handling conditional inputs: stress points are generally input as binary discrete points, resulting in rigid feature representations and discontinuous local information, making it difficult for the model to learn the smooth relationship between stress location and stress diffusion; mask features are not integrated into the encoding process of the generative model, making it impossible to use structural features of components to guide stress field generation, and the model has a weak ability to perceive structural constraints; in addition, existing methods do not introduce flow matching into the latent space for stress field vector field learning, making it impossible to balance generation stability, detail accuracy, and inference speed.
[0008] Therefore, fundamentally improving the conditional encoding method, structural prior injection mechanism, and latent space learning framework of stress generation models to enhance the model's ability to perceive and model long-range structural features, stress transmission laws, stress influence range, and effective stress regions has become a key challenge in improving the accuracy and efficiency of sketch-driven stress distribution generation. Gaussian heatmap encoding, mask feature fusion, and latent space flow matching have been proven effective in improving the smoothness of conditional representations, consistency of structural constraints, and generation stability in image generation. By transforming discrete points into continuous heatmaps, injecting mask structural features, and learning vector fields in low-dimensional space, they provide new approaches for the rapid, accurate, and stable generation of stress fields. Summary of the Invention
[0009] Based on the above background, this invention aims to solve the problems of blurred stress details, inaccurate stress relationship modeling, artifacts in non-structural regions, and low generation efficiency in existing stress distribution generation methods, caused by coarse force point encoding, lack of latent space learning, insufficient structural priors, and lack of foreground constraints and region guidance. However, due to the significant two-dimensional spatial structure, long-range stress transmission law, and local diffusion characteristics of force points in the stress field of components, its generation logic differs fundamentally from that of natural images and ordinary visual generation tasks. Stress regions and background regions have obvious distinctions in importance, and the component structure itself has a strong constraint effect on stress distribution. Therefore, although Gaussian heatmap encoding, latent space flow matching, and mask feature learning have been applied in general generation fields, existing technologies have not combined these three methods and introduced them into the sketch-force point dual-condition driven stress field generation task.
[0010] To achieve the above objectives, this invention provides a sketch-driven stress distribution generation method based on latent space flow matching, Gaussian heatmap encoding, and mask feature fusion. The core of this invention lies in: introducing Gaussian heatmap encoding into the stress point condition processing, converting discrete binary points into smooth, continuous features; simultaneously constructing a mask predictor to extract structural priors from the sketch and output multi-scale features; deploying flow matching learning in the VAE latent space, and injecting mask features into the vector field learning process through feature fusion UNet; and combining foreground weighted loss to strengthen the effective stress region constraint. Thus, without significantly increasing model complexity, the model can accurately learn the mapping relationship between stress location, component structure, and stress diffusion, improving the generation accuracy, physical consistency, and structural rationality for complex components, long-range structures, and stress concentration areas.
[0011] The technical solution adopted in this invention is:
[0012] A sketch-driven stress distribution generation method based on potential spatial flow matching includes the following steps:
[0013] Step 1: Obtain the component sketch image, binary stress point annotation image, and stress distribution true value image; perform preprocessing on the images, including normalization, and generate a stress region mask within the sketch structure range;
[0014] Step 2: Construct a stress distribution generation model, which includes a pre-trained variational autoencoder (VAE) module that has been fine-tuned and fixed, a Gaussian heatmap conversion module, a mask predictor, and a flow matching UNet. Each module is used sequentially for feature mapping between the image space and the latent space, stress distribution conversion, stress region prediction, structural feature extraction, and flow matching learning in the latent space.
[0015] Step 3: Construct a joint loss function that includes foreground-weighted flow matching loss and mask prediction loss. Fix the VAE parameters and perform joint optimization training only on the mask predictor and the flow matching UNet.
[0016] Step 4: Input the component sketch and stress point image to be generated into the trained stress distribution generation model, fuse the multi-scale structural features output by the mask predictor with the hidden layer features of the flow matching UNet, and generate the stress distribution image through latent space flow matching inference and pre-trained VAE module decoding.
[0017] Furthermore, the specific process of step 1 is as follows:
[0018] To construct a ternary paired dataset, we acquire sketch structures, binary stress point labeled images, and corresponding ground truth images of stress distribution. First, to enhance the model's generalization ability to sketches of components of different sizes and scales, we maintain the original aspect ratio of the images during training and uniformly scale all images to 256×256 resolution. Then, we standardize the images, converting them to RGB three-channel format, and sequentially perform tensor transformation and normalization operations. We use the mean and standard deviation to map pixel values from [0,1] to the [-1,1] interval to match the input distribution of the pre-trained variational autoencoder. Simultaneously, a binary mask for the effective region is automatically generated based on the ground truth image of stress distribution: the stress image is converted into an array, and it is determined whether a pixel in any channel is less than the brightness threshold of 245. If so, it is identified as an effective stress region; otherwise, it is identified as a white background. The generated single-channel grayscale mask image undergoes an independent spatial transformation, is uniformly scaled to 256×256, and converted into a tensor. Then, it is binarized using a threshold of 0.5 to obtain a mask tensor of shape [1,256,256], which is used to identify the effective stress region and the invalid background region. Finally, the normalized sketch image and the stress point image are concatenated along the channel dimension to form a conditional input tensor of shape [6,256,256]. At the same time, the independent ground truth stress tensor and mask tensor are retained, which together constitute the standard sample structure required for model training.
[0019] Furthermore, the specific process of step 2 is as follows:
[0020] A sketch-driven stress distribution generation model is constructed, comprising four parts: a pre-trained variational autoencoder (VAE), a Gaussian heatmap transformation module, a mask predictor, and a feature fusion flow matching UNet. The pre-trained VAE employs the AutoencoderKL architecture, a common approach for latent diffusion models, specifically a KL divergence-constrained variational autoencoder. Full parameter fine-tuning is performed on the target task data to map 3-channel RGB images to 4-channel low-dimensional latent features, achieving efficient conversion from high-resolution images to compact latent representations. Its encoding process includes the output of mean and logarithmic variance, as well as reparameterized sampling. During training, the VAE parameters remain fixed and do not participate in backpropagation updates, serving only as a feature converter between the image and the latent space. The Gaussian heatmap transformation module smooths and enhances the binary stress point images: by constructing a two-dimensional Gaussian kernel and performing convolution operations on the binary point map, discrete and rigid stress points are transformed into continuous and smooth Gaussian distribution heatmaps. This allows the model to effectively learn the influence range of the stress location and the stress diffusion law, improving the physical plausibility of the generated results. The mask predictor employs an encoder-bottleneck-decoder architecture, taking a 3-channel sketch as input and outputting a binary mask of the effective stress region. During the encoding stage, it outputs multi-scale intermediate features. These features are injected into the flow matching UNet, providing structural priors for the generation process, suppressing artifacts in unstructured regions, and enhancing stress edge consistency. The feature fusion flow matching UNet is a U-shaped network based on residual structure, self-attention, temporal embedding, and mask feature fusion, specifically designed for latent spatial vector field learning. The network input is a 12-channel concatenated feature, composed of 4-channel latent noise, 4-channel sketch latent features, and 4-channel stress heatmap latent features concatenated along the channel dimension. The network output is a 4-channel vector field used for flow matching iteration. Internally, the network includes sinusoidal temporal position embedding, multi-scale residual blocks, a self-attention module, a downsampling module, an upsampling module, a skip connection structure, and a mask feature fusion layer, enabling it to simultaneously capture local stress details, global component structural dependencies, and structural prior constraints. In the self-attention layer, long-range stress transfer relationships are modeled through group normalization and query-key-value attention computation. In the residual block, scaling and offset parameters are generated through temporal embedding, and affine modulation is applied to the features, enabling the network to adapt to potential state changes at different time steps. In the downsampling stage, the multi-scale features output by the mask predictor are concatenated and fused with the hidden layer features of the network through convolution, explicitly introducing prior structural knowledge to guide stress field generation. During the flow matching learning process, random sampling time t∈(0,1) is used to handle initial noise. With stress true value potential characteristics Linear interpolation is used to obtain intermediate latent states. ;Will After concatenating the sketch and latent features of the force points, the data is input into UNet along with the mask features to obtain the prediction vector field. The target vector field is defined as follows: The model achieves an accurate mapping from the dual conditions and structural priors to the stress distribution by fitting a vector field.
[0021] Furthermore, the specific process of step 3 is as follows:
[0022] A joint loss function is constructed as the main optimization objective for model training, comprising two parts: flow matching loss and mask prediction loss. The flow matching loss employs foreground-weighted L1 loss: pixel-level masks are downsampled to the latent space size, with effective stress regions assigned a 10x loss weight, while background regions maintain standard weights, optimizing the prediction error of the latent space vector field. The mask prediction loss uses binary cross-entropy (BCE) loss, constraining the mask predictor output to match the ground truth effective region. The total loss is a weighted sum of the two parts. The AdamW optimizer and cosine annealing learning rate scheduling strategy are used to jointly train the mask predictor and the flow matching UNet in an end-to-end manner. Backpropagation iteratively optimizes the model parameters, enabling the model to learn an accurate mapping from sketch structure and stress point conditions to latent stress features.
[0023] Furthermore, the specific process of step 4 is as follows:
[0024] During the inference phase, the component sketch and binary stress point diagram to be generated are input into the model. First, the conditional latent features are obtained through Gaussian heatmap transformation and VAE encoding. At the same time, the multi-scale structural features of the sketch are extracted through a mask predictor. Starting from Gaussian noise, multi-step Euler integral iteration is performed to gradually generate the stress latent representation under the guidance of mask features. Finally, the VAE is decoded and the value range is mapped from [-1,1] back to [0,1] to output the final stress distribution image. Attached Figure Description
[0025] Figure 1 This is a schematic diagram of the sketch-driven stress distribution generation method based on potential spatial flow matching of the present invention. Detailed Implementation
[0026] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0027] This invention proposes a sketch-driven stress distribution generation method based on latent space flow matching. By converting the stress points into Gaussian heatmaps to achieve continuous conditional encoding, flow matching vector field learning is performed in the VAE latent space, and structural features are extracted using a mask predictor and integrated into the UNet generation process. This enables the model to accurately model the mechanical mapping relationship between component sketches, stress locations, and stress distribution, significantly improving the detail accuracy, physical consistency, and structural rationality of stress field generation.
[0028] This method employs an end-to-end latent space generation architecture: a pre-trained VAE is used as an image-latent space converter, a Gaussian heatmap module is used to achieve smooth encoding of stress points, a mask predictor is used to provide prior structural features, and a feature fusion UNet is used to complete flow matching learning in the latent space, ultimately generating a high-fidelity stress distribution image quickly.
[0029] As shown in Figure 1, a sketch-driven stress distribution generation method based on potential spatial flow matching is described in detail below:
[0030] Step 1: Preprocess the component sketch, stress point image, and stress true value image. The specific process is as follows:
[0031] Step 1.1: Obtain the component sketch image, binary stress point annotation image, and corresponding finite element simulation stress distribution true value image, and construct a sketch-stress point-stress diagram ternary paired dataset according to a unified naming rule.
[0032] Step 1.2: Perform channel conversion and standardization on the images. Convert all images to RGB three-channel format and convert them to tensor form through tensor transformation to normalize the pixel values from 0-255 to the [0,1] interval. Then, perform standardization using mean=[0.5,0.5,0.5] and standard deviation=[0.5,0.5,0.5] to further map the pixel values to the [-1,1] interval, so that it strictly matches the input distribution requirements of the pre-trained VAE model.
[0033] Step 1.3: Normalize the image size to 256×256. This step ensures that all image sizes are within a preset effective range, avoiding images that are too large or too small from affecting feature extraction. If the image exceeds the effective range, bilinear interpolation is used to proportionally enlarge or reduce the image size to ensure it remains within the effective range.
[0034] Step 1.4: Automatically generate a binary mask for the effective stress region based on the true stress image. Use a brightness threshold of 245 to distinguish between the foreground and background, generate a single-channel binary mask, scale it to 256×256 and binarize it with a threshold of 0.5 to obtain a mask tensor with the shape [1,256,256].
[0035] Step 1.5: Concatenate the standardized sketch image and the stress point image in the channel dimension to form a conditional input tensor of [6,256,256], which together with the stress truth value and the mask constitutes the training sample.
[0036] Step 2: Construct a sketch-driven stress distribution generation model. The specific process is as follows:
[0037] The stress distribution generation model includes a pre-trained VAE module, a Gaussian heatmap conversion module, a mask predictor, and a flow matching UNet.
[0038] Step 2.1: Construction of pre-trained VAE modules.
[0039] The pre-trained VAE employs the AutoencoderKL architecture within the latent diffusion framework to achieve efficient bidirectional mapping between 3-channel RGB images and 4-channel latent features. The encoder receives the normalized image and outputs the mean μ and log-variance of the latent distribution. And latent features are obtained through reparameterization techniques:
[0040]
[0041] in The low-dimensional latent feature vector output by the VAE encoder represents a compact representation of the high-resolution stress image in the latent space. μ is the mean vector of the latent distribution, and σ is the standard deviation of the latent distribution, characterizing the dispersion of the latent features. It follows a standard Gaussian distribution N(0,I). This represents element-wise multiplication. The decoder receives the latent feature z and reconstructs a 3-channel RGB image. Throughout the training and inference process, all parameters of the VAE remain fixed and are not updated. They do not participate in backpropagation gradient calculation and are only used as a feature transformation tool between the image and the latent space.
[0042] Step 2.2: Constructing the Gaussian heatmap conversion module.
[0043] The Gaussian heatmap conversion module is used to convert discrete, binary, and rigid stress points into continuous, smooth, and physically interpretable Gaussian distribution heatmaps. First, a two-dimensional Gaussian convolution kernel is constructed:
[0044]
[0045] In this embodiment, the Gaussian kernel size is set to 9×9, and the standard deviation is... =2.0, x and y are the pixel coordinates inside the Gaussian convolution kernel, and g(x,y) is the value of the two-dimensional Gaussian convolution kernel at coordinates (x,y). The binary stress point map is depthwise convolved with the Gaussian kernel, keeping the size unchanged and padding=4, to obtain the stress Gaussian heat map, which enables the model to effectively learn the influence range, diffusion trend and stress concentration law of the stress point.
[0046] Step 2.3: Mask predictor construction.
[0047] The mask predictor adopts an encoder-bottleneck-decoder fully convolutional architecture. It takes a normalized 3-channel sketch image as input and outputs a binary mask of the effective stress region and multi-scale structural features, providing structural prior constraints for stress generation.
[0048] Step 2.3.1: The encoder consists of 4 levels of downsampled convolutional blocks. Each level includes 3×3 convolution, group normalization, SiLU activation function and 2×2 max pooling. The layer-by-layer structural features of the sketch layer are extracted, and the downsampled features of the first and second levels are retained for subsequent fusion with the UNet features of flow matching.
[0049] Step 2.3.2: The bottleneck layer consists of convolution, group normalization, SiLU activation function and random deactivation (Dropout) layer, which is used to enhance the modeling of global structural information.
[0050] Step 2.3.3: The decoder part upsamples layer by layer through transposed convolution and makes skip connections with the corresponding layer features of the encoder to gradually restore the spatial resolution.
[0051] Step 2.3.4: The output layer uses 1×1 convolution and Sigmoid activation function to output a single-channel probability mask image. After binarization with a threshold of 0.5, the effective stress region prediction result with the same size as the true value is obtained.
[0052] Step 2.3.5: The mask predictor is jointly optimized with the flow matching UNet during the training process. Its output multi-scale intermediate features are injected into the flow matching UNet to achieve accurate stress field generation guided by structural priors.
[0053] Step 2.4: Stream matching UNet construction.
[0054] UNet, a stream matching algorithm, uses a U-shaped encoder-decoder architecture and operates entirely in the VAE latent space, with 12 input channels and 4 output channels.
[0055] Step 2.4.1, Sine Time Embedding Module.
[0056] Sine position encoding for continuous time t:
[0057]
[0058] in The temporal embedding vector is encoded as a sinusoidal position. Let t be a continuous time step in the stream matching learning process, with values ranging from t∈(0,1). For the dimension index of the time embedding vector, The total dimension of the time embedding vector. This is a concatenation operation. The encoded result is input into a multilayer perceptron (MLP) consisting of linear layers, SiLU activation functions, and dropout layers, and the output is a final temporal embedding vector used for dynamic affine modulation of network features.
[0059] Step 2.4.2, Residual Block and Time Modulation.
[0060] Each residual block contains two 3×3 convolutional layers, group normalization, and SiLU activation function; the temporal embedding vector is mapped to two sets of parameters, scale and shift, through a linear layer, and the features are then subjected to an affine transformation.
[0061]
[0062] in This is an intermediate feature map in the residual block. Scaling parameters generated for time embedding, Offset parameters generated for time embedding.
[0063] Step 2.4.3, Self-attention module.
[0064] In the deep network structure, a self-attention module is enabled. First, the features are grouped and normalized, and then a 1×1 convolutional linear mapping is used to obtain the query q, key k, and value v.
[0065]
[0066]
[0067] in Here is the self-attention weight matrix. For attention query vectors, For attention key vectors, For attention value vectors, The number of channels in the feature map. For normalization function, Output feature maps for self-attention. For matrix transpose, The feature map is used as input for self-attention.
[0068] Step 2.4.4, Mask Feature Fusion Module.
[0069] During the UNet encoding downsampling stage, the multi-scale sketch structure features output by the mask predictor are concatenated with the hidden layer features of the corresponding network level in the channel dimension. Feature fusion is completed through 1×1 convolution, which explicitly introduces the component structure prior into the generation process, suppresses artifacts in unstructured regions, and enhances the generation of effective stress regions.
[0070] Step 2.4.5: Encoding downsampling, decoding upsampling, and skip connections.
[0071] UNet gradually reduces the spatial size of the feature map through downsampling convolution and gradually restores the size through upsampling interpolation. Each upsampling layer is spliced with the downsampling features of the corresponding layer by skip connections, preserving multi-scale stress details and avoiding information loss.
[0072] Step 2.4.6, Core process of potential spatial flow matching.
[0073] Random sampling time t∈(0,1), with initial Gaussian noise With stress true value potential characteristics Perform linear interpolation:
[0074]
[0075] Will The latent features of the sketch and the latent features of the force heatmap are concatenated along the channel dimension to form a model input of [B, 12, 32, 32], where B is the batch size. This input is fed into UNet and combined with the mask feature fusion result to obtain the prediction vector field. The target vector field is defined as:
[0076]
[0077] in For flow matching, the continuous-time parameter is used to control the transition speed of the potential state from noise to truth. The initial Gaussian noise latent features correspond to the generation starting point. These are the latent features of the target after VAE encoding of the stress ground truth image. Let t be the intermediate latent state feature corresponding to time t, where time t is the time t. The corresponding intermediate latent state features, The target vector field for flow matching learning represents the mapping direction of the latent space.
[0078] Step 3: Construct the foreground-weighted loss function and train the model. The specific process is as follows:
[0079] A foreground-weighted L1 loss is constructed as the core optimization objective for model training. The base loss uses L1 loss to measure the error between the predicted vector field and the target vector field.
[0080]
[0081] in For flow matching, the basic L1 loss, For the vector field predicted by the model, Flow matching target vector field.
[0082] The pixel space mask is downsampled to a latent space size of 32×32 using nearest neighbor interpolation, resulting in... Constructing weighted weights:
[0083]
[0084] The effective stress region weighting coefficient, This represents the foreground loss magnification factor, which is 10 in this embodiment. This is the effective region mask downsampled to the potential spatial size.
[0085] The final loss is the average of the weighted losses:
[0086]
[0087] in The AdamW optimizer was used for training the mean function with an initial learning rate of 10. −4 Weight decay 10 −5 The learning rate is dynamically adjusted using cosine annealing learning rate scheduling; the maximum norm of gradient clipping is set to 1.0 to prevent gradient explosion; the batch size is 32, and the total number of training epochs is 300. Only the flow matching UNet parameters are optimized in an end-to-end manner, enabling the model to efficiently learn an accurate mapping from sketch structure and stress point conditions to potential stress features.
[0088] Step 4: Inference stage - Generate stress distribution image. The specific process is as follows:
[0089] During the inference phase, the component sketch to be generated and the binary stress point image are input into the trained model. First, a Gaussian heatmap transformation is performed on the stress point image; then, the sketch and stress heatmap are fed into VAE encoding to obtain the corresponding latent features; simultaneously, the sketch is input into the mask predictor to obtain multi-scale structural features and a stress effective region mask. The latent noise z is initialized from a standard Gaussian distribution, and 50 steps of Euler integral iteration are performed.
[0090]
[0091]
[0092] in This represents the time step size for a single step in the Euler integral. This represents the total number of inference iterations; in this example, it is 50. For the latent feature vectors in the iterative update, This is the predicted vector field output by UNet.
[0093] During the iteration process, the mask features continuously guide the generation of the stress field, ensuring structural rationality and regional integrity. After the iteration is completed, the final latent features are fed into the VAE decoder to restore the pixel space image, and the value range is mapped back from [−1,1] to [0,1] using the following formula:
[0094]
[0095] in For the final generated stress distribution image, Perform restoration calculations for the VAE decoder. Output a final high-fidelity, physically consistent visualization of the stress distribution.
[0096] This invention employs a combined approach of pre-trained VAE latent space learning, Gaussian heatmap force encoding, masked prediction of structural priors, flow-matched vector field fitting, masked feature fusion, and foreground weighted joint loss constraints. This significantly improves the clarity, gradient accuracy, physical consistency, and structural rationality of stress distribution generation without substantially increasing computational overhead or model complexity. It effectively solves problems such as the cumbersome process of traditional finite element simulation, the computational inefficiency of existing deep learning methods, coarse force point encoding, loss of stress details, and artifact interference in non-structural areas. The method can directly and quickly generate stress fields from component sketches and force points without requiring specialized simulation software, manual modeling, or complex parameter settings. It offers advantages such as stable training, fast inference, realistic details, and physical rationality, making it suitable for scenarios such as mechanical structure design, industrial product simulation, rapid visualization, and lightweight intelligent design.
Claims
1. A sketch-driven stress distribution generation method based on latent spatial flow matching, characterized in that, Includes the following steps: Step 1: Obtain the component sketch image, binary stress point annotation image, and stress distribution true value image; perform preprocessing on the images, including normalization, and generate a stress region mask within the sketch structure range; Step 2: Construct a stress distribution generation model, which includes a fine-tuned and fixed pre-trained variational autoencoder (VAE) module, a Gaussian heatmap transformation module, a mask predictor, and a flow matching UNet. Each module sequentially achieves the transformation between image space and latent space through encoding, the transformation of stress point distribution through Gaussian convolution, the prediction of stress region through convolutional coding structure, and the flow matching of latent space through vector field learning. Step 3: Construct a joint loss function that includes foreground-weighted flow matching loss and mask prediction loss. Fix the VAE parameters and perform joint optimization training only on the mask predictor and the flow matching UNet. Step 4: Input the component sketch and stress point image to be generated into the trained stress distribution generation model, fuse the multi-scale structural features output by the mask predictor with the hidden layer features of the flow matching UNet, and generate the stress distribution image through latent space flow matching inference and pre-trained VAE module decoding.
2. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 1, the image preprocessing includes: converting the channels to RGB three channels, normalizing the size to 256×256, and normalizing the pixel values to [-1,1]. The effective stress region mask is automatically generated based on the brightness threshold of the stress distribution true image. It is a single-channel binary mask tensor used to identify the spatial range between the effective stress region and the invalid background region.
3. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 2, the pre-trained VAE adopts a variational autoencoder architecture based on the latent diffusion model and using KL divergence constraints. The VAE is first fine-tuned on the target task dataset. The parameters of the fine-tuned VAE are fixed in both the training and inference stages. It serves as a feature transformation module between the image space and the latent space, mapping the 3-channel RGB image to 4-channel low-dimensional latent features, and performing latent representation learning through reparameterized sampling.
4. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 2, the Gaussian heat map conversion module constructs a 9×9 Gaussian kernel to convolve the binary stress points, transforming the discrete points into a continuously distributed heat map to model the stress diffusion range and stress concentration law.
5. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 2, the mask predictor adopts an encoder-bottleneck-decoder architecture, takes a 3-channel sketch as input, outputs a stress effective region mask, and in the encoding stage, outputs multi-scale intermediate features and flow-matched UNet hidden layer features to be concatenated in dimensions to inject structural priors.
6. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 2, the latent spatial flow matching UNet is a U-shaped network structure, which includes sinusoidal temporal embedding, residual block, self-attention module, downsampling, upsampling, skip connections and mask feature fusion layer; the mask feature fusion layer is located in the downsampling stage of the UNet encoder, and concatenates the feature maps of two different spatial scales output by the mask predictor with the hidden layer feature maps of the corresponding layers of UNet in the channel dimension.
7. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 2, the input of the flow matching UNet is a 12-channel spliced feature, which is composed of latent noise, sketch latent features, and stress heat map latent features spliced in the channel dimension; the network output is a vector field with the same dimension as the VAE latent features, which is used to represent the latent vector corresponding to the output stress field from the dual input of sketch and stress point.
8. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 3, the foreground weighted flow matching loss adopts L1 loss and assigns a loss weight to the effective stress region that is much higher than that to the background region. The mask prediction loss adopts binary cross-entropy loss. The total loss is a weighted sum of two terms. The mask predictor and flow matching UNet are jointly trained using the AdamW optimizer and cosine annealing strategy.
9. The sketch-driven stress distribution generation method based on latent spatial flow matching according to claim 1, characterized in that, In step 4, the inference stage uses an ordinary differential equation solver to iterate and gradually generate a stress potential representation from Gaussian noise under the guidance of mask features. After VAE decoding, the value range is mapped from [-1,1] back to [0,1] to generate the final stress distribution image.