Scarf pattern generation method based on generative adversarial network and stable diffusion model

By combining the generative adversarial network and stable diffusion model, the ComfyUI workflow of the SDXL model is used to expand the data set and redraw the graphs, which solves the problem of poor results in the generation of complex scarf patterns in the existing technology, and achieves efficient and detailed scarf patterns generation.

CN119540229BActive Publication Date: 2025-04-11ZHEJIANG SCI-TECH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510088062.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-21
Publication Date
2025-04-11
Estimated Expiration
2045-01-21

AI Technical Summary

Technical Problem

The existing image generation model does not work well when generating complex scarf patterns, lack of details, and is difficult to achieve good results in a small-scale data environment.

Method used

The scarf pattern generation method based on the generative adversarial network and stable diffusion model is adopted, and combined with the ComfyUI workflow of the SDXL model, the scarf pattern data set is expanded and constructed, and applied it to the generative adversarial network training. After generating the semi-finished scarf pattern, the final scarf pattern is redrawed through the SDXL model diagram to obtain the final scarf pattern.

Benefits of technology

It significantly improves the design efficiency and pattern generation effect, ensures the integrity of pattern details and the consistency of composition themes, and solves the problems of blur, distortion, adhesion and other problems of semi-finished scarf patterns.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540229B_ABST
    Figure CN119540229B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for generating scarf patterns based on a generative adversarial network and a stable diffusion model. Firstly, with the help of the ComfyUI custom workflow and IPAdapter‑Plus node of the SDXL model, a reference composition theme is generated for a classic floral scarf pattern with a simple structure, data amplification is completed, and then a set of floral scarf pattern data sets that meet the scarf pattern specifications are generated; on this basis, the present invention adopts and optimizes the StyleGAN model to preliminarily complete the task of generating scarf patterns, and especially introduces the self-attention and border attention mechanisms, which significantly improves the generation quality of the scarf patterns; finally, the SDXL model and the ComfyUI workflow are used to redraw the semi-finished scarf pattern generated preliminarily, and the problems of missing details, blurring, distortion, etc. in the semi-finished scarf pattern generated preliminarily are solved by redrawing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of computer vision and image processing, and in particular relates to a method for generating scarf patterns based on a generative adversarial network and a stable diffusion model. Background Art

[0002] In the textile and apparel industry, especially in the field of scarf design, the importance of pattern design is becoming increasingly prominent; with the rapid development of the fashion industry and the increasing demand of consumers for personalization and fashion, the market has put forward higher requirements for the innovation and diversity of scarf pattern design. The traditional scarf pattern design process is highly dependent on the personal experience and creativity of the designer, which not only limits the diversity and innovation of the design, but also increases the time and cost of the design; in this context, the technology of automatic and rapid generation of scarf patterns is particularly important and necessary. The technology of automatic and rapid generation of scarf patterns can significantly improve design efficiency and reduce the time and cost from design to market. This has become particularly prominent in the context of industrial digitalization. Large-scale personalized customization has become an inevitable trend in the wave of industrial digitalization. Through automation technology, designers can quickly respond to market changes, provide design solutions that meet popular trends, and meet consumers' needs for personalization and fashion; for the automatic and rapid generation of scarf patterns, image generation technology based on deep learning can effectively solve this problem.

[0003] At present, the core of deep learning-based image generation technology is to generate new and realistic images by learning the patterns and structures of images in the data set. This technology can accurately generate the required patterns in batches. At present, image generation models have been gradually applied to many fields, such as virtual fitting, clothing design, home textile decoration design, etc., and their application prospects are broad; however, most of the current image generation models rely on a large number of image data sets for training, which is difficult to use in fields with scarce or no data, and when generating complex patterns, they still face challenges such as poor generation effect and insufficient detail retention.

[0004] The main image generation models are currently divided into two categories:

