Pattern generation method and system based on conditional generative adversarial network

Through the method of generating an adversarial network based on conditions, using the extended graphic grammar rule library and iterative adversarial training, patterns that meet the design needs are generated, which solves the problem of difficult balance between structural and cultural adaptability in the existing technology, and achieves efficient and controllable pattern generation.

CN120411279APending Publication Date: 2025-08-01XIAN UNIV OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510452490.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-11
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

The existing technology is difficult to achieve a balance between structural normativeness, richness of details, controllability and cultural adaptability, resulting in limited practical application of traditional pattern intelligent generation technology.

Method used

The method of generating adversarial network based on condition is adopted, and conditional vectors are generated by extending the graph syntax rule base, and combined with iterative adversarial training of the generator and discriminator, a conditional adversarial network is built. The generator's loss function has symmetry, repetition and normative constraints to ensure that the generated patterns meet design requirements.

Benefits of technology

The generated patterns are visually balanced and standardized, meet cultural style requirements, reduce manual intervention, improve design efficiency, and enhance designers' sense of control and satisfaction with results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120411279A_ABST
    Figure CN120411279A_ABST
Patent Text Reader

Abstract

The invention discloses a pattern generation method based on a conditional generative adversarial network. The pattern generation method comprises the following steps: analyzing an extended graph grammar rule into a conditional vector; step 2, obtaining a feature map of the pattern image; step 3, based on the condition vector and the feature map, establishing a joint input vector; 4, training a conditional generative adversarial network; 5, generating a pattern image by using a conditional generative adversarial network; step 6, judging whether the user needs to adjust parameters, if so, entering step 7; otherwise, entering step 8; 7, updating the condition vector, and regenerating a pattern image; and step 8, saving or outputting the generated pattern image. According to the method, the condition vector is generated by expanding the graph grammar rule base, the attribute of the generated pattern is controlled, the loss function of the generator has symmetry, repeatability and normative constraint terms, it is ensured that the pattern meeting the design requirement is generated, the pattern attribute is finely adjusted again through user input adjustment, and the control feeling and the satisfaction degree of the result are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of image generation, and particularly relates to a pattern generation method and system based on a conditional generative adversarial network. Background Art

[0002] The traditional intelligent pattern generation method refers to the technology of automatically or semi-automatically generating traditional pattern designs that conform to specific cultural styles, aesthetic rules, and structural characteristics through computer technology and artificial intelligence algorithms. Its core principle is to encode the design rules of traditional patterns, such as symmetry, repeatability, and color matching, into a computable grammar model by integrating rule-driven design and data-driven learning, and to combine the deep learning capabilities of generative adversarial networks to achieve high-quality and diverse pattern generation. This technology is of great significance for the digital protection of cultural heritage, the modern innovation of traditional crafts, and personalized art design. It can significantly improve the pattern design efficiency, reduce labor costs, and provide high-precision data support for cultural research and historical analysis.

[0003] However, in the prior art, although the method based on graphic grammar can generate structured patterns, it relies on manual rule design and is difficult to capture the detailed features of complex patterns and the dynamic adaptation requirements of multi-cultural styles. The generation results of the method based on pure GAN have strong randomness and lack control over core aesthetic rules such as symmetry axes and repeat units, resulting in structural imbalance or loss of cultural symbolic meaning. The above problems make it difficult for the prior art to achieve a balance among structural normativity, detail richness, controllability, and cultural adaptability, thus restricting the practical application of traditional pattern intelligent generation technology. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a pattern generation method and system based on a conditional generative adversarial network for the deficiencies in the above-mentioned prior art. The method and system have a simple structure and reasonable design. By expanding the graphic grammar rule library to generate a conditional vector, the attributes of the generated patterns can be flexibly controlled. The loss function of the generator has symmetry constraint terms, repeatability constraint terms, and normativity constraint terms to ensure that patterns that meet the design requirements can be generated. Through user input adjustment, the pattern attributes can be precisely controlled, enhancing the sense of control and satisfaction with the results.

[0005] To solve the above technical problems, the technical solution adopted by the present invention is:

[0006] The first aspect of the present invention provides a pattern generation method based on a conditional generative adversarial network, which is characterized by including the following steps:

[0007] Step 1: Establish an extended graphic grammar rule and parse the extended graphic grammar rule into a conditional vector I i =(C i , R i, T i ), C i represents the color combination vector of the i-th pattern image, R i represents the repeatability vector of the i-th pattern image, T i represents the symmetry vector of the i-th pattern image;

[0008] Step 2: Establish a multi-cultural style rule library. The multi-cultural style rule library has various pattern images, and obtain the feature map F of the pattern image j , F j represents the feature map of the j-th pattern image;

[0009] Step 3: Based on the conditional vector I i and the feature map F j , establish the joint input vector of the conditional generative adversarial network;

[0010] Step 4: Construct a conditional generative adversarial network, including a generator and a discriminator. The generator generates patterns according to the joint input vector; the discriminator judges whether the generated patterns are real pattern images; among them, the generator and the discriminator optimize the generation quality through iterative adversarial training to obtain a trained conditional generative adversarial network;

[0011] Step 5: Use the conditional generative adversarial network to generate pattern images:

[0012] Step 501: The user provides a pattern image or design requirement with an extended graphic grammar rule, and uses a grammar parser to parse the pattern image or design requirement with the extended graphic grammar rule into a conditional vector; generate an input vector based on the conditional vector;

