Embroidery map generation method and device, electronic equipment and storage medium
Through pre-trained embroidery generation models, the target embroidery map is generated using the embroidery basic sub-model and the Lora sub-model, which solves the problems of low efficiency and inconsistent quality of embroidery map production in the existing technology, realizes automated and mass production, and reduces the design Technical requirements of the teacher.
Patent Information
- Application Number
- CN202311091707.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-28
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2043-08-28
AI Technical Summary
In the production of existing game character models, the production efficiency of embroidery textures is low, the quality is inconsistent, and the designer's technical requirements are high, making it difficult to achieve automation and batching.
The pre-trained embroidery generation model is adopted, including the embroidery basic sub-model and the embroidery Lora sub-model. The target embroidery map corresponding to the target embroidery type is generated through the original embroidery image to achieve automated and mass production.
It significantly improves the production efficiency of embroidery textures, consistent production quality, reduces the designer's technical requirements, and realizes the automation and mass production of embroidery textures.
Smart Images

Figure CN119107373A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a method, device, electronic device and storage medium for generating an embroidery map. Background Art
[0002] In the existing game character model production process, the embroidery map part is a very important part. It is mainly responsible for adding details to the character model and improving the visual effects and realism of the character. Usually, these embroidery maps are manually created by professional graphic designers. Therefore, the production method of embroidery maps has problems such as low work efficiency, inconsistent map quality, high technical requirements for designers, and difficulty in automation and batch production. Summary of the invention
[0003] In view of this, the present application provides a method, device, electronic device and storage medium for generating an embroidery map, which can significantly improve the efficiency of making embroidery maps, generate embroidery maps of consistent quality, significantly reduce the technical requirements for designers, and realize the automation and batch production of embroidery maps.
[0004] In a first aspect, an embodiment of the present application provides a method for generating an embroidery map, comprising:
[0005] Obtaining the original embroidery image to be processed;
[0006] A target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model is used to generate a target embroidery map corresponding to the target embroidery type based on the original embroidery image; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
[0007] In a second aspect, the embodiment of the present application further provides a device for generating an embroidery map, comprising:
[0008] An image acquisition module is used to acquire the original embroidery image to be processed;
[0009] The embroidery map generation module is used to generate a target embroidery map corresponding to the target embroidery type based on the original embroidery image through a target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
[0010] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement any one of the methods provided in the first aspect.
[0011] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement any one of the methods provided in the first aspect.
[0012] The embodiment of the present application provides a method, device, electronic device and storage medium for generating an embroidery map. First, an original embroidery image to be processed is obtained, and a target embroidery generation model matching the target embroidery type among multiple pre-trained embroidery generation models is used to generate a target embroidery map corresponding to the target embroidery type based on the original embroidery image. The above method constructs an embroidery generation model obtained by an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model. The embroidery generation model is obtained by training a basic training image set and a Lora training image set corresponding to the embroidery type. The target embroidery map corresponding to the required target embroidery type is generated based on the original embroidery image. Compared with the method of manually creating embroidery maps by designers in the related art, the embodiment of the present application can significantly improve the efficiency of making embroidery maps, can generate embroidery maps of consistent quality, can significantly reduce the technical requirements for designers, and can realize the automation and batch production of embroidery maps.
[0013] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application are realized and obtained by the structures specifically pointed out in the description, claims and drawings.
[0014] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the related technologies, the drawings required for use in the specific implementation methods or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1A schematic diagram of a flow chart of a method for generating an embroidery map provided in an embodiment of the present application;
[0017] Figure 2 A target embroidery texture rendering output by an embroidery basic sub-model provided in an embodiment of the present application;
[0018] Figure 3 A target embroidery mapping effect diagram output by a Suzhou embroidery generation model provided in an embodiment of the present application;
[0019] Figure 4 A target embroidery mapping effect diagram output by a Hunan embroidery generation model provided in an embodiment of the present application;
[0020] Figure 5 A target embroidery mapping effect diagram output by a Guangdong embroidery generation model provided in an embodiment of the present application;
[0021] Figure 6 A target embroidery mapping effect diagram output by a Shu embroidery generation model provided in an embodiment of the present application;
[0022] Figure 7 A schematic diagram of the structure of an embroidery map generating device provided in an embodiment of the present application;
[0023] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
[0025] At present, in the related technology, embroidery maps are usually created manually by graphic designers. The main steps of manually creating embroidery maps are as follows: (1) Design sketch: The designer first needs to create a sketch of the embroidery map of the character model. The sketch usually contains all the main features of the pattern, such as color, shape, embroidery type, performance effect, story background and meaning, details, etc. (2) Sketch review and modification: The designer needs to review and modify the sketch to ensure that it can meet the visual requirements of the game. During this process, it may be necessary to modify and adjust repeatedly. (3) Create embroidery maps: After the sketch review and modification are completed, the designer will use professional drawing software, such as Photoshop, Adobe Substance 3D Painter, to create embroidery maps. This process usually takes a lot of time and effort because every detail needs to be drawn manually. (4) Game engine effect debugging: After drawing the map, it needs to be imported into the game engine and provide some attribute material highlight maps required by the engine to facilitate the display of realistic embroidery effects. (5) Texture review and modification: After the embroidery texture is created, the designer needs to review and modify it to ensure that its effect on the character model meets the requirements.
[0026] Therefore, the current method of making embroidery maps for game character models has the following shortcomings: (1) Low work efficiency: As mentioned above, the existing embroidery map production process requires designers to manually perform a lot of work, including sketch design, review and modification, embroidery map creation and review and modification. This process is very time-consuming. For large-scale game projects, this inefficient working method may cause project delays. (2) Inconsistent quality: Since each embroidery map is created manually, differences in the designer's technical level and aesthetic concepts may lead to inconsistent quality of embroidery maps. This inconsistency may affect the visual effects of the game character and reduce the player's gaming experience. (3) High technical requirements for designers: The existing embroidery map production method has very high technical requirements for designers, requiring strong drawing skills and artistic vision. This makes embroidery map production a job with a high threshold, limiting the possibility of more people participating in the production of game character models. (4) Difficult to achieve automation and batch production: The existing embroidery map production method is almost impossible to achieve automation and batch production, because every detail requires the designer to manually draw and adjust. This makes embroidery map production a highly manual job that is difficult to adapt to the development needs of the game industry.
[0027] Based on this, the present application provides a method, device, electronic device and storage medium for generating embroidery maps, which can significantly improve the efficiency of making embroidery maps, generate embroidery maps of consistent quality, significantly reduce the technical requirements for designers, and realize the automation and mass production of embroidery maps.
[0028] To facilitate understanding of this embodiment, firstly, a method for generating an embroidery map disclosed in an embodiment of the present application is described in detail, see Figure 1 The schematic diagram of the process of generating a method for an embroidery map shown in FIG. 1 mainly includes the following steps S102 to S104:
[0029] Step S102, obtaining an original embroidery image to be processed, wherein the original embroidery image may be an initial sketch with relatively low precision.
[0030] In one embodiment, an upload channel may be provided for the user to obtain the original embroidery image to be processed through the upload channel; in another embodiment, the original embroidery image to be processed may be stored in a designated storage area so as to facilitate reading the original embroidery image from the designated storage area.
[0031] Step S104, using a target embroidery generation model that matches the target embroidery type in the pre-trained embroidery generation models, generates a target embroidery map corresponding to the target embroidery type based on the original embroidery image.
[0032] Among them, the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora (Low-Rank Adaptation of Large Language Models) sub-model carried on the embroidery basic sub-model. The embroidery generation model is obtained by training the basic training image set and the Lora training image set corresponding to the embroidery type. The embroidery generation model can include one or more of the Shu embroidery generation model, the Yue embroidery generation model, the Xiang embroidery generation model, and the Su embroidery generation model. The embroidery basic sub-models of different embroidery generation models are the same, and the difference lies in the different embroidery Lora sub-models carried by each. The embroidery map is a pattern with embroidery stitch effects (also known as an embroidery effect map).
[0033] In one embodiment, the identification corresponding to each embroidery generation model can be displayed through a graphical user interface, and in response to a selection operation on the identification, a target embroidery type and its matching target embroidery generation model can be determined. By inputting the original embroidery image into the target embroidery generation model, the target embroidery generation model can output a target embroidery map corresponding to the target embroidery type.
[0034] Optionally, the target embroidery generation model can output multiple embroidery maps and select a suitable embroidery map from them as the target embroidery map.
[0035] The method for generating an embroidery map provided in the embodiment of the present application uses an embroidery generation model constructed by an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model to generate a target embroidery map corresponding to the required target embroidery type based on the original embroidery image. Compared with the method in which designers manually create embroidery maps in the related art, the embodiment of the present application can significantly improve the efficiency of making embroidery maps, generate embroidery maps with consistent quality, and significantly reduce the technical requirements for designers, and can realize the automation and batch production of embroidery maps.
[0036] To facilitate understanding of the above embroidery generation model, the present application embodiment provides an implementation method for training the embroidery generation model, see the following steps 1 to 3:
[0037] Step 1: construct a basic training image set, construct a Lora training image set corresponding to the embroidery type, and construct an embroidery generation model matching the embroidery type.
[0038] In one example, a large number of real embroidery high-definition images can be screened as a training image set of the embroidery basic sub-model (referred to as the basic training image set).
[0039] In one example, the Lora training image set includes a regularized training image set and a training image set (also referred to as a formal training image set), the regularized training image set is used to pre-train the embroidery Lora sub-model, and the formal training image set is used to formally train the embroidery Lora sub-model. Further, the embodiment of the present application provides an implementation method for constructing a Lora training image set corresponding to each embroidery type, see steps 1.1 to 1.5 below:
[0040] Step 1.1, obtain the initial image set corresponding to each embroidery type, the initial image set includes embroidery images. Optionally, a large number of high-definition images (i.e., embroidery images) of cultural relic embroidery and traditional embroidery artists can be collected, which need to have clear pattern style, clear stitch details, and clear embroidery type recognition, and then divided into the initial image set corresponding to each embroidery type.
[0041] In an optional implementation, the following steps 1.2 to 1.4 may be executed by a Python script to implement preprocessing of the initial image set.
[0042] Step 1.2, determining the depth threshold of the embroidery image in the initial image set. In one embodiment, the depth detection of NUKE can be used to generate the depth threshold of each embroidery image, wherein the depth threshold can be used to indicate whether the embroidery image contains a large amount of blurred depth of field.
[0043] Step 1.3, remove the embroidery images whose depth threshold is greater than the preset depth threshold from the initial image set. In one embodiment, the depth threshold is used to determine whether the embroidery image contains a large amount of blurred depth of field. If the depth of field caused by photography is more than 20% of the overall area of the image, the embroidery image will be eliminated.
[0044] Step 1.4, collect edge pixels of the embroidery image in the initial image set after elimination, scale the embroidery image, and use the edge pixels to fuzzy fill the scaled embroidery image to obtain the target embroidery image. In one embodiment, batch process the screened images, first use the opencv module of python to collect the edge color of the image, and then scale the non-512*512 image, and the image side length greater than 512 will be scaled to 512 first. Optionally, for square images, the scaling operation can be performed directly; for rectangular images, the scaling process is performed and then cropped to obtain a 512*512 image. Furthermore, the RGB value list of the edge pixels is used to fuzzily fill the scaled image to obtain the target embroidery image.
[0045] Step 1.5, annotate a training label for each target embroidery image, and divide the target embroidery images annotated with training labels into a regularized training image set and a training image set.
[0046] The training labels include image type, embroidery stitch type and clarity direction. Specifically, the image type is the content of the image, such as flower type, animal type, etc.; the embroidery stitch type is Suzhou embroidery, Sichuan embroidery, Guangdong embroidery, and Hunan embroidery; the clarity direction is used to describe the image quality, mainly composed of descriptions of image quality such as masterpiece, ultra-clear, and best quality.
[0047] In one example, the embodiment of the present application also provides an implementation method for constructing an embroidery generation model that matches each embroidery type. The embroidery basic sub-model can be called, and the embroidery Lora sub-model that matches the embroidery type is loaded onto the embroidery basic sub-model to obtain an embroidery generation model that matches the embroidery type. Among them, the embroidery basic sub-model is also the basic embroidery large model. The embodiment of the present application is based on the basic embroidery large model, and carries different embroidery type Lora sub-models to generate embroidery maps of different cultural styles for 3D embroidery map production.
[0048] Step 2, through the basic training image set, adjust the network parameters of the embroidery basic sub-model in the embroidery generation model until the loss value of the embroidery basic sub-model converges or reaches a preset number of iterations. Optionally, after training the embroidery basic sub-model, the embroidery basic sub-model can be stored in a specified storage path, so that when the embroidery Lora sub-model is subsequently trained, the file path of the embroidery basic sub-model can be set to realize the call of the embroidery basic sub-model.
[0049] Step 3, freeze the network parameters of the embroidery basic sub-model in the embroidery generation model, and adjust the network parameters of the embroidery Lora sub-model in the embroidery generation model through the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model. For specific implementation, please refer to the following steps 3.1 to 3.2:
[0050] Step 3.1, adjusting the network parameters of the embroidery Lora sub-model in the embroidery generation model by regularizing the training image set to obtain pre-trained network parameters; Step 3.2, adjusting the pre-trained network parameters by the training image set to obtain target network parameters.
[0051] In practical applications, you can use SD's dreambooth+lora training script, adjust the training parameters, use regularized training ideas to train the embroidery model multiple times, and produce multiple embroidery generation models that match the embroidery type. From them, select the embroidery generation model with the best embroidery generation effect for standby use and use it as the target embroidery generation model that matches the embroidery type.
[0052] Before training, the key is to adjust the training parameters. The parameters that are adjusted in the embodiments of the present application are: learning rate, number of multi-resolution noise diffusion times, multi-resolution noise scaling multiples, optimizer, number of gradient checks and gradient accumulations, training set input path, training set output path, etc.
[0053] The method of adjusting training parameters is as follows: The initial version will use a basic value. After training, the degree of model fit will be judged based on the results of the generated graph of the initial version model. If it is overfitting, the learning rate needs to be lowered. If it is underfitting, the learning rate needs to be increased.
[0054] After training the embroidery generation model matching multiple embroidery types, the target embroidery map can be output based on the original embroidery image only through the embroidery basic sub-model, such as Figure 2 The target embroidery map effect diagram output by an embroidery basic sub-model shown in the figure; or, the target embroidery map is output based on the original embroidery image through the Suzhou embroidery embroidery generation model, such as Figure 3The target embroidery map output by the Suzhou embroidery generation model is shown in the figure. The target embroidery map output by the Suzhou embroidery generation model is consistent with the color distribution of the comprehensive embroidery stitch direction, and the highlight color and distribution are more distinctive (70%); or, the target embroidery map is output based on the original embroidery image by the Hunan embroidery generation model, such as Figure 4 The target embroidery map effect diagram output by a Hunan embroidery embroidery generation model is shown in the figure. Hunan embroidery has a variety of needlework methods, mainly mixed needlework, and has developed into more than 70 needlework methods according to the different requirements of expressing different objects and natural textures of different parts; or, the target embroidery map is output based on the original embroidery image through the Guangdong embroidery embroidery generation model, such as Figure 5 The target embroidery map effect diagram output by a Guangdong embroidery generation model is shown. Compared with comprehensive embroidery, Guangdong embroidery has a strong sense of volume, regular and obvious stitches, and does not have such strong highlights compared with Suzhou embroidery; or, the target embroidery map is output based on the original embroidery image through the Shu embroidery generation model, such as Figure 6 The target embroidery texture rendering output by a Shu embroidery generation model is shown. Compared with comprehensive embroidery, Shu embroidery is closer to Hunan embroidery, with a flat overall shape but slender and varied stitches.
[0055] In the method for generating embroidery maps provided in the embodiment of the present application, in the original step of "creating embroidery maps", after the "sketch review and modification" is completed, the step of "importing the sketch into the AI embroidery model and generating the embroidery map from the picture" is used to replace the step of "the designer uses the drawing software to manually draw the embroidery map". On this basis, the method for generating embroidery maps provided in the embodiment of the present application has at least the following characteristics:
[0056] (1) It reduces the time and energy required for hand-painted embroidery, and puts precious human resources into the more important aesthetic design link.
[0057] (2) Realize automation and batch production of embroidery maps, and greatly improve the efficiency of embroidery map drawing: The original embroidery map production method is almost impossible to achieve automation and batch production, because every detail requires the designer to draw and adjust manually, which makes embroidery map production a highly manual job, which is difficult to adapt to the development needs of the game industry. The embodiment of this application uses a self-developed AI embroidery model to quickly generate embroidery maps with one click. By generating multiple embroidery pictures, the most suitable map can be screened and directly imported into the engine for use. Successfully realize embroidery automation and batch production.
[0058] (3) Greatly improve the artistic quality of embroidery textures and the expressiveness of realistic embroidery materials.
[0059] (4) Lower the threshold for embroidery map production and completely solve the problem of uneven embroidery map quality due to different hand-drawing skills of designers: AI embroidery model is easy and quick to use. As long as you master the basic operations and numerical setting methods, you can directly generate high-precision embroidery pictures; in addition, since each embroidery map is created by AI model images, the differences in designers' technical levels and aesthetic concepts will not affect the quality of the embroidery map, ensuring the consistency of the output quality of embroidery maps by multiple people.
[0060] (5) Solve the problem of single embroidery style and realize the diversification of embroidery style. Manually drawn maps cannot capture the stitch characteristics of different embroidery types and can only meet the production of generalized embroidery styles, resulting in the lack of cultural heritage and type and style distinction of embroidery maps, and the embroidery expressiveness cannot be further improved.
[0061] The embodiment of the present application deeply explores the embroidery effect performance of different embroidery types, improves the embroidery cultural recognition and credibility of the generated embroidery map, and meets the embroidery fashion expression needs of different cultural atmospheres. In addition, the embodiment of the present application uses a self-developed AI embroidery model for production, and can obtain embroidery generation effects of different styles by matching different embroidery types Lora models. In addition, it is also possible to match multiple embroidery types Lora to generate embroidery maps of comprehensive styles, which greatly increases the style diversity of the embroidery map and the realism of the embroidery expression.
[0062] (6) Improved work efficiency: The embodiment of the present application adopts the latest AI model training method of SD (Stable Diffuion, AI animation generation tool) to train the basic embroidery large model + the lora model of the four famous embroidery types. In addition, the embodiment of the present application uses the embroidery model AI to generate embroidery maps to replace the designer's hand-painted embroidery map step, which greatly improves the work efficiency of map production.
[0063] For ease of understanding, the core idea of the method for generating embroidery maps provided in the embodiment of the present application is: (a) training a basic embroidery model by screening a large number of real high-definition embroidery pictures. (b) classifying the pictures of the four famous embroidery types, and training the Lora sub-models of Shu embroidery, Yue embroidery, Hunan embroidery, and Su embroidery after adjusting the training parameters through the AI training script. (c) based on the basic embroidery model, carrying different embroidery types Lora sub-models, to generate embroidery pictures of different cultural styles for 3D embroidery map production.
[0064] On this basis, the embodiment of the present application provides a specific implementation method of a method for generating an embroidery map to solve the problems and shortcomings existing in the relevant technical solutions, improve the efficiency and quality of embroidery map production, lower the production threshold, and realize automation and batch production, see the following steps a to e:
[0065] (a) Collect training data: Collect a large number of high-definition images of cultural relic embroidery and embroidery by traditional embroidery artists. The pattern style should be clear, the stitch details should be clear, and the embroidery type should be clearly recognizable.
[0066] (b) Training data screening: First, the core purpose of training is to generate embroidery images with high-definition stitch details. Therefore, the training images are enlarged and cropped, and the clearest stitches are retained as training data, and the formal training image set and the regularized training image set are sorted out.
[0067] (c) Labeling: The formal training image set and the regularized training image set are labeled separately to ensure that the corresponding keywords can summon the corresponding embroidery effects.
[0068] (d) Model training: Use SD's dreambooth+lora training script, adjust the training parameters, and use the regularization training idea to train the embroidery model multiple times to produce multiple embroidery models, from which the model with the best embroidery generation effect is selected for use.
[0069] (e) Producing embroidery maps: Import the design sketch (i.e., the original embroidery image) into the trained and screened embroidery model, use the image-to-image function to generate multiple patterns with embroidery stitch effects, and select the appropriate embroidery effect image to be used as the embroidery map.
[0070] In the embodiment of the present application, the Stable Diffusion model can better meet specific needs after being trained for specific tasks. For the embroidery drawing of game character textures, there are the following main differences between using a specially trained model and using an ordinary Stable Diffusion model when generating embroidery textures:
[0071] (1) Professionalism and accuracy: The specially trained model can produce more detailed and realistic results when processing complex embroidery maps. It understands and processes embroidery-specific textures, colors, and styles more accurately;
[0072] (2) Efficiency and speed: A model that has been trained on a specific task will be faster and more efficient in processing related tasks because it better understands the specific characteristics and requirements of the domain;
[0073] (3) Innovation: A specially trained model can be more innovative when generating embroidery maps because it can learn various embroidery styles and techniques from a large amount of training data;
[0074] (4) Adaptability: A specifically trained model can adapt better when dealing with new embroidery designs because it has been trained to understand and handle the various possibilities in this specific domain;
[0075] (5) Stability: A specially trained model will be more stable during the generation process because it better understands the specific requirements and challenges of embroidery maps, thus avoiding certain possible problems during the generation process;
[0076] (6) Better expressiveness of famous embroidery types and embroidery style characteristics.
[0077] Since a large number of real cultural relics of the four famous embroidery styles are used as training sets, the biggest style feature is the ability to generate embroidery pictures that conform to the stitch characteristics of the four famous embroidery styles. Compared with the existing AI models, there are obvious differences in the recognition of the style of traditional Chinese embroidery culture, the stitch characteristics and the expression of stitch details. Using it in fashion production is more conducive to the expression of traditional Chinese embroidery culture. Let the traditional embroidery culture shine in the game.
[0078] There are some significant differences when using a Stable Diffusion model trained specifically for embroidery maps and an untrained model to generate embroidery maps and convert them into normal maps:
[0079] (1) More accurate details: The specially trained model can better capture the details and texture of the embroidery map, which will be more accurately reflected when converted into a normal map;
[0080] (2) More natural texture effects: Since the specially trained model understands the characteristics of embroidery maps, the generated embroidery map texture is more natural and can better simulate the surface details and lighting effects of the real world when converted into normal maps;
[0081] (3) Better consistency: The consistency between the maps generated by the specially trained model and the converted normal maps may be better because the model has learned how to correctly process and understand the characteristics of the embroidery map;
[0082] (4) Fewer errors: The specially trained model may make fewer errors in the generation and translation process because it better understands the structure and requirements of embroidery maps.
[0083] For the embroidery map generation method provided in the above embodiment, the present application embodiment provides an embroidery map generation device, see Figure 7 The schematic diagram of the structure of a device for generating an embroidery map is shown, and the device mainly includes the following parts:
[0084] An image acquisition module 702 is used to acquire an original embroidery image to be processed;
[0085] The embroidery map generation module 704 is used to generate a target embroidery map corresponding to the target embroidery type based on the original embroidery image through a target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
[0086] The embroidery map generation device provided in the embodiment of the present application uses an embroidery generation model constructed by an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model to generate a target embroidery map corresponding to the required target embroidery type based on the original embroidery image. Compared with the method in which designers manually create embroidery maps in the related art, the embodiment of the present application can significantly improve the efficiency of making embroidery maps, generate embroidery maps with consistent quality, and significantly reduce the technical requirements for designers, and can realize the automation and batch production of embroidery maps.
[0087] In one embodiment, a model training module is further included, which is used to:
[0088] Constructing a basic training image set, constructing a Lora training image set corresponding to the embroidery type, and constructing an embroidery generation model matching the embroidery type; wherein the Lora training image set includes a regularized training image set and a training image set;
[0089] Adjust the network parameters of the embroidery basic sub-model in the embroidery generation model through the basic training image set until the loss value of the embroidery basic sub-model converges or reaches a preset number of iterations;
[0090] The network parameters of the embroidery basic sub-model in the embroidery generation model are frozen, and the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted through the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model.
[0091] In one embodiment, the model training module is further used to:
[0092] Obtaining an initial image set corresponding to each embroidery type; wherein the initial image set includes embroidery images;
[0093] Determining a depth threshold of the embroidery image in the initial image set;
[0094] Eliminate embroidery images whose depth threshold is greater than a preset depth threshold from the initial image set;
[0095] Collect edge pixels of the embroidery image in the initial image set after elimination, scale the embroidery image, and use the edge pixels to perform fuzzy filling on the scaled embroidery image to obtain a target embroidery image;
[0096] Training labels are labeled for target embroidery images, and the target embroidery images labeled with training labels are divided into a regularized training image set and a training image set.
[0097] In one embodiment, the training labels each include image type, embroidery stitch type, and clarity direction.
[0098] In one embodiment, the model training module is further used to:
[0099] The embroidery basic sub-model is called, and the embroidery Lora sub-model matching the embroidery type is loaded onto the embroidery basic sub-model to obtain the embroidery generation model matching the embroidery type.
[0100] In one embodiment, the model training module is further used to:
[0101] By regularizing the training image set, the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted to obtain the pre-trained network parameters;
[0102] The pre-trained network parameters are adjusted through the training image set to obtain the target network parameters.
[0103] In one embodiment, the embroidery generation model includes one or more of a Shu embroidery generation model, a Yue embroidery generation model, a Hunan embroidery generation model, and a Su embroidery generation model.
[0104] The implementation principle and technical effects of the device provided in the embodiments of the present application are the same as those of the aforementioned method embodiments. For the sake of brief description, for matters not mentioned in the device embodiment, reference may be made to the corresponding contents in the aforementioned method embodiments.
[0105] An embodiment of the present application provides an electronic device. Specifically, the electronic device includes a processor and a storage device. The storage device stores a computer program, and when the computer program is run by the processor, it executes:
[0106] A method for generating an embroidery map, comprising:
[0107] Obtaining the original embroidery image to be processed;
[0108] A target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model generates a target embroidery map corresponding to the target embroidery type based on the original embroidery image; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
[0109] In one embodiment, the training step of the embroidery generation model includes:
[0110] Constructing a basic training image set, constructing a Lora training image set corresponding to the embroidery type, and constructing an embroidery generation model matching the embroidery type; wherein the Lora training image set includes a regularized training image set and a training image set;
[0111] Adjust the network parameters of the embroidery basic sub-model in the embroidery generation model through the basic training image set until the loss value of the embroidery basic sub-model converges or reaches a preset number of iterations;
[0112] The network parameters of the embroidery basic sub-model in the embroidery generation model are frozen, and the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted through the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model.
[0113] In one implementation, constructing a Lora training image set corresponding to an embroidery type includes:
[0114] Obtaining an initial image set corresponding to each embroidery type; wherein the initial image set includes embroidery images;
[0115] Determining a depth threshold of the embroidery image in the initial image set;
[0116] Eliminate embroidery images whose depth threshold is greater than a preset depth threshold from the initial image set;
[0117] Collect edge pixels of the embroidery image in the initial image set after elimination, scale the embroidery image, and use the edge pixels to perform fuzzy filling on the scaled embroidery image to obtain a target embroidery image;
[0118] Training labels are labeled for target embroidery images, and the target embroidery images labeled with training labels are divided into a regularized training image set and a training image set.
[0119] In one embodiment, the training labels each include image type, embroidery stitch type, and clarity direction.
[0120] In one embodiment, constructing an embroidery generation model matching each embroidery type includes:
[0121] The embroidery basic sub-model is called, and the embroidery Lora sub-model matching the embroidery type is loaded onto the embroidery basic sub-model to obtain the embroidery generation model matching the embroidery type.
[0122] In one embodiment, the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted by using the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model, including:
[0123] By regularizing the training image set, the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted to obtain the pre-trained network parameters;
[0124] The pre-trained network parameters are adjusted through the training image set to obtain the target network parameters.
[0125] In one embodiment, the embroidery generation model includes one or more of a Shu embroidery generation model, a Yue embroidery generation model, a Hunan embroidery generation model, and a Su embroidery generation model.
[0126] The electronic device provided in the embodiment of the present application uses an embroidery generation model constructed by an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model to generate a target embroidery map corresponding to the required target embroidery type based on the original embroidery image. Compared with the method in which designers manually create embroidery maps in the related art, the embodiment of the present application can significantly improve the efficiency of making embroidery maps, generate embroidery maps of consistent quality, and significantly reduce the technical requirements for designers, and can realize the automation and batch production of embroidery maps.
[0127] Figure 8 A structural schematic diagram of an electronic device provided in an embodiment of the present application, the electronic device 100 includes: a processor 80, a memory 81, a bus 82 and a communication interface 83, wherein the processor 80, the communication interface 83 and the memory 81 are connected via the bus 82; the processor 80 is used to execute an executable module stored in the memory 81, such as a computer program.
[0128] The memory 81 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 83 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used.
[0129] The bus 82 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0130] Among them, the memory 81 is used to store programs, and the processor 80 executes the program after receiving the execution instruction. The method executed by the device for flow process definition disclosed in any of the embodiments of the present application can be applied to the processor 80 or implemented by the processor 80.
[0131] The processor 80 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 80. The above processor 80 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 81, and the processor 80 reads the information in the memory 81 and completes the steps of the above method in combination with its hardware.
[0132] The computer program product of a readable storage medium provided in an embodiment of the present application includes a computer readable storage medium storing program code, and the instructions included in the program code can be used to execute:
[0133] A method for generating an embroidery map, comprising:
[0134] Obtaining the original embroidery image to be processed;
[0135] A target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model generates a target embroidery map corresponding to the target embroidery type based on the original embroidery image; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
[0136] In one embodiment, the training step of the embroidery generation model includes:
[0137] Constructing a basic training image set, constructing a Lora training image set corresponding to the embroidery type, and constructing an embroidery generation model matching the embroidery type; wherein the Lora training image set includes a regularized training image set and a training image set;
[0138] Adjust the network parameters of the embroidery basic sub-model in the embroidery generation model through the basic training image set until the loss value of the embroidery basic sub-model converges or reaches a preset number of iterations;
[0139] The network parameters of the embroidery basic sub-model in the embroidery generation model are frozen, and the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted through the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model.
[0140] In one implementation, constructing a Lora training image set corresponding to an embroidery type includes:
[0141] Obtaining an initial image set corresponding to each embroidery type; wherein the initial image set includes embroidery images;
[0142] Determining a depth threshold of the embroidery image in the initial image set;
[0143] Eliminate embroidery images whose depth threshold is greater than a preset depth threshold from the initial image set;
[0144] Collect edge pixels of the embroidery image in the initial image set after elimination, scale the embroidery image, and use the edge pixels to perform fuzzy filling on the scaled embroidery image to obtain a target embroidery image;
[0145] Training labels are labeled for target embroidery images, and the target embroidery images labeled with training labels are divided into a regularized training image set and a training image set.
[0146] In one embodiment, the training labels each include image type, embroidery stitch type, and clarity direction.
[0147] In one embodiment, constructing an embroidery generation model matching each embroidery type includes:
[0148] The embroidery basic sub-model is called, and the embroidery Lora sub-model matching the embroidery type is loaded onto the embroidery basic sub-model to obtain the embroidery generation model matching the embroidery type.
[0149] In one embodiment, the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted by using the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model, including:
[0150] By regularizing the training image set, the network parameters of the embroidery Lora sub-model in the embroidery generation model are adjusted to obtain the pre-trained network parameters;
[0151] The pre-trained network parameters are adjusted through the training image set to obtain the target network parameters.
[0152] In one embodiment, the embroidery generation model includes one or more of a Shu embroidery generation model, a Yue embroidery generation model, a Hunan embroidery generation model, and a Su embroidery generation model.
[0153] The readable storage medium provided in the embodiment of the present application, through the embroidery basic sub-model and the embroidery Lora sub-model mounted on the embroidery basic sub-model to construct the embroidery generation model, generates the target embroidery map corresponding to the required target embroidery type based on the original embroidery image. Compared with the method of manually creating embroidery maps by designers in the related art, the embodiment of the present application can significantly improve the efficiency of making embroidery maps, can generate embroidery maps with consistent quality, can also significantly reduce the technical requirements for designers, and can realize the automation and batch production of embroidery maps.
[0154] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0155] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for generating an embroidery map, It is characterized in that include: Obtaining the original embroidery image to be processed; A target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model is used to generate a target embroidery map corresponding to the target embroidery type based on the original embroidery image; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
2. The method for generating an embroidery map according to claim 1, It is characterized in that The training steps of the embroidery generation model include: Constructing a basic training image set, constructing a Lora training image set corresponding to the embroidery type, and constructing an embroidery generation model matching the embroidery type; wherein the Lora training image set includes a regularized training image set and a training image set; Adjusting the network parameters of the embroidery basic sub-model in the embroidery generation model through the basic training image set until the loss value of the embroidery basic sub-model converges or reaches a preset number of iterations; Freeze the network parameters of the embroidery basic sub-model in the embroidery generation model, and adjust the network parameters of the embroidery Lora sub-model in the embroidery generation model through the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model.
3. The method for generating an embroidery map according to claim 2, It is characterized in that Construct the Lora training image set corresponding to the embroidery type, including: Acquire an initial image set corresponding to each embroidery type; wherein the initial image set includes embroidery images; Determining a depth threshold of the embroidery image in the initial image set; Eliminate the embroidery images whose depth threshold is greater than a preset depth threshold from the initial image set; Collecting edge pixels of the embroidery image in the initial image set after elimination, scaling the embroidery image, and using the edge pixels to perform fuzzy filling on the scaled embroidery image to obtain a target embroidery image; A training label is labeled for the target embroidery image, and the target embroidery image labeled with the training label is divided into a regularized training image set and a training image set.
4. The method for generating an embroidery map according to claim 3, It is characterized in that The training labels include image type, embroidery stitch type and clarity direction.
5. The method for generating an embroidery map according to claim 2, It is characterized in that Construct an embroidery generation model that matches each embroidery type, including: The embroidery basic sub-model is called, and the embroidery Lora sub-model matching the embroidery type is loaded onto the embroidery basic sub-model to obtain the embroidery generation model matching the embroidery type.
6. The method for generating an embroidery map according to claim 2, It is characterized in that Adjusting the network parameters of the embroidery Lora sub-model in the embroidery generation model by using the Lora training image set corresponding to the embroidery type matched by the embroidery generation model to determine the target network parameters of the embroidery Lora sub-model includes: By using the regularized training image set, adjusting the network parameters of the embroidery Lora sub-model in the embroidery generation model to obtain pre-trained network parameters; The pre-trained network parameters are adjusted using the training image set to obtain target network parameters.
7. The method for generating an embroidery map according to any one of claims 1 to 6, It is characterized in that The embroidery generation model includes one or more of a Shu embroidery generation model, a Yue embroidery generation model, a Hunan embroidery generation model, and a Su embroidery generation model.
8. A device for generating an embroidery map, It is characterized in that include: An image acquisition module is used to acquire the original embroidery image to be processed; The embroidery map generation module is used to generate a target embroidery map corresponding to the target embroidery type based on the original embroidery image through a target embroidery generation model that matches the target embroidery type in a pre-trained embroidery generation model; wherein the embroidery generation model includes an embroidery basic sub-model and an embroidery Lora sub-model mounted on the embroidery basic sub-model, and the embroidery generation model is trained by a basic training image set and a Lora training image set corresponding to the embroidery type.
9. An electronic device, It is characterized in that The method comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Speech synthesis model training method and device, equipment and readable storage medium
CN113870837A
Image processing method, readable storage medium and computer terminal
CN114170472A
Human face in-vivo detection method, and in-vivo detection network model training method and device
CN115082994A
Image generation method, model training method, related device and electronic equipment
CN115222581A
Chuxiong textile clothing element migration method and system based on convolutional neural network
CN116342578A