[0005] One is the Generative Adversarial Network (GANs), which is a generative model based on game theory and consists of two networks: the generator and the discriminator. The generator is responsible for generating images, while the discriminator determines whether the generated images are real. Through continuous adversarial training, the capabilities of the generator and the discriminator are gradually improved. In the field of image generation, various types of GANs have shown their unique advantages and limitations, especially in terms of training stability, detail processing, and computational efficiency. Taking traditional GAN ​​as an example, although it has opened the door to the research of generative adversarial networks and can generate images of various styles, the instability of its training process and the problem of mode collapse limit its application in high-quality image generation. In addition, the traditional GAN ​​has a high computational cost when processing high-resolution images, and it is difficult to flexibly adapt to small-scale or rapidly changing data environments. DCGAN (Deep Convolutional Generative Adversarial Network) is an improvement after GAN. DCGAN has greatly improved the stability of GAN training and the quality of generated results by introducing convolutional layers and batch normalization. However, this method is only a temporary solution to the stability of GAN training, and does not fundamentally solve the problem. In addition, it is still necessary to carefully balance the training process of the generator and the discriminator during training. WGAN (Wasserstein Generative Adversarial Network) improves training stability and reduces the problem of mode collapse by introducing Wasserstein distance, but there are still challenges in computational efficiency, especially when processing high-resolution images, the training and inference time are long. In addition, although WGAN has advantages in the flexibility and robustness of style transfer, its adaptability has certain problems when dealing with scenes that require fine-tuning and retaining the style of specific image features. In order to overcome these problems, StyleGAN (Style Generative Adversarial Network) has become a breakthrough in the field of image generation with its stable and high-quality image generation capabilities and controllability of style and content. StyleGAN, through its unique noise mapping and style modulation mechanism, can finely control the various visual attributes of the image during the generation process. These characteristics make StyleGAN have broad application prospects in many fields such as image synthesis, art creation, and game development. However, it is still difficult to achieve good results in a small-scale data environment.

[0006] The other type is the diffusion model. The diffusion model is a generative model that has emerged in recent years. It generates new images by simulating the process of image data gradually generated from noise. The images generated by the diffusion model are of high quality and have achieved better performance than GANs in some tasks. One of the best diffusion models at present is SDXL (Stable Diffusion XL). SDXL consists of several key parts: a U-Net main model, a VAE (Variational Autoencoder), a CLIP (Contrastive Language-Image Pre-training) text encoder, and a separate latent space-based Refiner model to improve the refinement of the image. The technical development of SDXL is based on the SD (Stable Diffusion) series of models. It has been significantly optimized and expanded on the original SD. The biggest advantage of the SDXL model is that it can easily generate high-resolution and high-quality images. However, it also has some limitations, including higher requirements for GPU memory, longer image rendering time, and the common problems of the key SD series models, poor controllability and image rendering stability. For non-professional "Prompt Engineers", it is difficult to constrain the image generation effect only through text.

[0007] In summary, the current existing technologies are difficult to meet the unique needs of the textile industry, and there is an urgent need for a scarf pattern generation method that can generate scarves in batches and finely preserve pattern details. Summary of the invention

[0008] In view of the above, the present invention provides a scarf pattern generation method based on a generative adversarial network and a stable diffusion model. The method combines the ComfyUI (Comfy user interface) workflow method of the SDXL model, expands and constructs a scarf pattern dataset, and cleverly applies it to generative adversarial network training. After successfully completing the model training, a scarf pattern semi-finished product is generated, which is then redrawn through the SDXL model graph to obtain the final scarf pattern, which can improve the design efficiency and the pattern generation effect.

[0009] A method for generating scarf patterns based on a generative adversarial network and a stable diffusion model comprises the following steps:

[0010] (1) Collect a large number of floral scarf patterns and floral pattern patterns, and after preprocessing, input them into the pattern augmentation workflow based on ComfyUI and SDXL models to construct a floral scarf pattern dataset;

[0011] (2) Construct an improved scarf pattern generation model based on the StyleGAN architecture, which consists of two parts: a generator and a discriminator. The mapping network in the generator samples a noise vector from a normal distribution and maps it to another latent space to generate multiple style features for controlling the generation of scarf patterns. These style features are input into the synthesis network from different positions to generate a floral scarf pattern Silk_G (fake). The discriminator uses the floral scarf pattern dataset to determine whether Silk_G is real or generated by the generator.