[0013] Step 502: Input a random noise vector and the input vector into the generator, and the generator outputs a generated pattern image that meets the conditional input;

[0014] Step 6: Judge whether the user needs to adjust the parameters. If so, go to Step 7; otherwise, go to Step 8;

[0015] Step 7: Update the conditional vector in Step 501 according to the user input, and return to Step 502 to obtain an optimized generated pattern image;

[0016] Step 8: Save or output the generated pattern image.

[0017] For the above pattern generation method based on a conditional generative adversarial network, it is characterized in that: the specific steps of generating the input vector of the conditional generative adversarial network based on the conditional vector are:

[0018] Step 201: Randomly initialize the latent space distribution P z (z);

[0019] Step 202: conditional vector I i With the latent space distribution P z (z) splicing to form the first vector V 1i , the feature map F j With the latent space distribution P z (z) splicing to form the second vector V 2j , forming the joint input vector V of the conditional generative adversarial network i+1 =[V 1i , V 2j ].

[0020] The above-mentioned pattern generation method based on conditional generative adversarial network is characterized by: i =[n i , type ij ,...,(x ij ,y ij ), ..., dmean ij , dvar ij ], where n i Indicates the number of symmetry axes of the i-th pattern image, n i Represents a positive integer, type ij Indicates the symmetry axis type code of the i-th pattern image, 1≤j≤n i ,(x ij ,y ij ) represents the position coordinate of the jth symmetry axis in the i-th pattern image, dmean ij represents the mean distance between the symmetric points of the jth symmetry axis in the i-th pattern image, dvar ij represents the variance between the symmetric points of the jth symmetry axis in the i-th pattern image; C i =[H i1 、S i1 , L i1 , H i2 、S i2 , L i2 , H i3 、S i3 , L i3 ], where (H i1 、S i1 , L i1 ) represent the hue, saturation and brightness of red in the i-th pattern image, (H i2 、S i2 , L i2 ) represent the hue, saturation and brightness of green in the i-th pattern image, (H i3 、S i3 , L i3 ) represent the hue, saturation and brightness of blue in the i-th pattern image, where m = 1, 2, 3; n = 1, 2, 3; μ H represents the reference hue, S max = max(S1, S2, S3), S min = min(S1, S2, S3), L max = max(L1, L2, L3), L min = min(L1, L2, L3); R i = [d i-xj , d i-yj , n ix , n iy , where d i-xj represents the repetition interval of the pattern in the i-th pattern image with respect to the j-th axis of symmetry on the X-axis, d i-yj represents the repetition interval of the pattern in the i-th pattern image with respect to the j-th axis of symmetry on the Y-axis, n ix represents the number of repetitions of the pattern in the i-th pattern image with respect to the X-axis, n iy represents the number of repetitions of the pattern in the i-th pattern image with respect to the Y-axis.

[0021] In the above method for generating patterns based on a conditional generative adversarial network, it is characterized in that: the generator and the discriminator optimize the generation quality through iterative adversarial training. After each iteration, calculate L val (t) - min(L val (t - k)) on the validation set, where L val (t) represents the loss of the validation set in the current round, and min(L val (t - k)) represents the minimum value of the losses of the validation set in the past k rounds. If L val (t) - min(L val (t - k)) ≤ ε, then stop training, where ε represents the threshold.

[0022] In the above method for generating patterns based on a conditional generative adversarial network, it is characterized in that: the generator and the discriminator optimize the generation quality through iterative adversarial training. After each iteration, calculate L train (t) on the training set. L train (t) represents the loss of the training set at the end of the t-th round of training. If L train (t) = min(L train (1),..., L train (t)), then save the model parameters of the current round.

[0023] In the above method for generating patterns based on a conditional generative adversarial network, it is characterized in that: the loss function of the generator is L total = L G + ω1Lsym +ω2L rep +ω3L struct , where L G represents the initial loss function of the generator, L sym represents the symmetry constraint term, L rep represents the repeatability constraint term, L struct represents the normalization constraint term, and ω1, ω2, and ω3 represent weights respectively.

[0024] For the above pattern generation method based on conditional generative adversarial network, it is characterized in that: the initial loss function L of the generator G =E x,y [log(1 - D(G(x))) + λ||y - G(x)||1], where E x,y represents the expected value, G(x) represents the image output by the generator, D(G(x)) is the prediction of the discriminator for the generated image, y represents the real pattern image, and λ represents the hyperparameter.

[0025] For the above pattern generation method based on conditional generative adversarial network, it is characterized in that: the loss function formula of the discriminator is: where 表 represents the expected value of the logarithm of the output D(y) of the discriminator D for the real sample y, represents calculating the expected value for the sample x sampled from the conditional input distribution p data (x), y represents the real pattern image, D(y) represents the output of the discriminator for the real sample y, p data (y) represents the distribution of the real pattern data, p data (x) represents the conditional input distribution, and G(x) represents the image output by the generator, and D(G(x)) is the prediction of the discriminator for the generated image.

[0026] For the above pattern generation method based on conditional generative adversarial network, it is characterized in that: the generator and the discriminator optimize the generation quality through iterative adversarial training, and the optimization function of the adversarial training is: where D represents the discriminator, G represents the generator, and p data (x) represents the conditional input distribution, represents calculating the expected value for the sample x sampled from the conditional input distribution p data (x), D(x) represents the evaluation output of the discriminator for the sample x, P z (z) represents the latent space distribution, represents calculating the expected value for the sample sampled from the latent space distribution P zThe expected value is calculated for the sample z sampled in (z), G(x) represents the image generated by the generator from the sample x, and D(G(x)) represents the evaluation output of the discriminator for the generated image G(x).

[0027] The second aspect of the present invention provides a pattern generation system based on a conditional generative adversarial network for performing the pattern generation method based on a conditional generative adversarial network described in claims 1-9, characterized in that it includes a user interface layer, a syntax rule layer, a storage layer, a feature extraction layer, a vector construction layer, a model processing layer, a parameter adjustment judgment layer, a parameter optimization layer, and a storage and output layer;

[0028] The user interface layer is for the user to submit a pattern image or design requirement with an extended graphical syntax rule;

[0029] The syntax rule layer parses the pattern image or design requirement with an extended graphical syntax rule provided by the user into a conditional vector;

[0030] The storage layer stores pattern images of various cultural styles;

[0031] The feature extraction layer uses a convolutional neural network to extract the feature map of the pattern image;

[0032] The vector construction layer constructs a joint input vector of the conditional generative adversarial network based on the conditional vector and the feature map;

[0033] The model processing layer generates a pattern image that meets the user's requirements based on the joint input vector;

[0034] The parameter adjustment judgment layer determines whether the user needs to adjust the parameters;

[0035] The parameter optimization layer obtains the user input, updates the conditional vector according to the user input, and adjusts the input of the model processing layer;

[0036] The storage and output layer saves or outputs the generated pattern image.

[0037] The present invention has the following advantages compared with the prior art:

[0038] 1. The structure of the present invention is simple, reasonably designed, and convenient to implement and use.

[0039] 2. By expanding the graphical syntax rule library, the present invention systematically encodes the three design rules of symmetry, repeatability, and color matching, and the generated patterns strictly follow the preset rules, ensuring that the generated results are visually balanced, standardized, and meet the cultural style requirements.

[0040] 3. Based on the conditional vector and the feature map, the present invention establishes a joint input vector of the conditional generative adversarial network, and flexibly controls the attributes of the generated patterns through the conditional vector, thereby generating diverse pattern images.

[0041] 4. The present invention uses a conditional generative adversarial network. The loss function of the generator has symmetry constraint terms, repeatability constraint terms, and normalization constraint terms, ensuring that the generated patterns have symmetry and meet the aesthetic requirements of traditional patterns; ensuring that the generated patterns have periodic repeating units and conform to the design rules of patterns; ensuring that the generated patterns conform to preset rules in the overall structure. Through these constraint terms, the generator can generate high-quality patterns that meet the design requirements, while reducing manual intervention and improving design efficiency.

[0042] 5. Through user input adjustment, the present invention can fine-tune the pattern attributes again to generate a design that meets the requirements, giving full play to the generative ability of artificial intelligence and the creativity of designers. Designers participate in the entire generation process, enhancing the sense of control and satisfaction with the results, and generating high-quality pattern images.

[0043] In summary, the present invention has a simple structure and reasonable design. By expanding the graphic grammar rule library to generate conditional vectors, it flexibly controls the attributes of the generated patterns. The loss function of the generator has symmetry constraint terms, repeatability constraint terms, and normalization constraint terms, ensuring that patterns that meet the design requirements can be generated. Through user input adjustment, the pattern attributes can be precisely controlled, enhancing the sense of control and satisfaction with the results.

[0044] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Description of the Drawings

[0045] Figure 1 is the method flow chart of the present invention.

[0046] Figure 2 is the calculation flow chart of the combined input vector of the present invention.

[0047] Figure 3 is the structural diagram of pattern generation based on the conditional generative adversarial network in the second embodiment of the present invention.

[0048] Figure 4 is a comparison diagram of patterns generated according to the symmetry vector of the present invention.

[0049] Figure 5 is a comparison diagram of patterns generated according to the repeatability vector of the present invention.

[0050] Figure 6 is a comparison diagram of patterns generated according to the color matching vector of the present invention. Detailed Embodiments

[0051] The method of the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments of the present invention.

[0052] It should be noted that, without conflict, the embodiments in the present application and the features in the embodiments may be combined with each other. The present invention will be described in detail below with reference to the drawings and in combination with the embodiments.

[0053] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular forms are also intended to include the plural forms. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0054] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence. It should be understood that such data can be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units does not necessarily have to be limited to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products, or devices.

