PSD file automatic restoration and processing method and system based on machine learning
Using machine learning methods to extract layer features and relationships in PSD files, build a layer tree, and perform automatic processing, it solves the problems of low efficiency and poor accuracy in PSD file processing in the existing technology, and achieves efficient and intelligent layer relationships. Comprehension and file restoration.
Patent Information
- Application Number
- CN202410763588.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-13
AI Technical Summary
Existing machine learning-based PSD file processing methods fail to effectively utilize the hierarchical structure and interactive relationships between layers, resulting in unsatisfactory restoration and processing effects. They also rely on manual operations, which are inefficient and prone to errors.
Using a machine learning-based method, we extract layer details and contextual features through convolution operations, generate layer category probability distributions, build layer neural bundles, iteratively update coupling coefficients, and combine layer sequence representation and layout information to build a layer tree. , perform layer position restoration and style matching, and automatically process PSD files.
It realizes intelligent and automated processing of PSD files, improves layer recognition accuracy and processing efficiency, ensures accurate capture of layer relationships and information fusion, and generates restored images that are highly consistent with the original files.
Smart Images

Figure CN118334180B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and in particular to a method and system for automatically restoring and processing PSD files based on machine learning. Background Art
[0002] PSD files are the proprietary file format of Adobe Photoshop software, which is widely used in the fields of image design, editing and processing. PSD files use layers as the basic unit, and each layer contains image content, style effects and layout information. Through the combination and superposition of layers, a complete image design is formed.
[0003] Traditional PSD file processing methods mainly rely on manual operations. Designers need to manually open PSD files, check and edit layer contents layer by layer, adjust layouts and styles, and export them to target formats. This processing method is time-consuming and labor-intensive, inefficient, and prone to human errors. With the development of artificial intelligence and machine learning technologies, using machine learning methods to process PSD files has become a new research direction. However, existing machine learning-based PSD file processing methods still have some limitations. Most methods focus on the parsing and conversion of PSD files, ignoring the hierarchical structure and interactive relationships between layers in PSD files, resulting in unsatisfactory restoration and processing effects.
[0004] In summary, a more intelligent, comprehensive and efficient PSD file automatic restoration and processing method is needed to effectively extract and understand the content, structure and style features of PSD files, automatically restore PSD files, and support flexible editing and processing operations. The present invention can solve the problems in the prior art. Summary of the invention
[0005] The embodiment of the present invention provides a method and system for automatic restoration and processing of PSD files based on machine learning, which can solve the problems in the prior art.
[0006] According to a first aspect of the embodiments of the present invention,
[0007] Provided is a method for automatically restoring and processing PSD files based on machine learning, including:
[0008] Input the PSD file into the layer classification network, extract the layer detail features and layer context features for each layer in the PSD file through convolution operation, generate the layer category probability distribution, select the layer category corresponding to the maximum probability, and determine the layer category information;
[0009] Based on the layer category information, the corresponding layer feature vector is determined, and the layer neural bundle is generated through the conversion mapping of the fully connected layer. The coupling coefficient between the layer neural bundles is updated iteratively, and the output vector of the upper layer neural bundle is calculated to obtain the layer sequence representation;
[0010] Based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, a layer embedding vector is determined, a layer tree is constructed, each node and the corresponding child node in the layer tree are aggregated, the hidden state of the node is updated, and the final representation of the root node in the layer tree is obtained through bottom-up recursive propagation to determine the layout information and style features of the PSD file;
[0011] Based on the layer category information, the layers are grouped and vectorized, and the layer attributes are extracted. The layer positions are restored on a blank canvas in combination with the layer sequence representation and the layout information to obtain a restored layout canvas. The style features are matched with a predefined style library to obtain a matching style, and the matching style is applied to the restored layout canvas to determine a PSD restored image.
[0012] In an optional embodiment,
[0013] The PSD file is input into the layer classification network. For each layer in the PSD file, the layer detail features and layer context features are extracted through convolution operation to generate the layer category probability distribution. The layer category corresponding to the maximum probability is selected, and the layer category information is determined to include:
[0014] Input the PSD file into the layer classification network and use the preset PSD parsing library to extract the layer data, including image data, position, size, transparency and blending mode;
[0015] For each layer data, a pre-trained convolutional neural network is applied to extract layer detail features through convolutional layers and pooling layers. Combined with the pre-built graph convolutional network, the long-range dependencies between layer data and the aggregation information of neighboring layer data are constructed to capture the layer topology and semantic relationships, extract layer context features, and fuse the layer detail features with the layer context features to obtain a comprehensive layer representation.
[0016] The comprehensive representation of the layer is input into the classifier, the probability of the layer belonging to the predefined category is calculated, and the classifier output is normalized to the layer category probability distribution through the Softmax function;
[0017] Based on the layer category probability distribution, the highest probability is selected. If the highest probability is greater than or equal to a preset category probability threshold, the category corresponding to the highest probability is used as the predicted category of the layer to determine the layer category information;
[0018] When the highest probability is less than the preset category probability threshold, the unknown category is set, and the predefined categories are expanded by analyzing the comprehensive representation of the layer and combining it with manual annotation.
[0019] In an optional embodiment,
[0020] Based on the layer category information, the corresponding layer feature vector is determined, and the layer neural bundle is generated through the conversion mapping of the fully connected layer. The coupling coefficient between the layer neural bundles is iteratively updated, and the output vector of the upper layer neural bundle is calculated to obtain the layer sequence representation including:
[0021] Based on a preset embedding matrix, each layer category information is mapped to a low-dimensional dense space to determine a layer feature vector;
[0022] The layer feature vector is linearly transformed through a predefined fully connected layer, and is mapped into a group of layer neurons by performing matrix multiplication operation with a weight matrix of the fully connected layer, combined with a superimposed bias vector, and a layer neural bundle is generated based on each group of layer neurons;
[0023] Based on the upper and lower layer relationship of the layer nerve bundle, determining the upper layer nerve bundle and the lower layer nerve bundle;
[0024] Initialize the coupling coefficient between each lower layer neural bundle and the corresponding upper layer neural bundle according to the preset initial value of the coupling coefficient;
[0025] Based on each lower neural bundle, a prediction vector of the lower neural bundle is calculated through a preset shared weight matrix and a lower output vector of the lower neural bundle, based on the prediction vector, combined with the coupling coefficient, an upper input vector of the upper neural bundle is obtained, and an upper output vector of the upper neural bundle is calculated through a Squash activation function;
[0026] Based on the cosine similarity calculated between the prediction vector and the upper layer output vector, the updated coupling coefficient is calculated to obtain a new coupling coefficient. The new coupling coefficient is iterated sequentially until the preset number of iterations is reached. The latest coupling coefficient is determined, the latest upper layer output vector is calculated, and the layer sequence representation is obtained.
[0027] In an optional embodiment,
[0028] Based on the prediction vector and the coupling coefficient, an upper layer input vector of the upper layer neural bundle is obtained, and the upper layer output vector of the upper layer neural bundle is calculated by the Squash activation function, including:
[0029] The prediction vector is calculated as follows:
[0030] ;
[0031] in,x represents the upper layer nerve bundle number, y represents the number of the lower layer nerve bundle, Indicates the underlying nerve bundle y Upper nerve bundle x The prediction vector of W pred represents the shared weight matrix, s y Indicates the underlying nerve bundle y The lower layer output vector of
[0032] The upper layer input vector is calculated as follows:
[0033] ;
[0034] in, u x Indicates the upper nerve bundle x The upper input vector of m represents the total number of nerve bundles in the lower layer, c xy Indicates the upper nerve bundle x and underlying nerve bundles y The coupling coefficient between
[0035] The upper layer output vector is calculated as follows:
[0036] ;
[0037] in, x represents the upper layer nerve bundle number, u x Indicates the upper nerve bundle x The upper input vector of v x Indicates the upper nerve bundle x The upper output vector of .
[0038] In an optional embodiment,
[0039] Based on each lower neural bundle, through a preset shared weight matrix and a lower output vector of the lower neural bundle, calculating the prediction vector of the lower neural bundle also includes:
[0040] Based on all layer neural bundles, multiple aggregation strategies are pre-determined, and multiple aggregation protocols are constructed accordingly;
[0041] Based on each underlying neural bundle, determining a matching probability between the underlying neural bundle and each of the aggregation protocols;
[0042] Based on each of the aggregation protocols, the lower-layer output vector corresponding to each lower-layer neural bundle is extracted, combined with the corresponding matching probability, and weighted aggregation is performed to obtain the protocol vector corresponding to the aggregation protocol. The protocol vector is used as the lower-layer output vector, the prediction vector of the lower-layer neural bundle is calculated, and an iterative process is performed.
[0043] In an optional embodiment,
[0044] Based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, the layer embedding vector is determined, and a layer tree is constructed. By aggregating each node and the corresponding child node in the layer tree, the hidden state of the node is updated, and the final representation of the root node in the layer tree is obtained through bottom-up recursive propagation. The layout information and style features of the PSD file are determined, including:
[0045] Encoding the layer category information, the layer sequence representation, and the visual content corresponding to the layer into a layer embedding vector of fixed length through a pre-built neural network model;
[0046] Based on the layer embedding vector, determine the initial representation of the node, and build a layer tree based on the hierarchical structure of the PSD file;
[0047] Starting from the leaf node of the layer tree, recursively process each node, aggregate the current node and the child nodes corresponding to the current node based on the pre-built graph neural network, obtain the current subtree feature vector, fuse the subtree feature vector with the layer embedding vector corresponding to the current node, and the layer embedding vector of the corresponding ancestor node to obtain the fused node representation;
[0048] The fused node representation is used as the initial hidden state of the corresponding node, and the initial hidden state of each node and the initial hidden state of the corresponding child node are aggregated using a multi-head attention mechanism to obtain a node aggregate hidden state;
[0049] Through bottom-up recursive propagation, the node aggregation hidden state of each node in the layer tree is updated layer by layer until it is propagated to the root node, and the node aggregation hidden state of the root node is determined. The node aggregation hidden state of the root node is input into the terminal pooling layer, and subtree representations of different granularities are extracted by sliding pooling windows of different sizes on the layer tree. Finally, all subtree representations are spliced to obtain a hierarchical representation of the PSD file, including layout information and style features.
[0050] In an optional embodiment, it also includes:
[0051] The node aggregate hidden state is calculated as follows:
[0052] ;
[0053] in, i represents the node ordinal number, k represents the number of iterations, h i (k) Indicates k After iterations, nodes i The aggregate hidden state of σ represents the activation function, W0 represents the node i The corresponding transformation weight matrix, h i (k-1) Indicates k -1 Node after iteration i The aggregate hidden state of j Indicates the ordinal number of the child node. N ( i ) represents a node i The child node set of W1 represents the child node j The corresponding transformation weight matrix, h j (k-1) Indicates k -Child nodes after 1 iteration j The aggregate hidden state of .
[0054] According to a second aspect of the embodiments of the present invention,
[0055] Provided is a PSD file automatic restoration and processing system based on machine learning, including:
[0056] The first unit is used to input the PSD file into a layer classification network, extract layer detail features and layer context features for each layer in the PSD file through a convolution operation, generate a layer category probability distribution, select a layer category corresponding to a maximum probability, and determine layer category information;
[0057] The second unit is used to determine the corresponding layer feature vector based on the layer category information, generate the layer neural bundle through the conversion mapping of the fully connected layer, iteratively update the coupling coefficient between the layer neural bundles, calculate the output vector of the upper layer neural bundle, and obtain the layer sequence representation;
[0058] The third unit is used to determine the layer embedding vector based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, construct a layer tree, aggregate each node and the corresponding child node in the layer tree, update the hidden state of the node, obtain the final representation of the root node in the layer tree through bottom-up recursive propagation, and determine the layout information and style features of the PSD file;
[0059] The fourth unit is used to group and vectorize the layers based on the layer category information, extract layer attributes, restore the layer positions on a blank canvas in combination with the layer sequence representation and the layout information, obtain a restored layout canvas, match the style features with a predefined style library, obtain a matching style, apply the matching style to the restored layout canvas, and determine a PSD restored image.
[0060] According to a third aspect of the embodiments of the present invention,
[0061] An electronic device is provided, comprising:
[0062] processor;
[0063] a memory for storing processor-executable instructions;
[0064] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0065] A fourth aspect of the embodiments of the present invention is:
[0066] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0067] In the embodiment of the present invention, by generating a probability distribution of layer categories, each layer is classified, that is, it is determined that the layer belongs to a corresponding category, so that the system can automatically identify and understand the meaning and function of different layers in the PSD file, making the process of processing the PSD file more automated and efficient; by using a convolutional neural network to extract layer features and combining them with probability distribution for classification, the accuracy of classification is improved, which helps to ensure that the recognition of layer categories is more accurate and reliable; by iteratively updating the coupling coefficients between layer neural bundles, the relationship weights between layers can be dynamically adjusted, the long-range dependencies and topological structures between layers can be captured, and the correlation and information fusion between layers can be enhanced; by continuously updating the coupling coefficients, the model can more accurately capture and reflect the relationships between layers. The similarities and differences can be used to improve the accuracy of layer classification. Through the iterative process, the coupling coefficient can be adaptively adjusted to gradually optimize the model's learning ability for different layer features, so that the model can adapt to different layer features and complex scenes; through the aggregation of child node information and the update of the hidden state of the parent node, each node can obtain the comprehensive information of its child nodes, making the information flow in the layer tree more efficient. The aggregation operation helps to capture complex hierarchical relationships and information interactions, and improve the quality of node feature representation; combined with the layer sequence representation and layout information, the layer position is restored on a blank canvas. According to the stacking order and hierarchical relationship of the layers, the vector representation of the layers is accurately located and placed, so that the restored layout canvas can truly reflect the original layout and layer arrangement of the PSD file. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] Figure 1 A schematic diagram of a process of automatically restoring and processing a PSD file based on machine learning according to an embodiment of the present invention;
[0069] Figure 2 It is a structural schematic diagram of a PSD file automatic restoration and processing system based on machine learning according to an embodiment of the present invention. DETAILED DESCRIPTION
[0070] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0071] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0072] Figure 1 FIG. 1 is a flow chart of a method for automatically restoring and processing a PSD file based on machine learning according to an embodiment of the present invention. Figure 1 As shown, the method includes:
[0073] S101. Input the PSD file into the layer classification network, extract the layer detail features and layer context features for each layer in the PSD file through convolution operation, generate layer category probability distribution, select the layer category corresponding to the maximum probability, and determine the layer category information;
[0074] The layer classification network specifically refers to a learning model for classifying layers in a PSD file. The layer in the PSD file is received as input, and after a series of convolution operations, the detail features and context features of the layer are extracted. The detail features and context features are passed to the classifier. The classifier calculates the probability distribution of each layer belonging to a predefined category. According to the probability distribution, the category with the largest probability is selected as the predicted category of the layer to determine the category information of the layer.
[0075] In this embodiment, through the convolution operation, detail features and context features are extracted from each layer of the PSD file, including image texture, shape, color and other information, which helps to describe the visual properties of the layer; by generating a layer category probability distribution, each layer is classified, that is, it is determined that the layer belongs to the corresponding category, so that the system can automatically identify and understand the meaning and function of different layers in the PSD file, making the process of processing PSD files more automated and efficient, and can quickly classify a large number of layers without manual intervention, saving time and labor costs; by using a convolutional neural network to extract layer features and combining them with probability distribution for classification, the accuracy of classification is improved, which helps to ensure that the identification of layer categories is more accurate and reliable.
[0076] In an optional embodiment, a PSD file is input into a layer classification network, and for each layer in the PSD file, a convolution operation is performed to extract layer detail features and layer context features, generate a layer category probability distribution, select a layer category corresponding to the maximum probability, and determine that the layer category information includes:
[0077] Input the PSD file into the layer classification network and use the preset PSD parsing library to extract the layer data, including image data, position, size, transparency and blending mode;
[0078] For each layer data, a pre-trained convolutional neural network is applied to extract layer detail features through convolutional layers and pooling layers. Combined with the pre-built graph convolutional network, the long-range dependencies between layer data and the aggregation information of neighboring layer data are constructed to capture the layer topology and semantic relationships, extract layer context features, and fuse the layer detail features with the layer context features to obtain a comprehensive layer representation.
[0079] The comprehensive representation of the layer is input into the classifier, the probability of the layer belonging to the predefined category is calculated, and the classifier output is normalized to the layer category probability distribution through the Softmax function;
[0080] Based on the layer category probability distribution, the highest probability is selected. If the highest probability is greater than or equal to a preset category probability threshold, the category corresponding to the highest probability is used as the predicted category of the layer to determine the layer category information;
[0081] When the highest probability is less than the preset category probability threshold, the unknown category is set, and the predefined categories are expanded by analyzing the comprehensive representation of the layer and combining it with manual annotation.
[0082] Input the target PSD file into the layer classification network, use the preset PSD parsing library to parse the input PSD file, extract the corresponding layer data, for each layer, extract the following information: image data, position, size, transparency and blending mode, etc., organize the extracted layer data into a batch as input for subsequent processing;
[0083] For each layer data, a pre-trained convolutional neural network is applied for feature extraction. The convolutional neural network automatically learns and extracts local patterns and texture features within the layer through a series of convolutional layers and pooling layers, capturing detailed information such as the shape, texture, and color of the layer; through multi-layer convolution and downsampling operations, a high-level semantic feature representation of the layer is obtained, called layer detail features; combined with the pre-built graph convolutional network, long-range dependencies are established between layer data to capture the topological structure between layers; by aggregating the neighbor layer information of each layer, the semantic relationship between layers is extracted to obtain layer context features; the layer detail features and layer context features are fused to obtain a comprehensive representation of the layer;
[0084] The comprehensive representation of the layer is input into the preset classifier. The classifier calculates the probability that the layer belongs to each predefined category through a fully connected layer or other classification algorithm. The output of the classifier is normalized using the Softmax function to obtain the layer category probability distribution.
[0085] In the layer category probability distribution, the category with the highest probability value is selected as the candidate prediction category, and it is determined whether the highest probability is greater than or equal to the preset category probability threshold. If the highest probability is greater than or equal to the threshold, the corresponding category is determined as the predicted category of the layer, and the layer category information is obtained; if the highest probability is less than the threshold, it is considered that the layer category cannot be determined and is marked as an unknown category;
[0086] For layers marked as unknown categories, further parse the comprehensive representation of the layers, analyze and annotate the unknown category layers through manual annotation or other methods, expand the predefined categories based on the annotation results, add new categories to cover the unknown layers, and update the training data and model of the layer classification network so that the model can recognize the newly added categories;
[0087] For each layer, the predicted category information is output, the layer category information is associated with the original layer data, a layer representation with a category label is obtained, and the processed PSD file layer information is output, including the layer data and the corresponding category label.
[0088] In this embodiment, the automated parsing and classification process greatly improves the efficiency of processing layers in the PSD file, reducing the time and labor cost of manual intervention; using a convolutional neural network to extract features from each layer, it is possible to automatically learn and capture detailed information such as the shape, texture and color of the layer, ensuring that the extracted features are highly accurate and rich; by establishing long-range dependencies between layers through a graph convolutional network and aggregating neighbor layer information, it is possible to capture semantic relationships between layers, form a contextual understanding of the layers, and improve the accuracy and depth of classification; by combining the layer detail features and context features, the classifier calculates the class probability of the layer, and uses the Softmax function for normalization to ensure the efficiency and accuracy of the classification results; for layers of unknown categories, their comprehensive representation is further parsed, and the training data and model of the classification network are continuously updated and optimized by manually annotating or expanding predefined categories, thereby enhancing the generalization ability and adaptability of the model; according to the layer category probability distribution, the category with the highest probability value is selected as the candidate prediction category, and is judged in combination with a preset probability threshold to ensure the accuracy and rationality of the category determination.
[0089] S102. Based on the layer category information, determine the corresponding layer feature vector, generate the layer neural bundle through the conversion mapping of the fully connected layer, iteratively update the coupling coefficient between the layer neural bundles, calculate the output vector of the upper layer neural bundle, and obtain the layer sequence representation;
[0090] The layer neural bundle specifically refers to a high-level representation structure generated by a neural network method during layer classification and representation. Specifically, the layer neural bundle is a set of neurons that uses the layer feature vector after conversion through a fully connected layer. It reflects the high-level semantic information and features of the layer. As a node in the neural network, it transmits and shares information with each other through iterative updates of coupling coefficients to form a comprehensive representation of the entire layer sequence.
[0091] The coupling coefficient specifically refers to a parameter used to represent the strength and importance of the association between layer neural bundles. During the calculation and iteration process of the layer neural bundles, the coupling coefficient is used to determine the contribution of the lower layer neural bundles to the upper layer neural bundles, specifically reflecting the importance and influence of a certain lower layer neural bundle on a specific upper layer neural bundle.
[0092] In this embodiment, a layer feature vector is generated based on the layer category information. Through the fully connected layer conversion mapping, the high-dimensional feature information of the layer can be effectively captured, and efficient extraction and representation of the layer features can be achieved. By iteratively updating the coupling coefficients between the layer neural bundles, the relationship weights between the layers can be dynamically adjusted to capture the long-range dependencies and topological structures between the layers, and enhance the correlation and information fusion between the layers. By continuously updating the coupling coefficients, the model can more accurately capture and reflect the similarities and differences between the layers, and improve the accuracy of layer classification. Through the iterative process, the coupling coefficients can be adaptively adjusted to gradually optimize the model's learning ability for different layer features, so that the model can adapt to different layer features and complex scenes. Using layer neural bundles to process layer data can flexibly cope with complex layer structures, especially the multi-level and diverse layer combinations that may be contained in PSD files.
[0093] In an optional embodiment, based on the layer category information, a corresponding layer feature vector is determined, a layer neural bundle is generated through a conversion mapping of a fully connected layer, a coupling coefficient between the layer neural bundles is iteratively updated, and an output vector of an upper layer neural bundle is calculated to obtain a layer sequence representation including:
[0094] Based on a preset embedding matrix, each layer category information is mapped to a low-dimensional dense space to determine a layer feature vector;
[0095] The layer feature vector is linearly transformed through a predefined fully connected layer, and is mapped into a group of layer neurons by performing matrix multiplication operation with a weight matrix of the fully connected layer, combined with a superimposed bias vector, and a layer neural bundle is generated based on each group of layer neurons;
[0096] Based on the upper and lower layer relationship of the layer nerve bundle, determining the upper layer nerve bundle and the lower layer nerve bundle;
[0097] Initialize the coupling coefficient between each lower layer neural bundle and the corresponding upper layer neural bundle according to the preset initial value of the coupling coefficient;
[0098] Based on each lower neural bundle, a prediction vector of the lower neural bundle is calculated through a preset shared weight matrix and a lower output vector of the lower neural bundle, based on the prediction vector, combined with the coupling coefficient, an upper input vector of the upper neural bundle is obtained, and an upper output vector of the upper neural bundle is calculated through a Squash activation function;
[0099] Based on the cosine similarity calculated between the prediction vector and the upper layer output vector, the updated coupling coefficient is calculated to obtain a new coupling coefficient. The new coupling coefficient is iterated sequentially until the preset number of iterations is reached. The latest coupling coefficient is determined, the latest upper layer output vector is calculated, and the layer sequence representation is obtained.
[0100] The embedding matrix specifically refers to a preset matrix used to map high-dimensional layer category information to a low-dimensional dense space, and to represent each layer category information as a fixed-length vector so that the fixed-length vector can be processed by a subsequent neural network. Through the embedding matrix, the category information can be converted into a low-dimensional feature vector, so that the category information can be represented in a low-dimensional space, reducing the computational complexity and retaining the relative relationship between categories.
[0101] The layer neurons specifically refer to a group of neurons obtained by performing linear transformation of the fully connected layer on the layer feature vector, such as matrix multiplication and bias superposition. The layer neurons are the result of further processing and conversion of the layer features, capturing the high-dimensional features of the layer and providing basic data for generating layer neural bundles.
[0102] The upper-layer neural bundle specifically refers to a part of the layer neural bundle, which is located in the upper layer of the layer neural bundle hierarchy structure. It generates the output vector of the upper layer by integrating the prediction vector and coupling coefficient of the lower-layer neural bundle. The upper-layer neural bundle is responsible for integrating and compressing the feature information of the lower-layer neural bundle, and outputting information representing higher-level semantics, playing an important role in capturing complex relationships and long-range dependencies.
[0103] The lower-layer neural bundle specifically refers to a part of the layer neural bundle, which is located in the lower layer of the layer neural bundle hierarchy structure. It generates a prediction vector by sharing the weight matrix and its own output vector, which is provided to the upper-layer neural bundle. The lower-layer neural bundle is responsible for extracting and representing the local features of the layer, and providing basic information and prediction vectors for the upper-layer neural bundle, and participates in the representation and learning process of the entire layer sequence.
[0104] The shared weight matrix refers to a preset matrix used to perform a linear transformation on the lower-layer output vector when calculating the prediction vector of the lower-layer neural bundle. The shared weight matrix is shared in the entire network, rather than owned by each neural bundle alone. By sharing the weight matrix, weight information can be shared among all lower-layer neural bundles, improving parameter utilization and reducing model complexity, while enabling the network to effectively capture and utilize common features between layers.
[0105] Based on the preset embedding matrix, the category information of each layer is mapped to a low-dimensional dense space. For each layer, the embedding vector of the corresponding category information is found through the embedding matrix, and the found embedding vector is used as the feature vector of the layer to represent the representation of the layer in the low-dimensional space.
[0106] The layer feature vector is input into the pre-defined fully connected layer. The fully connected layer multiplies the layer feature vector by the weight matrix through matrix multiplication, and superimposes the bias vector on the result of the matrix multiplication to obtain the activation value of the layer neuron. For each layer, a group of layer neurons is generated to represent the representation of the layer in the neural network; based on each group of layer neurons, a corresponding layer neural bundle is generated. The layer neural bundle consists of multiple neurons and represents the high-level features of the layer in the neural network.
[0107] According to the connection relationship between the neural bundles of the layers, the upper and lower neural bundles are determined, and by analyzing the hierarchical structure of the layers in the PSD file, the upper and lower layer relationships between the neural bundles are established.
[0108] According to the preset initial value of the coupling coefficient, which is usually set to 0, the coupling coefficient is initialized between each lower-layer neural bundle and the corresponding upper-layer neural bundle. The coupling coefficient represents the contribution of the lower-layer neural bundle to the upper-layer neural bundle.
[0109] Based on each lower-layer neural bundle, calculate the corresponding prediction vector of the lower-layer neural bundle, perform matrix multiplication operation on the preset shared weight matrix and the lower-layer output vector of the lower-layer neural bundle to obtain the prediction vector, combine the prediction vector and the coupling coefficient, calculate the upper-layer input vector of the upper-layer neural bundle, multiply the prediction vector of each lower-layer neural bundle by the corresponding coupling coefficient, and sum them to obtain the upper-layer input vector, perform nonlinear transformation on the upper-layer input vector through the Squash activation function to obtain the upper-layer output vector, calculate the cosine similarity between the prediction vector and the upper-layer output vector, update the coupling coefficient based on the cosine similarity, adjust the value of the coupling coefficient according to the consistency between the prediction vector and the upper-layer output vector, normalize the coupling coefficient, ensure that the sum of the coupling coefficients of each lower-layer neural bundle is 1, and repeat the iteration until the preset number of iterations is reached.
[0110] After the iteration is completed, the final coupling coefficient and the upper layer output vector are determined, and the final upper layer output vector is used as the sequence representation of the layer, indicating the high-level features of the layer in the neural network.
[0111] In this embodiment, the layer feature vector is converted into layer neurons through the fully connected layer, and the layer neural bundle is generated based on the layer neurons, so that the high-level features of the layer can be extracted layer by layer. The layer-by-layer extraction and representation method can capture the complex patterns and semantic information of the layer, making the layer feature representation richer and more hierarchical; by analyzing the layer hierarchy in the PSD file and establishing the upper and lower layer relationships between the layer neural bundles, the dependencies and relationships between the layers can be accurately modeled in the neural network, which can better capture the contextual information between the layers and improve the integrity and consistency of the layer representation; by initially setting the coupling coefficient and dynamically updating the coupling coefficient during the iteration process, the contribution of the lower layer neural bundle to the upper layer neural bundle can be adjusted according to the consistency between the prediction vector and the upper layer output vector in each iteration. The dynamic adjustment process enables the model to adaptively optimize the coupling coefficient and improve the adaptability and representation ability of the model under different layer structures; through multiple iterations and nonlinear transformations, the long-range dependencies between the layer neural bundles can be effectively captured, so that the model can better understand and represent the complex dependencies in the layer sequence and improve the effectiveness of the layer sequence representation.
[0112] In an optional embodiment, based on the prediction vector and in combination with the coupling coefficient, an upper layer input vector of the upper layer neural bundle is obtained, and by using a Squash activation function, an upper layer output vector of the upper layer neural bundle is calculated, including:
[0113] The prediction vector is calculated as follows:
[0114] ;
[0115] in, x represents the upper layer nerve bundle number, y represents the number of the lower layer nerve bundle, Indicates the underlying nerve bundle y Upper nerve bundle x The prediction vector of W pred represents the shared weight matrix, s y Indicates the underlying nerve bundle y The lower layer output vector of
[0116] The upper layer input vector is calculated as follows:
[0117] ;
[0118] in, u x Indicates the upper nerve bundle x The upper input vector of m represents the total number of nerve bundles in the lower layer, cxy Indicates the upper nerve bundle x and underlying nerve bundles y The coupling coefficient between
[0119] The upper layer output vector is calculated as follows:
[0120] ;
[0121] in, x represents the upper layer nerve bundle number, u x Indicates the upper nerve bundle x The upper input vector of v x Indicates the upper nerve bundle x The upper output vector of .
[0122] First, the output of the lower-layer neural bundle is transformed using a shared weight matrix to generate a prediction vector for each lower-layer neural bundle to the upper-layer neural bundle. The input vector of the upper-layer neural bundle is obtained by weighted summation of the prediction vectors of all lower-layer neural bundles and their corresponding coupling coefficients. The upper-layer input vector is passed through the Squash activation function to obtain the output vector of the upper-layer neural bundle. The activation function can compress the norm of the vector so that it is within a relatively stable range. The coupling coefficient is normalized using the Softmax function to ensure that the sum of all coupling coefficients is 1. According to the relationship between the prediction vector and the upper-layer output vector, the logarithmic probability is iteratively updated. Through step-by-step adjustment, the contribution of the lower-layer neural bundle to the upper-layer neural bundle is made more accurate.
[0123] Preferably, the logarithmic probability is iteratively updated according to the relationship between the prediction vector and the upper layer output vector, and the formula is as follows through stepwise adjustment:
[0124] ;
[0125] in, x represents the upper layer nerve bundle number, y represents the number of the lower layer nerve bundle, c xy Indicates the upper nerve bundle x and underlying nerve bundles y The coupling coefficient between m represents the total number of nerve bundles in the lower layer, z represents the number of another lower layer neural bundle, b xy Indicates the upper nerve bundle x and underlying nerve bundles y The logarithmic probability between b xz Indicates the upper nerve bundle xand underlying nerve bundles z The logarithmic probability between α represents the learning rate, Indicates the underlying nerve bundle y Upper nerve bundle x The prediction vector of v x Indicates the upper nerve bundle x The upper output vector of n Indicates not equal to x Another upper layer of the neural bundle number, Indicates the underlying nerve bundle y Upper nerve bundle n The prediction vector of v n Indicates the upper nerve bundle n The upper output vector of .
[0126] According to the formula, using shared weight matrices and coupling coefficients, the model can learn and extract more representative features, improve the ability to represent layer information, and calculate prediction vectors and upper-layer input vectors, so that the information of the lower-layer neural bundles can be transmitted and integrated to form a representation of the upper-layer neural bundles. The update mechanism of the coupling coefficient ensures that the information transmission between different layers is more accurate and effective. The Squash activation function compresses the input vector into a stable range, which helps the model converge faster and reduce instability during training. The normalization of the coupling coefficient by the Softmax function ensures that the sum of the coupling coefficients after each update is 1, making the update process more stable and controllable.
[0127] In an optional embodiment, based on each lower neural bundle, by using a preset shared weight matrix and a lower output vector of the lower neural bundle, calculating the prediction vector of the lower neural bundle further includes:
[0128] Based on all layer neural bundles, multiple aggregation strategies are pre-determined, and multiple aggregation protocols are constructed accordingly;
[0129] Based on each underlying neural bundle, determining a matching probability between the underlying neural bundle and each of the aggregation protocols;
[0130] Based on each of the aggregation protocols, the lower-layer output vector corresponding to each lower-layer neural bundle is extracted, combined with the corresponding matching probability, and weighted aggregation is performed to obtain the protocol vector corresponding to the aggregation protocol. The protocol vector is used as the lower-layer output vector, the prediction vector of the lower-layer neural bundle is calculated, and an iterative process is performed.
[0131] The aggregation strategy specifically refers to a method for integrating the output information of multiple neural bundles, which defines how to integrate the output vectors from different underlying neural bundles to generate a unified representation. The aggregation strategy can include a variety of different methods, such as weighted average, maximum aggregation, minimum aggregation, etc. Each strategy has unique calculation rules and is suitable for different types of data and tasks.
[0132] The aggregation protocol specifically refers to a set of rules and parameter settings based on a specific aggregation strategy, which defines the specific aggregation method and details, including how to calculate the matching probability of each lower-layer neural bundle with the aggregation protocol, how to weight and combine these output vectors, etc. An aggregation protocol is actually a specific implementation of the aggregation strategy, which can be adjusted and optimized according to task requirements.
[0133] The protocol vector specifically refers to the vector representation obtained by applying the corresponding aggregation protocol. Specifically, for each lower-layer neural bundle, when calculating its output vector, the corresponding lower-layer output vector is extracted through multiple aggregation protocols, and weighted aggregation is performed based on the matching probability of each protocol. The final vector is the protocol vector. The protocol vector is a comprehensive representation of the output vector of the lower-layer neural bundle, which is used for further calculation and analysis.
[0134] Based on all the layer neural bundles, multiple aggregation strategies are pre-determined. Each aggregation strategy represents a specific way of information aggregation. Common aggregation strategies include: average aggregation, which takes the arithmetic average of the outputs of the lower layer neural bundles; maximum aggregation, which selects the maximum value among the outputs of the lower layer neural bundles; weighted aggregation, which takes the weighted sum of the outputs of the lower layer neural bundles according to the weights; the choice of aggregation strategy depends on the task requirements and data characteristics, and can be determined based on experience or experimental results.
[0135] For each aggregation strategy, an aggregation protocol is constructed. The aggregation protocol defines how to aggregate the outputs of the underlying neural bundles according to the aggregation strategy, including the specific implementation details of the aggregation strategy, such as the calculation method of weights, the selection of aggregation functions, etc.
[0136] For each lower neural bundle, the matching probability with each aggregation protocol is calculated, where the matching probability represents the correlation or degree of adaptation between the lower neural bundle and the aggregation protocol. The matching probability can be calculated by a variety of methods. Preferably, an attention mechanism is used to calculate the correlation between the lower neural bundle and the aggregation protocol through the attention weight. The calculation result of the matching probability is a probability distribution, which represents the degree of matching between the lower neural bundle and each aggregation protocol.
[0137] For each aggregation protocol, the lower-layer output vectors of the lower-layer neural bundles that match it are extracted, and the lower-layer output vectors are weighted aggregated according to the matching probability, wherein the weighted aggregation process includes: multiplying each lower-layer output vector by the corresponding matching probability to obtain a weighted output vector; adding all weighted output vectors to obtain a protocol vector corresponding to the aggregation protocol; the protocol vector represents the aggregation information of the lower-layer neural bundles that conform to the aggregation protocol; the dimension of the protocol vector is the same as the dimension of the lower-layer output vector, reflecting the feature representation after aggregation.
[0138] The process of matching probability calculation and protocol vector generation is repeated for multiple iterations. In each iteration, the updated protocol vector is used as the lower-layer output vector to calculate new matching probability and protocol vector. Through iterative optimization, the aggregation protocol and matching probability are continuously adjusted and optimized so that the protocol vector can better represent the aggregation information of the lower-layer neural bundles.
[0139] The protocol vector corresponding to each aggregation protocol is used as the lower-layer output vector. For each lower-layer neural bundle, the preset shared weight matrix and protocol vector are used to calculate the prediction vector. The protocol vector is multiplied by the shared weight matrix to obtain the prediction vector. The prediction vector represents the prediction or vote of the lower-layer neural bundle for the upper-layer neural bundle.
[0140] Repeat the aggregation iteration. In each iteration, use the updated protocol vector as the lower-layer output vector to calculate the new prediction vector. The purpose of the iterative process is to gradually optimize and adjust the information transfer and interaction between neural bundles through multiple aggregations and predictions, and then proceed to the information transfer step.
[0141] In this embodiment, by predetermining multiple aggregation strategies, it is possible to achieve diversified aggregation of the output information of the lower-level neural bundles, including different methods such as averaging, maximum, and weighted, and make full use of multiple information aggregation strategies to obtain richer and more diverse feature representations; the choice of aggregation strategy can be flexibly adjusted according to specific task requirements and data characteristics, so that the method can be flexibly adapted to different tasks and data scenarios, thereby improving the generalization ability and applicability of the model; by adopting methods such as the attention mechanism to calculate the matching probability between the lower-level neural bundles and the aggregation protocol, the correlation between the lower-level neural bundles and the aggregation protocol can be automatically calculated, reducing the need for manual intervention and improving the efficiency and accuracy of the calculation; by iteratively optimizing the aggregation protocol and the matching probability, the information transmission and interaction between the neural bundles can be gradually optimized and adjusted to obtain a more accurate and effective feature representation, thereby improving the performance and effect of the model.
[0142] S103. Based on the layer category information, the layer sequence representation, and the visual content corresponding to the layer, determine the layer embedding vector, construct a layer tree, aggregate each node and the corresponding child node in the layer tree, update the hidden state of the node, obtain the final representation of the root node in the layer tree through bottom-up recursive propagation, and determine the layout information and style features of the PSD file;
[0143] Based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, the embedding vector of each layer is determined, and the embedding vector is a low-dimensional dense vector obtained by comprehensive processing of the information, which represents the representation of the layer in the low-dimensional space; the layer tree is constructed using the layer embedding vector, and the layer tree represents the hierarchical structure of the layers in the PSD file, each node corresponds to a layer, and the connection relationship between the nodes reflects the hierarchical relationship of the layers; each node in the layer tree and the corresponding child nodes are aggregated, specifically the information of the child nodes is aggregated into the parent node to update the hidden state of the parent node; after each aggregation operation, the hidden state of the node is updated, and the hidden state represents the feature representation of the node in the current aggregation step, and the comprehensive information of the current node is reflected by the aggregation of the child nodes;
[0144] Recursive propagation is performed from bottom to top, starting from the leaf node and all the way to the root node. In each recursive operation, the information of the current node and its child nodes is aggregated to the current node, and the hidden state of the current node is updated. After the recursive propagation is completed, the final representation of the root node in the layer tree is obtained. The final representation of the root node integrates the information of all nodes in the entire layer tree. Based on the final representation of the root node, the overall layout information and style features of the PSD file are determined. The representation of the root node contains the information of all layers and can be used to extract the layout and style features of the entire PSD file.
[0145] In this embodiment, a low-dimensional dense vector is determined by integrating layer category information, layer sequence representation and visual content. The obtained embedding vector represents the characteristics of each layer more comprehensively and accurately. The low-dimensional dense vector reduces information redundancy while capturing layer features while retaining key information. By aggregating child node information and updating the hidden state of the parent node, each node can obtain the comprehensive information of its child nodes, making the information flow in the layer tree more efficient. The aggregation operation helps to capture complex hierarchical relationships and information interactions, and improves the quality of node feature representation. Bottom-up recursive propagation ensures that each node can gradually update the hidden state until the root node. The layer-by-layer aggregation and update mechanism enables the representation of each node in the layer tree to reflect the comprehensive characteristics of the entire subtree, thereby enhancing the globality and consistency of the representation.
[0146] In an optional embodiment, based on the layer category information, the layer sequence representation, and the visual content corresponding to the layer, a layer embedding vector is determined, a layer tree is constructed, each node and the corresponding child node in the layer tree are aggregated, the hidden state of the node is updated, and the final representation of the root node in the layer tree is obtained through bottom-up recursive propagation. Determining the layout information and style features of the PSD file includes:
[0147] Encoding the layer category information, the layer sequence representation, and the visual content corresponding to the layer into a layer embedding vector of fixed length through a pre-built neural network model;
[0148] Based on the layer embedding vector, determine the initial representation of the node, and build a layer tree based on the hierarchical structure of the PSD file;
[0149] Starting from the leaf node of the layer tree, recursively process each node, aggregate the current node and the child nodes corresponding to the current node based on the pre-built graph neural network, obtain the current subtree feature vector, fuse the subtree feature vector with the layer embedding vector corresponding to the current node, and the layer embedding vector of the corresponding ancestor node to obtain the fused node representation;
[0150] The fused node representation is used as the initial hidden state of the corresponding node, and the initial hidden state of each node and the initial hidden state of the corresponding child node are aggregated using a multi-head attention mechanism to obtain a node aggregate hidden state;
[0151] Through bottom-up recursive propagation, the node aggregation hidden state of each node in the layer tree is updated layer by layer until it is propagated to the root node, and the node aggregation hidden state of the root node is determined. The node aggregation hidden state of the root node is input into the terminal pooling layer, and subtree representations of different granularities are extracted by sliding pooling windows of different sizes on the layer tree. Finally, all subtree representations are spliced to obtain a hierarchical representation of the PSD file, including layout information and style features.
[0152] The subtree feature vector specifically refers to the vector representation obtained by aggregating the information of a node and all its child nodes, reflecting the comprehensive features of the current node and its child nodes. In the recursive processing of the layer tree, the features of the child nodes are aggregated layer by layer from the leaf node upward to form the overall representation of the current subtree. The subtree feature vector is used to integrate the features of each node and its child nodes in the recursive processing as the basis for further fusion and hidden state update.
[0153] The fused node representation specifically refers to the comprehensive feature representation obtained by fusing the layer embedding vector of the current node, the subtree feature vector, and the layer embedding vector of the ancestor node. The fused node representation integrates the information of the current node, its child nodes, and ancestor nodes to provide more comprehensive node features. The fused node representation serves as the initial hidden state of the current node and provides input for the subsequent multi-head attention mechanism aggregation;
[0154] The node aggregate hidden state specifically refers to the vector representation obtained by aggregating the initial hidden state of each node with the initial hidden state of its child nodes through the multi-head attention mechanism. The node aggregate hidden state reflects the position of the node in the entire layer tree and its related information, and is updated through layer-by-layer recursive propagation. The node aggregate hidden state is propagated and updated layer by layer, and finally forms a comprehensive representation of the entire layer tree at the root node, which is used to extract the overall layout and style features of the PSD file.
[0155] The layer category information, layer sequence representation, and visual content corresponding to the layer are taken as input and encoded through a pre-built neural network model. The neural network model can be a convolutional neural network, a recurrent neural network, and other structures. The encoding process maps the input to a vector space of a fixed length to generate a layer embedding vector, which represents the semantic information and visual features of the layer.
[0156] Based on the layer embedding vector, the initial representation of each node in the layer tree is determined. According to the hierarchical structure of the PSD file, the layer tree is constructed. The layer tree reflects the hierarchical relationship and nested structure between layers in the PSD file. Each node corresponds to a layer, and the connection between nodes represents the parent-child relationship between layers.
[0157] Starting from the leaf node of the layer tree, each node is processed recursively. For the current node, the pre-built graph neural network is used to aggregate the current node and the child nodes corresponding to the current node. The graph neural network can adopt structures such as graph convolutional network and graph attention network. Through the aggregation operation, the feature vector of the current subtree is obtained to represent the semantic information and structural characteristics of the subtree.
[0158] The subtree feature vector and layer embedding vector corresponding to the current node are fused. At the same time, the layer embedding vector of the ancestor node of the current node is considered and fused with the subtree feature vector and the layer embedding vector of the current node. The fusion operation can be performed by splicing, weighted averaging, etc. to obtain the fused node representation, which represents the semantic information and contextual information of the current node in the layer tree.
[0159] The fused node representation is used as the initial hidden state of the corresponding node. The multi-head attention mechanism is used to aggregate the initial hidden state of each node and the initial hidden state of the corresponding child node. The multi-head attention mechanism captures the dependency and interaction information between nodes by calculating the attention weights between nodes. Through the aggregation operation, the node aggregated hidden state is obtained, which represents the updated hidden state of the node in the layer tree.
[0160] Starting from the leaf node, the node aggregate hidden state is propagated upward layer by layer. For each node, its aggregate hidden state is passed to the parent node. After the parent node receives the aggregate hidden state of the child node, it updates its own aggregate hidden state. The recursive propagation process continues until it reaches the root node. The aggregate hidden state of the root node represents the global information of the entire layer tree.
[0161] The aggregated hidden state of the root node is input into the terminal pooling layer, and pooling windows of different sizes are slid on the layer tree to extract subtree representations of different granularities. The pooling operation can adopt maximum pooling, average pooling, etc. All the extracted subtree representations are spliced to obtain a hierarchical representation of the PSD file. The hierarchical representation contains the layout information and style features of the PSD file, reflecting the hierarchical structure and semantic relationship between layers.
[0162] In this embodiment, the layer category information, layer sequence representation and visual content are encoded into a fixed-length layer embedding vector, which integrates semantic information and visual features to provide a comprehensive representation of the layer; a layer tree is constructed to reflect the hierarchical relationship and nested structure of the layers in the PSD file, which helps to clarify the parent-child relationship and hierarchical relationship between the layers; a graph neural network is used to aggregate the information of the current node and its child nodes to generate a subtree feature vector, which accurately reflects the semantic and structural characteristics of the subtree; the subtree feature vector, the layer embedding vector of the current node and the ancestor node are fused to capture richer contextual information and make the node representation more comprehensive; the hidden states of the nodes and their child nodes are aggregated through a multi-head attention mechanism to capture the dependencies and interaction information between nodes and improve the effectiveness of information transmission; the aggregated hidden states of the nodes are recursively propagated from the bottom to the top, and the node information is transmitted and updated layer by layer to ensure that the state of each node reflects the comprehensive information of its child nodes.
[0163] In an optional embodiment, it also includes:
[0164] The node aggregate hidden state is calculated as follows:
[0165] ;
[0166] in, i represents the node ordinal number, k represents the number of iterations, h i (k)Indicates k After iterations, nodes i The aggregate hidden state of σ represents the activation function, W0 represents the node i The corresponding transformation weight matrix, h i (k-1) Indicates k -1 Node after iteration i The aggregate hidden state of j Indicates the ordinal number of the child node. N ( i ) represents a node i The child node set of W1 represents the child node j The corresponding transformation weight matrix, h j (k-1) Indicates k -Child nodes after 1 iteration j The aggregate hidden state of .
[0167] For each node, in each iteration, first apply a linear transformation to the hidden state of the node in the previous iteration; then, for all child nodes of the node, apply another linear transformation to the hidden state of these child nodes in the previous iteration respectively, and sum the transformation results of all child nodes, add the results, and perform a nonlinear transformation through the activation function to obtain the aggregated hidden state of the node after the current iteration.
[0168] According to the formula, by aggregating the hidden state information of the current node and its child nodes, the semantic and structural information between nodes can be effectively fused, the propagation and sharing of information in the layer tree can be realized, and it is helpful to build a global context representation of each node; through the bottom-up recursive aggregation operation, the hidden state of the node is gradually updated, and finally the global representation of the root node is obtained, which can capture the hierarchical characteristics of the layer tree and generate a richer hierarchical feature representation; through multiple iterations, the representation of each node includes not only its own characteristics, but also the comprehensive information of its child nodes, which can enhance the representation ability of the node and make the representation in the layer tree more comprehensive and accurate; by introducing nonlinear transformation through activation function, the expression ability of the model can be increased, more complex patterns and relationships can be captured, and the generalization ability of the model can be improved; using the predefined transformation weight matrix, the optimal parameters can be learned through the training process, so that the model can adapt to different input data and improve the performance and robustness of the model; this recursive aggregation method is particularly suitable for processing layer structures with complex hierarchical relationships, which can effectively capture the dependencies and mutual influences between layers and improve the ability to extract PSD file layout and style features.
[0169] S104. Based on the layer category information, the layers are grouped and vectorized, layer attributes are extracted, and the layer positions are restored on a blank canvas in combination with the layer sequence representation and the layout information to obtain a restored layout canvas. The style features are matched with a predefined style library to obtain a matching style, and the matching style is applied to the restored layout canvas to determine a PSD restoration image.
[0170] Based on the layer category information, the layers in the PSD file are grouped together. Layers with the same or similar categories are grouped together to form a layer group. The layers in each layer group are vectorized. The vectorization operation converts the layers into vector graphics, retaining the layer's shape, path, and outline information. The vectorized layers are convenient for subsequent editing, scaling, and transformation operations.
[0171] Relevant attribute information is extracted for each layer. The layer attributes include the layer's position, size, transparency, blending mode, etc. The extracted layer attributes are associated with the layer's vector representation.
[0172] Combined with the layer sequence representation and layout information, the layer position is restored on the blank canvas. The stacking order and hierarchical relationship of the layers are determined according to the layer sequence representation. The position and size of each layer on the canvas are determined according to the layout information. According to the determined order and position, the vector representation of the layer is placed on the blank canvas. Through position restoration, the restored layout canvas is obtained, which reflects the original layout and layer arrangement of the PSD file.
[0173] Match the style features of the PSD file with the predefined style library. The style library contains various predefined styles, such as color, font, effect, etc. By comparing the style features with the styles in the style library, find the most similar or matching style. Style matching can use similarity measurement, machine learning algorithm and other methods to obtain matching styles, indicating the predefined style that is closest to the PSD file style.
[0174] Apply the matching style to the restored layout canvas. Adjust and apply the style of the layers on the canvas according to the matching style. Style application includes setting the layer's color, font, effect and other properties. The style application process takes into account the interaction and overlay effects between layers to ensure the coordination and consistency of the style.
[0175] After applying the style, the final PSD restored image is obtained. The PSD restored image presents a similar visual effect and layout to the original PSD file. The restored image retains the layer structure, layout information and style characteristics of the PSD file. The restored image can be used for preview, sharing or further editing and processing.
[0176] In this embodiment, by grouping the layers in the PSD file, the layers can be effectively organized and managed, so that layers with the same or similar categories can be processed uniformly, simplifying subsequent operations and improving processing efficiency; combining the layer sequence representation and layout information, the layer position is restored on the blank canvas, and the vector representation of the layer is accurately located and placed according to the stacking order and hierarchical relationship of the layer, so that the restored layout canvas can truly reflect the original layout and layer arrangement of the PSD file; by matching the style features of the PSD file with the predefined style library, the most similar or most matching style is found and applied to the restored layout canvas, ensuring that the final restored image can be consistent with the visual effect and style of the original PSD file; in the process of style application, the interaction and overlay effects between layers are considered to ensure the coordination and consistency of the style, which can present a more harmonious and unified visual effect, so that the restored image is highly consistent with the original PSD file in visual terms, and the restored image can not only be used for preview and sharing, but also for further editing and processing, and has high practical value.
[0177] Figure 2 FIG. 1 is a schematic diagram of a structure of a PSD file automatic restoration and processing system based on machine learning according to an embodiment of the present invention. Figure 2 As shown, the system comprises:
[0178] The first unit is used to input the PSD file into a layer classification network, extract layer detail features and layer context features for each layer in the PSD file through a convolution operation, generate a layer category probability distribution, select a layer category corresponding to a maximum probability, and determine layer category information;
[0179] The second unit is used to determine the corresponding layer feature vector based on the layer category information, generate the layer neural bundle through the conversion mapping of the fully connected layer, iteratively update the coupling coefficient between the layer neural bundles, calculate the output vector of the upper layer neural bundle, and obtain the layer sequence representation;
[0180] The third unit is used to determine the layer embedding vector based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, construct a layer tree, aggregate each node and the corresponding child node in the layer tree, update the hidden state of the node, obtain the final representation of the root node in the layer tree through bottom-up recursive propagation, and determine the layout information and style features of the PSD file;
[0181] The fourth unit is used to group and vectorize the layers based on the layer category information, extract layer attributes, restore the layer positions on a blank canvas in combination with the layer sequence representation and the layout information, obtain a restored layout canvas, match the style features with a predefined style library, obtain a matching style, apply the matching style to the restored layout canvas, and determine a PSD restored image.
[0182] According to a third aspect of the embodiments of the present invention,
[0183] An electronic device is provided, comprising:
[0184] processor;
[0185] a memory for storing processor-executable instructions;
[0186] The processor is configured to call the instructions stored in the memory to execute the aforementioned method.
[0187] A fourth aspect of the embodiments of the present invention is:
[0188] A computer-readable storage medium is provided, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the aforementioned method is implemented.
[0189] The present invention may be a method, an apparatus, a system and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for executing various aspects of the present invention.
[0190] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. The automatic restoration and processing method of PSD files based on machine learning is characterized by: include: Input the PSD file into the layer classification network, extract the layer detail features and layer context features for each layer in the PSD file through convolution operation, generate the layer category probability distribution, select the layer category corresponding to the maximum probability, and determine the layer category information; Based on the layer category information, the corresponding layer feature vector is determined, and the layer neural bundle is generated through the conversion mapping of the fully connected layer. The coupling coefficient between the layer neural bundles is updated iteratively, and the output vector of the upper layer neural bundle is calculated to obtain the layer sequence representation; Based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, a layer embedding vector is determined, a layer tree is constructed, each node and the corresponding child node in the layer tree are aggregated, the hidden state of the node is updated, and the final representation of the root node in the layer tree is obtained through bottom-up recursive propagation to determine the layout information and style features of the PSD file; Based on the layer category information, the layers are grouped and vectorized, layer attributes are extracted, and the layer positions are restored on a blank canvas in combination with the layer sequence representation and the layout information to obtain a restored layout canvas, the style features are matched with a predefined style library to obtain a matching style, the matching style is applied to the restored layout canvas, and a PSD restoration image is determined; The PSD file is input into the layer classification network. For each layer in the PSD file, the layer detail features and layer context features are extracted through convolution operation to generate the layer category probability distribution. The layer category corresponding to the maximum probability is selected, and the layer category information is determined to include: Input the PSD file into the layer classification network and use the preset PSD parsing library to extract the layer data, including image data, position, size, transparency and blending mode; For each layer data, a pre-trained convolutional neural network is applied to extract layer detail features through convolutional layers and pooling layers. Combined with the pre-built graph convolutional network, the long-range dependencies between layer data and the aggregation information of neighboring layer data are constructed to capture the layer topology and semantic relationships, extract layer context features, and fuse the layer detail features with the layer context features to obtain a comprehensive representation of the layer. The comprehensive representation of the layer is input into the classifier, the probability of the layer belonging to the predefined category is calculated, and the classifier output is normalized to the layer category probability distribution through the Softmax function; Based on the layer category probability distribution, the highest probability is selected. If the highest probability is greater than or equal to a preset category probability threshold, the category corresponding to the highest probability is used as the predicted category of the layer to determine the layer category information; When the highest probability is less than the preset category probability threshold, the unknown category is set, and the predefined categories are expanded by analyzing the comprehensive representation of the layer and combining manual annotation; Based on the layer category information, the corresponding layer feature vector is determined, and the layer neural bundle is generated through the conversion mapping of the fully connected layer. The coupling coefficient between the layer neural bundles is iteratively updated, and the output vector of the upper layer neural bundle is calculated to obtain the layer sequence representation including: Based on a preset embedding matrix, each layer category information is mapped to a low-dimensional dense space to determine a layer feature vector; The layer feature vector is linearly transformed through a predefined fully connected layer, and is mapped into a group of layer neurons by performing matrix multiplication operation with a weight matrix of the fully connected layer, combined with a superimposed bias vector, and a layer neural bundle is generated based on each group of layer neurons; Based on the upper and lower layer relationship of the layer nerve bundle, determining the upper layer nerve bundle and the lower layer nerve bundle; Initialize the coupling coefficient between each lower layer neural bundle and the corresponding upper layer neural bundle according to the preset initial value of the coupling coefficient; Based on each lower neural bundle, a prediction vector of the lower neural bundle is calculated through a preset shared weight matrix and a lower output vector of the lower neural bundle, based on the prediction vector, combined with the coupling coefficient, an upper input vector of the upper neural bundle is obtained, and an upper output vector of the upper neural bundle is calculated through a Squash activation function; Based on the cosine similarity calculated between the prediction vector and the upper layer output vector, the updated coupling coefficient is calculated to obtain a new coupling coefficient, which is iterated in sequence until the preset number of iterations is reached, the latest coupling coefficient is determined, the latest upper layer output vector is calculated, and the layer sequence representation is obtained; Based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, the layer embedding vector is determined, and a layer tree is constructed. By aggregating each node and the corresponding child node in the layer tree, the hidden state of the node is updated, and the final representation of the root node in the layer tree is obtained through bottom-up recursive propagation. The layout information and style features of the PSD file are determined, including: Encoding the layer category information, the layer sequence representation, and the visual content corresponding to the layer into a layer embedding vector of fixed length through a pre-built neural network model; Based on the layer embedding vector, determine the initial representation of the node, and build a layer tree based on the hierarchical structure of the PSD file; Starting from the leaf node of the layer tree, recursively process each node, aggregate the current node and the child nodes corresponding to the current node based on the pre-built graph neural network, obtain the current subtree feature vector, fuse the subtree feature vector with the layer embedding vector corresponding to the current node, and the layer embedding vector of the corresponding ancestor node to obtain the fused node representation; The fused node representation is used as the initial hidden state of the corresponding node, and the initial hidden state of each node and the initial hidden state of the corresponding child node are aggregated using a multi-head attention mechanism to obtain a node aggregate hidden state; Through bottom-up recursive propagation, the node aggregation hidden state of each node in the layer tree is updated layer by layer until it is propagated to the root node, and the node aggregation hidden state of the root node is determined. The node aggregation hidden state of the root node is input into the terminal pooling layer, and subtree representations of different granularities are extracted by sliding pooling windows of different sizes on the layer tree. Finally, all subtree representations are spliced to obtain a hierarchical representation of the PSD file, including layout information and style features.
2. The method according to claim 1, characterized in that: Based on the prediction vector and the coupling coefficient, an upper layer input vector of the upper layer neural bundle is obtained, and the upper layer output vector of the upper layer neural bundle is calculated by the Squash activation function, including: The prediction vector is calculated as follows: ; in, x represents the upper layer nerve bundle number, y represents the number of the lower layer nerve bundle, Indicates the underlying nerve bundle y Upper nerve bundle x The prediction vector of W pred represents the shared weight matrix, s y Indicates the underlying nerve bundle y The lower layer output vector of The upper layer input vector is calculated as follows: ; in, u x Indicates the upper nerve bundle x The upper input vector of m represents the total number of nerve bundles in the lower layer, c xy Indicates the upper nerve bundle x and underlying nerve bundles y The coupling coefficient between The upper layer output vector is calculated as follows: ; in, x represents the upper layer nerve bundle number, u x Indicates the upper nerve bundle x The upper input vector of v x Indicates the upper nerve bundle x The upper output vector of .
3. The method according to claim 1, characterized in that Based on each lower neural bundle, through a preset shared weight matrix and a lower output vector of the lower neural bundle, calculating the prediction vector of the lower neural bundle also includes: Based on all layer neural bundles, multiple aggregation strategies are pre-determined, and multiple aggregation protocols are constructed accordingly; Based on each underlying neural bundle, determining a matching probability between the underlying neural bundle and each of the aggregation protocols; Based on each of the aggregation protocols, the lower-layer output vector corresponding to each lower-layer neural bundle is extracted, combined with the corresponding matching probability, and weighted aggregation is performed to obtain the protocol vector corresponding to the aggregation protocol. The protocol vector is used as the lower-layer output vector, the prediction vector of the lower-layer neural bundle is calculated, and an iterative process is performed.
4. The method according to claim 1, characterized in that: Also includes: The node aggregate hidden state is calculated as follows: ; in, i represents the node ordinal number, k represents the number of iterations, h i (k) Indicates k After iterations, nodes i The aggregate hidden state of σ represents the activation function, W0 represents the node i The corresponding transformation weight matrix, h i (k-1) Indicates k -1 Node after iteration i The aggregate hidden state of j Indicates the ordinal number of the child node. N ( i ) represents a node i The child node set of W1 represents the child node j The corresponding transformation weight matrix, h j (k-1) Indicates k -Child nodes after 1 iteration j The aggregate hidden state of .
5. A PSD file automatic restoration and processing system based on machine learning, used to implement the method described in any one of claims 1 to 4, characterized in that: include: The first unit is used to input the PSD file into a layer classification network, extract layer detail features and layer context features for each layer in the PSD file through a convolution operation, generate a layer category probability distribution, select a layer category corresponding to a maximum probability, and determine layer category information; The second unit is used to determine the corresponding layer feature vector based on the layer category information, generate the layer neural bundle through the conversion mapping of the fully connected layer, iteratively update the coupling coefficient between the layer neural bundles, calculate the output vector of the upper layer neural bundle, and obtain the layer sequence representation; The third unit is used to determine the layer embedding vector based on the layer category information, the layer sequence representation and the visual content corresponding to the layer, construct a layer tree, aggregate each node and the corresponding child node in the layer tree, update the hidden state of the node, obtain the final representation of the root node in the layer tree through bottom-up recursive propagation, and determine the layout information and style features of the PSD file; The fourth unit is used to group and vectorize the layers based on the layer category information, extract layer attributes, restore the layer positions on a blank canvas in combination with the layer sequence representation and the layout information, obtain a restored layout canvas, match the style features with a predefined style library, obtain a matching style, apply the matching style to the restored layout canvas, and determine a PSD restored image.
6. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; The processor is configured to call the instructions stored in the memory to execute the method described in any one of claims 1 to 4.
7. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 4 is implemented.
