$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
The proposed framework of SegCycle-SPADE is designed to reconstruct and improve traditional cultural heritage patterns through semantic segmentation, feature enhancement using attention, generative reconstruction, and artistic style synthesis. This study utilized publicly available cultural heritage and artistic image datasets, including the Miao Batik dataset and the WikiArt dataset. No human participants, patient data, personal information, animal subjects, or clinical records were involved in the research; therefore, institutional ethics committee approval and informed consent were not required. To start with, the Miao Batik cultural motif dataset and the WikiArt dataset are utilized for the evaluation. The Miao Batik dataset was described in Quan et al. (2024)32 and contains 15,148 annotated images of traditional Miao batik motifs. Existing annotations provided by the dataset creators were used directly, and no additional manual annotations were generated in this study. Then, preprocessing of the images is performed by resizing, normalizing, denoising, and creating a segmentation mask. The exact preprocessing parameters are described in the Data Preprocessing subsection. The proposed framework utilizes a transformer-based model named SegFormer-B2 for the semantic segmentation of the data. The method is designed to detect key regions of cultural motifs and learn their structures. The segmented features are then enhanced through an attention mechanism, where important information related to cultural motifs is highlighted and irrelevant information is discarded. The attention mechanism configuration is described in the CAFFM subsection. The enhanced features are then passed through CycleGAN, where damaged structures are reconstructed through cyclic learning. During training, incomplete motif samples were artificially created by applying random masking and partial occlusion operations to the original Miao Batik images. These degradation procedures simulated missing motif regions and structural damage commonly observed in deteriorated cultural heritage artifacts. The resulting incomplete images were used as inputs to the CycleGAN reconstruction module, while the corresponding original images served as reconstruction targets. The reconstructed cultural heritage patterns are then enhanced through SPADE, where artistic enhancement is carried out based on the generated segmentation maps. The performance of the proposed framework is evaluated using quantitative segmentation and image-quality metrics, while the visual authenticity of the reconstructed cultural motifs is assessed qualitatively. Visual authenticity was assessed through visual inspection of the generated cultural patterns and was not used as an independent quantitative metric. The assessment focused on motif preservation, semantic consistency, cultural characteristics, structural coherence, and artistic appearance relative to the corresponding reference cultural motifs. Quantitative evaluation of model performance was performed using Segmentation Accuracy, IoU, Dice Coefficient, Structural Similarity Index Measure (SSIM), Peak Signal-to-Noise Ratio (PSNR), and Fréchet Inception Distance (FID). Figure 2 illustrates the overall workflow of the proposed SegCycle-SPADE framework and summarizes the evaluation metrics used in this study.