[0055] For ease of description, spatial relative terms such as "above", "over", "on the upper surface", "above", etc. can be used herein to describe the spatial positional relationship of a device or feature shown in the figure with other devices or features. It should be understood that the spatial relative terms are intended to include different orientations in use or operation in addition to the orientation described in the figure for the device. For example, if the device in the figure is inverted, the device described as "above other devices or structures" or "over other devices or structures" will then be positioned as "below other devices or structures" or "under other devices or structures". Thus, the exemplary term "above" can include both the orientations of "above" and "below". The device can also be positioned in other different ways (rotated 90 degrees or in other orientations), and corresponding interpretations are made for the spatial relative descriptions used herein.

[0056] As Figure 1 shown, a pattern generation method based on a conditional generative adversarial network of the present invention includes the following steps:

[0057] Step 1: Establish an extended graph grammar rule and parse the extended graph grammar rule into a conditional vector I i =(Ci , R i , T i ), C i represents the color combination vector of the i-th pattern image, R i represents the repeatability vector of the i-th pattern image, T i represents the symmetry vector of the i-th pattern image.

[0058] By expanding the graphic grammar rule library, the three design rules of symmetry, repeatability, and color combination are systematically encoded, and the generated patterns strictly follow the preset rules to ensure that the generated results are visually balanced, standardized, and meet the cultural style requirements.