[0012] (3) The scarf pattern generation model is trained. After the training is completed, the model is used to generate a semi-finished floral scarf pattern as a reference image, which is input into the image-to-image workflow based on the SDXL model for redrawing, and the finished floral scarf pattern can be automatically generated.

[0013] Furthermore, in the step (1), the floral scarf patterns are first cleaned to screen out unqualified floral scarf patterns (those with incomplete patterns, low resolution, or shadows and wrinkles). Then, the floral scarf patterns that meet the requirements (those with more data and high public recognition) are selected from the qualified floral scarf patterns as a data set and augmented on this basis. These floral scarf patterns are input into a pattern augmentation workflow based on the ComfyUI and SDXL models together with the floral pattern patterns. The floral scarf patterns are used to learn composition themes, and the floral pattern patterns are used to learn style elements. The learned features are fused to generate new floral scarf patterns, thereby constructing a floral scarf pattern data set.

[0014] Furthermore, the pattern augmentation workflow accepts floral scarf patterns, floral pattern patterns, forward prompts (prompt words) and reverse prompts as inputs, wherein the forward prompts, in addition to basic quality prompt words, additionally add general prompt words obtained by annotating with WD14 (an open source marker in the SDXL model), and the reverse prompts only use basic quality prompt words; the floral scarf patterns and floral pattern patterns are cropped and input into the IPAdapter-Plus (image prompt adapter enhanced version) node (this node provides precise style reference and composition reference functions), which first uses a pre-trained CLIP encoder to extract image features from the patterns with prompt words, and then uses A decoupled cross-attention mechanism is used, that is, the cross-attention layers of text features and image features are separated, and a new cross-attention layer is added to each cross-attention layer in the U-Net of the SDXL model, so that the image features guide the image generation process through the decoupled cross-attention mechanism; in this way, the image features are independently embedded in the U-Net of the SDXL model, and at the same time the SDXL model converts the input prompt words into latent variables, and continuously optimizes these latent variables through U-Net to obtain a latent variable containing noise; finally, a Refiner model for denoising is used to refine the pattern after feature fusion, so that the newly generated floral scarf pattern has higher contrast and better edge detail processing.

[0015] Furthermore, the scarf pattern generation model in step (2) is improved accordingly based on StyleGAN, that is, a self-attention mechanism is added to the input part of the generator, and a boundary attention mechanism is added to the output part of the generator and the input part of the discriminator, which effectively improves the clarity and standardization of the floral scarf pattern finally generated by the model.

[0016] Furthermore, the mapping network in the generator is composed of a cascade of multiple fully connected layers, and the latent variables generated by them are processed through affine transformation to form style features. The synthesis network in the generator is composed of a cascade of multiple sub-modules, each sub-module adds Gaussian noise processed by broadcast operation to the input, and introduces style features through AdaIN (adaptive instance normalization), and then repeatedly adds noise and introduces style features after convolution processing, and finally outputs through the self-attention mechanism; the input is upsampled starting from the second sub-module, and the border attention mechanism is used to replace the self-attention mechanism in the last sub-module.

[0017] Furthermore, in step (3), the semi-finished floral scarf pattern is redrawn using the SDXL model-based image-generated image workflow. Specifically, a graphic-generated image redrawing process is constructed based on the ComfyUI workflow. The hidden variable required by the process is the floral scarf pattern generated by the scarf pattern generation model, which is used as a reference image for the basic pattern style, composition and color. At the same time, the IPAdapter-Plus node is used to learn the reference image, from which the pattern style is referenced to ensure that the style remains unchanged, and then the floral scarf pattern is redrawn. Finally, the refinement is completed by the Refiner model to obtain the finished floral scarf pattern. In this way, the problems of blurring, distortion, and adhesion of the semi-finished scarf pattern can be solved.

[0018] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the above-mentioned scarf pattern generation method based on a generative adversarial network and a stable diffusion model.