Figure 2. Overall Architecture Workflow of the Proposed SegCycle-SPADE Framework. Overview of the complete SegCycle-SPADE workflow. Images from the Miao Batik and WikiArt datasets undergo preprocessing before being processed through semantic segmentation using SegFormer-B2, feature enhancement using the CAFFM, pattern reconstruction using CycleGAN, and artistic style generation using SPADE. Model performance is evaluated using Segmentation Accuracy, Intersection over Union (IoU), Dice Coefficient, Structural Similarity Index Measure (SSIM), PSNR, Fréchet Inception Distance (FID), while visual authenticity is assessed qualitatively. Please click here to view a larger version of this figure.
The SegCycle-SPADE framework for cultural heritage pattern reconstruction is designed to integrate multiple DL components for accurate motif segmentation, reconstruction, and artistic enhancement, as illustrated in Figure 2. Images from the Miao Batik cultural motif dataset and the WikiArt dataset are used to provide diverse cultural patterns and artistic styles. Initially, the images are processed using a SegFormer-based semantic segmentation module to identify and delineate cultural motifs from the background. The overall architecture consists of four main stages. First, the SegFormer model extracts semantic segmentation maps from the cultural pattern images. Second, the CAFFM integrates segmentation features with generative representations to enhance feature learning. Third, the CycleGAN module reconstructs cultural patterns using the fused feature representations. Finally, the SPADE module generates stylistically enhanced outputs while preserving structural consistency through segmentation-guided synthesis. The refined feature maps are subsequently processed by the CycleGAN reconstruction module, which learns to restore incomplete cultural motifs by mapping degraded patterns to their corresponding complete forms. Incomplete motif samples were generated by applying random masking and partial occlusion operations to the original Miao Batik images, thereby simulating missing pattern regions and structural degradation commonly observed in damaged cultural artifacts. Each degraded image was paired with its corresponding original image, which served as the reconstruction target during training. This strategy enabled the CycleGAN module to learn the restoration of missing motif structures while preserving semantic consistency and culturally significant characteristics. Finally, the SPADE generator produces visually enhanced artistic outputs by conditioning image synthesis on the generated segmentation maps, thereby maintaining the structural integrity of the cultural motifs throughout the artistic enhancement process.
The following steps are involved in proposed SegCycle-SPADE framework.
Step 1: Dataset Collection
Two datasets were used to achieve the objectives of cultural pattern learning and artistic style generation. The Miao Batik Cultural Motif Dataset was used to provide traditional cultural pattern information. The dataset is publicly available through Zenodo (https://doi.org/10.5281/zenodo.20807658) and contains 15,148 annotated images of traditional Miao batik motifs. Existing annotations provided by the dataset creators were used directly, and no additional manual annotations were generated in this study. The WikiArt dataset was used to provide diverse artistic style information for artistic style generation and was obtained from the publicly available WikiArt repository (https://www.wikiart.org/).
Step 2: Data Preprocessing
All images were preprocessed through resizing, normalization, and noise reduction. Existing cultural motif annotations obtained from the original dataset sources were used to support the semantic segmentation stage. No additional annotation or relabeling procedures were performed as part of this study.
Step 3: Semantic Pattern Segmentation using SegFormer
The SegFormer model was used for cultural motif segmentation. The exact SegFormer backbone and initialization strategy are described in the Semantic Pattern Segmentation Using SegFormer subsection. Specifically, the SegFormer-B2 architecture with an ImageNet-pretrained MIT-B2 backbone was employed for semantic motif segmentation. This model effectively captures global contextual information while preserving the complex structural details of traditional cultural patterns.
Step 4: CAFFM
The CAFFM combines semantic segmentation features with generative representations, enabling the framework to learn both structural motif characteristics and artistic style information. Integration details of CAFFM are provided in the CAFFM subsection. The module is positioned between the SegFormer-based semantic segmentation stage and the generative reconstruction stage, where it fuses segmentation-derived structural features with reconstruction features through multi-head cross-attention. This process improves cultural motif preservation and enhances the realism of the reconstructed outputs.
Step 5: Pattern Reconstruction (CycleGAN)
The fused features are subsequently processed by the CycleGAN module to reconstruct cultural pattern structures. The CycleGAN architecture and training configuration are described in the Pattern Reconstruction Using CycleGAN subsection. The reconstruction module consists of two generators and two discriminators, utilizes a residual-network generator architecture with nine residual blocks, employs a PatchGAN discriminator, and is trained using adversarial and cycle-consistency losses. This configuration enables bidirectional domain mapping and facilitates the reconstruction of incomplete cultural pattern structures.
Step 6: Artistic Style Generation (SPADE)
The reconstructed patterns are then processed through the SPADE module to perform segmentation-guided artistic style synthesis. The SPADE generator configuration is described in the Artistic Style Generation Using SPADE subsection. The module employs SPADE residual blocks, spatially adaptive normalization layers, and semantic conditioning derived from SegFormer segmentation maps and CAFFM feature representations. By conditioning image generation on segmentation maps, the synthesized outputs maintain structural alignment with the original cultural motifs while incorporating artistic style characteristics.
Step 7: Performance Estimation
The proposed framework was evaluated using multiple segmentation and image-quality assessment metrics, including Segmentation Accuracy, IoU, Dice Similarity Coefficient (Dice), SSIM, PSNR, and FID. To assess experimental consistency, all experiments were repeated five times using different random seeds, and the results are reported as mean ± standard deviation. Statistical significance was evaluated using paired t-tests, with a significance threshold of p < 0.05.
Dataset Collection
In the proposed framework of SegCycle-SPADE, two datasets are employed for cultural pattern understanding and style learning. The first dataset employed in the proposed framework is the Miao Batik cultural motif dataset. This dataset contains cultural motifs of Miao Batik, which are generally images of traditional Miao Batik containing motifs like animals, plants, and geometric shapes, which are used in Miao ethnicity art. This dataset contains images with rich texture information, which are generally important for preserving cultural heritage. The second dataset employed in the proposed framework of SegCycle-SPADE is the WikiArt dataset. This dataset contains a huge number of artworks, which are generally from different styles. This dataset is employed for complex style learning, which is generally useful for enhancing artworks. This dataset has 80,000 artworks in HD, with 27 different designs, making it more useful for DL-based style generation or transformation tasks.
Miao Batik Dataset:
The Miao Batik dataset (https://doi.org/10.5281/zenodo.20807658) comprises 15,148 images of batik patterns depicting culturally significant motifs. The images include a variety of traditional designs, such as animal motifs (e.g., butterflies and fish), plant-based patterns, and geometric motifs that carry cultural symbolism. This dataset is an important component of the proposed framework because it provides authentic cultural structures that enable the segmentation module to accurately identify and preserve motif boundaries during pattern reconstruction (Table 1). In this study, culturally important motifs refer to symbolic visual elements commonly documented in Miao cultural heritage literature and represented within the dataset annotations, including birds, butterflies, floral patterns, and ancestral totems. These motifs were selected based on their documented cultural significance and recurring presence in traditional Miao batik and embroidery designs rather than solely on their frequency of occurrence or spatial composition. The expert-guided motif annotations and segmentation labels were obtained from the original Miao Batik dataset source and were used directly in this study. No additional manual annotation, relabeling, or expert-guided annotation procedures were performed by the authors. The existing annotations provided by the dataset creators were utilized for semantic segmentation training and evaluation.
| Parameter | Description |
| Dataset Name | Miao Batik Cultural Pattern Dataset |
| Dataset Source | Zenodo Repository (DOI: 10.5281/zenodo.20807658) |
| Domain | Intangible Cultural Heritage (ICH) / Textile Pattern Analysis |
| Total Images | 15,148 images |
| Image Type | Digital images of traditional Miao batik textile patterns |
| Pattern Categories | Animal motifs, plant motifs, and geometric motifs |
| Cultural Origin | Miao ethnic culture, Guizhou Province, China |
| Original Image Resolution | High-resolution images (typically ≥ 1,000 pixels on the shorter side) captured as raw scans or photographs prior to preprocessing |
| Training Resolution | Images resized to 256 × 256 pixels during preprocessing |
| Annotation Availability | Existing segmentation annotations provided by the dataset creators were used without modification for training and evaluation. No additional manual annotation, relabeling, or expert-confirmation procedures were performed in this study. |
| Application in This Study | Cultural motif segmentation, feature extraction, motif preservation, and pattern reconstruction |
Table 1: Characteristics of the Miao Batik Cultural Pattern Dataset. Summary of the Miao Batik cultural motif dataset used for semantic segmentation, cultural pattern analysis, and motif reconstruction. The table describes the dataset source, image characteristics, motif categories, cultural origin, image resolution, and its role within the proposed SegCycle-SPADE framework.
WikiArt Dataset:
The WikiArt dataset [https://www.wikiart.org/] is a popular large-scale digital art repository that comprises over 80,000 images from 27 different artistic styles in Table 2. The styles include Renaissance art, Impressionism, Cubism, and Surrealism. The dataset is very important in the suggested framework since it offers knowledge that allows the SPADE module to create culturally enriched patterns while maintaining structural information obtained from the segmentation process. The dataset comprises 56,000 pictures for learning and 12,000 pictures for both validation and testing. The images in the dataset help in training the DL model effectively.
| Parameter | Description |
| Dataset Name | WikiArt Dataset |
| Dataset Source | WikiArt Repository (https://www.wikiart.org/) |
| Domain | Digital Art and Paintings |
| Total Images | Approximately 80,000 artworks |
| Training Images | 56,000 |
| Validation Images | 12,000 |
| Test Images | 12,000 |
| Artistic Styles | 27 artistic styles, including Renaissance, Impressionism, Cubism, Surrealism, Expressionism, Realism, and Abstract Art |
| Original Image Resolution | Original image resolutions vary across artworks and sources. Images were resized to a uniform resolution of 256 × 256 pixels during preprocessing. |
| Training Resolution | Images resized to 256 × 256 pixels during preprocessing prior to artistic style learning and segmentation-guided image synthesis. |
| Dataset Partitioning | Stratified random partitioning (70% training, 15% validation, and 15% testing) using a fixed random seed of 42 |
| Style Sampling Strategy | Stratified proportional sampling was employed to preserve the distribution of the 27 artistic styles across the training, validation, and testing subsets |
| Application in This Study | Artistic style learning, style representation, and segmentation-guided artistic synthesis |
Table 2: Characteristics of the WikiArt Dataset. Summary of the WikiArt dataset used for artistic style learning and style-guided image synthesis. The table describes the dataset source, image distribution, artistic-style coverage, dataset partitioning, image resolution, and its application within the proposed SegCycle-SPADE framework.
The Miao Batik dataset contains 15,148 images representing traditional Miao cultural motifs.32 The dataset is publicly available through Zenodo (https://doi.org/10.5281/zenodo.20807658). Prior to model training, all images were visually inspected, resized to 256 × 256 pixels, normalized, and screened for corrupted or duplicate samples. Quality-control screening did not result in the exclusion of any images; therefore, all 15,148 images were retained for subsequent analysis. The dataset was randomly partitioned into training (70%), validation (15%), and testing (15%) subsets using a fixed random seed of 42 to ensure reproducibility of the dataset splits. The WikiArt dataset was accessed through the official WikiArt repository (https://www.wikiart.org/) and contains more than 80,000 artworks spanning 27 artistic styles. For style-learning experiments, 56,000 images were used for training, 12,000 for validation, and 12,000 for testing.
Data Preprocessing
Before training the proposed SegCycle-SPADE framework, the Miao Batik cultural motif dataset and the WikiArt dataset were subjected to several preprocessing steps to ensure consistent image quality and accurate feature representation. The same fundamental preprocessing pipeline, including Gaussian denoising, normalization, resizing to a consistent input resolution, and image-quality verification, was applied to both datasets. However, the datasets served distinct roles within the framework. The WikiArt dataset was used for artistic style learning and synthesis, whereas the Miao Batik dataset was used primarily for cultural motif segmentation and reconstruction. No dataset-specific preprocessing changes were made beyond these task-specific roles. To ensure consistent processing by the DL model, images were first resized to a fixed resolution. This step was necessary because images in both datasets varied in resolution depending on their source. Resizing improved computational efficiency and prevented dimensional inconsistencies from affecting training. The second preprocessing step was normalization, in which pixel values were scaled to a standardized range to stabilize gradient updates during training. The images were then processed using Gaussian filtering to reduce noise that could interfere with cultural motif structures. For the Miao Batik dataset, existing cultural motif segmentation masks obtained directly from the original dataset source were used without modification for semantic segmentation training and evaluation. No new segmentation masks were generated specifically for this study.
Unless otherwise indicated, equations describing established methods were adapted from previous studies and are cited accordingly. Equations describing the proposed CAFFM and the composite SegCycle-SPADE optimization framework were developed by the authors for this study.
Let an input image from the dataset be represented as Equation 1:
(1)
Here, H, W, and C refer to the image height, width, and number of color channels, respectively. All images are resized to a fixed dimension H′ × W′ as shown in Equation 2:

Here, Ir is the resized image. The normalized pixel values are computed according to Equation 3:
(3)
This helps stabilize the training procedure. Noise filtering is performed using a Gaussian filter as shown in Equation 4:

Here, G(σ) is a Gaussian filter and * represents convolution. A 5 × 5 kernel Gaussian filter with a standard deviation of σ = 1.0 was used. Reflective padding was applied to border pixels in order to reduce edge artifacts. Prior to scaling and normalization, the denoising process was carried out immediately following image loading. To guarantee uniform preprocessing throughout the study, the same filter configuration was applied to every image in the Miao Batik and WikiArt datasets. For the Miao Batik dataset, the segmentation masks are created according to Equation 5:

Here, M is a segmentation mask used to guide the SegFormer model.
The preprocessing pipeline starts with the acquisition of images from the Miao Batik dataset and the WikiArt dataset, as shown in Figure 3. No data augmentation techniques were employed during training. After preprocessing, which included resizing, normalization, Gaussian denoising, and segmentation-mask preparation, the images were directly used for training, validation, and testing of the proposed SegCycle-SPADE framework. The initial step of the preprocessing pipeline involves resizing the images to a fixed size, allowing the DL model to process the images more efficiently. The second step involves normalization, which converts pixel values to a standardized numerical range and facilitates model convergence. The third step involves noise removal, whereby the images are cleared of unwanted noise to improve pattern recognition. In addition, for the Miao Batik dataset, cultural motif regions are annotated, allowing the generation of masks that are used in the segmentation module of the proposed model, ensuring that cultural motifs are preserved during generation. The final output of this stage is a clean dataset that is ready for training the proposed model's segmentation and generation modules.

Figure 3. Data-Preprocessing Pipeline for Cultural Heritage Images. Workflow illustrating image preprocessing procedures applied prior to model training. The pipeline includes dataset acquisition, image resizing, normalization, Gaussian denoising, existing cultural-motif annotations and segmentation-mask preparation. The resulting processed images and masks are used as inputs for semantic segmentation and pattern reconstruction. Please click here to view a larger version of this figure.
Every image was subjected to a quality-control process before model training. The Miao Batik dataset contained 15,148 images. Corrupted, duplicate, and low-quality samples had already been addressed by the original dataset creators; therefore, no additional images were excluded during quality-control screening in this study. Consequently, all 15,148 images were retained for analysis. Images were loaded in RGB format during preprocessing and resized to 256 × 256 pixels using bilinear interpolation. Pixel values were scaled from the range [0, 255] to [0, 1] by dividing by 255. Channel-wise normalization was then applied using mean values of [0.485, 0.456, 0.406] and standard deviation values of [0.229, 0.224, 0.225] for the red, green, and blue channels, respectively. The preprocessing pipeline included image loading, RGB conversion, resizing, pixel-value scaling, normalization, and tensor conversion. When necessary, grayscale images were converted to three-channel RGB format to maintain compatibility with the DL models. Following preprocessing, the images were partitioned into training, validation, and testing subsets. All stages of the SegCycle-SPADE framework—including semantic segmentation, feature fusion, motif reconstruction, and SPADE-based artistic synthesis—used a consistent input resolution of 256 × 256 pixels.
Semantic Pattern Segmentation using SegFormer
After this preprocessing step, the cleaned and normalized images of the Miao Batik cultural motif dataset and the WikiArt dataset are fed into the semantic segmentation module based on the proposed framework of SegFormer-B2. The purpose of this step is to correctly identify and separate cultural motifs that are present in heritage patterns. The proposed framework of SegFormer is based on a transformer architecture that incorporates a hierarchical Transformer encoder and a lightweight MLP decoder to accurately capture global contextual information as well as detailed structural information from complex heritage patterns. The model first extracts feature representations at multiple scales from the input image, followed by fusion of these representations through the decoder to generate accurate segmented patterns. This ensures that the patterns in the heritage image are correctly segmented into motifs such as geometric patterns, floral patterns, and symbolic patterns, thereby separating them from the background while maintaining their structural integrity. This structural information is subsequently used during the later stages of pattern generation within the SegCycle-SPADE framework.
Let the preprocessed input image be represented as Equation 6:
(6)
The SegFormer encoder splits the image into patches and extracts hierarchical features using transformer layers, as shown in Equation 71:

Here, F denotes the multiscale feature maps obtained from the transformer encoder. These features encode both local texture patterns and global contextual relationships among motif regions. The SegFormer model extracts feature maps at different scales as defined in Equation 8:

The use of multiscale representations facilitates the detection of patterns of different sizes within cultural motifs. Finally, the features are combined using the MLP decoder as shown in Equation 91:

Here, S denotes the final predicted segmentation map.
The SegFormer-B2 backbone was initialized using ImageNet-pretrained weights and subsequently fine-tuned on the Miao Batik dataset for cultural motif segmentation. The pretrained checkpoint was obtained from the official SegFormer implementation. Specifically, the ImageNet-1K pretrained MIT-B2 checkpoint (mit_b2.pth) provided by the official SegFormer repository was used to initialize the SegFormer-B2 backbone prior to fine-tuning. The pretrained weights correspond to the MIT-B2 backbone released by the SegFormer authors and served as the initialization model for semantic segmentation training. The remaining task-specific layers were initialized using the default PyTorch weight-initialization procedures prior to training.
A four-stage hierarchical Transformer encoder with overlapping patch embeddings is used in the architecture. In the initial stage, the patch size was set to 7 × 7 with a stride of 4. For each of the four encoder stages, the embedding dimensions were 64, 128, 320, and 512. Across the four stages, there were 1, 2, 5, and 8 multihead self-attention heads, and the corresponding encoder depths were 3, 4, 6, and 3 layers. Multiscale features retrieved from the encoder were aggregated using a lightweight all-MLP decoder. Before creating the final segmentation map, the decoder projected features from every encoder stage into a single embedding space. All Transformer blocks used the Gaussian Error Linear Unit (GELU) activation function. A dropout rate of 0.1 was used during training to improve generalization and reduce overfitting.
During the training phase, the SegFormer framework receives the preprocessed images from both datasets. The images from the Miao Batik dataset contain motif regions that serve as labels for supervised learning of the segmentation model. The Transformer encoder processes the entire image and captures long-range relationships among image components, which is particularly important for traditional batik patterns containing spatially distributed motifs. The hierarchical feature extraction mechanism simultaneously captures local structures such as repeated geometric textures. The MLP decoder processes these extracted features and produces a segmentation mask highlighting motif regions. The segmentation maps generated during this stage are subsequently used as structural inputs for the attention module and pattern reconstruction stage, thereby helping preserve the authenticity of generated patterns.
Cultural motifs were divided into different classes for semantic segmentation according to their visual and cultural characteristics. The segmentation taxonomy comprised animal motifs (e.g., butterflies, fish, birds, and other symbolic fauna), plant motifs (e.g., flowers, leaves, vines, and botanical patterns), geometric motifs (e.g., repeating shapes, borders, and abstract geometric structures), and background regions representing non-motif areas. Pixel-level segmentation masks were used to assign each pixel to one of the predefined classes. Integer labels were encoded as follows: Label 0 = background, Label 1 = animal motifs, Label 2 = plant motifs, and Label 3 = geometric motifs. The segmentation annotations and motif labels were obtained directly from the original Miao Batik dataset source. No additional manual annotation, relabeling, boundary verification, or expert-confirmation procedures were performed in this study. The existing annotations provided by the dataset creators were used without modification for training and evaluation.
The SegFormer model for cultural motif segmentation processes the preprocessed images from the Miao Batik dataset and the WikiArt dataset using a transformer-based mechanism for accurate detection of cultural pattern regions, as shown in Figure 4. First, the input image containing traditional cultural motifs is provided to the SegFormer model. The Transformer encoder extracts both global contextual information and local structural features from image patches. The resulting multiscale features are provided to the segmentation decoder, which utilizes a Mix Feed-Forward Network to refine feature representations and improve motif detection. The output of the SegFormer model is a segmentation mask that highlights pixels corresponding to cultural patterns while suppressing irrelevant background information. The isolated cultural patterns then serve as structural guidance for the subsequent stages of the SegCycle-SPADE framework.

Figure 4. SegFormer-B2-Based Semantic Segmentation of Cultural Motifs. Architecture of the SegFormer-B2 semantic segmentation module used for cultural motif extraction and trained exclusively on the Miao Batik dataset. The framework consists of a Transformer-based encoder for multiscale feature extraction and a lightweight segmentation decoder for generating motif masks. The model predicts four semantic classes—animal, plant, geometric, and background—where the resulting segmentation masks identify culturally significant motif regions while suppressing irrelevant background information. These segmentation outputs provide structural guidance for the subsequent feature-fusion, reconstruction, and artistic-synthesis stages of the proposed SegCycle-SPADE framework. Please click here to view a larger version of this figure.
There is no need to create new segmentation annotations in the suggested framework. The Miao Batik dataset was acquired from an already existing public source, and the model was trained using the related motif information supplied by the dataset creators. During the learning process, the SegFormer model produced semantic segmentation maps. As a result, the current study did not require any additional manual annotation software, annotation guidelines, or annotation quality-control procedures.
CAFFM
To improve the interaction between the features of semantic segmentation and the representations of generative reconstruction, the study also proposed a CAFFM. The SegFormer-B2 encoder provides semantic feature maps to the CAFFM module, whereas the CycleGAN reconstruction step provides generative feature maps. First, linear projection layers are used to project both feature streams into a common embedding space. For cross-attention computation, query (Q), key (K), and value (V) representations are created using the generated feature tensors. The relationships between structural motif information and artistic style elements are then modeled using multihead cross-attention. Layer normalization, residual connections, and feed-forward layers with GELU activation are then applied to the fused feature representations. The SPADE-based synthesis stage receives the CAFFM module’s output, allowing for the preservation of culturally meaningful themes without sacrificing artistic coherence.
To guarantee feature compatibility, the input features are first projected using linear projection layers onto a shared embedding space with an embedding dimension of 256. The interconnections between semantic structural information and generative style representations are then modeled using a MultiHead Cross-Attention mechanism with eight attention heads. Cross-attention computation uses the Query (Q), Key (K), and Value (V) vectors that are produced by specific linear transformation layers. To increase training stability and maintain feature integrity, residual connections and Layer Normalization are employed to further enhance the fused feature representations. Non-linear feature learning is then improved by applying a feed-forward network with the Gaussian Error Linear Unit (GELU) activation function. An output feature representation of dimension 256 is generated by the module and sent to other stages for creative synthesis. The CAFFM successfully combines artistic style data with cultural motif structures by using a cross-attention-based fusion technique, which enhances motif preservation and visual coherence in the reconstructed cultural heritage patterns.
In the proposed system, the structural features are derived from the Miao Batik dataset, while the stylistic features are learned from the WikiArt dataset. Let the feature map derived from the SegFormer segmentation network using images from the Miao Batik dataset be denoted by Fs, while the feature map derived from the style-feature extraction branch using WikiArt images is denoted by Fa. The proposed CAFFM combines the two feature domains using a cross-attention mechanism to learn both structural and stylistic dependencies of cultural patterns. Table 3 reports all architectural characteristics, including embedding dimensions, normalization layers, activation functions, and attention-head configuration. For an input image size of 256 × 256 pixels, the SegFormer-B2 encoder produced semantic feature maps of size 64 × 64 × 128, while the style-feature extraction branch produced feature maps of size 64 × 64 × 128. Both feature maps were projected through learnable linear layers into a shared embedding space of dimension 256 prior to cross-attention fusion.
| Parameter | Configuration |
| Proposed Framework | SegCycle-SPADE |
| Semantic Segmentation Model | SegFormer-B2 |
| SegFormer Encoder Stages | 4 |
| Weight Initialization | ImageNet-1K Pretrained SegFormer-B2 (MIT-B2 Backbone) |
| Checkpoint Source | Official NVIDIA SegFormer Repository (https://github.com/NVlabs/SegFormer); checkpoint: segformer.b2.512x512.ade.160k |
| Fine-Tuning Strategy | End-to-end fine-tuning on the Miao Batik dataset |
| Patch Embedding Size | 7 × 7 |
| Patch Stride | 4 |
| Embedding Dimensions | 64, 128, 320, and 512 |
| Encoder Depths | 3, 4, 6, and 3 |
| Attention Heads | 1, 2, 5, and 8 |
| Decoder Type | All-MLP Decoder |
| Activation Function | GELU |
| Dropout Rate | 0.1 |
| Feature Enhancement Module | Cross-Attention Cultural Feature Fusion Module (CAFFM) |
| CAFFM Embedding Dimension | 256 |
| CAFFM Attention Heads | 8 |
| CAFFM Fusion Scales | 4 |
| Reconstruction Model | CycleGAN |
| Style Generation Model | SPADE |
| Cultural Dataset | Miao Batik Dataset |
| Style Dataset | WikiArt Dataset |
| Miao Batik Images | 15,148 |
| WikiArt Images | Approximately 80,000 |
| Input Image Resolution | 256 × 256 pixels |
| Color Format | RGB |
| Interpolation Method | Bilinear Interpolation |
| Denoising Method | Gaussian Filtering |
| Gaussian Kernel Size | 5 × 5 |
| Gaussian Sigma (σ) | 1 |
| Normalization Range | [0, 1] |
| Batch Size | 16 |
| Number of Epochs | 100 |
| Optimizer | Adam |
| Learning Rate | 0.0002 |
| Adam Parameters | β₁ = 0.5, β₂ = 0.999, ε = 1 × 10⁻⁸, weight decay = 0 |
| Loss Functions | Segmentation Loss, Adversarial Loss, Cycle-Consistency Loss, Reconstruction Loss, Motif-Preservation Loss, and Style-Consistency Loss |
| Dataset Split Strategy | Training / Validation / Testing |
| Training Set | 70% |
| Validation Set | 15% |
| Testing Set | 15% |
| Random Seed | 42 |
| Evaluation Metrics | Segmentation Accuracy, IoU, Dice Coefficient, SSIM, PSNR, and FID |
| Programming Language | Python 3.8.10 |
| Deep Learning Framework | PyTorch 1.10.0 |
| Hardware Platform | NVIDIA RTX 3090 GPU (24 GB VRAM), Intel Core i7 (11th Generation), 32 GB RAM |
| Operating Environment | Ubuntu 20.04 LTS |
Table 3: Experimental Setup and Model Configuration. Summary of the architectural components, training configuration, preprocessing settings, datasets, optimization parameters, evaluation metrics, and computational environment used for implementation and evaluation of the proposed SegCycle-SPADE framework.
The attention module first maps the feature map into query, key, and value representations using Equation 10:

Here, Wq, Wk, and Wv are learnable weight matrices. The attention weights are calculated based on the similarity between the query vector and the key vector using Equation 1117:

Here, dk is the dimension of the key vector. The enhanced feature representation is computed by multiplying the attention weights with the value matrix using Equation 12:

Here, Fa is the enhanced feature representation of the feature map. The enhanced feature representation is computed by combining the original segmentation features with the enhanced features obtained using the attention mechanism using Equation 13:
Here, Fe is the enhanced feature map used for pattern reconstruction. The CAFFM is extended with a multiscale cross-attention mechanism to extract features for cultural motifs at different scales. Let Fsi denote the segmentation features at scale i, while Faj denotes the artistic-style features at the same scale. The final feature representation is defined using Equation 14:

Here, Qi, Ki, and Vi represent the query, key, and value matrices at scale i, respectively, and N denotes the number of feature scales. In this study, N = 4, corresponding to feature maps extracted at spatial resolutions of 1/4, 1/8, 1/16, and 1/32 of the input image size. These multiscale feature representations were fused using learnable attention weights prior to reconstruction and artistic synthesis. The above extension enables the method to extract global cultural motifs and textures to reconstruct cultural patterns. CAFFM is situated between the SegFormer-based segmentation stage and the SPADE-based creative synthesis stage in the suggested SegCycle-SPADE system. First, while CycleGAN concurrently creates reconstruction features with stylistic and pattern-related information, SegFormer-B2 recovers semantic feature maps that depict the structural properties of cultural motifs. The CAFFM module receives these two feature streams and uses cross-attention-based fusion to identify relationships between structural and artistic representations. In order to create culturally authentic patterns while maintaining semantic consistency and structural features, the resulting fused feature maps are then sent to the SPADE module for segmentation-guided creative synthesis.
Pattern Reconstruction using CycleGAN
Once the attention-based feature enhancement stage is done, the feature maps will contain the enhanced cultural motif structures. However, the feature maps may still contain incomplete or damaged pattern regions. Therefore, to address the problem of reconstructing the patterns, the proposed framework will make use of the CycleGAN model. In the proposed framework, the two domains will be the original cultural motif patterns and the reconstructed cultural motif patterns. Using the enhanced features from the previous stages, the CycleGAN model will reconstruct the cultural patterns while maintaining structural consistency. This will ensure that cultural patterns such as geometric patterns, floral patterns, and symbolic patterns maintain their spatial arrangement. The original Miao Batik images were subjected to random masking and partial occlusion operations to generate incomplete or damaged cultural motifs. These degradation procedures simulated missing pattern regions and structural damage commonly observed in deteriorated cultural heritage artifacts. The degraded images were used as inputs to the reconstruction module, while the corresponding original images served as reference images for performance evaluation and reconstruction-quality assessment. This strategy enabled the model to learn the restoration of missing motif structures while preserving semantic consistency and cultural characteristics.
Let X be the domain of incomplete cultural patterns and Y be the domain of reconstructed cultural patterns. The two generators learn to perform bidirectional mapping using Equation 15:

Here, GE is used to reconstruct motif structures and FM is used to map the patterns back to the original domain. The adversarial loss is used to ensure that the reconstructed patterns are realistic (Equation 16)30

Here, DY is the discriminator used to distinguish real and reconstructed patterns, and GE(x) denotes the generated reconstructed pattern. The CycleGAN also enforces cycle consistency to preserve the structural layout of cultural motifs (Equation 17)30.

The final loss function is defined using Equation 1830:

Here, λi denotes the weighting coefficient for the cycle-consistency loss and was set to 10 during training, consistent with the original CycleGAN formulation. This value was selected to balance adversarial learning and reconstruction consistency between the source and target domains.
The CycleGAN reconstruction module consists of two generators and two discriminators for bidirectional image translation. Each generator follows a residual-network architecture comprising an initial 7 × 7 convolution layer, followed by two downsampling convolution layers, nine residual blocks, and two upsampling layers. All convolution operations employ a kernel size of 3 × 3, except for the input layer, which utilizes a 7 × 7 kernel for enhanced feature extraction. Instance Normalization is applied after each convolution layer to improve training stability, while ReLU activation is used throughout the generator network. The output layer employs a Tanh activation function to generate normalized image outputs. The discriminator follows a 70 × 70 PatchGAN architecture consisting of a series of convolutional layers with kernel sizes of 4 × 4 and progressively increasing feature channels. Instance Normalization and LeakyReLU activation (negative slope = 0.2) are employed in the discriminator to improve feature discrimination and adversarial learning. The CycleGAN module receives preprocessed cultural motif images as input and generates reconstructed pattern representations, which are subsequently forwarded to the CAFFM for integration with segmentation features. CycleGAN training was performed using the Adam optimizer (β₁ = 0.5, β₂ = 0.999) with an initial learning rate of 0.0002. The learning rate was maintained for the first 100 epochs and subsequently linearly decayed to zero over the remaining training period. A replay buffer containing 50 previously generated images was employed to stabilize discriminator training. The generators and discriminators were updated using a 1:1 update ratio, with one generator update followed by one discriminator update during each training iteration.
The reconstruction process of the CycleGAN is based on the enhanced feature maps obtained using the CAFFM mechanism in Figure 5. The feature maps contain enhanced cultural motifs obtained from the previous stages of segmentation and CAFFM. The feature maps are used as input to the first generator GE. The first generator GE learns the mapping required to reconstruct cultural patterns. The outputs are then fed to the discriminator DY to distinguish between real cultural patterns and reconstructed patterns. The discriminator DY helps the generator GE produce realistic outputs. To ensure that cultural patterns are not distorted during reconstruction, the second generator FM performs cycle-consistency mapping. The second generator FM maps the outputs back to the original domain. The outputs are then evaluated by the discriminator to ensure realism. The final outputs are subsequently forwarded to the SPADE module for artistic style generation in the next stage of the proposed SegCycle-SPADE framework.

Figure 5. CycleGAN-Based Pattern Reconstruction Workflow. Workflow of the CycleGAN reconstruction module. Attention-enhanced feature representations are provided as inputs to the generator network to reconstruct incomplete cultural motifs. The discriminator evaluates reconstructed outputs against reference patterns, while cycle-consistency mapping preserves structural integrity during bidirectional image translation. Reconstructed motifs are subsequently forwarded to the SPADE module for artistic style synthesis. Please click here to view a larger version of this figure.
Artistic Style Generation using SPADE
Subsequently, the reconstructed cultural motifs are subjected to the SPADE module for the generation of artistic style. The main goal of the SPADE module is to add more visually rich textures of artistic style to the reconstructed cultural motifs without compromising the structural layout of the motifs. The SPADE module is a conditional image generation technique that makes use of the concept of image segmentation for the generation of images. Multichannel semantic maps that corresponded to the predetermined motif classes were encoded from the semantic segmentation masks produced by SegFormer-B2. The SPADE generator received these encoded maps as conditioning inputs. The spatially adaptive scaling (γ) and bias (β) parameters were produced by processing the semantic maps through convolutional layers within each SPADE layer. The generator was thus able to maintain motif boundaries, structural layouts, and semantic information during artistic synthesis by applying these parameters to the normalized feature activations. Semantic guiding was able to affect both high-level structural reconstruction and low-level texture synthesis since the conditioning process was carried out at several layers of the SPADE generator. As a result, created artistic patterns incorporated stylistic traits gained from the WikiArt dataset while maintaining the cultural motif structures found during the segmentation stage.
The WikiArt dataset, which includes works from 27 different artistic categories—such as Renaissance, Impressionism, Cubism, Expressionism, Surrealism, Realism, and Abstract Art—was used as the main resource for understanding artistic styles. In order to expose the model to a variety of creative traits and enhance style generalization, style images were randomly selected from the various categories during training. The dataset was divided into training, validation, and testing subsets with a balanced representation of artistic categories in order to lessen style bias. To ensure balanced representation of all 27 artistic categories, stratified sampling was used. Samples from each category were proportionally allocated to the training, validation, and testing subsets while preserving the original class distribution. The CAFFM module was used to merge the style aspects that were derived from WikiArt images with the reconstruction features produced by CycleGAN. In order to allow the synthesis network to transfer artistic qualities while maintaining the semantic structure and cultural motif boundaries derived from the segmentation maps, the resulting fused representations were supplied as conditioning information to the SPADE generator. The suggested framework was able to produce culturally authentic artistic patterns with consistent structural and stylistic representations thanks to this style-conditioning technique.
SPADE also introduces spatially adaptive parameters that depend on the segmentation map. The parameters can be defined as shown in Equation 191:

Here, γ(S) is the spatially varying scale parameter and β(S) is the spatially varying bias parameter. The parameters can help the generator create different textures and styles depending on the semantic region in the images. The final cultural artwork can be defined as shown in Equation 20:

Here, GE is the SPADE generator, XrP is the reconstructed pattern, and SM is the segmentation map. The final artwork maintains the structural integrity of cultural motifs while enhancing artistic appearance. A composite loss function that balances semantic segmentation accuracy, cultural motif preservation, pattern reconstruction quality, and artistic style consistency was used to optimize the suggested SegCycle-SPADE architecture. A weighted mixture of segmentation loss (Lseg), adversarial loss (Ladv), cycle-consistency loss (Lcycle), reconstruction loss (Lrecon), motif-preservation loss (Lmotif), and style-consistency loss (Lstyle) was used to establish the overall training objective. The total loss function is defined in Equation 21:
(21)
In order to guarantee structural consistency between the input and reconstructed cultural motifs, the cycle-consistency loss coefficient was set to 10. To maintain fine-grained motif features and enhance visual accuracy, the reconstruction loss coefficient was set at 5. To highlight the preservation of culturally essential structural patterns during artistic synthesis, a coefficient of 2 was used for the motif-preservation loss. In order to promote artistic style transfer without unduly distorting semantic motif structures, the style-consistency loss coefficient was adjusted to 1. To maintain a balanced contribution between realistic image production and precise motif segmentation, equal weights were given to the segmentation and adversarial losses. The WikiArt dataset's feature-based style representations were used to calculate the style-consistency loss. In particular, artistic style traits were captured using Gram matrix correlations that were taken from deep feature maps. The Frobenius norm difference between the Gram matrices of the target style image and the generated image was used to calculate the style loss, as shown in Equation 22:

Here, Gl is the Gram matrix computed from the lth feature layer, Igen denotes the generated artistic image, Istyle denotes the target style image from the WikiArt dataset, and F denotes the Frobenius norm. This formulation enables the proposed framework to preserve artistic characteristics while maintaining the structural and semantic integrity of cultural motifs.
The fused feature representations produced by the CAFFM module are used as conditioning inputs to the SPADE module, which serves as the artistic synthesis component of the proposed framework. The SPADE generator comprises seven SPADE residual blocks with a latent feature dimension of 256 channels and generates output images at a resolution of 256 × 256 pixels. Semantic segmentation maps obtained from the SegFormer–CAFFM module are used as conditioning inputs throughout the SPADE residual layers. SPADE layers are applied prior to the activation functions within each residual block, enabling segmentation-guided semantic conditioning. Through successive upsampling and convolutional operations, the latent feature representation is progressively refined to generate high-resolution artistic patterns while preserving semantic consistency and motif structure. LeakyReLU activation functions are used throughout the generator, and a Tanh activation function is applied at the output layer to produce normalized images.
Algorithm and Workflow
The SegCycle-SPADE framework integrates semantic segmentation, feature fusion, pattern reconstruction, and artistic style synthesis within a unified training pipeline. The workflow begins with dataset acquisition and preprocessing, including image resizing, normalization, denoising, and segmentation-mask preparation. Preprocessed images are subsequently processed using the SegFormer-B2 segmentation network to extract semantic motif representations. The resulting segmentation features are fused with reconstruction features through the CAFFM, enabling interaction between structural motif information and artistic feature representations. The fused feature maps are then supplied to the CycleGAN reconstruction module, which restores incomplete cultural motif structures while preserving semantic consistency. The reconstructed patterns are subsequently provided to the SPADE generator for segmentation-guided artistic synthesis, allowing stylistic enhancement while maintaining motif boundaries and structural authenticity. During training, model parameters are optimized using the composite loss function described in Equations 21 and 22, which balances segmentation accuracy, motif preservation, reconstruction quality, and artistic style consistency. A detailed step-by-step implementation workflow, including dataset loading, preprocessing, model initialization, training iterations, validation procedures, checkpoint selection, and final evaluation, is provided in Supplementary File 1 (Algorithm 1). The complete algorithmic workflow was implemented using a batch size of 16, a learning rate of 0.0002, and 100 training epochs. A fixed random seed of 42 was used for dataset partitioning, model initialization, and all training experiments. The seed was applied consistently across Python, NumPy, and PyTorch random number generators to ensure reproducibility. The Adam optimizer was configured with β₁ = 0.5, β₂ = 0.999, and no weight decay (weight decay = 0). Model checkpoints were selected based on the highest validation IoU score achieved on the validation dataset.
Loss Function Optimization
To preserve cultural motif structures during reconstruction and artistic synthesis, the proposed framework employs a composite optimization objective that combines segmentation, adversarial, cycle-consistency, reconstruction, motif-preservation, and style-consistency losses. The complete mathematical formulation, weighting coefficients, and style-loss definition are provided in Equations 21 and 22 within the Artistic Style Generation using SPADE subsection. The motif-preservation component penalizes structural deviations between predicted motif regions and the corresponding ground-truth segmentation masks, thereby encouraging preservation of culturally significant pattern structures throughout the reconstruction process.