[0059] Among them, the condition vector I i =(C i , R i , T i , and the symmetry vector T of the i-th pattern image i =[n i , type ij ,..., (x ij , y ij ),..., dmean ij , dvar ij , where n i represents the number of symmetry axes of the i-th pattern image, n i represents a positive integer, type ij represents the symmetry axis type code of the i-th pattern image, 1≤j≤n i , (x ij , y ij ) represents the position coordinates of the j-th symmetry axis in the i-th pattern image, dmean ij represents the average distance between the symmetric points of the j-th symmetry axis in the i-th pattern image, dvar ij represents the variance between the symmetric points of the j-th symmetry axis in the i-th pattern image.

[0060] The condition vector I i =(C i , R i , T i ), and the color combination vector C of the i-th pattern image i =[H i1 , S i1 , L i1 , H i2 , S i2 , L i2 , H i3 , S i3 , L i3 , where (H i1 , Si1 , L i1 ) represent the hue, saturation, and lightness of red in the i-th pattern image, (H i2 , S i2 , L i2 ) represent the hue, saturation, and lightness of green in the i-th pattern image, (H i3 , S i3 , L i3 ) represent the hue, saturation, and lightness of blue in the i-th pattern image, where m = 1, 2, 3; n = 1, 2, 3; μ H represents the reference hue, S max = max(S1, S2, S3), S min = min(S1, S2, S3), L max = max(L1, L2, L3), L min = min(L1, L2, L3).

[0061] The condition vector I i = (C i , R i , T i ), the repeatability vector of the i-th pattern image, R i = [d i-xj , d i-yj , n ix , n iy , where d i-xj represents the repeat interval of the pattern in the i-th pattern image with respect to the j-th axis of symmetry on the X-axis, d i-yj represents the repeat interval of the pattern in the i-th pattern image with respect to the j-th axis of symmetry on the Y-axis, n ix represents the number of repetitions of the pattern in the i-th pattern image with respect to the X-axis, n iy represents the number of repetitions of the pattern in the i-th pattern image with respect to the Y-axis.

[0062] Parse the extended graphic grammar rules into the condition vector I i = (C i , R i , T i ), which is completed by a grammar parser or by manual annotation.

[0063] Store the pattern image and the corresponding extended graphic grammar rules in a suitable data format, for example, store the rules in JSON format and save the image in common image formats such as JPEG, PNG, etc., and establish an association relationship to facilitate subsequent data reading and processing.

[0064] Step 2: Establish a multi-cultural style rule base. The multi-cultural style rule base has a variety of pattern images, and obtain the feature map F of the pattern image j , F j represents the feature map of the j-th pattern image.

[0065] It should be noted that based on the cultural background and pattern characteristics, the multi-cultural style rule base classifies the pattern images into multiple categories, including geometric pattern patterns, symmetric structure patterns, and culturally characteristic exclusive patterns.

[0066] Among them, the geometric pattern patterns include circular pattern patterns, square pattern patterns, triangular pattern patterns, polygonal pattern patterns, and rhombic pattern patterns, such as copper coin patterns, huiwen patterns, arrow patterns, turtle shell patterns, and fang sheng patterns.

[0067] The symmetric structure patterns include axisymmetric patterns, central symmetric patterns, translational symmetric patterns, rotational symmetric patterns, and mirror symmetric patterns, such as double fish patterns, sun patterns, wave patterns, wanzi patterns, and double happiness patterns.

[0068] The culturally characteristic exclusive patterns include Chinese cloud patterns and Islamic patterns, such as curly cloud patterns, ruyi cloud patterns, star patterns, and intertwined patterns.

[0069] Step 3: Based on the conditional vector I i and the feature map F j , establish the joint input vector of the conditional generative adversarial network. By flexibly controlling the attributes of the generated patterns through the conditional vector, diverse pattern images can be generated.

[0070] The specific steps for generating the input vector of the conditional generative adversarial network based on the conditional vector are as follows:

[0071] Step 201: Randomly initialize the latent space distribution P z (z);

[0072] Step 202: Concatenate the conditional vector I i with the latent space distribution P z (z) to form the first vector V 1i , and concatenate the feature map F j with the latent space distribution P z (z) to form the second vector V 2j , and form the joint input vector V i+j = [V 1i , V 2j .

[0073] The latent space distribution P z (z) is a random noise vector used to generate diverse outputs, usually sampled from a certain distribution, such as a Gaussian distribution or a uniform distribution. If the conditional vector Ii has a dimension of d, and the latent space distribution P z (z) has a dimension of z, then the first vector V 1i has a dimension of d + z.

[0074] During training, the first vector V 1i and the second vector V 2j are jointly input into the generator. The generator simultaneously utilizes the information of the conditional vector and the feature map to generate an output that conforms to specific conditions and styles. In a possible embodiment, the first vector and the second vector are further concatenated to form a larger joint input vector, and then input into the generator. In another possible embodiment, the generator is designed as a multi-branch structure, which separately receives the first vector and the second vector as inputs, and then fuses them at a certain layer of the generator network.

[0075] The conditional vector I i is concatenated with the latent space distribution P z (z) to form the first vector V 1i , and the first vector V 1i provides conditional information for generating the target, such as category, style, etc. The feature map F j is concatenated with the latent space distribution P z (z) to form the second vector V 2j , and the second vector V 2j provides the pattern feature information extracted from the multi-cultural style rule base. The joint input of these two vectors can ensure that the generator simultaneously considers the conditional constraints and the pattern features during the generation process, thereby generating an image that better meets the requirements.

[0076] Step Four: Construct a conditional generative adversarial network, including a generator and a discriminator. The generator generates patterns based on the joint input vector; the discriminator determines whether the generated patterns are real pattern images; among them, the generator and the discriminator optimize the generation quality through iterative adversarial training to obtain a trained conditional generative adversarial network.

[0077] Combined with the deep learning ability of the conditional generative adversarial network, the generator can capture the delicate features of the complex distribution of real pattern images, generate realistic and detailed pattern images, and reduce the time and cost of manual design.

[0078] The loss function of the generator has symmetry constraint terms, repeatability constraint terms, and normality constraint terms, ensuring that the generated patterns have symmetry and meet the aesthetic requirements of traditional patterns; ensuring that the generated patterns have periodic repeating units and conform to the design rules of patterns; ensuring that the generated patterns conform to the preset rules in the overall structure; through these constraint terms, the generator can generate high-quality patterns that meet the design requirements, while reducing manual intervention and improving the design efficiency.

[0079] Step 401: Fix the generator and train the discriminator:

[0080] The parameters of the generator remain unchanged.

[0081] The discriminator D receives the real pattern image y and the corresponding joint input vector, and outputs a probability value D(y), representing the probability that the image is real; the discriminator hopes that D(y) is close to 1.

[0082] The generator receives the random noise and the joint input vector U, and generates an image G(x).

[0083] The discriminator receives the generated image G(x) and the joint input vector U, and outputs a probability value D(G(x)), representing the probability that the image is real; the discriminator hopes that D(G(x)) is close to 0.

[0084] The loss function of the discriminator is By minimizing L D to distinguish between real images and generated images. Where, represents the expected value of taking the logarithm of the output D(y) of the discriminator D for the real sample y, represents calculating the expected value for the sample x sampled from the conditional input distribution p data (x), y represents the real pattern image, D(y) represents the output of the discriminator for the real sample y, p data (y) represents the distribution of real pattern data, p data (x) represents the distribution of conditional input, G(x) represents the image output by the generator, and D(G(x)) is the prediction of the discriminator for the generated image.

[0085] Update the parameters of the discriminator to maximize the optimization function V DG , to better distinguish between real images and generated images.

[0086] Step 402: Fix the discriminator and train the generator:

[0087] The parameters of the discriminator remain unchanged.

[0088] The generator receives the random noise and the joint input vector U, and generates an image G(x);

[0089] The discriminator receives the generated image G(x) and the joint input vector U, and outputs a probability value D(G(x)). The generator hopes that D(G(x)) is close to 1, that is, to make the discriminator misjudge the generated image as real.

[0090] The loss function of the generator is L total = L G + ω1L sym + ω2L rep + ω3L [[ID= 58]] struct, by minimizing L total来 Generate more realistic images.

[0091] Update the parameters of the generator and minimize the optimization function V DG to generate more realistic images that are difficult for the discriminator to distinguish.

[0092] where L G represents the initial loss function of the generator, and L G = E x,y [log(1 - D(G(x))) + λ||y - G(x)||1], where E x,y represents the expected value, G(x) represents the image output by the generator, D(G(x)) is the prediction of the discriminator for the generated image, y represents the real pattern image, and λ represents the hyperparameter.

[0093] The output of the generator needs to satisfy the constraints of symmetry, repeatability, and structural normality. Therefore, a symmetry constraint term L sym , a repeatability constraint term L rep , and a normality constraint term L struct are added to the loss function, where ω1, ω2, and ω3 represent the weights respectively.

[0094] It should be noted that G(p) represents the output of the generator at point P, represents the symmetry mapping function, point p i and point p j represent symmetric points. By minimizing the symmetry constraint term L sym , the generator is forced to generate symmetric pattern images.

[0095] G(x, y) represents the output of the generator at point (x, y), G(x + Δx, y + Δy) represents the output of the generator at point (x + Δx, y + Δy), Δx represents the offset on the x-axis, and Δy represents the offset on the x-axis. Define the repeat intervals Δx and Δy such that the repeating unit satisfies p j = p i + (Δx, Δy) to ensure the periodic distribution and visual continuity of the pattern. L struct = ||G - T|| 2 , where G represents the image generated by the generator and T represents the initial module image. The normality constraint term L struct forces the generator to generate images that conform to the preset structure by calculating the difference between the generator output G and the initial template T.

[0096] Step 403: Repeat Step 401 and Step 402, alternately train the discriminator and the generator. The discriminator and the generator are continuously optimized until they finally reach equilibrium.

[0097] In a conditional generative adversarial network, the goal of the discriminator is to accurately determine whether the samples generated by the generator are real or fake, while the goal of the generator is to generate samples that can deceive the discriminator so that it cannot distinguish between real and fake. By continuously training the discriminator and the generator alternately, their performance gradually improves until they finally reach a balanced state, namely the Nash equilibrium. When the training reaches equilibrium, the discriminator cannot distinguish between real images and generated images, that is, D(y) = 0.5 and D(G(x)) = 0.5. The images generated by the generator are distributed identically to the real images, that is, p data (y) = p data (x).

[0098] The generator and the discriminator optimize the generation quality through iterative adversarial training. Among them, the optimization function of adversarial training is: where D represents the discriminator, G represents the generator, p data (x) represents the distribution of conditional inputs, represents calculating the expected value for the sample x sampled from the conditional input distribution p data (x), D(x) represents the evaluation output of the discriminator for the sample x, P z (z) represents the latent space distribution, represents calculating the expected value for the sample z sampled from the latent space distribution P z (z), G(x) represents the image generated by the generator from the sample x, and D(G(x)) represents the evaluation output of the discriminator for the generated image G(x).

[0099] Divide the joint input vector into a training set, a validation set, and a test set according to the ratio of 6:2:2.

[0100] After each iteration ends, calculate L val (t) - min(L val (t - k)) on the validation set, where L val (t) represents the validation set loss of the current round, and min(L val (t - k)) represents the minimum value of the validation set losses in the past k rounds. If L val (t) - min(L val (t - k)) ≤ ε, stop the training, where ε represents the threshold.

[0101] The core idea of the early stopping mechanism in this application is to determine whether the current validation set loss L val (t) is smaller than the minimum loss min(L val(t - k)) has a significant improvement, that is, whether the improvement amplitude exceeds the threshold ε. If there is no significant improvement, early stopping is triggered. The formula introduces the minimum loss min(L val in the past k rounds, increasing the consideration of the loss change trend, being able to more comprehensively reflect the change trend of the loss, and avoiding misjudgment due to the fluctuation of the single-round loss.

[0102] After each iteration ends, calculate L train (t) on the training set. L train (t) represents the training set loss at the end of the t-th round of training. If L train (t) = min(L train (1),..., L train (t)), then save the model parameters of the current round.

[0103] The core idea of the model checkpoint of this application is that in each training round, if the training set loss reaches the historical minimum, the model parameters are saved. By saving the model parameters with the minimum training set loss, it is ensured that the finally used model has the best performance and overfitting is avoided.

[0104] Step Five: Use a conditional generative adversarial network to generate pattern images:

[0105] Step 501: The user provides a pattern image with extended graphic grammar rules or a design requirement, and uses a grammar parser to parse the pattern image with extended graphic grammar rules or the design requirement into a conditional vector.

[0106] As shown in Figure 4, for example, the design requirement can be: generate a pattern with horizontal symmetry; generate a pattern with a periodic repeating unit with a repeating interval of 5 units; generate a pattern with red and gold as the main colors.

[0107] Through the grammar parser, these design requirements can be parsed into structured conditional vectors, and the generated conditional vector is: I = (C, T, R).

[0108] Suppose the image height is H = 256, the number of symmetry axes: 1; the symmetry axis type encoding: 1 (indicating horizontal symmetry); the position coordinate of the symmetry axis is y = 128; the average distance between symmetric points: 128; the variance between symmetric points: 0. Then, T = [1, 1, (0, 128), 128, 0].

[0109] Suppose the image width is 100, the repeating interval of the symmetry axis on the X-axis: 5; the repeating interval of the symmetry axis on the Y-axis: 5; the number of repetitions about the X-axis: 20; the number of repetitions about the Y-axis: 20. Then, R = [5, 5, 20, 20].

[0110] If the hue range is [0, 1], red is expressed as hue: 0; saturation: 1.0; brightness: 1.0. Gold is expressed as hue: 50; saturation: 1.0; brightness: 0.5. Then, C = [0, 1, 1, 0, 0, 0, 0.138, 1, 0.5].

[0111] Then, an input vector is generated based on the conditional vector, and the method is as follows:

[0112] First, randomly initialize the latent space distribution P z (z);

[0113] Then, splice the conditional vector I and the latent space distribution P z (z) to form the first vector V1, and splice the feature map F and the latent space distribution P z (z) to form the second vector V2, thus forming the joint input vector of the conditional generative adversarial network

[0114] Step 502: Input the random noise vector ∈ and the input vector V into the generator, and the generator outputs a generated pattern image that meets the conditional input;

[0115] Step Six: Determine whether the user needs to adjust the parameters. If so, go to Step Seven; otherwise, go to Step Eight;

[0116] Step Seven: Update the conditional vector in Step 501 according to the user input, return to Step 502, and obtain an optimized generated pattern image;

[0117] In a possible embodiment, the user input here refers to the parameters input by the user, such as the number of symmetry axes, repetition interval, and color parameters. Update the parameters of the conditional vector I = (C, T, R) according to the user input. In another possible embodiment, the user input is converted into parameters through a mapping function, and the conditional vector I = (C, T, R) is updated according to these parameters. Then, regenerate the input vector V, input the random noise vector ∈ and the input vector V into the generator, and the generator outputs a generated pattern image that meets the conditional input. Then, enter the judgment in Step Six again. Ensure that the generator quickly responds to the design requirements and generates patterns that meet the expectations.

[0118] Through the adjustment of the user input, the pattern attributes can be fine-tuned again to generate designs that meet the requirements, which can give full play to the generative ability of artificial intelligence and the creativity of designers. The designers participate in the entire generation process, enhancing the sense of control and satisfaction with the results, and generating high-quality pattern images.

[0119] As shown in Figure 4, Figure 4a the design requirement is: to generate a pattern with horizontal symmetry; the conditional vector is I = (0, T, 0), T = [1, 1, (0, 128), 128, 0], and the output isFigure 4b 。 Figure 4b Further strengthened and regularized the Figure 4a symmetrical pattern elements in Figure 4a Sorted out the relatively complex and intertwined lines in

[0120] Figure 5a The design requirements of Figure 5b are: generate a pattern with periodic repeating units, and the repeating interval is 5 units; the condition vector is I=(0, 0, R), R=[5, 5, 20, 20], and the output is Figure 5b In Figure 5a the pattern in Figure 5b is regularly replicated in the horizontal and vertical directions. Arranged neatly in rows and columns, the pattern units in each row and each column are consistent, meeting the requirements of periodic repeating units.

[0121] Figure 6a The design requirements of Figure 6b are: generate a pattern with red and gold as the main colors; the condition vector is I=(C, 0, 0), C=[0, 1, 1, 0, 0, 0, 0.138, 1, 0.5], and the output is Figure 6b In

[0122] Step Eight: Save or output the generated pattern image.

[0123] It should be noted that it also has the function of real-time displaying the generated pattern image.

[0124] In a possible embodiment, an SQLite database is used to store the generated pattern images and their metadata. The metadata includes cultural style tags, generation parameters, creation time, etc. The SQLite database provides retrieval functions based on keywords and attributes, supporting fuzzy matching and multi-condition filtering.

[0125] Embodiment Two

[0126] The pattern generation system based on conditional generative adversarial network in this embodiment is used to execute the pattern generation method based on conditional generative adversarial network described in claims 1-9. System architecture design and development environment configuration: Developed based on the Python 3.8 environment, the cGAN model is implemented using the PyTorch framework, and the graphical grammar parser is custom-developed in Python; the user interface is built using PyQt5, the front-end design tool is Figma, the hardware environment is equipped with a high-performance workstation with NVIDIA RTX 3090 GPU, and the operating system is Windows 11; OpenCV is integrated for image processing, SQLite is used for pattern data management, and Git and GitHub are used for version control and collaborative development.

[0127] The pattern generation system based on conditional generative adversarial network includes a user interface layer, a syntax rule layer, a storage layer, a feature extraction layer, a vector construction layer, a model processing layer, a parameter adjustment judgment layer, a parameter optimization layer, and a storage and output layer;

[0128] The user interface layer is for users to submit pattern images or design requirements with extended graphical syntax rules;

[0129] The syntax rule layer parses the pattern images or design requirements with extended graphical syntax rules provided by users into conditional vectors;

[0130] The storage layer stores pattern images of various cultural styles;

[0131] The feature extraction layer uses a convolutional neural network to extract the feature map of the pattern image;

[0132] The vector construction layer constructs the joint input vector of the conditional generative adversarial network based on the conditional vector and the feature map;

[0133] The model processing layer generates pattern images that meet the user's needs based on the joint input vector;

[0134] The parameter adjustment judgment layer determines whether the user needs to adjust the parameters;

[0135] The parameter optimization layer obtains the user input, updates the conditional vector according to the user input, and adjusts the input of the model processing layer;

[0136] The storage and output layer saves or outputs the generated pattern images.

[0137] As mentioned above, it is only an embodiment of the present invention and does not impose any limitations on the present invention. Any simple modification, change, and equivalent structural change made to the above embodiments according to the technical essence of the present invention still fall within the protection scope of the technical solution of the present invention.

Claims

1. A pattern generation method based on a conditional generative adversarial network, characterized in that: It includes the following steps: Step 1. Establish extended graphic grammar rules and parse the extended graphic grammar rules into a condition vector I i =(C i , R i , T i ), where C i represents the color combination vector of the i-th pattern image, R i represents the repeatability vector of the i-th pattern image, and T i represents the symmetry vector of the i-th pattern image; Step 2: Establish a multi-cultural style rule base. The multi-cultural style rule base has multiple pattern images, and obtain the feature map F of the pattern images j , F j represents the feature map of the j-th pattern image; Step 3: Based on the conditional vector I i and the feature map F j , establish the joint input vector of the conditional generative adversarial network; Step 4: Construct a conditional generative adversarial network, including a generator and a discriminator. The generator generates patterns according to the joint input vector; the discriminator judges whether the generated pattern is a real pattern image. Among them, the generator and the discriminator optimize the generation quality through iterative adversarial training to obtain a trained conditional generative adversarial network; Step 5: Use the conditional generative adversarial network to generate pattern images: Step 501: The user provides a pattern image or design requirement with extended graphic grammar rules, and uses a grammar parser to parse the pattern image or design requirement with extended graphic grammar rules into a conditional vector; Generate an input vector based on the conditional vector; Step 502: Input a random noise vector and the input vector into the generator, and the generator outputs a generated pattern image that meets the conditional input; Step 6: Judge whether the user needs to adjust the parameters. If so, go to Step 7; otherwise, go to Step 8; Step 7: Update the conditional vector in Step 501 according to the user input, and return to Step 502 to obtain an optimized generated pattern image; Step 8: Save or output the generated pattern image.

2. The pattern generation method based on conditional generative adversarial network according to claim 1, characterized in that: The specific steps for generating the input vector of the conditional generative adversarial network based on the conditional vector are as follows: Step 201: Randomly initialize the latent space distribution P z (z); Step 202: Concatenate the conditional vector I i with the latent space distribution P z (z) to form the first vector V 1i . Concatenate the feature map F j with the latent space distribution P z (z) to form the second vector V 2j . Form the joint input vector V i+j of the conditional generative adversarial network as V 1i , V 2j .

3. A pattern generation method based on a conditional generative adversarial network according to claim 1, characterized in that: T i = [n i , type ij ,..., (x ij , y ij ),..., dmean ij , dvar ij , where n i represents the number of symmetry axes of the i-th pattern image, n i represents a positive integer, type ij represents the symmetry axis type code of the i-th pattern image, 1 ≤ j ≤ n i , (x ij , y ij ) represents the position coordinates of the j-th symmetry axis in the i-th pattern image, dmean ij represents the mean distance between the symmetric points of the j-th symmetry axis in the i-th pattern image, dvar ij represents the variance between the symmetric points of the j-th symmetry axis in the i-th pattern image; C i = [H i1 、S i1 、L i1 ,H i2 、S i2 、L i2 ,H i3 、S i3 、L i3 , where (H i1 、S i1 、L i1 ) respectively represent the hue, saturation, and brightness of red in the i-th pattern image, (H i2 、S i2 、L i2 ) respectively represent the hue, saturation, and brightness of green in the i-th pattern image, (H i3 、S i3 、L i3 ) respectively represent the hue, saturation, and brightness of blue in the i-th pattern image, where m = 1, 2, 3; n = 1, 2, 3; μ H represents the reference hue, S max = max(S1, S2, S3), S min = min(S1, S2, S3), L max = max(L1, L2, L3), L min = min(L1, L2, L3); R i = [d i-xj , d i-yj , n ix , n iy , where d i-xj represents the repetition interval of the pattern in the X-axis direction of the i-th pattern image with respect to the j-th axis of symmetry, d i-yj represents the repetition interval of the pattern in the Y-axis direction of the i-th pattern image with respect to the j-th axis of symmetry, n ix represents the number of repetitions of the pattern in the X-axis direction of the i-th pattern image, n iy represents the number of repetitions of the pattern in the Y-axis direction of the i-th pattern image.

4. A pattern generation method based on a conditional generative adversarial network according to claim 1, characterized in that: The generator and discriminator optimize the generation quality through iterative adversarial training. After each iteration, calculate L on the validation set val (t) - min(L val (t - k)), where L val (t) represents the validation set loss of the current round, and min(L val (t - k)) represents the minimum value of the validation set losses in the past k rounds. If L val (t) - min(L val (t - k)) ≤ ε, stop the training, where ε represents the threshold.

5. A pattern generation method based on a conditional generative adversarial network according to claim 1, characterized in that: The generator and discriminator optimize the generation quality through iterative adversarial training. After each iteration, calculate L train (t) on the training set. L train (t) represents the training set loss at the end of the t-th round of training. If L train (t) = min(L train (1),..., L train (t)), then save the model parameters of the current round.

6. A pattern generation method based on a conditional generative adversarial network according to claim 1, characterized in that: The loss function of the generator is L total = L G + ω1L sym + ω2L rep + ω3L struct , where L G represents the initial loss function of the generator, L sym represents the symmetry constraint term, L rep represents the repeatability constraint term, L struct represents the normality constraint term, and ω1, ω2, and ω3 represent weights respectively.

7. A pattern generation method based on conditional generative adversarial network according to claim 6, characterized in that: Generator initial loss function L G = E x,y [log(1 - D(G(x))) + λ||y - G(x)||1], where E x,y denotes the expected value, G(x) denotes the image output by the generator, D(G(x)) is the prediction of the discriminator for the generated image, y denotes the real pattern image, and λ denotes the hyperparameter.

8. A pattern generation method based on a conditional generative adversarial network according to claim 1, characterized in that: The loss function formula of the discriminator is: Among them, represents the expected value after taking the logarithm of the output D(y) of the discriminator D for the real sample y, represents calculating the expected value for the sample x sampled from the conditional input distribution p data (x), y represents the real pattern image, D(y) represents the output of the discriminator for the real sample y, p data (y) represents the distribution of the real pattern data, p data (x) represents the distribution of the conditional input, G(x) represents the image output by the generator, and D(G(x)) is the prediction of the discriminator for the generated image.

9. A pattern generation method based on conditional generative adversarial network according to claim 1, characterized in that: The generator and discriminator optimize the generation quality through iterative adversarial training, and the optimization function for adversarial training is: where D represents the discriminator, G represents the generator, and p data (x) represents the distribution of the conditional input, denotes calculating the expected value for the sample x sampled from the conditional input distribution p data (x), D(x) represents the evaluation output of the discriminator for the sample x, P z (z) represents the latent space distribution, denotes calculating the expected value for the sample z sampled from the latent space distribution P z (z), G(x) represents the image generated by the generator from the sample x, and D(G(x)) represents the evaluation output of the discriminator for the generated image G(x).

10. A pattern generation system based on a conditional generative adversarial network, which is used to execute the pattern generation method based on a conditional generative adversarial network described in claims 1-9, and is characterized in that: It includes a user interface layer, a grammar rule layer, a storage layer, a feature extraction layer, a vector construction layer, a model processing layer, a parameter adjustment judgment layer, a parameter optimization layer, and a storage and output layer; The user interface layer is for the user to submit a pattern image or design requirement with extended graphic grammar rules; The grammar rule layer parses the pattern image or design requirement with extended graphic grammar rules provided by the user into a conditional vector; The storage layer stores pattern images of various cultural styles; The feature extraction layer uses a convolutional neural network to extract the feature map of the pattern image; The vector construction layer constructs the joint input vector of the conditional generative adversarial network based on the conditional vector and the feature map; The model processing layer generates a pattern image that meets the user's needs based on the joint input vector; The parameter adjustment judgment layer judges whether the user needs to adjust the parameters; The parameter optimization layer obtains the user input, updates the conditional vector according to the user input, and adjusts the input of the model processing layer; The storage and output layer saves or outputs the generated pattern image.