[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for generating a silk scarf pattern based on a generative adversarial network and a stable diffusion model is implemented.

[0020] The scarf pattern generation method based on the generative adversarial network and the stable diffusion model of the present invention cleverly integrates the ComfyUI workflow of the SDXL model with the improved StyleGAN model, and can automatically generate scarf patterns, ensuring the integrity of pattern details, the consistency of pattern composition themes, and significantly improving the efficiency of generating patterns. In the process of redrawing the scarf pattern image, the present invention uses SDXL to generate the image, and redraws the semi-finished scarf pattern generated by the improved StyleGAN model, effectively reducing the distortion and blurring of the semi-finished scarf pattern; at the same time, the present invention also uses the IPAdapter-Plus node to learn the style of the semi-finished scarf pattern during the redrawing process to keep the scarf style stable.

[0021] The scarf pattern generation method based on the generative adversarial network and the stable diffusion model of the present invention can ultimately be applied to the method quickly without relying on additional target images, only by providing a few original patterns and some materials of the same type of theme, and a large number of scarf patterns can be quickly generated without relying on additional target images. This innovation not only simplifies the design process and reduces manual intervention, but also allows designers to devote themselves to creative design. Designers only need to complete one creative design, and then they can generate it in batches.

[0022] In summary, the present invention has the following beneficial technical effects:

[0023] 1. This paper cleverly uses the SDXL model and ComfyUI workflow to expand the scarf dataset. The generated patterns have the advantages of high resolution, beautiful appearance, and similar composition. A new dataset expansion method is proposed.

[0024] 2. The improved StyleGAN model of the present invention significantly improves the robustness and generation effect of the model by introducing the self-attention mechanism and the border attention mechanism, and the generated patterns are more standardized and realistic.

[0025] 3. The present invention uses the SDXL model and IPAdapter-Plus node graph to generate the image, thereby greatly improving the image details of the semi-finished scarf pattern while maintaining the style of the scarf, and solving the problems of blurring, distortion, adhesion, etc. of the semi-finished scarf.

[0026] 4. The present invention provides an efficient and intelligent silk scarf pattern generation solution for the silk scarf textile industry, which can quickly respond to changes in market trends, significantly shorten the design cycle, and effectively reduce the waste of design resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] Figure 1 The figure is a flow chart of a method for generating scarf patterns based on a generative adversarial network and a stable diffusion model according to the present invention.

[0028] Figure 2 Schematic diagram of the scarf pattern generation model structure based on the StyleGAN architecture.

[0029] Figure 3 Schematic diagram of the scarf pattern amplification workflow of the present invention.

[0030] Figure 4 The present invention is a schematic diagram of the workflow of redrawing the semi-finished silk scarf pattern. DETAILED DESCRIPTION

[0031] In order to describe the present invention more specifically, the technical solution of the present invention is described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0032] like Figure 1 As shown, the scarf pattern generation method based on the generative adversarial network and the stable diffusion model in this embodiment includes the following steps:

[0033] (1) Construction of the scarf pattern dataset.

[0034] This embodiment generates a classic floral pattern scarf dataset based on three key factors: scarf pattern data collected from the Internet, floral pattern data, and a designed ComfyUI workflow. The specific steps are as follows:

[0035] First, this embodiment cleans the scarf pattern data set collected on the Internet, removes a large number of unqualified scarf patterns in the data collected on the Internet, and mainly selects and removes scarf patterns with incomplete patterns, low resolution, shadows and wrinkles. Since there are many themes and styles of scarf patterns, floral scarf patterns with more data and high public recognition are selected as the basis for data set augmentation. Then, the floral pattern scarf data and floral pattern data are input into the pattern augmentation workflow based on ComfyUI and SDXL models.

[0036] like Figure 3 As shown in the figure, the workflow accepts the input of floral scarf pattern, floral pattern (collected from the Internet), forward prompt, and reverse prompt. The input floral scarf pattern is used as the reference for the composition theme of the generated pattern, and the input floral pattern is used as the reference for the style material; in addition to the basic quality prompt words, the forward prompt also adds the general prompt words (flower, border, leaf, simple background, no human, etc.) obtained after the floral scarf pattern is annotated by WD14, and the reverse prompt uses the basic quality prompt words.

