A method for generating a clear image with periodicity
By introducing a stitching and focusing mechanism and a super-resolution process into the image generation model, the problem of the inability to generate strictly periodic and high-resolution patterns in existing technologies has been solved, achieving efficient generation of high-quality patterns and reducing the cost of printing and dyeing design.
Patent Information
- Application Number
- CN202411823199.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-11
- Publication Date
- 2026-01-06
- Estimated Expiration
- 2044-12-11
AI Technical Summary
Existing image generation methods cannot directly generate strictly periodic patterns and cannot efficiently improve resolution, resulting in high time costs and reduced quality in printing and dyeing design.
By employing a stitching and focusing mechanism and a super-resolution process, periodic patterns are generated by modifying the attention mechanism of the diffusion model. Combined with super-resolution technology, image resolution and details are improved, and image editing techniques are used to repair the image.
It enables efficient generation of high-quality periodic patterns, reduces the time and manpower costs of printing and dyeing design, and improves the usability of image generation models.
Smart Images

Figure CN119887550B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image generation and relates to a method for generating clear images with periodicity. Background Technology
[0002] In the printing and dyeing industry, pattern design requires a high degree of periodicity and high definition to ensure seamless splicing effects on large areas of fabric. However, existing pattern design typically relies on manual hand-drawing or digital drawing tools, which consumes a lot of time and human resources and makes it difficult to make flexible and diverse modifications to the image content according to the user's needs.
[0003] In recent years, generative models, especially text-to-pattern diffusion models (such as Midjourney and StableDiffusion), have made significant progress in image generation technology. Image generation models have also been widely used due to their diverse generated content and efficient generation process.
[0004] However, existing image generation methods cannot directly generate periodic patterns through text constraints. Furthermore, limited by computational resources, the models cannot directly generate high-resolution patterns, requiring the reliance on existing super-resolution techniques to improve the clarity of the generated patterns. However, this method amplifies artifacts and distortions during the generation process in printing and dyeing applications, leading to a decrease in quality.
[0005] Therefore, there is an urgent need for a generation framework that can generate strictly periodic data and automatically optimize image resolution, in order to improve generation quality and reduce the time cost of printing and dyeing design. Summary of the Invention
[0006] To address the aforementioned problems, this invention proposes a method for generating clear, periodic images. This method comprises two core components: a stitching and focusing mechanism and a super-resolution process. Strictly periodic patterns are generated through stitching and attention focusing in the feature space during image generation. Then, a super-resolution process, which integrates image editing and super-resolution techniques, is used to repair the image and improve its resolution.
[0007] This invention provides a method for generating clear images with periodicity, the steps of which include:
[0008] Modify the attention mechanism of the diffusion model to be used to a focused attention mechanism and input text prompts;
[0009] Generate the central region of the image in the feature space of the diffusion model, and restrict attention to the central region;
[0010] The central region is sampled and repeatedly copied and stitched around it until the set number of steps are reached to obtain the initial pattern;
[0011] Upsampling techniques are used to improve image resolution;
[0012] Image editing techniques are used to repair and add details to an image, guided by text prompts, to generate a clear image that meets the target resolution requirements.
[0013] Furthermore, the modification method is as follows: trim the corresponding dimensions of the K and V vectors from the attention process, retaining only the central region to smooth the splicing of the edge regions.
[0014] Furthermore, during the sampling process, an extended feature vector is generated at each time step using a replacement function and then concatenated with the original feature vector.
[0015] Furthermore, the initial pattern is magnified to the target resolution using a pre-trained diffusion model upsampling technique and segmented into sub-images with overlapping regions, the resolution of which is within the processing capability of the diffusion model.
[0016] Furthermore, consistency constraints are added to the corresponding parts of the original region and the expanded region of the segmented subgraph.
[0017] Furthermore, the feature is that after repairing the image and adding details, all sub-images are re-stitched, and consistency constraints are applied to the overlapping parts of adjacent regions.
[0018] Furthermore, the process of increasing image resolution and repairing and adding details is repeated multiple times until the set image resolution is achieved.
[0019] The beneficial effects of this invention are:
[0020] Compared with existing technologies, this invention provides a plug-and-play framework for generating periodic patterns without training. It also provides a matching image processing workflow that simultaneously completes image restoration, generates details, and improves resolution. This improves the usability of image generation models in the field of printing and dyeing pattern design, enabling the generation of high-quality stylized patterns and significantly reducing production costs. Attached Figure Description
[0021] Figure 1 This is a flowchart illustrating an embodiment of the present invention;
[0022] Figure 2 This is a schematic diagram illustrating the splicing and focusing mechanism in an embodiment of the present invention;
[0023] Figure 3 This is a schematic diagram of the super-resolution module in an embodiment of the present invention. Detailed Implementation
[0024] This invention provides a method for generating clear images with periodicity, the flowchart of which is shown below. Figure 1 As shown.
[0025] Step 1: Periodic Pattern Generation. This step receives text prompts from the user and uses a diffusion model to generate a low-resolution initial pattern. In this embodiment, the central region is 512. 2 640 pixels after expansion 2 Pixels. To ensure the periodicity of the generated pattern, the diffusion model is extended using the following stitching-focusing mechanism.
[0026] Feature space concatenation: In this embodiment, the StableDiffusion1.5 model is used as the basic generative model. First, random Gaussian distribution features x are sampled in the feature space. T ~N(0,1), whose resolution corresponds to the ratio of the size of the initial pattern image to the feature space scaling factor. Define the replacement function S(x t )=x t ′, i.e., x t,e1′ ′=x t,e1 x t,c1′ ′=x t,c1 And so on, such as Figure 2 As shown, the feature vector x at each time step t in the above generative model sampling process is... t The process involves stitching together corresponding portions of the central region and copying them to the outer regions to achieve strict consistency. Sampling and stitching are repeated throughout the sampling process until all 50 sampling steps are completed.
[0027] Focused Attention Mechanism: The standard self-attention mechanism of the diffusion model is modified by limiting the attention range to the effective central region of the image to ensure smooth edge stitching. Specifically, the corresponding dimensions of the K and V vectors are cropped during the self-attention process, retaining only the central region (the original region before the feature space expansion). A focused attention mechanism, FocAttention, is defined, and its calculation formula is as follows: Here, K′ and V′ are the cropped K and V vectors, their dimensions corresponding to the portion of the central region in the expanded image. Throughout the sampling process, the self-attention mechanism is replaced with the above mechanism until the prescribed number of sampling steps are completed. This mechanism requires no additional training and improves the naturalness of pattern generation through lightweight modifications.
[0028] Step 2: Super-resolution and Detail Reconstruction. To meet the printing and dyeing industry's requirements for pattern resolution, a super-resolution workflow is applied to perform super-resolution and detail restoration on the low-resolution periodic patterns generated in the previous steps. The super-resolution module consists of two stages: a super-resolution stage and an image editing stage, which alternately enhance the clarity of the pattern and repair distortion, such as... Figure 3 As shown. In this example, the original region is 4096. 2 5120 pixels after expansion 2 Pixel.
[0029] In the super-resolution stage, upsampling techniques are used to enlarge the initial pattern to the target resolution. In this example, a pre-trained diffusion model-based upsampling technique is used to segment the enlarged high-resolution image into sub-images with overlapping regions, ensuring that the resolution of the sub-images is within the processing capability of the diffusion model, thus facilitating subsequent detail restoration. Simultaneously, consistency constraints are added to corresponding parts of the original and expanded regions of the segmented sub-images, ensuring that the feature vectors of corresponding parts remain consistent, guaranteeing the smoothness and periodicity of the re-stitching.
[0030] In the image editing stage, image editing methods are used to reconstruct details of the super-resolution sub-images under the guidance of text prompts. This method first adds noise of intensity 0.3 to the original image, and then uses a diffusion model to progressively sample and denoise the image during the denoising process, generating structures and details that meet the target resolution requirements. Finally, all sub-images are re-stitched, and consistency constraints are applied to overlapping areas of adjacent regions (ensuring that the feature vectors of corresponding parts remain consistent) to ensure seamless connection and guarantee the overall consistency of the pattern.
[0031] The above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Those skilled in the art can modify or make equivalent substitutions to the technical solutions of the present invention without departing from the spirit and scope of the present invention. The scope of protection of the present invention should be determined by the claims.
Claims
1. A method for generating a clear image with periodicity, comprising the steps of: modifying an attention mechanism of a diffusion model to be a focused attention mechanism and inputting a text prompt; the modification method is to clip the corresponding dimensions of K and V vectors in the self-attention process, only keeping the center region to smooth the splicing of the edge region; generating a center region of the image in the feature space of the diffusion model and limiting attention to the center region; sampling the center region and repeatedly copying and splicing in the periphery until a set number of steps, obtaining an initial pattern; using up-sampling technology to improve the resolution of the image; using image editing technology to repair the image and add details under the guidance of the text prompt, generating the clear image meeting the target resolution requirement. In the sampling process, the expanded feature vector of each time step is generated by a replacement function, and is spliced with the original feature vector. Using the pre-trained diffusion model up-sampling technology to enlarge the initial pattern to the target resolution, and dividing it into subgraphs with overlapping areas, the resolution of the subgraph is within the processing capacity of the diffusion model. Adding consistency constraints to the corresponding parts of the original and expanded regions of the segmented subgraph. After repairing the image and adding details, all subgraphs are spliced again, and consistency constraints are applied to the overlapping parts of adjacent regions. Alternately improving the resolution of the image and repairing the image and adding details for multiple times until the set image resolution is reached.
2. The method of claim 1, wherein, 7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the steps of the method of any one of claims 1-6.
3. The method of claim 1, wherein, 8. A storage medium storing a computer program, which when executed implements the steps of the method of any one of claims 1-6.
4. The method of claim 3, wherein, 5. The method of claim 3 or 4, wherein, 6. The method of claim 1, wherein,
Citation Information
Patent Citations
Single image super-resolution reconstruction method based on improved diffusion model
CN117575907A
Personalized virtual fitting method based on shape control and texture guidance
CN117670893A