Automatic tagging method for figured cloth pattern
Through the automatic labeling method, the SDSCAM module and attention mechanism are used to solve the problem that the metadata labeling of blue printed fabric patterns is difficult to show semantics and cultural implications, and higher precision and standardized labeling is achieved, supporting digital research and cultural heritage of patterns.
Patent Information
- Application Number
- CN202510159461.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-13
- Publication Date
- 2025-05-27
AI Technical Summary
The existing blue printed fabric pattern metadata labeling method is difficult to fully demonstrate the internal semantics and cultural implications of the pattern, and cannot meet the needs of accurate retrieval, in-depth analysis and cultural heritage.
A method of automatic labeling of floral patterns is proposed. By constructing the early pattern description data and constructing COCO data sets, combining the SDSCAM module for feature extraction, and using the channel attention mechanism and self-attention mechanism to achieve automatic labeling of patterns.
It significantly improves the accuracy and standardization of the data labeling of blue printed fabric patterns, deeply reveals the cultural connotation and semantic information of the patterns, and provides strong support for the digital research, protection and inheritance of blue printed fabric patterns.
Smart Images

Figure CN120047949A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of blue printed cloth pattern processing, and in particular to an automatic marking method for printed cloth patterns. Background Art
[0002] Blue printed cloth patterns have extremely high research value and artistic value. With the development of digital technology and cultural computing, more and more blue printed cloth patterns are digitized and visualized. In order to effectively store, retrieve and utilize such digital resources, it is particularly important to realize deep semantic annotation. In order to fully reveal the mapping mechanism between blue printed cloth patterns and their cultural connotations, metadata-based blue printed cloth pattern annotation has been realized, and the blue printed cloth pattern metadata standard has been completed. The annotated content includes name, blue printed cloth time, region, creator, usage scenario, organizational appearance, color, cultural connotation, location, artistic expression form, current collection place, etc. However, due to the semantic gap between high-level semantic information and low-level semantic information, metadata methods expose many defects when annotating cultural genes, making it difficult to fully display the intrinsic semantics and cultural implications of blue printed cloth patterns, and unable to meet the needs of accurate retrieval, in-depth analysis and cultural inheritance. In order to make up for the defects of metadata annotation, so that users can better understand and appreciate blue printed cloth patterns, facilitate the analysis of the semantic label system of blue printed cloth patterns, and realize digital structured annotation of blue printed cloth patterns, this application proposes a method for automatic annotation of flower cloth patterns. Summary of the invention
[0003] In view of the problems mentioned in the background technology, the purpose of the present invention is to provide a method for automatic labeling of floral cloth patterns, which makes up for the shortcomings of metadata labeling of blue printed cloth digital patterns, studies the connotation and meaning expression of blue printed cloth patterns from the outside to the inside, improves data labeling accuracy, realizes the standardization of blue printed cloth pattern labeling, and provides a technical basis for fully automatic machine labeling to solve the problems mentioned in the background technology.
[0004] The above technical objectives of the present invention are achieved through the following technical solutions:
[0005] A method for automatically marking floral patterns, comprising the following steps:
[0006] S1. Construct the preliminary pattern description data. Based on the metadata specification of blue calico patterns, analyze and determine that the five parts of metadata, namely scene, expression, location, linked patterns, and cultural connotation, are the key contents. Generate a dedicated title for each pattern Cap = {key(fE)‖key(fS)‖key(fL)‖key(fC)‖key(fLi)}, and further generate the final description Des = {Cap‖fE.sentence‖fS.sentence‖fL.sentence‖fC.sentence‖fLi.sentence} to construct the preliminary pattern description data;
[0007] S2. Construct the COCO dataset for blue calico patterns, such that each image corresponds to 5 descriptions (Des) with no more than 50 words. Expand the dataset quantity through data augmentation methods such as geometric transformation and color transformation, and divide the dataset into a training set, a validation set, and a test set, where the training set accounts for 80%, the validation set accounts for 10%, and the test set accounts for 10%. Manually annotate the dataset to establish a json file. The annotation of patterns in this file includes two parts: images and annotations. Images contain the names and non-repeating digital numbers of the patterns in the corresponding dataset, and annotations contain the corresponding picture numbers, non-repeating numbers, and 5 English descriptions;
[0008] S3. Regarding the feature that blue calico patterns only have two colors, blue and white, use the SDSCAM (Stack double SenetCAM) module for feature extraction. First, use ResNet50 to perform preliminary feature extraction on blue calico patterns, then introduce a channel attention mechanism, and assign weights to each channel through a series of calculations to strengthen the features useful for the current task and suppress unimportant features. The output feature map of the channel attention block is defined as L(X) = BN(conv2(ReLU(BN(conv1(X))))). The output after the first calculation of the channel attention block is defined as G(X′) = GAP(BN(conv2(ReLU(BN(conv1(X′)))))). The final feature map is obtained during the superposition process of channel attention calculations Use two channel attentions as the visual encoder of the model, and obtain global information through the self-attention mechanism.
[0009] The above-mentioned automatic annotation method for calico patterns, wherein: in the SDSCAM module, conv1 uses a 1×1 convolutional kernel to reduce the number of channels of the input feature X to 1 / r, BN is the batch Norm function for data normalization, conv2 uses a 1×1 convolutional kernel to restore the number of channels to the number of channels of X, GAP is the global average pooling operation, and σ(·) is the sigmoid activation function. It is an operation of multiplying the feature map and the feature weights respectively.
[0010] The above-mentioned automatic annotation method for calico patterns, wherein: in the specification for constructing the preliminary pattern description data, Culture is the key content. When generating the title and the final description, each part of the information is combined in a specific order to ensure the key position of the cultural connotation in the description and the logic and integrity of the overall description, so as to accurately reflect the characteristics and semantics of the blue calico patterns.
[0011] The above-mentioned automatic annotation method for calico patterns, wherein: in the manually annotated json file of the COCO dataset, the caption in annotations represents the description (Des) of the corresponding pattern, and it corresponds to the image one by one. The data-augmented photos and their original photos use the same description, and the corresponding json file and the dataset are placed in the same folder to ensure the standardization and consistency of data management, which is convenient for data calling and model training.
[0012] The above-mentioned automatic annotation method for calico patterns, wherein: when performing data augmentation operations of geometric transformation, it includes but is not limited to rotation, flipping, cropping, and scaling operations, and the rotation angle range is from 0 degrees to 360 degrees, and the scaling ratio range is between 0.5 and 2.0, so as to fully expand the dataset and improve the model's recognition ability for blue calico patterns of different shapes and sizes.
[0013] The above-mentioned automatic annotation method for calico patterns, wherein: when using ResNet50 for preliminary feature extraction, the dimension of the output feature is adjusted to make it more suitable for subsequent SDSCAM module processing, and during the feature extraction process, according to the texture characteristics of the blue calico patterns, appropriate convolutional kernel sizes and strides are set to extract the most representative local features.
[0014] The above-mentioned automatic annotation method for calico patterns, wherein: when performing data augmentation operations of color transformation, the hues, saturations, or brightnesses of the blue and white colors of the blue calico patterns are changed. Among them, the hue adjustment range of blue is between -30 degrees and 30 degrees, the saturation adjustment range is between 0.5 and 1.5 times, and the brightness adjustment range is between 0.5 and 1.5 times, so as to enhance the model's recognition and annotation ability for patterns under different color changes.
[0015] The above-mentioned automatic annotation method for calico patterns, wherein: when the self-attention mechanism obtains global information, different weights are assigned according to the feature importance of different regions in the pattern. The weight calculation considers the density of patterns, the thickness of lines, and the distribution of pattern elements in the pattern to ensure that the overall structural information of the pattern can be accurately captured.
[0016] The above-mentioned automatic annotation method for calico patterns, wherein: when the channel attention mechanism assigns weights, it dynamically adjusts according to the proportion of pattern elements of the blue calico pattern in different regions. Higher weights are given to the channels corresponding to the pattern elements with a larger proportion to highlight the role of important elements in the annotation.
[0017] The above-mentioned automatic annotation method for calico patterns, wherein: when annotating the blue calico pattern, the final annotation information is stored in a database. This database has scalability and supports different types of query operations, including but not limited to querying according to the pattern name, pattern elements, cultural connotations, etc., facilitating subsequent information retrieval and utilization.
[0018] In summary, the present invention mainly has the following beneficial effects:
[0019] The present invention can effectively realize the automatic annotation function of blue calico patterns, accurately attach relevant information of the patterns during the annotation process, significantly improve the accuracy and standardization of blue calico pattern data annotation. Compared with traditional metadata annotation methods, it can more deeply reveal the cultural connotations and semantic information of the patterns, provide strong support for the digital research, protection and inheritance of blue calico patterns, and strongly promote the application and development of blue calico patterns in the cultural industry and information technology fields. Brief Description of the Drawings
[0020] Figure 1 It is a schematic diagram of the SDSCAM module in the automatic annotation method for calico patterns of the present invention;
[0021] Figure 2 It is a schematic diagram of the overall framework in which the visual encoder in the automatic annotation method for calico patterns of the present invention obtains the dependency relationship between its input and output sequences through the self-attention mechanism to obtain global information;
[0022] Figure 3 It is a schematic diagram of the Five Blessings Holding the Longevity calico pattern involved in the automatic annotation method for calico patterns of the present invention. Detailed Embodiment
[0023] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0024] Referring to Figure 1 - Figure 2 , this embodiment provides an automatic annotation method for calico patterns, including the following steps:
[0025] S1. Construct the pre - period pattern description data. Based on the blue - printed calico pattern metadata specification, analyze and determine that the five parts of scene, expression, location, component pattern, and cultural connotation in the metadata are the key contents. Generate a dedicated title for each pattern Cap = {key(fE)‖key(fS)‖key(fL)‖key(fC)‖key(fLi)}, and further generate the final description Des = {Cap‖fE.sentence‖fS.sentence‖fL.sentence‖fC.sentence‖fLi.sentence} to construct the pre - period pattern description data;
[0026] S2. Construct the COCO dataset for blue - printed calico patterns, so that each image corresponds to 5 descriptions (Des) with no more than 50 words. Expand the number of the dataset through data augmentation methods such as geometric transformation and color transformation, and divide the dataset into a training set, a validation set, and a test set, where the training set accounts for 80%, the validation set accounts for 10%, and the test set accounts for 10%. Manually annotate the dataset to establish a json file. The annotation of the pattern in this file includes two parts: images and annotations. The images contain the names and non - repeating digital numbers of the patterns in the corresponding dataset, and the annotations contain the corresponding picture numbers, non - repeating numbers, and 5 English descriptions;
[0027] S3. Regarding the feature that the blue calico pattern has only two colors, blue and white, the SDSCAM (Stack double Senet CAM) module is used for feature extraction. First, ResNet50 is used to perform preliminary feature extraction on the blue calico pattern. Then, a channel attention mechanism is introduced to assign weights to each channel through a series of calculations, strengthening the features useful for the current task and suppressing unimportant features. The output feature map of the channel attention block is defined as L(X) = BN(conv2(ReLU(BN(conv1(X))))). The calculation output after the first channel attention block is defined as G(X′) = GAP(BN(conv2(ReLU(BN(conv1(X′)))))). The final feature map is obtained during the superposition process of channel attention calculation. Two channel attentions are used as the visual encoder of the model, and global information is obtained through the self-attention mechanism.
[0028] Specifically, in this embodiment: In the SDSCAM module, conv1 uses a 1×1 convolution kernel to reduce the number of channels of the input feature X to 1 / r. BN is the batch Norm function for data normalization. conv2 uses a 1×1 convolution kernel to restore the number of channels to the number of channels of X. GAP is the global average pooling operation, and σ(·) is the sigmoid activation function. It is the operation of multiplying the feature map and the feature weight respectively.
[0029] The automatic annotation method for the calico pattern using the above scheme can effectively realize the automatic annotation function of the blue calico pattern, accurately attach the relevant information of the pattern during the annotation process, significantly improve the accuracy and standardization of the data annotation of the blue calico pattern. Compared with the traditional metadata annotation method, it can more deeply reveal the cultural connotation and semantic information of the pattern, provide strong support for the digital research, protection and inheritance of the blue calico pattern, and strongly promote the application and development of the blue calico pattern in the cultural industry and the field of information technology.
[0030] Specifically, in this embodiment: In the construction specification of the preliminary pattern description data, Culture is the key content. When generating the title and the final description, each part of the information is combined in a specific order to ensure the key position of the cultural connotation in the description and the logic and integrity of the overall description, so as to accurately reflect the characteristics and semantics of the blue calico pattern.
[0031] Specifically, in this embodiment: In the manually annotated json file of the COCO dataset, the caption in the annotations represents the description (Des) of the corresponding pattern, and it corresponds to the image one by one. The data augmentation photos and their original photos use the same description, and the corresponding json file and dataset are placed in the same folder to ensure the standardization and consistency of data management, facilitating data invocation and model training.
[0032] Specifically, in this embodiment: When performing data augmentation operations for geometric transformation, it includes but is not limited to rotation, flipping, cropping, and scaling operations. The rotation angle range is from 0 degrees to 360 degrees, and the scaling ratio range is between 0.5 and 2.0 to fully expand the dataset and improve the model's recognition ability for blue calico patterns of different shapes and sizes.
[0033] Specifically, in this embodiment: When using ResNet50 for preliminary feature extraction, the dimension of the output features is adjusted to make it more suitable for subsequent processing by the SDSCAM module. And during the feature extraction process, according to the texture features of the blue calico patterns, appropriate convolutional kernel sizes and strides are set to extract the most representative local features.
[0034] Specifically, in this embodiment: When performing data augmentation operations for color transformation, the hues, saturations, or brightnesses of the blue and white colors of the blue calico patterns are changed. The hue adjustment range of blue is between -30 degrees and 30 degrees, the saturation adjustment range is between 0.5 and 1.5 times, and the brightness adjustment range is between 0.5 and 1.5 times to enhance the model's recognition and annotation ability for patterns under different color changes.
[0035] Specifically, in this embodiment: When the self-attention mechanism obtains global information, different weights are assigned according to the feature importance of different regions in the pattern. The weight calculation considers the density of the patterns in the pattern, the thickness of the lines, and the distribution of the pattern elements to ensure that the overall structural information of the pattern can be accurately captured.
[0036] Specifically, in this embodiment: When the channel attention mechanism assigns weights, it is dynamically adjusted according to the proportion of the pattern elements of the blue calico pattern in different regions. Higher weights are given to the channels corresponding to the pattern elements with a larger proportion to highlight the role of important elements in the annotation.
[0037] Specifically, in this embodiment: When annotating the blue calico patterns, the final annotation information is stored in the database. This database has scalability and supports different types of query operations, including but not limited to querying according to the pattern name, pattern elements, cultural connotations, etc., facilitating subsequent information retrieval and utilization.
[0038] Working principle: Please refer toFigure 1 , Figure 2 and Figure 3 As shown in ,
[0039] , the specific process is as follows:
[0039] Step 1: Specification for constructing preliminary pattern description data
[0040] For each blue calico pattern, according to the blue calico pattern metadata specification, its title includes five parts: scene, expression, location, linked pattern, and cultural connotation. Among them, Culture is the key content. Therefore, a dedicated title can be generated for each pattern:
[0041] Cap = {key(fE)‖key(fS)‖key(fL)‖key(fC)‖key(fLi)}.
[0042] Subsequently, connect and embed Cap in random order to present the final description:
[0043] Des = {Cap‖fE.sentence‖fS.sentence‖fL.sentence‖fC.sentence‖fLi.sentence}.
[0044]
[0045] Step 2: Construct the COCO dataset for blue calico patterns
[0046] 1. Construct the COCO dataset for blue calico patterns, where each image corresponds to 5 different descriptions (Des), and each description (Des) contains no more than 50 words, thus constructing the dataset.
[0047] 2. Data augmentation: Expand the dataset size through geometric transformation, color transformation, and other data augmentation methods.
[0048] 3. Dataset division: Divide the dataset into a training set, a validation set, and a test set. Among them, 80% is included in the training set, 10% is included in the validation set, and 10% is included in the test set. Use the training set to train the model, use the validation set to verify the evaluation metric scores of the model obtained after training, use it to measure the quality of the trained model, and use the test set to test the actual application effect of the trained model to generate sentences describing the images.
[0049] 4. First, manually annotate the dataset to create a JSON file. Provide corresponding descriptions for the patterns in the training set and validation set respectively. Each photo corresponds to a different description. Use the same description for the data-augmented photos and their original photos, and place the corresponding JSON file and dataset in the same folder. Select some of the annotated JSON files. The annotation of the patterns in the JSON file is mainly divided into two parts, namely images and annotations. In images, filename is the name of the pattern in the corresponding dataset, and id is a non-repeating numerical number. In annotations, image_id is the numerical number of the picture corresponding to filename in image, id is a non-repeating numerical number, caption represents the description (Des) of the corresponding pattern, with a total of 5 English sentences, each sentence not exceeding 50 words.
[0050] Step 3: There are only two colors in the blue calico pattern: blue and white. Therefore, in view of this feature of the blue calico pattern, the present invention designs a new module SDSCAM (Stack double Senet CA M), and its module schematic diagram is as Figure 1 shown. That is, first, use ResNet50 to perform preliminary feature extraction on the blue calico pattern, then introduce a channel attention mechanism to further extract fine-grained information from the image, and then generate a threshold by analyzing each feature channel, so as to assign different weights to each channel, model the correlation between channels, and thus strengthen the features useful for the current task and suppress unimportant features. The output (feature map) of the channel attention block is defined as:
[0051] L(X) = BN(conv2(ReLU(BN(conv1(X)))))
[0052] Where: X represents the rough feature map extracted by ResNet-501; conv1 represents a 1×1 convolution kernel, which can reduce the number of channels of the input feature X to 1 / r; BN represents the batch Norm function, which normalizes the data and prevents the data from being too large before performing ReLU, resulting in unstable network performance; conv2 is also a 1×1 convolution kernel, which restores the number of channels to the number of channels of X.
[0053] The calculation output after the first channel attention block is defined as
[0054] G(X′) = GAP(BN(conv2(ReLU(BN(conv1(X′))))))
[0055] Where, GAP is the operation of global average pooling, and X′ is the feature map generated after passing through the attention calculation once, that is
[0056]
[0057] Among them, σ(〃) is the sigmoid activation function, is the operation of multiplying the feature map and the feature weights respectively. Different from the local channel attention feature map L(X), the global channel attention feature map G(X′) performs X′, retains global average pooling, and further fuses the features extracted by the local channel attention block.
[0058] During the superposition process of channel attention calculation, after enhancing the attention of the input feature X, the final feature map X″ is obtained, that is
[0059]
[0060] Although the embodiments of the present invention have been shown and described, for those of ordinary skill in the art, it can be understood that various changes, modifications, substitutions, and variations can be made to these embodiments without departing from the principles and spirit of the present invention. The scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for automatically marking floral patterns, characterized in that: The following steps are involved: S1. Construct preliminary pattern description data. Based on the blue printed cloth pattern metadata specification, analyze and determine the five parts of the metadata, namely scene, expression, location, link and culture, as the key contents. Generate a special title Cap={key(fE)‖key(fS)‖key(fL)‖key(fC)‖key(fLi)} for each pattern, and further generate the final description Des={Cap‖fE.sentence‖fS.sentence‖fL.sentence‖fC.sentence‖fLi.sentence} to construct preliminary pattern description data. S2. Construct a COCO dataset of blue printed cloth patterns, so that each image corresponds to 5 descriptions (Des) of no more than 50 words. Expand the number of datasets through geometric transformation and color transformation data enhancement, and divide the dataset into training set, validation set and test set, of which the training set accounts for 80%, the validation set accounts for 10%, and the test set accounts for 10%. Manually annotate the dataset to create a json file. The annotations of the patterns in this file include images and annotations. Images contain the name of the pattern in the corresponding dataset and a non-repeating digital number. Annotations contain the corresponding picture number, a non-repeating number and 5 English descriptions. S3. In view of the fact that the blue printed cloth pattern has only two colors, blue and white, the SDSCAM module is used for feature extraction. First, ResNet50 is used to perform preliminary feature extraction on the blue printed cloth pattern. Then, the channel attention mechanism is introduced. Through a series of calculations, weights are assigned to each channel to enhance the features that are useful for the current task and suppress unimportant features. The output feature map of the channel attention block is defined as L(X)=BN(conv2(ReLU(BN(conv1(X)))))). The output of the first channel attention block calculation is defined as G(X′)=GAP(BN(conv2(ReLU(BN(conv1(X′)))))). In the process of channel attention calculation superposition, the final feature map X′′=X⊗σ(G(X′)⊕L(X′)) is obtained. Two channel attentions are used as the visual encoder of the model, and the global information is obtained through the self-attention mechanism.
2. The method for automatically marking floral patterns according to claim 1, characterized in that: In the SDSCAM module, conv1 uses a 1×1 convolution kernel to reduce the number of channels of the input feature X to 1 / r, BN is a batch Norm function for data normalization, conv2 uses a 1×1 convolution kernel to restore the number of channels to the number of channels of X, GAP is a global average pooling operation, σ (・) is a sigmoid activation function, and ⊗ is an operation of multiplying the feature map and the feature weight respectively.
3. The method for automatically marking floral patterns according to claim 1, characterized in that: In the aforementioned preliminary pattern description data construction specifications, Culture is the key content. When generating the title and final description, the various parts of information are combined in a specific order to ensure the key position of cultural connotation in the description and the logic and completeness of the overall description, so as to accurately reflect the characteristics and semantics of the blue printed cloth pattern.
4. The method for automatically marking floral patterns according to claim 1, characterized in that: In the manually annotated json file of the COCO dataset, the caption of annotations represents the description of the corresponding pattern (Des), and corresponds one-to-one with the image. The data-enhanced photos and their original photos use the same description, and the corresponding json files and datasets are placed in the same folder to ensure the standardization and consistency of data management, which facilitates data calling and model training.
5. The method for automatically marking floral patterns according to claim 1, characterized in that: When performing data augmentation operations for geometric transformations, including but not limited to rotation, flipping, cropping, and scaling operations, the rotation angle range is 0 to 360 degrees, and the scaling ratio range is between 0.5 and 2.0, so as to fully expand the data set and improve the model's ability to recognize blue print patterns of different shapes and sizes.
6. The method for automatically marking floral patterns according to claim 1, characterized in that: When using ResNet50 for preliminary feature extraction, the dimension of its output features is adjusted to make it more suitable for subsequent SDSCAM module processing. In the feature extraction process, the appropriate convolution kernel size and step size are set according to the texture characteristics of the blue print pattern to extract the most representative local features.
7. The method for automatically marking floral patterns according to claim 1, characterized in that: When performing color transformation data augmentation operations, the hue, saturation or brightness of the blue and white colors of the indigo print pattern is changed. The hue of blue is adjusted between -30 degrees and 30 degrees, the saturation is adjusted between 0.5 and 1.5 times, and the brightness is adjusted between 0.5 and 1.5 times, so as to enhance the model's ability to recognize and label patterns under different color changes.
8. The method for automatically marking floral patterns according to claim 1, characterized in that: When acquiring global information, the self-attention mechanism assigns different weights according to the feature importance of different regions in the pattern. The weight calculation takes into account the density of the pattern, the thickness of the lines, and the distribution of the pattern elements, ensuring that the overall structural information of the pattern can be accurately captured.
9. The method for automatically marking floral patterns according to claim 1, characterized in that: When allocating weights, the channel attention mechanism dynamically adjusts according to the proportion of pattern elements of the blue print in different areas, and assigns higher weights to channels corresponding to pattern elements with a larger proportion, so as to highlight the role of important elements in annotation.
10. The method for automatically marking floral patterns according to claim 1, characterized in that: When marking the blue print patterns, the final marking information is stored in a database. The database is scalable and supports different types of query operations, including but not limited to queries based on pattern names, pattern elements, and cultural connotations, to facilitate subsequent information retrieval and utilization.