[0037] The input floral scarf patterns and floral patterns are cropped and input into the IPAdapter-Plus node. IPAdapter-Plus first uses a pre-trained CLIP image encoder to extract image features from the provided image prompts (the CLIP model is a multimodal model that is trained on a large number of image-text pair datasets through contrastive learning and can encode image content and style well). Then, a unique decoupled cross-attention mechanism is used, that is, the cross-attention layers of text features and image features are separated. A new cross-attention layer is added to each cross-attention layer in the U-Net part of the pre-trained SDXL model to insert image features to guide the image generation process through the decoupled cross-attention layer.

[0038]

[0039]

[0040] in: Q, K', V' are the query matrix, key matrix and value matrix from image features, and is the corresponding weight matrix.

[0041] In this way, image features can be independently embedded into the U-Net model of the diffusion model. The SDXL_base_1.0 model converts the input text into latent variables (Latent), and continuously optimizes these latent variables through the U-Net model, and finally obtains a noisy latent variable, which is then further processed by the refinement model (SDXL_Refiner_1.0) dedicated to denoising. The image further processed by the refinement model has higher contrast and better edge detail processing. After manually operating this workflow, some new floral scarf patterns are obtained, and the floral scarf pattern dataset is completed.

[0042] (2) Improve the StyleGAN image generation model.

[0043] StyleGAN is a deep learning model. StyleGAN is a generative adversarial network developed by the NVIDIA research team, which has made breakthrough progress in the field of image synthesis. StyleGAN introduces a novel latent space structure that separates style (color, texture, etc.) and content (overall layout and shape), allowing for more fine-grained image control. StyleGAN's generator uses a progressive structure, gradually upsampling from low resolution to high resolution, with each step adding more details and complexity; the StyleGAN series is known for its high-resolution, realistic images, especially in image synthesis of faces and other complex scenes. Although the StyleGAN series of models has brought significant technical advances in the field of image synthesis, especially in generating high-quality, high-resolution images. However, due to the limitations of factors such as the quantity and quality of key data sets in deep learning, it is difficult to fit small batches of image data with more details and higher complexity, and the effect of generating images is often unsatisfactory.

[0044] The present invention proposes a new generative adversarial network, whose structure is as follows Figure 2 As shown in the figure, firstly, the input is given by the computer, that is, the latent variable z in the latent space Z. After Normalization, it passes through a nonlinear mapping network (Mapping network) constructed by 8 fully connected layers FC to generate w (intermediate latent variable) ∈ W (intermediate latent space), and then A (representing affine transformation) is used to process w to form style features; the above part is the mapping network in the generator (Generator).

[0045] Then comes the synthetic network in the generator. First, a random input is given by the computer, that is, Const 4×4×512, and then Gaussian noise (Noise) processed by B (representing broadcast operation) is added, and then the style features obtained by processing w by A are introduced through adaptive instance normalization (AdaIN) to control the generator; after 3×3 convolution (Conv 3×3) processing, noise and adaptive instance normalization are repeatedly added, and then the self-attention mechanism is added to complete the first step of the synthetic network; then upsampling (Upsample), convolution, adding noise, AdaIN, convolution, adding noise, AdaIN, self-attention mechanism are executed in a loop until the feature dimension is increased to 256×256, and then the self-attention mechanism is replaced by the border attention mechanism, and finally a false silk scarf pattern is obtained, which is sent to the discriminator together with the data in the silk scarf pattern dataset.

[0046] The discriminator uses the basic convolution block (ConvBlock) to extract image features, and then uses the border attention mechanism to cyclically execute multiple convolution blocks to obtain high-dimensional features and input them into the fully connected layer FC to obtain the discriminant value D; finally, according to the generation loss and the discrimination loss, the model weights are modified, and the above process is repeatedly executed until the discriminator can hardly distinguish the authenticity of the scarf pattern generated by the generator.

