Building three-dimensional skin lighting performance prediction method based on Swin Transform neural network
Through the three-dimensional skin light performance prediction method of building construction based on Swin Transformer neural network, the problem that traditional light design is difficult to cope with complex building forms is solved, and efficient and accurate light performance evaluation and energy consumption optimization are achieved.
Patent Information
- Application Number
- CN202411804287.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-15
- Estimated Expiration
- 2044-12-10
AI Technical Summary
Traditional lighting designs are difficult to cope with changes in complex building forms and environments, resulting in excessive or insufficient lighting and increasing energy consumption. The prior art cannot effectively handle the prediction of lighting environment under complex input conditions.
The three-dimensional epidermal light performance prediction method of architectural 3D epidermal light performance is adopted based on Swin Transformer neural network. The epidermal geometric information is converted into multi-layer two-dimensional tensors through voxelization processing, and the global multi-scale feature extraction is used to achieve fast and efficient indoor lighting effect prediction.
Accurate lighting performance evaluation under complex geometric forms is achieved, replacing traditional physical simulation methods, significantly improving computing efficiency, and reducing lighting energy consumption through optimizing skin design, helping buildings to save energy and reduce emissions.
Smart Images

Figure CN119830393A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of building lighting design, and in particular to a method for predicting building three-dimensional skin lighting performance based on a Swin Transformer neural network. Background Art
[0002] Lighting design is an important aspect that affects building energy consumption. How to effectively reduce unnecessary energy consumption while ensuring the comfort of the indoor light environment is one of the main challenges in architectural design. Traditional lighting design is usually based on fixed parameter settings, which is difficult to cope with complex building forms and changing environmental conditions, resulting in excessive or insufficient lighting, which in turn increases the energy consumption of air conditioning and lighting systems. Especially in high-density urban environments, the complex form of the building's surface has a particularly significant impact on lighting performance. Conventional design methods are difficult to obtain appropriate lighting requirements, resulting in increased building energy consumption.
[0003] The Chinese patent "A system, method and device for simulating indoor daylighting rate for interior design (CN1175747B7B)" discloses a novel indoor daylighting rate simulation method, establishing a convolutional neural network model; constructing a feature sequence of image features in a training set; mapping a first vector set S1 obtained by processing the feature sequence to obtain a second vector set S2; the second vector set S2 passes through a convolution layer including a Sigmoid function to obtain a detail feature vector set S3; the detail feature vector set S3 passes through a pooling layer to obtain a global feature map S4; through the combination of a support vector machine model and a convolutional neural network model, and the combination of image and illumination data, a more accurate daylighting image and daylighting rate output are obtained, which provides great convenience for interior design, and combines image recognition (neural network) with a prediction and recommendation process (machine learning model) to improve the accuracy of daylighting simulation, and obtain daylighting rate prediction and simulation for interior design in all weather, all seasons and all time periods.
[0004] However, this method also has its shortcomings. First, this method uses historical data of a specific room as a sample, so it is only used for lighting prediction and interior design of a specific room, and cannot be used for more architectural design pre-research. Secondly, the neural network for indoor lighting image prediction described in this method does not use window morphology as an input feature, so it cannot reflect the impact of changes in the morphology of the light-inlet window on lighting. At the same time, this method uses a conventional convolutional neural network for lighting image prediction, which lacks the ability to capture global information and is not efficient in multi-scale feature extraction, so it is difficult to handle lighting environment prediction under complex input conditions. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] Based on this, the present invention proposes a method for predicting the lighting performance of three-dimensional building skins based on the Swin Transformer neural network. For the complex skin as the light-transmitting enclosure structure of the building, a Swin Transformer neural network model is trained to quickly generate indoor lighting images, replacing the traditional physical simulation method.
[0007] (II) Technical solution
[0008] In order to achieve the above object, the present invention provides a method for predicting the lighting performance of a three-dimensional building surface based on a Swin Transformer neural network, the method comprising the following steps:
[0009] S1: construct a mapping relationship between different epidermal mesh samples and lighting images to obtain a data set;
[0010] S101: establishing a parameterized model with adjustable thickness, opening direction, and opening size at all positions, and generating epidermal mesh samples by randomly inputting seed parameters;
[0011] S102: voxelize the epidermal mesh sample and convert it into a tensor T1, where the shape of T1 is (206, 43, 16);
[0012] S103: Establish a room model Z, add the tensor T1 obtained after voxelization of the epidermis mesh sample to the room model, obtain the regional meteorological file EPW, and use Honeybee to simulate and generate an indoor lighting image;
[0013] S2: Establish Swin Transformer neural network model;
[0014] S201: Input the feature tensor T1 into F.interpolate for interpolation to obtain a feature tensor T2 (224, 224, 16);
[0015] S202: Input the feature tensor T2 into Shift and Combine to perform gradient shift and combination to obtain a feature tensor T3 (224, 224, 1);
[0016] S203: Input the feature tensor T3 into Swin Transformer, and after four stages, realize global multi-scale feature extraction to obtain a feature tensor T4 (7, 7, 768);
[0017] S204: Input the feature tensor T4 into the fully connected layer to obtain the feature tensor T5;
[0018] S205: Convert the feature tensor T5 from a one-dimensional tensor with a length of 800 to a two-dimensional lighting image with a shape of (40, 20, 1);
[0019] S3: training the Swin Transformer neural network model using the data set;
[0020] S4: Input the epidermal mesh sample to be tested into the trained Swin Transformer neural network model to obtain an output indoor lighting image.
[0021] Optionally, S101 includes:
[0022] Step 1: A parametric skin model with adjustable thickness, opening direction, and opening size at all positions is established in the visual programming software Rhino-Grasshopper. The settings of the parametric skin model are as follows:
[0023] (1) Rectangular grid R setting: Set the rectangular grid R with the number of x, y, and z directions as 20, 1, and 5 respectively, and the cell size as 1m×1m×1m;
[0024] (2) Thickness setting: Select n control points (X t1 , Z t1 )、(X t2 , Z t2 )…(X tn , Z tn ), respectively according to the interference force F in the y direction t1 、F t2 …F tn , controls the partition thickness of the grid in the y direction; the closer the area is to the control point, the greater the degree to which its thickness changes in the direction of the interference force;
[0025] (3) Opening direction setting: In each cell, select the midpoint of the grid space as the base point Pi, and select m control points (X d1 , Z d1 )、(X d2 , Z d2 )…(X dm , Z dm ), according to the interference force F in the xz plane d1 、F d2 …F dm , controls the offset of the base point Pi in the xz plane; the closer the area is to the control point, the greater the offset of the base point Pi in the direction of the interference force; the line segment formed by connecting the base point Pi and the 8 corner points of the cell serves as the skeleton baseline of the epidermis;
[0026] (4) Opening size setting: Use the Dendro plug-in to convert the skeleton baseline into a smooth tubular mesh with thickness features; set the thickness of the tubular mesh at all positions to d i , whose initial values are all d0; select q control points (X s1 , Z s1 )、(X s2 , Z s2 )…(X sq , Z sq ), according to the scalar interference force F s1 、F s2 …F sm , control thickness d i The size of the area closer to the control point is changed; the thickness of the area d i The greater the degree of change in the direction of the interference force;
[0027] Step 2: Based on the parameterized epidermis model after the above settings, randomly adjust the parameters n, m, q, X t1 , X t2 …X tn , X d1 , X d2 …X dm , X s1 , X s2 …X sq , Z t1 , Z t2 …Z tn , Z d1 , Z d2 …Z dm , Z s1 , Z s2 …Z sq , d0, F t1 、F t2 …F tn , F d1 、F d2 …F dm , F s1 、F s2 …F sm , a total of 2000 sets of parameters are obtained, and 2000 smooth tubular mesh skin samples M are generated.
[0028] Optionally, S102 includes:
[0029] A cuboid C is constructed according to the maximum possible range of the epidermal sample, with a size of 20.6m×1.6m×4.3m. The cuboid C is converted into a voxel model V according to a voxel size of 0.1m×0.1m×0.1m. Then, the intersection of all epidermal mesh samples M and the voxel model V is calculated. The voxels intersecting with the epidermal mesh are marked as 1, and the voxels not intersecting with the epidermis are marked as 0, thereby obtaining the voxel labeling sequence S of the epidermal sample. The epidermal sample labeling sequence S is divided into 16 layers according to the levels of the voxel positions in the direction of the epidermal thickness. Pytorch is used to convert the multi-layer labeling sequence of the sample into a tensor T1 with a shape of (206,43,16).
[0030] Optionally, S202 includes:
[0031] The tensor T2 (224, 224, 16) passes through a ShiftAndCombine module, splits the tensor into 16 layers of two-dimensional tensors, performs gradient translation with a step size of B, and recombines it into a single-layer tensor; 12 translation step sizes B are set: (1, -1), (1, -2), (2, -1), (2, -2), (-1, -1), (-1, -2), (-2, -1), (-2, -2), (3, -1), (3, -2), (-3, -1), (-3, -2); the tensors combined according to the 12 step size gradient translations are added according to the 12 learnable weights Q to obtain the tensor T3 (224, 224, 1).
[0032] Optionally, S203 includes:
[0033] Step 1: Perform the Patch Embedding operation, embed the tensor T3 into blocks through the convolution layer, and convert it into a feature map with a shape of (56,56,96);
[0034] Step 2: Input the feature map of shape (56, 56, 96) into Swin Transformer, and go through four stages (Stage), each stage consists of several Transformer Blocks, which are responsible for feature extraction at different levels;
[0035] Among them, in Stage 1: after 2 Transformer Blocks, the output tensor shape is (56,56,96);
[0036] In Stage 2: After 2 Transformer Blocks, the output tensor shape is (28, 28, 192);
[0037] In Stage 3: After 6 Transformer Blocks, the output tensor shape is (14,14,384);
[0038] In Stage 4: After 2 Transformer Blocks, the output tensor shape is (7,7,768);
[0039] Step 3: The output tensor of shape (7, 7, 768) is normalized (LayerNorm), shifted window self-attention (Shifted Window Attention), residual connection (ResidualConnection), normalized, multi-layer perceptron (MLP), and residual connection in the Transformer Block structure to obtain the feature tensor T4 (7, 7, 768).
[0040] Optionally, S204 includes:
[0041] Step 1: The feature tensor T4 is flattened into a one-dimensional vector through a linear layer, converting the feature dimension to 1600;
[0042] Step 2: Apply the ReLU activation function to introduce nonlinearity, so that the model can learn more complex features;
[0043] Step 3: Use the Dropout function and set the Dropout rate to 0.1 to prevent the model from overfitting;
[0044] Step 4: The feature tensor passes through the linear layer (Linear) to convert the feature dimension from 1600 to 800, obtaining tensor T5.
[0045] Optionally, S3 includes:
[0046] S301: randomly divide the data set into a training set and a test set, and load them;
[0047] S302: define a loss function;
[0048] S303: In each cycle of executing training, the neural network model sequentially trains the samples of the training set through forward propagation, loss calculation, and back propagation;
[0049] S304: After each cycle, the generalization performance of the neural network model is evaluated using the test set;
[0050] S305: Perform N cycles of training iterations on the neural network model to obtain a SwinTransformer neural network model that meets the accuracy requirements.
[0051] Optionally, the expression of the loss function defined in S302 is: loss=MSE+k×SSIM, where k is an adjustable weight, MSE is a mean square error, and SSIM is a structural similarity loss; the calculation formula of the mean square error MSE is:
[0052]
[0053] Where n represents the number of samples; y i represents the true value; y j represents the predicted value;
[0054] The calculation formula of structural similarity loss SSIM is:
[0055]
[0056] Among them, x and y represent two images respectively; μ x and μ y Represent the mean of image x and y features respectively; and Respectively represent the standard deviation of image x and y features; σ xy is the covariance of the image x and y features; C1 and C2 are constants used for stable calculations, usually taken as: C1 = (K1 × L) 2 、C1=(K2×L) 2 , L is the dynamic range of the image feature, the L value is 1, K1 and K2 are small constants, K1=0.01, K2=0.03.
[0057] Optionally, the value of N in S305 is 100.
[0058] (III) Beneficial effects
[0059] It can be seen from the above technical solution that the method for predicting the lighting performance of a three-dimensional building surface based on a Swin Transformer neural network proposed in the present invention has the following beneficial effects:
[0060] 1. For the three-dimensional volume of the complex building surface, the voxel method is used to discretize it and transform the surface geometry information into multi-layer two-dimensional tensors. These tensors can fully characterize the spatial form of the three-dimensional surface and serve as the feature input of the lighting prediction model, thereby realizing accurate lighting performance evaluation under complex geometric forms in the design stage.
[0061] 2. Use the Swin Transformer neural network model to process the multi-layer two-dimensional tensor extracted by the voxel method. With its powerful self-attention mechanism, the Swin Transformer neural network model can effectively capture the complex relationship between the geometric form of the building surface and the lighting performance, and achieve fast and efficient indoor lighting effect prediction, replacing the traditional physical simulation method, while ensuring accuracy and significantly improving the computational efficiency.
[0062] 3. The Swin Transformer neural network model of the present invention can not only provide designers with rapid lighting evaluation, but also reduce lighting energy consumption during the use phase by optimizing the surface design, thereby indirectly helping to achieve the building's energy conservation and emission reduction goals. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The features and advantages of the present invention will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present invention in any way. In the accompanying drawings:
[0064] Figure 1 is a flow chart of an embodiment of the present invention;
[0065] Figure 2 A schematic diagram of a parameterized epidermis model according to an embodiment of the present invention;
[0066] Figure 3 A schematic diagram of an epidermal sample according to an embodiment of the present invention;
[0067] Figure 4 is a schematic diagram of a voxelized model according to an embodiment of the present invention;
[0068] Figure 5 A flow chart of establishing a Swin Transformer neural network model in an embodiment of the present invention;
[0069] Figure 6 A real UDI lighting image in the training set of the embodiment of the present invention;
[0070] Figure 7 This is a Swin Transformer neural network model predicting a UDI lighting image in an embodiment of the present invention. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0072] like Figure 1 As shown, an embodiment of the present invention provides a method for predicting the lighting performance of a three-dimensional building surface based on a Swin Transformer neural network, the steps comprising:
[0073] S1: Construct a mapping relationship between different epidermal mesh samples and lighting images to obtain a data set; the specific steps include:
[0074] S101: establishing a parameterized model with adjustable thickness, opening direction, and opening size at all positions, and generating epidermal mesh samples by randomly inputting seed parameters;
[0075] A parametric epidermis model with adjustable thickness, opening direction, and opening size at all positions is established in the visual programming software Rhino-Grasshopper, and a large number of epidermis mesh samples M are generated by randomly inputting seed parameters. Specifically, the settings of the parametric epidermis model are as follows:
[0076] (1) Rectangular grid R setting: Set the rectangular grid R with the number of cells in the x, y, and z directions to 20, 1, and 5 respectively, and the cell size to 1m×1m×1m.
[0077] (2) Thickness setting: Select n control points within the xz plane of the rectangular grid R. According to the interference force in the y direction Controls the thickness of the grid in the y direction. The closer the area is to the control point, the more its thickness changes in the direction of the interference force.
[0078] (3) Opening direction setting: In each cell, select the midpoint of the grid space as the base point Pi, and select m control points within the xz plane of the rectangular grid R. According to the interference force in the xz plane Control the offset of the base point Pi in the xz plane. The closer the area is to the control point, the greater the offset distance of its base point Pi in the direction of the interference force. Connect the base point Pi and the 8 corner points of the cell to form a line segment as the skeleton baseline of the epidermis.
[0079] (4) Opening size setting: Use the Dendro plug-in to convert the skeleton baseline into a smooth tubular mesh with thickness features. Set the thickness of the tubular mesh at all positions to d i , whose initial value is d0. Select q control points in the xz plane of the rectangular grid R According to the scalar interference force Control thickness iThe closer the area is to the control point, the thicker it is. i The greater the degree of change in the direction of the interference force.
[0080] Schematic diagram of parameterized epidermis model Figure 2 As shown, the intersection position of the skeleton baseline controls the opening direction, and the thickness of the skeleton baseline indirectly controls the opening size, that is, the opening rate.
[0081] In this embodiment, based on the parameterized epidermis model after the above settings, the parameters n, m, q are randomly adjusted.
[0082] A total of 2000 sets of parameters were obtained, and 2000 smooth tubular mesh skin samples M were generated. The skin samples are as follows: Figure 3 shown.
[0083] S102: voxelize the epidermal mesh sample and convert it into tensor T1;
[0084] According to the maximum possible range of the epidermis, a rectangular parallelepiped C is constructed. In this embodiment, the size of the rectangular parallelepiped C is 20.6m×1.6m×4.3m. According to the appropriate voxel size, in this embodiment, the voxel size is 0.1m×0.1m×0.1m, the rectangular parallelepiped C is converted into a voxel model V, such as Figure 4 As shown. Then calculate the intersection of all epidermal mesh samples M and voxel model V. Voxels that intersect with the epidermal mesh are marked as 1, and voxels that do not intersect with the epidermis are marked as 0, and the voxel labeling sequence S of the epidermal sample is obtained. The epidermal sample labeling sequence S is divided into 16 layers according to the level of its voxel position in the direction of epidermal thickness. Pytorch is used to convert the multi-layer labeling sequence of the sample into a tensor T1 with a shape of (206,43,16).
[0085] S103: Simulate and generate indoor lighting images;
[0086] Establish a room model Z, add the epidermis mesh sample to the room model, obtain the regional meteorological file EPW, use Honeybee to simulate the annual lighting UDI (the percentage of time that the annual illumination meets the requirements), and obtain the indoor lighting image U, such as Figure 5 shown.
[0087] In this way, the mapping relationship between the epidermis mesh samples and the indoor lighting images was constructed to obtain the data set.
[0088] S2: Establish Swin Transformer neural network model;
[0089] In this embodiment, the Python-based PyTorch framework is used to build and train the Swin Transformer neural network model. The specific operations are as follows:
[0090] S201: Input the feature tensor T1 into F.interpolate for interpolation to obtain the feature tensor T2;
[0091] The input feature T1 (206, 43, 16) is first interpolated by the F.interpolate function to resize the input image to 224x224, and the tensor T2 (224, 224, 16) is obtained to meet the fixed size expected by the Swin Transformer structure.
[0092] S202: Input the feature tensor T2 into Shift and Combine to perform gradient shift and combination to obtain the feature tensor T3;
[0093] The tensor T2 (224, 224, 16) is passed through a ShiftAndCombine module, split into 16 layers of two-dimensional tensors, and then gradient translation with a step size of B is performed, and then recombined into a single layer tensor. 12 translation step sizes B are set: (1, -1), (1, -2), (2, -1), (2, -2), (-1, -1), (-1, -2), (-2, -1), (-2, -2), (3, -1), (3, -2), (-3, -1), (-3, -2). The tensors combined according to the 12 step size gradient translations are added according to the 12 learnable weights Q to obtain the tensor T3 (224, 224, 1).
[0094] S203: Input the feature tensor T3 into Swin Transformer, and after four stages, realize global multi-scale feature extraction to obtain the feature tensor T4;
[0095] The specific steps are as follows:
[0096] 1. Perform Patch Embedding operation, embed the tensor T3 into blocks through the convolution layer, and convert it into a feature map with a shape of (56,56,96);
[0097] 2. Input the feature map into Swin Transformer and go through four stages. Each stage consists of several Transformer Blocks, which are responsible for feature extraction at different levels.
[0098] Among them, in Stage 1: after 2 Transformer Blocks, the output tensor shape is (56,56,96);
[0099] In Stage 2: After 2 Transformer Blocks, the output tensor shape is (28, 28, 192);
[0100] In Stage 3: After 6 Transformer Blocks, the output tensor shape is (14,14,384);
[0101] In Stage 4: After 2 Transformer Blocks, the output tensor shape is (7, 7, 768).
[0102] 3. The extracted features are normalized (LayerNorm), shifted window attention, residual connection, normalized, multi-layer perceptron (MLP), and residual connection in the Transformer Block structure to obtain the feature tensor T4 (7, 7, 768).
[0103] Among them, in the sliding window self-attention stage, the feature map is divided into local windows of fixed (5×5) size. In each window, the attention distribution is calculated using Query, Key, and Value, and the attention weight is normalized using Softmax. The Value is weighted and summed using the attention weight to output the aggregated features. In adjacent layers, the window position is slid with a step size of 3, so that the features between different windows are fused layer by layer to promote the integration of global information.
[0104] In the residual connection stage, the input of the self-attention module is directly added to the output to alleviate the gradient vanishing problem.
[0105] The normalization after the residual connection is to normalize the self-attention output again to ensure the stability of the features input to the next module.
[0106] In the multi-layer perceptron (MLP) stage, the feature dimension is expanded to 4 times of the input feature through the first layer of linear transformation; nonlinearity is introduced through GELU activation to improve the feature expression ability; and the feature dimension is restored to its original size through the second layer of linear transformation.
[0107] The residual connection after the multi-layer perceptron adds the input and output of the MLP to enhance the stability of feature transfer.
[0108] S204: Input the feature tensor T4 into the fully connected layer to obtain the feature tensor T5;
[0109] The specific steps are as follows:
[0110] 1. The feature tensor T4 is flattened into a one-dimensional vector through a linear layer (Linear), converting the feature dimension to 1600;
[0111] 2. Apply the ReLU activation function to introduce nonlinearity, so that the model can learn more complex features;
[0112] 3. Use the Dropout function to prevent the model from overfitting. The Dropout rate set in this embodiment is 0.1, which means that 10% of the neurons will be randomly "turned off";
[0113] 4. The feature tensor passes through the linear layer (Linear) to convert the feature dimension from 1600 to 800, obtaining tensor T5.
[0114] S205: Convert the feature tensor T5 from a one-dimensional tensor with a length of 800 to a two-dimensional lighting image L with a shape of (40, 20, 1), where (40, 20, 1) is used to represent a three-dimensional array, the image resolution is (40, 20), and 1 means there is only one numerical feature, that is, the annual lighting UDI value, which can be mapped to grayscale or color;
[0115] S3: training the Swin Transformer neural network model using the data set;
[0116] S301: randomly divide the data set into a training set and a test set, and load them;
[0117] The random_split function is used to randomly split the data set into training and test sets, with 80% of the data used for training and 20% for testing. Subsequently, a data loader is defined to load training and test data in batches. The size of each batch of data during training is 50, and the training data is set to be randomly shuffled (shuffle = True) to ensure that the model can generalize better.
[0118] S302: define a loss function;
[0119] This embodiment uses the weighted sum of two loss functions, namely, mean square error (MSE) and structural similarity (SSIM), as the total loss function, which is expressed as: loss = MSE + k × SSIM, where k is an adjustable weight used to adjust the balance between image fidelity and numerical accuracy of the output image.
[0120] The mean square error (MSE) calculates the square of the error between the predicted value and the true value, and then takes the average value to measure the accuracy of the model prediction. The smaller the value, the more accurate the model prediction. The calculation formula is:
[0121]
[0122] Where n represents the number of samples; y i represents the true value; y j Represents the predicted value.
[0123] Structural similarity loss SSIM is used to calculate the image structural similarity between images, and its calculation formula is:
[0124]
[0125] Among them, x and y represent two images respectively; μ x and μ y Represent the mean of image x and y features respectively; and Respectively represent the standard deviation of image x and y features; σ xy is the covariance of the image x and y features; C1 and C2 are constants used for stable calculations, usually taken as: C1 = (K1 × L) 2 、C1=(K2×L) 2 , L is the dynamic range of the image feature. This embodiment performs normalization processing, so the value of L is 1. K1 and K2 are small constants, usually K1=0.01, K2=0.03.
[0126] S303: In each cycle of executing training, the neural network model sequentially trains the samples of the training set through forward propagation, loss calculation, and back propagation;
[0127] The entire model training is performed for 100 epochs. In each epoch, the model processes all training samples in turn:
[0128] Forward propagation is the input feature, and the output result is obtained through model calculation. Loss calculation is to calculate MSE loss and SSIM loss separately, and the weighted addition of the two is used to obtain the total loss function. Backward propagation is to use the backpropagation algorithm to calculate the gradient of the loss relative to the model parameters, and update the model parameters (i.e. the model weights) through the Adam optimizer. The optimizer updates the model weights based on these gradients, so that the model loss function gradually decreases. During each cycle of training, the loss value of each batch, as well as MSE and SSIM, will gradually optimize, and the performance of the model will gradually improve.
[0129] S304: After each cycle, the generalization performance of the neural network model is evaluated using the test set;
[0130] After each cycle, the model is evaluated on the test set. Unlike the training process, no parameter updates are performed during the test process, that is, the gradients are not back-propagated, and the model only performs forward propagation to calculate the test loss. By calculating the ratio of the loss function of the test set to the loss function of the training set, the generalization ability of the model on unseen data can be measured. In this embodiment, the loss function of the model evaluated on the test set is only 5% higher than that of the training set, indicating that the model has good generalization ability.
[0131] S305: Performing N cycles of training iterations on the neural network model to obtain a SwinTransformer neural network model that meets the accuracy requirements;
[0132] In this embodiment, the value of N is 100. After multiple iterations, the weight parameters of the model are gradually optimized, so that the training and test losses are gradually reduced. Finally, the training loss function reaches 0.94, and the test loss function reaches 0.90. The test loss function is only 4.4% higher than the training loss, indicating that the model has good prediction accuracy and generalization ability.
[0133] S4: Input the epidermal mesh sample to be tested into the trained Swin Transformer neural network model to obtain an output indoor lighting image.
[0134] In this embodiment, 30 new parameterized building skins are generated, converted into tensors and input into the trained neural network model, and the predicted UDI lighting images (set P) are output. In addition, Honeybee is used to simulate the lighting throughout the year to obtain the UDI lighting images (set R). In this embodiment of the present invention, for the same parameter skin, the real UDI lighting images simulated by Honeybee are as follows: Figure 6 As shown, the model is used to predict the UDI lighting image as Figure 7 As shown. Taking set R as the real data and verifying the accuracy of set P, the average MSE is 0.95, indicating that the numerical accuracy of the prediction is high, and the average SSIM is 0.92, indicating that the structural similarity between the predicted image and the real image is high. The verification results show that the model has good performance.
[0135] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for predicting the lighting performance of a three-dimensional building surface based on a Swin Transformer neural network, characterized in that: The method comprises: S1: construct a mapping relationship between different epidermal mesh samples and lighting images to obtain a data set; S101: establishing a parameterized model with adjustable thickness, opening direction, and opening size at all positions, and generating epidermal mesh samples by randomly inputting seed parameters; S102: voxelize the epidermal mesh sample and convert it into a tensor T1, where the shape of T1 is (206, 43, 16); S103: Establish a room model Z, add the tensor T1 obtained after voxelization of the epidermis mesh sample to the room model, obtain the regional meteorological file EPW, and use Honeybee to simulate and generate an indoor lighting image; S2: Establish Swin Transformer neural network model; S201: Input the feature tensor T1 into F.interpolate for interpolation to obtain a feature tensor T2 (224, 224, 16); S202: Input the feature tensor T2 into Shift and Combine to perform gradient shift and combination to obtain a feature tensor T3 (224, 224, 1); S203: Input the feature tensor T3 into Swin Transformer, and after four stages, realize global multi-scale feature extraction to obtain a feature tensor T4 (7, 7, 768); S204: Input the feature tensor T4 into the fully connected layer to obtain the feature tensor T5; S205: Convert the feature tensor T5 from a one-dimensional tensor with a length of 800 to a two-dimensional lighting image with a shape of (40, 20, 1); S3: training the Swin Transformer neural network model using the data set; S4: Input the epidermal mesh sample to be tested into the trained Swin Transformer neural network model to obtain an output indoor lighting image.
2. The method according to claim 1, characterized in that S101 includes: Step 1: A parametric skin model with adjustable thickness, opening direction, and opening size at all positions is established in the visual programming software Rhino-Grasshopper. The settings of the parametric skin model are as follows: (1) Rectangular grid R setting: Set the rectangular grid R with the number of x, y, and z directions as 20, 1, and 5 respectively, and the cell size as 1m×1m×1m; (2) Thickness setting: Select n control points within the xz plane of the rectangular grid R. According to the interference force in the y direction Controls the thickness of the grid in the y direction; the closer the area is to the control point, the greater the degree to which its thickness changes in the direction of the interference force; (3) Opening direction setting: In each cell, select the midpoint of the grid space as the base point Pi, and select m control points within the xz plane of the rectangular grid R. According to the interference force in the xz plane Control the offset of the base point Pi in the xz plane; the closer the area is to the control point, the greater the offset distance of its base point Pi in the direction of the interference force; the line segment formed by connecting the base point Pi and the 8 corner points of the cell is used as the skeleton baseline of the epidermis; (4) Opening size setting: Use the Dendro plug-in to convert the skeleton baseline into a smooth tubular mesh with thickness features; set the thickness of the tubular mesh at all positions to d i , whose initial value is d0; select q control points in the xz plane of the rectangular grid R According to the scalar interference force Control thickness i The size of the area closer to the control point is changed; the thickness of the area d i The greater the degree of change in the direction of the interference force; Step 2: Based on the parameterized epidermis model after the settings, randomly adjust the parameters n, m, q. A total of 2000 sets of parameters are obtained, and 2000 smooth tubular mesh skin samples M are generated.
3. The method according to claim 1, characterized in that S102 includes: A cuboid C is constructed according to the maximum possible range of the epidermal sample, with a size of 20.6m×1.6m×4.3m. The cuboid C is converted into a voxel model V according to a voxel size of 0.1m×0.1m×0.1m. Then, the intersection of all epidermal mesh samples M and the voxel model V is calculated. The voxels intersecting with the epidermal mesh are marked as 1, and the voxels not intersecting with the epidermis are marked as 0, thereby obtaining the voxel labeling sequence S of the epidermal sample. The epidermal sample labeling sequence S is divided into 16 layers according to the levels of the voxel positions in the direction of the epidermal thickness. Pytorch is used to convert the multi-layer labeling sequence of the sample into a tensor T1 with a shape of (206,43,16).
4. The method according to claim 1, characterized in that S202 includes: The tensor T2 (224, 224, 16) passes through a ShiftAndCombine module, splits the tensor into 16 layers of two-dimensional tensors, performs gradient translation with a step size of B, and recombines it into a single-layer tensor; 12 translation step sizes B are set: (1, -1), (1, -2), (2, -1), (2, -2), (-1, -1), (-1, -2), (-2, -1), (-2, -2), (3, -1), (3, -2), (-3, -1), (-3, -2); the tensors combined according to the 12 step size gradient translations are added according to the 12 learnable weights Q to obtain the tensor T3 (224, 224, 1).
5. The method according to claim 1, characterized in that S203 includes: Step 1: Perform the Patch Embedding operation, embed the tensor T3 into blocks through the convolution layer, and convert it into a feature map with a shape of (56,56,96); Step 2: Input the feature map of shape (56, 56, 96) into Swin Transformer, and go through four stages (Stage), each stage consists of several Transformer Blocks, which are responsible for feature extraction at different levels; Among them, in Stage 1: after 2 Transformer Blocks, the output tensor shape is (56,56,96); In Stage 2: After 2 Transformer Blocks, the output tensor shape is (28, 28, 192); In Stage 3: After 6 Transformer Blocks, the output tensor shape is (14,14,384); In Stage 4: After 2 Transformer Blocks, the output tensor shape is (7,7,768); Step 3: The output tensor of shape (7, 7, 768) is normalized (LayerNorm), shifted window self-attention (Shifted Window Attention), residual connection (ResidualConnection), normalized, multi-layer perceptron (MLP), and residual connection in the Transformer Block structure to obtain the feature tensor T4 (7, 7, 768).
6. The method according to claim 1, characterized in that S204 includes: Step 1: The feature tensor T4 is flattened into a one-dimensional vector through a linear layer, converting the feature dimension to 1600; Step 2: Apply the ReLU activation function to introduce nonlinearity, so that the model can learn more complex features; Step 3: Use the Dropout function and set the Dropout rate to 0.1 to prevent the model from overfitting; Step 4: The feature tensor passes through the linear layer (Linear) to convert the feature dimension from 1600 to 800, obtaining tensor T5.
7. The method according to claim 1, characterized in that S3 include: S301: randomly divide the data set into a training set and a test set, and load them; S302: define a loss function; S303: In each cycle of executing training, the neural network model sequentially trains the samples of the training set through forward propagation, loss calculation, and back propagation; S304: After each cycle, the generalization performance of the neural network model is evaluated using the test set; S305: Perform N cycles of training iterations on the neural network model to obtain a SwinTransformer neural network model that meets the accuracy requirements.
8. The method according to claim 7, characterized in that The expression of the loss function defined in S302 is: loss = MSE + k × SSIM, where k is an adjustable weight, MSE is the mean square error, and SSIM is the structural similarity loss; the calculation formula of the mean square error MSE is: Where n represents the number of samples; y i represents the true value; y j represents the predicted value; The calculation formula of structural similarity loss SSIM is: Among them, x and y represent two images respectively; μ x and μ y Represent the mean of image x and y features respectively; and Respectively represent the standard deviation of image x and y features; σ xy is the covariance of the image x and y features; C1 and C2 are constants used for stable calculations, usually taken as: C1 = (K1 × L) 2 、C1=(K2×L) 2 , L is the dynamic range of the image feature, the L value is 1, K1 and K2 are small constants, K1=0.01, K2=0.
03.
9. The method according to claim 7, characterized in that: The value of N in S305 is 100.
Citation Information
Patent Citations
Porous medium permeability prediction method based on Transform network
CN116680988A
Hyperspectral image classification method based on high-order interactive convolutional network
CN118506112A
Perception model training method, and perception model-based scene perception method
WO2023040068A1
Unsupervised low-illumination-domain adaptive training method and detection method
WO2024055398A1