Method and system for accurately identifying gear image by using multi-modal model
Through the multi-modal model, combined with the multi-modal Transformer model of ResNet and Llama2, the image and text information are fused to solve the problem of low recognition accuracy of complex mechanical components such as gears in complex environments, and achieve high-precision gear image recognition.
Patent Information
- Application Number
- CN202410762047.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-13
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-06-13
AI Technical Summary
In the image recognition of complex mechanical components such as gears, the existing technology has low recognition accuracy due to factors such as illumination, pollution, and wear. It is especially difficult to achieve high-precision recognition in environments with high complexity and high similarity.
Using a multi-modal model, combined with the multi-modal Transformer model of ResNet and Llama2, through deep learning of image and text information, multi-modal features are integrated to improve the recognition accuracy of gear images. Specific steps include data acquisition and preprocessing, dynamic sample pair selection, multimodal model establishment, advanced fusion strategies, and model training and evaluation.
It significantly improves the recognition accuracy of gear images, enhances the recognition accuracy and consistency of complex gear images, and is suitable for accurate identification and classification of gear types in industrial automation systems.
Smart Images

Figure CN118537705A
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of computer vision and multimodal learning, and in particular to a method and system for accurately identifying gear images using a multimodal model. Background Art
[0002] In the current field of industrial automation and computer vision, accurate recognition of images of complex mechanical parts, especially in the classification and recognition of highly complex parts such as gears, faces major technical challenges. Traditional image recognition methods are single-modal methods that only use images as a recognition method for judgment. Because they are easily affected by factors such as light, pollution, and wear, they are usually unable to cope with diverse industrial environments. In addition, single-modal recognition methods often have less than ideal recognition accuracy when dealing with mechanical parts with complex geometric shapes or high similarities. Especially in the field of gear recognition, since various types of gears are difficult to accurately distinguish from images alone, there is an urgent need to develop gear image recognition methods with high-precision recognition capabilities. Summary of the invention
[0003] In view of the problems existing in the prior art, the purpose of the present invention is to provide a method and system for accurately identifying gear images using a multimodal model, which is achieved by integrating a multimodal Transformer model of ResNet and Llama2. This technology combines image processing and text information processing, and realizes the fusion and modeling of multimodal features through a deep learning model, which can effectively improve the recognition accuracy of gear images.
[0004] To achieve the above object, the present invention provides a method for accurately identifying gear images using a multimodal model. The method realizes gear image recognition by fusing a multimodal Transformer model of ResNet and Llama2. The method comprises the following steps:
[0005] Step S100: data collection and preprocessing; collecting image data and text data from various open source parts libraries and parts standard files, and processing the image data and text data through normalized embedding and data enhancement methods;
[0006] Step S200: Dynamic sample pair selection strategy: using the knowledge and data stored in the knowledge graph to integrate positive and negative sample pairs, and applying the hard negative mining method to generate negative sample pairs;
[0007] Step S300: Establish a multimodal model; the multimodal model includes an image processing branch and a text processing branch, the image processing branch uses a ResNet model for image embedding and model training; the text processing branch uses an LlaMa2 model to obtain text embedding and perform deep text learning;
[0008] Step S400: Advanced fusion strategy: The feature vector of the image and the embedding vector of the text are fused by vector concatenation to form a vector pair, and then the vector pair is input into the multimodal model for training;
[0009] Step S500: model training and evaluation; using contrastive learning method, contrastive loss and triplet loss are used to train the model to achieve gear image recognition; at the same time, the model performance is evaluated on an independent test set.
[0010] Further, step S100 includes:
[0011] Step S101: Collecting gear image data; collecting various types of gear images from various open source parts libraries and parts standard files, and storing them in the knowledge graph;
[0012] Step S102: using GPT-4V to identify gear images; performing preliminary recognition on the collected gear images through GPT-4V and generating corresponding description text;
[0013] Step S103: Text quality check; check the description text generated by GPT-4V to determine whether it meets the standard requirements; if the text does not meet the requirements, return and modify the prompt in the API to ensure that the generated description text is accurate and meets the requirements.
[0014] Further, step S200 includes:
[0015] Step S201: constructing a knowledge graph; by integrating data from various parts libraries and standard documents, a knowledge graph is established to store detailed properties of gears and knowledge in the engineering field;
[0016] Step S202A: Generate positive sample pairs; based on the data in the knowledge graph, generate positive sample pairs from correctly paired images and text descriptions for training the model;
[0017] Step S202B: Generate negative sample pairs; based on the hard negative mining method, generate negative sample pairs that meet the similarity requirements with the positive sample pairs but have different labels to enhance the challenge of model training, wherein step S202B is executed in parallel with step S202A.
[0018] Further, step S300 includes an image processing branch and a text processing branch; wherein the image processing branch includes:
[0019] Step S301A: vectorizing the gear image using the ResNet model; vectorizing the gear image data using the pre-trained ResNet model to generate image feature embedding;
[0020] Step S302A: Extract image features; Continue to use the pre-trained ResNet model to extract the gear image features after vectorization. The image features refer to the visual information that is crucial for the gear recognition task, including: gear edge and shape information (such as contour, tooth shape, size and scale), gear surface texture and pattern (such as material texture and surface wear), color and reflection characteristics under lighting, and local features such as tooth gap, keyway hole and threaded hole;
[0021] The text processing branch includes:
[0022] Step S301B: Use the LlaMa2 model to vectorize the text; input the description text into the LlaMa2 model, perform vectorization processing, and generate text embedding;
[0023] Step S302B: Extract text features: Use the pre-trained LlaMa2 model to process the description text and extract key features in the text embedding. The key features include semantic information (such as the type of gear, its purpose, and how it fits with other mechanical parts), grammatical structure (such as sentence construction and the use of grammatical elements), technical keywords and phrases (covering proprietary terms and key descriptions of gears), and dimensional data and process information (describing the specific dimensions and manufacturing process of the gears).
[0024] Further, step S400 includes:
[0025] Step S401: fusion vector feature fusion: fusing the image feature vector and the text embedding vector through vector concatenation to form a multimodal feature representation;
[0026] Step S402: dimensional conversion of fused vectors: To ensure consistency, the fused vectors are dimensionally converted to make them compatible with the subsequent model structure;
[0027] Step S403: design a multimodal Transformer model; design a multimodal Transformer model, input the fused feature vector into it, so as to combine the gear image with the gear description text to realize gear image recognition.
[0028] Further, step S500 includes:
[0029] Step S501: delivering positive and negative sample pairs to the model in a controlled variable manner; by controlling the variable, delivering the positive and negative sample pairs to the model in order and proportion in a progressive manner;
[0030] Step S502: Designing a learning ratio of positive and negative sample pairs; through experiments and model training experience, designing an appropriate learning ratio of positive and negative sample pairs to ensure that the model learns between positive and negative sample pairs;
[0031] Step S503: designing a loss function to distinguish between positive and negative sample pairs; using a contrastive loss function to distinguish between positive and negative sample pairs;
[0032] Step S504: Recognition of gear images: using the trained model to achieve accurate recognition of gear images.
[0033] Further, in step S202A, the specific operation steps are: extracting text descriptions and corresponding images from the knowledge graph, and determining the correct positive sample pairs based on attribute data and pairing relationships; then, these positive sample pairs are normalized and embedded, the text description is vectorized through the LlaMa2 model, and the image is feature extracted using the ResNet model to ensure the consistency of the two embedding dimensions; on this basis, the image feature vector and the text embedding vector are fused using the vector concatenation method to form the final representation of the positive sample pairs, so as to serve as a reference standard in subsequent model training.
[0034] Further, in step S202B, the specific operation steps are as follows: when constructing negative sample pairs, first obtain attribute data about gears from the knowledge graph and vectorize these data; by calculating the Euclidean distance of the feature vectors, determine the sample pairs that meet the similarity requirements but have different labels; for two feature vectors χ 1 and χ 2 , the calculation formula of Euclidean distance is: where x 1 i and x 2 i is the value of the two eigenvectors in the i-th dimension, and n is the dimension of the eigenvector.
[0035] Further, in step S403, the construction of the multimodal Transformer model includes:
[0036] First, we define the self-attention module, which allows the model to assign different attention weights between features at different positions in the sequence.
[0037] Then, a standard multi-head self-attention mechanism is used to focus on different representation subsets by scaling the dot product attention calculation;
[0038] Then, a Transformer module with self-attention as the core is constructed; it contains 12 Transformer modules, each of which contains a multi-head self-attention mechanism and a feedforward network
[0039] In the model integration stage, a deep network structure is formed by stacking the Transformer blocks;
[0040] Finally, the output layer is constructed; the output layer for the classification task is customized to identify the gear type, while the task of gear property and parameter prediction is achieved by building additional output layers.
[0041] In another aspect, the present invention provides a system for accurately identifying gear images using a multimodal model, the system comprising:
[0042] Data integration and optimization module: collects gear image data and text data from multiple sources, and processes the image data and text data through normalized embedding and data augmentation;
[0043] Dynamic sample scheduling module: Integrate positive and negative sample pairs through knowledge graphs and apply hard negative mining strategies to generate highly challenging negative sample pairs;
[0044] Multimodal architecture design module: A framework with two branches was established: one branch is the image processing branch, which uses the ResNet model to extract gear image features; the other branch is the text processing branch, which uses the LlaMa2 model to vectorize text descriptions and further perform deep training;
[0045] Advanced feature fusion module: image features and text embedding vectors are fused through vector concatenation, and then input into the multimodal Transformer model to achieve gear recognition;
[0046] Deep training and performance evaluation module: The model is trained by combining triplet loss and contrastive loss through contrastive learning method.
[0047] Beneficial effects:
[0048] This paper proposes a new multimodal learning model for accurately identifying gear images by combining the visual language model GPT-4V, the large language model Llama2, and the pre-trained convolutional neural network model ResNet. The model effectively integrates image data and text data, and effectively improves the recognition accuracy of complex gear images through advanced feature extraction and multimodal fusion strategies. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A flow chart of a method for accurate gear image recognition according to the present invention is shown;
[0050] Figure 2 A schematic diagram showing the dynamic generation of positive and negative sample pairs using the knowledge and data stored in KG according to the present invention is shown;
[0051] Figure 3 A high-level fusion diagram of image and text feature vectors is shown according to the multimodal Transformer model of the present invention. DETAILED DESCRIPTION
[0052] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. 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.
[0053] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0054] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0055] The following combination Figure 1-Figure 3 The specific embodiments of the present invention are described in detail. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0056] The present invention provides a method and system for accurate recognition of gear images by integrating a multimodal Transformer model of ResNet and Llama2, which is used for accurate recognition and classification of gear types in industrial automation systems, as well as gear selection for specific engineering tasks.
[0057] This paper presents a multimodal Transformer model combining ResNet and Llama2 technology, which is particularly suitable for industrial automation systems. The specific implementation is as follows: First, a ResNet model is used to extract key visual features from gear images, including but not limited to information such as gear size, shape, surface texture, etc. The deep network structure of the ResNet model allows for effective analysis of these complex image data, thereby identifying the unique features of various types of gears.
[0058] The Llama2 model then processes the gear-related descriptive text, which contains information about the gear material, load capacity, and application range. Llama2 uses its advanced text embedding technology to transform semantic information into a vector form that can be learned by the model, thus supplementing the data provided by the image analysis.
[0059] The data from these two technologies are input into the multimodal Transformer model, which efficiently integrates the feature vectors of images and text through an innovative fusion strategy. Through the self-attention mechanism, the model can assign different weights to different features of the gears and optimize the information processing during the recognition process. Ultimately, the system can accurately identify the type of gear, greatly improving the selection efficiency and accuracy.
[0060] The system for accurately identifying gear images using a multimodal model according to the present invention includes the following five functional modules:
[0061] Data integration and optimization module: responsible for collecting gear images and related text data from various sources, and processing this data through normalized embedding and data enhancement (such as rotation, scaling, cropping, text synonym replacement, etc.) to provide standardized input for subsequent steps.
[0062] Dynamic sample scheduling module: Integrate positive and negative sample pairs through knowledge graphs, and apply hard negative mining strategies to generate highly challenging negative sample pairs, thereby improving the difficulty and effect of model training.
[0063] Multimodal architecture design module: A framework consisting of two branches was established: the image processing branch used the ResNet model to extract gear image features, while the text processing branch used the LlaMa2 model to vectorize the text description and further perform deep training.
[0064] Advanced feature fusion module: Image features and text embedding vectors are fused through vector concatenation and then input into the multimodal Transformer model to improve recognition accuracy and consistency.
[0065] Deep training and performance evaluation module: The model is trained by contrastive learning method, combining triplet loss and contrastive loss. During the training process, the model alternately processes positive and negative sample pairs, and a rigorous evaluation process is used to ensure the generalization ability and stability of the model. Ultimately, this multi-module system design enables the multimodal learning model to have a high degree of accuracy in identifying gear images, and can be used in practical application scenarios such as recommendation and classification of gear types.
[0066] like Figure 1As shown, according to the method for accurately identifying gear images using a multimodal model of the present invention, the method is implemented by integrating a multimodal Transformer model of ResNet and Llama2, and the method includes the following steps:
[0067] Step S100: Data collection and preprocessing: Gear images and related text data are collected from various sources, including various parts libraries and / or parts standard files, and a series of standardized embedding and data enhancement techniques are applied for processing. These techniques include image rotation, scaling, cropping, and synonym replacement of text, aiming to enhance the diversity and quality of data and ensure that in the subsequent multimodal learning process, the model can adapt to a variety of different inputs and maintain high-precision recognition and classification performance, specifically including the following steps S101-S103:
[0068] Step S101: Collect gear image data; collect various types of gear images from various open source parts libraries and parts standard files, and store them in the knowledge graph.
[0069] Step S102: Use GPT-4V to identify gear images; perform preliminary recognition on the collected gear images through GPT-4V and generate corresponding description text.
[0070] Specifically, in step S102, GPT-4V is used to recognize the gear image, and the accuracy and comprehensiveness of the gear text description are enhanced through a prompt strategy specially customized for industrial applications. Specifically, it includes:
[0071] 1. Refine the description requirements: clearly specify the gear characteristics that need to be described in the prompt, such as material, size, type, usage status (newness, wear), etc.
[0072] 2. Add relevant contextual information: Add more context about the gear usage environment in the prompt, such as common mechanical applications or specific industry background, to guide the generation of more professional descriptions;
[0073] 3. Use structured prompts: When constructing prompts, the present invention adopts a phased strategy to guide GPT-4V to describe the physical properties of gears in depth, and then expand to their functions and uses in specific industrial applications, ensuring that the generated description is accurate and fits the actual industrial needs;
[0074] 4. Introduce a comparative selection mechanism: Set the model to generate three different description texts at one time, and then select the most accurate and comprehensive answer through a scoring mechanism and manual screening.
[0075] Step S103: Text quality check: Check the description text generated by GPT-4V to determine whether it meets the standard requirements. If the text does not meet the standard, return and modify the prompt in the API to ensure that the generated description text is accurate and meets the requirements.
[0076] Step S103: Text quality check; check the description text generated by GPT-4V to determine whether it meets the standard requirements. The judgment criteria are divided into two stages: First, the system automatically compares the generated text with the gear types, attribute parameters and dimensional data stored in the knowledge graph. This step ensures that the key numbers contained in the text are consistent with the verified and accurate information source. Secondly, on the basis of ensuring that the key information is accurate, a combination of a scoring mechanism and manual review is used to examine the expression and logical relationship of the text, and select the description text that can most accurately express the gear characteristics. If the generated text does not meet the standards or the quality is too poor, modify the prompt in the API to ensure that the generated description text is accurate and meets the requirements.
[0077] Step S200: The dynamic sample pair selection strategy constructs positive and negative sample pairs based on the knowledge and data stored in the knowledge graph. This strategy introduces the hard negative mining method into the sample generation process, and forms a difficult and challenging sample set by identifying and selecting negative samples with high similarity but different labels from the positive sample pairs. This method aims to increase the difficulty and diversity of model training, ensure that the training process is sufficiently challenging, thereby improving the model's ability to distinguish between different samples, and ultimately enhance the model's generalization performance and accuracy, and specifically includes the following steps S201, S202A, S202B. Among them:
[0078] Step S201: Constructing a knowledge graph; By integrating data from various parts libraries and standard documents, the present invention establishes a knowledge graph to store detailed properties of gears and knowledge in the engineering field. The knowledge graph contains image data of the gears and also integrates text data corresponding to the image, including descriptions such as technical specifications, material type, and size information.
[0079] Step S202A: Generate positive sample pairs; extract text descriptions and corresponding images from the knowledge graph (KG), and determine the correct positive sample pairs based on attribute data and pairing relationships. Then, these positive sample pairs are normalized and embedded, the text descriptions are vectorized using the LlaMa2 model, and the images are feature extracted using the ResNet model to ensure the consistency of the two embedding dimensions. On this basis, the image feature vector and the text embedding vector are fused using the vector concatenation method to form the final representation of the positive sample pair, so that it can be used as a reference standard in subsequent model training.
[0080] Step S202B: Generate negative sample pairs; Figure 2 As shown in the figure, based on the hard negative mining method, when constructing negative sample pairs, the attribute data about the gear is first obtained from the knowledge graph, and the attribute feature vector is generated. The feature vector refers to the conversion of various attribute parameters of the gear into numerical representations, which can be processed by computer programs. For example, the number of teeth can be directly represented as an integer, the material properties can be represented by the index number of the material type, the modulus can be represented as a real number, and the precision level can be encoded as an ordinal level. These numerical features constitute a point in a multidimensional space, namely the feature vector. By calculating the Euclidean distance of the feature vector, the sample pairs with high similarity but different labels are determined. For two feature vectors χ 1 and χ 2 , the calculation formula of Euclidean distance is:
[0081] where x 1 i and x 2 i is the value of the two eigenvectors in the i-th dimension, and n is the dimension of the eigenvector. The smaller the Euclidean distance, the higher the similarity between the samples. For example, two gears may be very similar in attributes such as module, number of teeth, gear shape, and appearance features such as tooth surface profile, but one of them has a special hole position processed while the other does not. This is a highly similar negative sample pair. By comparing the eigenvectors of these attributes, if their similarity reaches a certain threshold, a negative sample pair can be generated.
[0082] In this process, the focus is on identifying sample combinations that are highly similar to positive samples, but there are subtle differences in key features between these samples. This way of generating negative sample pairs provides more challenging data for model training, ensuring that the model can correctly distinguish samples with different labels during the learning process and improving the generalization ability and accuracy of the model.
[0083] In this process, the focus is on identifying sample combinations that have high similarity to positive samples but have slight differences in key features. Key features are determined by referring to expert knowledge and industry practice experience. Among them, key features include tooth shape, number of teeth, size, tooth surface processing type, contour accuracy, surface treatment and other special processing details. The tooth shape includes straight teeth, helical teeth and bevel teeth; the size includes specific measurements such as the top circle diameter, root circle diameter, pitch circle diameter and tooth width; the tooth surface processing type includes no processing, polishing, and hardening; the contour accuracy includes the accuracy grade or tolerance range; the surface treatment includes plating and coating; the processing details include the hub design, the size and type of threaded holes and keyways. This way of generating negative sample pairs provides more challenging data for model training, ensuring that the model can correctly distinguish samples with different labels during the learning process and improve the generalization ability and accuracy of the model.
[0084] Step S300: Construct a multimodal model: The multimodal model framework includes an image processing branch and a text processing branch. The image processing branch uses the ResNet model to extract embedded features from the gear image and trains a deep learning model based on this. The text processing branch uses the Llama2 model to embed the text description to obtain a vectorized representation of the text features, and then conducts deep learning and training on the text data. Specifically, the image processing branch includes the following steps:
[0085] Step S301A: Use the ResNet model to vectorize the gear image; vectorize the gear image data through the pre-trained ResNet model to generate image feature embedding.
[0086] Step S302A: Extract image features; continue to use the pre-trained ResNet model to extract the gear image features after vectorization processing; the image features refer to the visual information used for the gear recognition task, including: gear edge and shape information, gear surface texture and pattern, color and reflection characteristics under illumination, and tooth clearance, keyway hole and threaded hole local features. Among them, the gear edge and shape information includes contour, tooth shape, size and proportion; the gear surface texture and pattern includes material texture and surface wear.
[0087] The text processing branch includes the following steps:
[0088] Step S301B: Use the LlaMa2 model to vectorize the text; input the description text into the LlaMa2 model, perform vectorization processing, and generate text embedding.
[0089] Step S302B: Extract text features: Use the pre-trained LlaMa2 model to process the description text and extract key features in the text embedding. The "key features" here include: semantic information (such as the type of gear, its purpose, and how it fits with other mechanical parts), grammatical structure (such as sentence construction and the use of grammatical elements), technical keywords and phrases (covering proprietary terms and key descriptions of gears), and dimensional data and process information (describing the specific dimensions and manufacturing process of the gears).
[0090] Step S400: Advanced fusion strategy; Figure 3 As shown, through vector concatenation, the image feature vector and the text embedding vector are integrated to form a multimodal feature representation. Then, these fused vectors are input into a carefully designed multimodal Transformer model for deep training. This process aims to improve the model's recognition accuracy for gear images while ensuring the consistency of the recognition results, and specifically includes the following steps S401, S402, and S403.
[0091] Step S401: fusion vector feature fusion: the image feature vector and the text embedding vector are fused by vector concatenation to form a multimodal feature representation.
[0092] Step S402: Dimension conversion of fused vectors: To ensure consistency, the fused vectors are dimensionally converted to make them compatible with the subsequent model structure.
[0093] Step S403: Design a multimodal Transformer model; first, define the self-attention module, which is the basis of the Transformer architecture. Self-attention allows the model to assign different attention weights between features at different positions in the sequence. Among them, the features at different positions include: (1) tooth shape area: including the number, shape, size and gap of teeth; (2) gear edge processing: including gear edge processing, such as chamfering or sharpening; (3) surface texture: including different processing techniques (such as grinding, rolling) will leave different textures on the gear surface, which may appear as subtle grayscale or color changes in the image. In this process, the concepts of query (Q), key (K) and value (V) are introduced, which are automatically adjusted through the learning process to assist the model in capturing complex relationships in the data.
[0094] Then, a standard multi-head self-attention mechanism is used, which enhances the model's attention ability by processing different subspace representations in parallel. By scaling the dot product attention calculation, it is possible to focus on different representation subsets, thereby promoting the synthesis and abstraction of information.
[0095] Subsequently, a Transformer block with self-attention as the core is constructed. This design contains 12 such modules, each of which contains not only a multi-head self-attention mechanism but also a feed-forward network (FFN). In order to stabilize the training process and improve learning efficiency, layer normalization and residual connections are also embedded in each block. In addition, normalization layers are integrated when necessary to prevent overfitting.
[0096] In the model integration phase, a deep network structure is formed by stacking the Transformer blocks defined above. Initially, it is recommended to start experimenting with a model of 6 to 12 layers, which is usually able to handle tasks of medium complexity. The initial evaluation of the model performance will determine whether it is necessary to increase the number of layers to capture more complex data structures.
[0097] Finally, the design of the output layer focuses on the specific requirements of the task. The output layer of the classification task is customized to identify the gear type, while additional output layers are designed for the tasks of gear attribute and parameter prediction. This design ensures the adaptability and flexibility of the model in different tasks.
[0098] The design of the entire multimodal Transformer model takes into account both efficiency and accuracy, thus providing powerful learning capabilities for accurate recognition and type recommendation of gear images.
[0099] Step S500: Model training and evaluation; The model training and evaluation phase adopts a contrastive learning strategy, using contrastive loss and triplet loss as core training methods to enhance the model's ability to distinguish positive and negative sample pairs. During the training process, the learning effect of the model in a multimodal environment is enhanced by introducing a variety of positive and negative sample pairs. After the model training is completed, an independent test set is used to comprehensively evaluate its performance to measure the generalization ability and stability of the model in practical applications. Such an evaluation ensures that the model can accurately identify gear images, and specifically includes the following steps S501-S504.
[0100] Step S501: Deliver positive and negative sample pairs to the model in a controlled variable manner; by controlling the variables, the core is to establish a training sequence from simple to complex to ensure the model's gradual learning and generalization capabilities when recognizing gear images. For positive samples, although the text description and the image match, they are not randomly delivered to the model, but are progressively trained and learned according to the complexity. For example, in a series of gears, there may be three shapes: A-shaped without bosses, B-shaped with bosses, and BK-shaped with bosses and threads. The premise must be that the selected gear set is consistent in other properties. During training, the simplest A-shaped sample will be delivered first, followed by the medium-complexity B-shaped sample, and finally the most complex BK-shaped sample. The purpose is to allow the model to master the basics first, and then gradually understand the differences in complex structures.
[0101] When setting the complexity sequence of gear images, the gears are mainly differentiated based on their design characteristics, processing accuracy, and functional complexity.
[0102] Simple gear images usually show the basic gear shape, with very little additional processing, suitable for general transmission applications, without excessive performance customization requirements; medium-complexity images contain one detail feature among the boss, keyway and threaded hole in the basic gear structure, and are used in mechanical loads and working conditions with high performance requirements; while more complex gear images contain two or more detail features among the boss, keyway and threaded hole, and contain multiple engineering characteristics and sophisticated manufacturing processes, suitable for special application scenarios with high performance and high load. Through the above sequence, progressive training and learning according to the complexity ensures the model's gradual learning and generalization capabilities when recognizing gear images.
[0103] Negative sample pairs are samples where the text description and the image do not match. For negative samples, the model's delivery strategy also follows the idea of controlling variables, but the difference is that negative samples control the similarity between sample pairs. By delivering them in order from high to low similarity, the model can gradually understand the subtle differences between different features and learn to distinguish between similar but mismatched samples.
[0104] By controlling variables in this way, the model can gradually accumulate knowledge during the training process, avoiding abrupt changes and overly complex inputs. This method helps the model learn at a steady pace, ensuring that it is adaptable enough when faced with complex data, while maintaining the consistency and regularity of training.
[0105] Step S502: Designing a learning ratio of positive and negative sample pairs; through experiments and model training experience, designing an appropriate learning ratio of positive and negative sample pairs to ensure that the model learns sufficient information between positive and negative sample pairs.
[0106] The present invention preferably maintains the ratio of positive and negative samples between 1:1 and 1:3. Setting the ratio of positive and negative samples within this range can help the model to effectively identify and exclude wrong gear types while maintaining sufficient recognition of positive samples, ensuring the overall performance of the model and the breadth of application. This balancing strategy helps to avoid overfitting or learning bias and improve the stability and accuracy of the model in actual industrial environments.
[0107] Step S503: Design a loss function to distinguish positive and negative sample pairs; The goal of designing a loss function is to finely distinguish positive and negative sample pairs, thereby guiding the model to correctly separate them in the feature space. To achieve this goal, an effective strategy is to adopt a composite loss function that combines triplet loss and contrast loss.
[0108] The triplet loss function focuses on the relative distance between an anchor sample, a positive sample, and a negative sample. Its purpose is to make the distance between samples of the same class closer than the distance between samples of different classes. In this context, the contrastive loss aims to push samples directly to their corresponding positive samples and away from negative samples. Combining these two losses can provide stronger discrimination ability. Therefore, the designed loss function L can be expressed as:
[0109] L=α·L triplet +β·L contrastive ;
[0110] Among them, L triplet is the triplet loss, L contrastive is the contrast loss, while α and β are the coefficients that adjust the weights of the two parts of the loss.
[0111] The formula for triplet loss is:
[0112]
[0113] The formula for contrast loss is:
[0114]
[0115] Here, f(x) represents the feature vector, a represents the anchor sample, p represents the positive sample, n represents the negative sample, and m is a preset boundary value used to define the minimum distance between positive and negative samples. i is the label of the sample pair, and N is the number of samples.
[0116] This composite loss function allows the model to simultaneously learn the absolute and relative distances between samples in a multimodal space, improving its ability to distinguish between positive and negative sample pairs. By adjusting the values of α and β in the experiment, a balance between the two losses can be achieved to find the best combination for a specific dataset and model architecture.
[0117] Step S504: Gear evaluation and accurate recognition of images; During the training process of the multimodal learning model, the key parameters to be adjusted include batch size, learning rate, and the ratio of positive to negative samples. During training, the model adopts a multimodal fusion strategy to extract features from image and text data respectively. After each training, the performance of the model is evaluated by an independent test set. Model evaluation indicators include accuracy, recall, F1 score, normalized discounted cumulative gain (NDCG), contrastive loss, and triplet loss to ensure the generalization ability and stability of the model. In addition, cross-validation will be used to measure the performance of the model with multiple evaluation criteria to ultimately determine the optimal model configuration. The calculation methods of each indicator are shown in Table 1:
[0118]
[0119] According to Table 1, the calculation formula of accuracy is:
[0120]
[0121] Among them, TP is the number of samples that are correctly classified in the test results; FP is the number of samples that are incorrectly classified as positive. The calculation formula of recall is
[0122]
[0123] Among them, FN is the number of actual positive samples omitted by the model.
[0124] The calculation formula of F1 score is
[0125]
[0126] The calculation formula of normalized discounted cumulative gain (NDCG) is:
[0127]
[0128] Where k is the length of the recommendation list output by the model.
[0129] The formula for calculating contrastive loss is:
[0130]
[0131] Among them, m is the boundary value or threshold of the contrast loss. The goal of the loss function is to minimize the distance between positive sample pairs and to make the distance between negative sample pairs at least greater than the boundary value m.
[0132] The calculation formula for triplet loss is:
[0133]
[0134] Among them, m is used to control the threshold of the distance between positive and negative samples. The model needs to be adjusted to shorten the distance between the anchor point and the positive sample.
[0135] The best model determined after evaluation is used to accurately identify the gear images in the test set.
[0136] The following is an embodiment of the present invention.
[0137] Step S100: Data collection and preprocessing: Gear images and text data are collected from industrial libraries, engineering design documents, and standard documents. The text data sources are divided into two parts: one part comes directly from documents such as technical manuals, which record the physical properties of gears in detail; the other part is the description generated by GPT-4V after identifying the gear image, which not only covers the basic properties of gears, but also contains more extensive information such as application scenarios and functions.
[0138] The image is resized to a uniform size of 224x224 pixels during normalization, and then the image data is processed using the formula:
[0139] Among them, μ is the mean of the image data, and σ is the standard deviation. Then the diversity of image samples is increased by methods such as rotation, scaling, and cropping. Synonym replacement and denoising are performed on the text part to ensure data quality.
[0140] Step S200: Dynamic sample pair selection strategy, using attribute data in the knowledge graph to generate positive and negative sample pairs.
[0141] Use GPT-4V to perform preliminary recognition of gear images and generate corresponding text descriptions.
[0142] Both types of text data are integrated and stored in the knowledge graph, where the text descriptions generated by GPT-4V are further embedded through the Llama model for in-depth model training and analysis.
[0143] To ensure the accuracy of the text description, the following process is adopted:
[0144] First, use GPT-4V to generate a preliminary text description and perform a text quality check. There are two stages to determine whether the content and length of the text description meet the requirements: First, the system automatically compares the description text generated by CPT-4V with the gear type, attribute parameters and dimensional data stored in the knowledge graph. This step ensures that the key numbers contained in the text are consistent with the verified and accurate information source. Secondly, on the basis of ensuring that the key information is accurate, a combination of a scoring mechanism and manual review is used to examine the expression method and logical relationship of the text, and select the description text that can most accurately express the gear characteristics. If the generated text does not meet the standards or the quality is too poor, modify the prompt in the API to ensure that the generated description text is accurate and meets the requirements. If it does not meet the requirements, return and modify the prompt of GPT-4V to regenerate it. Ensure that the text description does not have redundant noise information and retain the core content.
[0145] To ensure the accuracy of the text description, the prompt is designed to generate high-quality text description.
[0146] To ensure the accuracy of text description, a prompt strategy specially customized for the gear field enhances the accuracy and comprehensiveness of gear text description. Specific technologies include:
[0147] 1. Refine the description requirements: clearly specify the gear characteristics that need to be described in the prompt, such as material, size, type, usage status (newness, wear), etc.
[0148] 2. Add relevant contextual information: Add more context about the gear usage environment in the prompt, such as common mechanical applications or specific industry background, to guide the generation of more professional descriptions;
[0149] 3. Use structured prompts: When constructing prompts, we adopted a phased strategy to guide GPT-4V to describe the physical properties of gears in depth, and then expand to their functions and uses in specific industrial applications, ensuring that the generated description is accurate and fits actual industrial needs;
[0150] 4. Introduce a comparison selection mechanism: Set the model to generate three different description texts at a time, and then select the most accurate and comprehensive answer through a scoring mechanism and manual screening. The following Table 2 shows the process of adjusting the prompt to generate text descriptions and the corresponding quality inspection results:
[0151]
[0152]
[0153] Use the attribute data in the knowledge graph to generate positive and negative sample pairs.
[0154] Generation of positive sample pairs: First, obtain the attribute data of the gear from the knowledge graph, and then pair the image and text description. The positive sample pair consists of a correctly paired image and text description.
[0155] Generation of negative sample pairs: First, use the hard negative mining method to select samples that have high similarity with the positive sample pairs but different labels. Then calculate the similarity using the Euclidean distance formula: The differences between negative sample pairs are calculated, and then the sample pairs are sorted according to the calculated distance to ensure that the selection of negative sample pairs can enhance the challenge of model training.
[0156] Step S300: Multimodal model design: Design a multimodal learning model, including two branches: image processing and text processing. The image processing branch uses the ResNet model to extract image features and normalize them. The text processing branch uses Llama2 to embed text descriptions and then perform deep training.
[0157] Step S400: Advanced fusion strategy: concatenate the image features and text features into vectors, and then input them into the multimodal Transformer model for fusion. This step shows the fusion process through the formula:
[0158] V=[V image , V text ];
[0159] Among them, V is the fused multimodal feature vector, V image represents the feature vector extracted from the gear image, V text Represents the feature vector extracted from the relevant text description.
[0160] Step S500: Model training and evaluation, using contrast loss and triplet loss for model training. The loss function is calculated as:
[0161] L=α·L triplet +β·L contrastive ;
[0162] Among them, L triplet is the triplet loss, L contrastive is the contrast loss, while α and β are the coefficients that adjust the weights of the two parts of the loss.
[0163] The formula for triplet loss is:
[0164]
[0165] The formula for contrast loss is:
[0166]
[0167] Here, f(x) represents the feature vector, a represents the anchor sample (a reference point selected from the data set as a comparison point, usually highly representative, and able to represent the typical features of a category or group. In the case of gear recognition, it means that the selected anchor sample should typically reflect the general properties and features of this type of gear), p represents the positive sample pair, n represents the negative sample pair, and m is a preset boundary value used to define the minimum distance between positive and negative samples. i is the label of the sample pair, and N is the number of samples.
[0168] During the training process, an independent test set is used to evaluate the model performance, measuring the accuracy, recall, F1 score and normalized discounted cumulative gain (NDCG) to determine the best model configuration.
[0169] After the model training is completed, it is applied to the industrial production line to identify gear images. The key points of this step are:
[0170] 1. Use multimodal learning models for gear image recognition to ensure high accuracy.
[0171] 2. Use performance metrics to evaluate the model to ensure the generalization ability of the model in real-world environments.
[0172] The key points of the present invention are:
[0173] Multimodal fusion architecture integrating visual and language models: This invention achieves deep fusion of visual information and text information by integrating cutting-edge visual and language models, such as GPT-4V and Llama2, to create a multimodal Transformer model. This fusion strategy enriches the contextual dimension of the model's information processing, while significantly enhancing the model's interpretation and reasoning capabilities. The key innovation is that through this multimodal architecture, the model is able to integrate and utilize complex knowledge that each modality cannot provide independently, thereby greatly improving the recognition accuracy and processing efficiency of gear images. This architecture ensures that information from different data sources can be effectively fused and interacted within a unified framework, bringing unprecedented accuracy and depth to gear image recognition.
[0174] Refined text generation enhances the accuracy of the gear identification system: This invention adopts a set of prompt strategies designed specifically for the gear field. This strategy is implemented through the following four core steps: First, clearly specify the gear characteristics that need to be described in the prompt, such as material, size, and type, to ensure that the text information fully matches the actual properties of the gear. Secondly, add detailed contextual information about the gear usage environment to guide the generation of more professional and specific descriptions. In addition, we use a phased strategy to build the prompt, starting with a description of the physical properties of the gear and gradually expanding to its function and value in specific industrial applications. Finally, by generating multiple text options and using a scoring mechanism and manual review to select the optimal text description, this not only improves the quality of the text, but also ensures the high accuracy and reliability of the model when processing professional and technical content. This innovative strategy significantly improves the performance and practicality of the entire system.
[0175] High-quality sample generation and progressive training strategy: This paper uses knowledge graph and hard negative mining strategy to generate high-quality positive and negative sample pairs. This method ensures the diversity and sufficient challenge of training data, providing rich learning materials for model training.
[0176] During the model training process, a progressive training strategy is adopted to gradually introduce more difficult negative sample pairs by controlling the ratio of positive and negative sample pairs. This strategy allows the model to be exposed to positive sample pairs in the early stages to help the model establish basic feature recognition capabilities; in the later stages, the ratio of negative sample pairs is increased to enhance the model's learning ability for complex samples. Through progressive training, it is ensured that the model can effectively distinguish between positive and negative samples and improve generalization capabilities.
[0177] Refined contrastive learning and hybrid loss function design: This invention optimizes the model training process through a refined contrastive learning method and an innovative combination of contrastive loss and triplet loss. This hybrid loss function design is tailored to the characteristics of the multimodal feature space and can accurately distinguish between positive and negative sample pairs. The key innovation is that this loss function not only considers the direct differences between samples (contrastive loss), but also considers the relative position of samples in the multimodal space (triplet loss). Through this composite strategy, the boundary values and weight parameters of the model can be adjusted more effectively. This method enhances the model's sensitivity to subtle feature differences, improves the stability of training and the accuracy of the model, thereby significantly improving performance in practical applications.
[0178] According to the multimodal gear recognition method of the present invention, the multimodal model has stronger interpretation and processing capabilities compared to traditional single-modal recognition. Under this technical framework, the system can simultaneously analyze information from images and text descriptions to better understand the characteristics of complex components. Through the combination of deep learning and large language models, higher accuracy and flexibility are provided for the recognition of complex components.
[0179] The present invention provides a method for effectively fusing data of different modes, designing an adaptive feature extraction algorithm, and developing an efficient data preprocessing strategy, which has the technical advantage of high recognition accuracy in industrial environments, especially in the field of gear recognition. The development of this technology will promote the further improvement of industrial intelligence and bring higher efficiency and accuracy to the manufacturing industry.
[0180] Any process or method description in the flowchart of the present invention or described in other ways herein can be understood as a module, segment or part of a code including one or more executable instructions for implementing the steps of a specific logical function or process, which can be implemented in any computer-readable medium for use by an instruction execution system, device or equipment, and the computer-readable medium can be any medium containing storage, communication, propagation or transmission programs for use by execution systems, devices or equipment, including read-only memories, magnetic disks or optical disks, etc.
[0181] In the description of this specification, the description with reference to the terms "embodiment", "example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. In addition, those skilled in the art can combine or combine different embodiments or examples described in this specification and the features therein without causing any contradiction.
[0182] Although the above content has shown and described the embodiments of the present invention, it can be understood that the above embodiments are exemplary and cannot be understood as limitations of the present invention. Ordinary technicians in the field can change, modify, replace, modify and other update operations on the above embodiments within the scope of the present invention.
Claims
1. A method for accurately identifying gear images using a multimodal model, characterized in that: The method realizes gear image recognition by fusing a multimodal Transformer model of ResNet and Llama2; the method comprises the following steps: Step S100: data collection and preprocessing; collecting image data and text data from various open source parts libraries and parts standard files, and processing the image data and text data through normalized embedding and data enhancement methods; Step S200: Dynamic sample pair selection strategy; Use the knowledge and data stored in the knowledge graph to integrate positive and negative sample pairs, and apply the hard negative mining method to generate negative sample pairs; Step S300: Establish a multimodal model; the multimodal model includes an image processing branch and a text processing branch, the image processing branch uses a ResNet model for image embedding and model training; the text processing branch uses an LlaMa2 model to obtain text embedding and perform deep text learning; Step S400: Advanced fusion strategy: The feature vector of the image and the embedding vector of the text are fused by vector concatenation to form a vector pair, and then the vector pair is input into the multimodal model for training; Step S500: model training and evaluation; using contrastive learning method, contrastive loss and triplet loss are used to train the model to achieve gear image recognition; at the same time, the model performance is evaluated on an independent test set.
2. The method for accurate gear image recognition according to claim 1, characterized in that: Step S100 includes: Step S101: Collecting gear image data; collecting various types of gear images from various open source parts libraries and parts standard files, and storing them in the knowledge graph; Step S102: using GPT-4V to identify gear images; performing preliminary recognition on the collected gear images through GPT-4V and generating corresponding description text; Step S103: Text quality check; check the description text generated by GPT-4V to determine whether it meets the standard requirements; if the text does not meet the requirements, return and modify the prompt in the API to ensure that the generated description text is accurate and meets the requirements.
3. The method for accurate gear image recognition according to claim 1, characterized in that: Step S200 includes: Step S201: constructing a knowledge graph; by integrating data from various parts libraries and standard documents, a knowledge graph is established to store detailed properties of gears and knowledge in the engineering field; Step S202A: Generate positive sample pairs; based on the data in the knowledge graph, generate positive sample pairs from correctly paired images and text descriptions for training the model; Step S202B: Generate negative sample pairs; based on the hard negative mining method, generate negative sample pairs that meet the similarity requirements with the positive sample pairs but have different labels to enhance the challenge of model training, wherein step S202B is executed in parallel with step S202A.
4. The method for accurate gear image recognition according to claim 1, characterized in that: Step S300 includes an image processing branch and a text processing branch; The image processing branches include: Step S301A: vectorizing the gear image using the ResNet model; vectorizing the gear image data using the pre-trained ResNet model to generate image feature embedding; Step S302A: extracting image features; continuing to use the pre-trained ResNet model to extract the gear image features after vectorization processing; the image features refer to the visual information used for the gear recognition task, including: edge and shape information of the gear, texture and pattern of the gear surface, color and reflection characteristics under illumination, and local features of tooth clearance, keyway hole and threaded hole; The text processing branch includes: Step S301B: Use the LlaMa2 model to vectorize the text; input the description text into the LlaMa2 model, perform vectorization processing, and generate text embedding; Step S302B: extract text features; use the pre-trained LlaMa2 model to process the description text and extract key features in the text embedding; the key features include semantic information, grammatical structure, technical keywords and phrases, as well as dimensional data and process information.
5. The method for accurate gear image recognition according to claim 1, characterized in that: Step S400 includes: Step S401: fusion vector feature fusion: fusing the image feature vector and the text embedding vector through vector concatenation to form a multimodal feature representation; Step S402: dimensional conversion of fused vectors: To ensure consistency, the fused vectors are dimensionally converted to make them compatible with the subsequent model structure; Step S403: design a multimodal Transformer model; design a multimodal Transformer model, input the fused feature vector into it, so as to combine the gear image with the gear description text to realize gear image recognition.
6. The method for accurate gear image recognition according to claim 1, characterized in that: Step S500 includes: Step S501: delivering positive and negative sample pairs to the model in a controlled variable manner; by controlling the variable, delivering the positive and negative sample pairs to the model in order and proportion in a progressive manner; Step S502: Designing a learning ratio of positive and negative sample pairs; through experiments and model training experience, designing an appropriate learning ratio of positive and negative sample pairs to ensure that the model learns between positive and negative sample pairs; Step S503: designing a loss function to distinguish between positive and negative sample pairs; using a contrastive loss function to distinguish between positive and negative sample pairs; Step S504: Recognition of gear images: using the trained model to achieve accurate recognition of gear images.
7. The method for accurate gear image recognition according to claim 3, characterized in that: In step S202A, the specific operation steps are: extract text descriptions and corresponding images from the knowledge graph, and determine the correct positive sample pairs based on attribute data and pairing relationships; then, these positive sample pairs are normalized and embedded, the text description is vectorized through the LlaMa2 model, and the image is feature extracted using the ResNet model to ensure the consistency of the two embedding dimensions; on this basis, the image feature vector and the text embedding vector are merged using the vector concatenation method to form the final representation of the positive sample pair, so as to serve as a reference standard in subsequent model training.
8. The method for accurate gear image recognition according to claim 3, characterized in that: In step S202B, the specific operation steps are as follows: when constructing negative sample pairs, first obtain attribute data about gears from the knowledge graph and vectorize these data; by calculating the Euclidean distance of the feature vectors, determine the sample pairs that meet the similarity requirements but have different labels; for two feature vectors χ1 and χ2, the calculation formula of the Euclidean distance is: Where x1i and x2i are the values of the two eigenvectors in the i-th dimension, and n is the dimension of the eigenvector.
9. The method for accurate gear image recognition according to claim 5, characterized in that: In step S403, the construction of the multimodal Transformer model includes: First, we define the self-attention module, which allows the model to assign different attention weights between features at different positions in the sequence. Then, a standard multi-head self-attention mechanism is used to focus on different representation subsets by scaling the dot product attention calculation; Then, a Transformer module with self-attention as the core is constructed; it contains 12 Transformer modules, each of which contains a multi-head self-attention mechanism and a feedforward network In the model integration stage, a deep network structure is formed by stacking the Transformer blocks; Finally, the output layer is constructed; the output layer for the classification task is customized to identify the gear type, while the task of gear property and parameter prediction is achieved by building additional output layers.
10. A system for accurately identifying gear images using a multimodal model, characterized in that: The system is used to implement the method according to any one of claims 1 to 9, and the system includes: Data integration and optimization module: collects gear image data and text data from multiple sources, and processes the image data and text data through normalized embedding and data augmentation; Dynamic sample scheduling module: integrates positive and negative sample pairs through knowledge graphs, and applies hard negative mining strategies to generate highly challenging negative sample pairs; Multimodal architecture design module: A framework with two branches was established: one branch is the image processing branch, which uses the ResNet model to extract gear image features; the other branch is the text processing branch, which uses the LlaMa2 model to vectorize text descriptions and further perform deep training; Advanced feature fusion module: image features and text embedding vectors are fused through vector concatenation, and then input into the multimodal Transformer model to achieve gear recognition; Deep training and performance evaluation module: The model is trained by combining triplet loss and contrastive loss through contrastive learning method.
Citation Information
Patent Citations
Open domain relation extraction method and system based on adaptive clustering
CN116662457A
Pedestrian re-identification method based on image-text multi-modal fusion
CN117079310A
Transform-based image-text multi-modal system operation and maintenance knowledge matching method and system
CN117788987A
Multi-modal model training method, target object detection method and system
CN117935019A
News event search method and system based on multi-level image-text semantic alignment model
WO2023093574A1
Cited By
3D design auxiliary method based on multi-modal input and intelligent optimization
CN119832157A
Data leakage risk quantification method for autoregression language model training process
CN120541866A