[0047] This network is similar to StyleGAN, but different from StyleGAN, considering that floral scarf patterns have more texture details than other types of patterns, in order to better generate patterns, the present invention adds a self-attention mechanism to the generator of the model. The self-attention mechanism can help the generator pay more attention to image details and structures, and can improve the quality of the generated image; by introducing the self-attention mechanism, the model can more effectively distinguish the relationship between space and region, and learn more detailed information in the image. At the same time, the present invention adds border attention at the end of the convolution of the generator and the beginning of the discriminator, and adds additional weights to the primary features of the pattern through the attention mechanism to guide the model to pay more attention to the border part, thereby improving the problem of uneven borders of scarf patterns; in this way, the network improves the quality and standardization of generated scarf patterns, and completes the generation of semi-finished scarf patterns.

[0048] (3) Graph based on the SDXL model.

[0049] After the semi-finished scarf pattern is generated, the SDXL basic model is used to redraw the image. Build an image generation process based on the ComfyUI workflow, such as Figure 4As shown in the figure, the input latent variables required by the process are extracted from the semi-finished scarf pattern generated in step (3) as a basic pattern style, composition, and color reference. At the same time, the IPAdapter-Plus node is used to learn the input semi-finished scarf pattern, and the pattern style is referenced to ensure that the style remains unchanged. After the above constraints and references, the scarf pattern model is redrawn, and then refined by the Refiner model to obtain the final high-quality floral scarf pattern.

[0050] Below we conduct experiments on scarf pattern generation. By introducing self-attention and border attention, the improved StyleGAN model of the present invention can effectively generate semi-finished floral scarf patterns, and then redraw the image through the stable diffusion model, and finally obtain a floral scarf pattern that meets the standards. We strictly monitor the experimental results using the FID (Fréchet Inception Distance) indicator. The lower the FID value, the closer the distribution of the two images, the higher the similarity between the images, and the better the quality of the generated image. The significant effectiveness of the improved StyleGAN model in scarf pattern generation and the significant effectiveness of the stable diffusion model in redrawing the image are verified. The detailed data of the experimental results are shown in Table 1:

[0051] Table 1

[0052]

[0053] As can be seen from the table above, except for the last row which is the complete scarf pattern generation method of the present invention, the other methods are classic models in the current image processing and image generation fields and the StyleGAN improved model used alone. The experimental data clearly shows that the present invention has achieved significant improvement in the FID index and has significant advantages over other models and methods. This comparative experimental result fully proves the effectiveness and advancement of the present invention.

[0054] In addition, we also used SSIM (structural similarity index), PSNR (peak signal-to-noise ratio) and MBM (average blur metric) indicators to strictly monitor the experimental results and verify the effectiveness and stability of image generation and image redrawing. The higher the SSIM value and PSNR value, the higher the image similarity, and the lower the MBM value, the clearer the generated image. The detailed data of the experimental results are shown in Table 2:

[0055] Table 2

[0056]

[0057] By referring to the SSIM and PSNR values, the present invention can find that the image-generated image redrawing retains the basic composition and content of the original image, and the visual similarity of the image is very high; by referring to the MBM value, it can be found that the clarity of the image has been greatly improved. The experimental data clearly shows the effectiveness and stability of the stable diffusion model for image-generated image redrawing.

[0058] The above description of the embodiments is to facilitate the understanding and application of the present invention by those skilled in the art. It is obvious that those skilled in the art can easily make various modifications to the above embodiments and apply the general principles described herein to other embodiments without creative work. Therefore, the present invention is not limited to the above embodiments. Improvements and modifications made by those skilled in the art to the present invention based on the disclosure of the present invention should be within the protection scope of the present invention.

Claims

1. A method for generating scarf patterns based on a generative adversarial network and a stable diffusion model, comprising the following steps: (1) A large number of floral scarf patterns and floral pattern patterns are collected and input into the pattern augmentation workflow based on ComfyUI and SDXL model after preprocessing to construct a floral scarf pattern dataset. Specifically, the floral scarf patterns are first cleaned to screen out unqualified floral scarf patterns, and then the floral scarf patterns that meet the requirements are selected from the qualified floral scarf patterns as the dataset and augmented on this basis. These floral scarf patterns and floral pattern patterns are input into the pattern augmentation workflow based on ComfyUI and SDXL model, and the floral scarf patterns are used to learn the composition theme and the floral pattern patterns are used to learn the style elements. The learned features are fused to generate new floral scarf patterns, thereby constructing a floral scarf pattern dataset; The pattern augmentation workflow accepts a floral scarf pattern, a floral pattern pattern, a forward prompt, and a reverse prompt as inputs, wherein the forward prompt, in addition to the basic quality prompt words, additionally adds a general prompt word obtained by WD14 annotation, and the reverse prompt only uses the basic quality prompt word; the floral scarf pattern and the floral pattern pattern are cropped and input into the IPAdapter-Plus node, which first uses a pre-trained CLIP encoder to extract image features from the pattern with the prompt word, and then uses a decoupled cross-attention mechanism, that is, the cross-attention layers of text features and image features are separated, and a new cross-attention layer is added to each cross-attention layer in the SDXL model U-Net, so that the image features guide the image generation process through the decoupled cross-attention mechanism; in this way, the image features are independently embedded in the U-Net of the SDXL model, and at the same time, the SDXL model converts the input prompt words into latent variables, and continuously optimizes these latent variables through the U-Net, thereby obtaining a latent variable containing noise; finally, a Refiner model for denoising is used to refine the pattern after feature fusion; (2) Construct a scarf pattern generation model based on the improved StyleGAN architecture, which consists of two parts: a generator and a discriminator. The mapping network in the generator samples noise vectors from a normal distribution and maps them to another latent space to generate multiple style features for controlling the generation of scarf patterns. These style features are input into the synthesis network from different positions to generate a floral scarf pattern Silk_G. The discriminator uses the floral silk scarf pattern dataset to determine whether Silk_G is real or generated by the generator; (3) The scarf pattern generation model is trained. After the training is completed, the semi-finished floral scarf pattern is generated by the model as a reference image, which is input into the image-generated-image workflow based on the SDXL model for redrawing, so that the finished floral scarf pattern can be automatically generated. Specifically: a graphic-generated-image redrawing process is constructed based on the ComfyUI workflow. The hidden variable required by the process is the floral scarf pattern generated by the scarf pattern generation model, which serves as a basic pattern style, composition and color reference image. At the same time, the IPAdapter-Plus node is used to learn the reference image, from which the pattern style is referenced to ensure that the style remains unchanged, and then the floral scarf pattern is redrawn. Finally, the Refiner model is used to complete the refinement to obtain the finished floral scarf pattern.

2. The method for generating scarf patterns based on a generative adversarial network and a stable diffusion model according to claim 1, characterized in that: The scarf pattern generation model in step (2) is improved accordingly based on StyleGAN, that is, a self-attention mechanism is added to the input part of the generator, and a border attention mechanism is added to the output part of the generator and the input part of the discriminator, which effectively improves the clarity and standardization of the floral scarf pattern finally generated by the model.

3. The method for generating scarf patterns based on generative adversarial networks and stable diffusion models according to claim 1, characterized in that: The mapping network in the generator is composed of a cascade of multiple fully connected layers, and the latent variables generated by it are processed by affine transformation to form style features. The synthesis network in the generator is composed of a cascade of multiple sub-modules. Each sub-module adds Gaussian noise processed by broadcast operation to the input, introduces style features through AdaIN, and then repeatedly adds noise and introduces style features after convolution processing, and finally outputs through the self-attention mechanism; the input is upsampled starting from the second sub-module, and the border attention mechanism is used to replace the self-attention mechanism in the last sub-module.

4. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: The processor is used to execute the computer program to implement a method for generating a silk scarf pattern based on a generative adversarial network and a stable diffusion model as described in any one of claims 1 to 3.

5. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements a method for generating a silk scarf pattern based on a generative adversarial network and a stable diffusion model as described in any one of claims 1 to 3.

Citation Information

Patent Citations

  • Real world image super-resolution method based on stable diffusion

    CN118918009A

  • Image processing method and device

    CN119295305A