Image recognition method and device based on scan coding, equipment and storage medium

By using a scan-encoding-based image recognition method, which employs image segmentation algorithms and pre-trained models for self-labeling, the problem of low efficiency in image recognition technology is solved, achieving rapid classification and efficient recognition.

CN116452870BActive Publication Date: 2026-07-21PING AN TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
PING AN TECH (SHENZHEN) CO LTD
Filing Date
2023-04-04
Publication Date
2026-07-21

Smart Images

  • Figure CN116452870B_ABST
    Figure CN116452870B_ABST
Patent Text Reader

Abstract

The application provides an image recognition method and device based on scan coding, equipment and storage medium, which classifies and identifies pictures in a scan coding manner, cuts a to-be-tested mark picture with a small amount of mark data through an image cutting algorithm, obtains a target binary tree corresponding to the to-be-tested mark picture, performs full-level image scanning on the to-be-tested mark picture, and maintains the correlation of the image; and based on a small amount of artificial mark parameters of the to-be-tested mark picture, a parameter model that can be matched is quickly found in a pre-training model, so that the to-be-tested mark picture is quickly marked, and the training efficiency is improved. The application can quickly match the training model parameters, quickly self-mark the to-be-tested mark picture, avoids a complicated training process, and effectively improves the application efficiency of the image recognition model. The application relates to the technical field of image processing and can improve the application efficiency of the image recognition model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image recognition method, apparatus, device and storage medium based on scan coding. Background Technology

[0002] Currently, image intelligent recognition applications are an important part of modern business operations. For almost all operational businesses, there are numerous advanced cases of using image recognition technology to replace manual labor.

[0003] However, the application of image intelligent recognition is often limited, mainly because applications in specific scenarios require a large number of labeled samples for fine-tuning. Labeling requires significant manpower, and the accuracy of the model still lags behind manual recognition. Therefore, replacing specific commercial operations with image intelligent recognition is often not cost-effective from a cost assessment perspective. For example, in the auto insurance industry, assessing vehicle damage requires collecting numerous images of damaged areas from different angles for model training, and manually labeling a large number of parameters to obtain accurate recognition results, making the application efficiency of image recognition models low.

[0004] Therefore, how to solve the current low efficiency of image recognition applications has become an urgent technical problem. Summary of the Invention

[0005] This application provides an image recognition method, apparatus, device, and storage medium based on scan coding, which aims to...

[0006] In a first aspect, this application provides an image recognition method based on scan coding, the image recognition method based on scan coding comprising the following steps:

[0007] Obtain the image to be tested and segment it based on an image segmentation algorithm to generate a target binary tree;

[0008] Traverse the nodes of the target binary tree to generate at least one target sequence;

[0009] Based on the pre-trained model and the pre-labeled data in the image to be tested, the target sequence is self-labeled to obtain labeling parameters. Based on the labeling parameters, the image to be tested is classified and predicted to determine the classification category corresponding to the image to be tested.

[0010] Secondly, this application also provides an image recognition device based on scan coding, the image recognition device based on scan coding comprising:

[0011] The target binary tree generation module is used to acquire the image to be tested and segment the image to be tested based on an image segmentation algorithm to generate a target binary tree.

[0012] The target sequence generation module is used to traverse the nodes of the target binary tree and generate at least one target sequence;

[0013] The classification category determination module is used to self-label the target sequence based on the pre-trained model and the pre-labeled data in the image to be tested, obtain labeling parameters, and perform classification prediction on the image to be tested based on the labeling parameters to determine the classification category corresponding to the image to be tested.

[0014] Thirdly, this application also provides a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, it implements the steps of the image recognition method based on scan encoding as described above.

[0015] Fourthly, this application also provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, it implements the steps of the image recognition method based on scan encoding as described above.

[0016] This application provides an image recognition method, apparatus, device, and storage medium based on scan coding. This application classifies and recognizes images using scan coding. Through an image segmentation algorithm, a test image with limited labeled data is segmented to obtain a target binary tree corresponding to the test image. This allows for full-level image scanning of the test image, hierarchically recording the correlation between images and maintaining their associative properties. By traversing all nodes of the target binary tree, a corresponding target sequence is generated. Based on the pre-labeled data in the test image, a pre-trained model self-labels the target sequence, thus completing the parameter labeling of the test image. Based on the labeling parameters, the category of the test image can be predicted, thereby completing the recognition of the test image. The pre-labeled data can be used as reference data to quickly find matching parameter models in the pre-trained model, thereby achieving rapid labeling of the test image and improving training efficiency. This application can quickly match training model parameters and rapidly self-label test images, avoiding cumbersome training processes and effectively improving the application efficiency of image recognition models. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 An image recognition system based on scan encoding is provided for embodiments of this application;

[0019] Figure 2 This application provides a schematic flowchart of a first embodiment of an image recognition method based on scan coding.

[0020] Figure 3 This application provides a schematic flowchart of a second embodiment of an image recognition method based on scan coding.

[0021] Figure 4 This is a schematic block diagram of an image recognition device based on scan encoding provided in an embodiment of this application;

[0022] Figure 5 This is a schematic block diagram of the structure of a computer device provided in an embodiment of this application.

[0023] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0024] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0025] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0026] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0027] The embodiments of this application provide an image recognition method, an image recognition device, a computer device, and a storage medium based on scan coding, for quickly matching training model parameters and rapidly self-labeling test images, avoiding the cumbersome training process and improving the application efficiency of the image recognition model.

[0028] like Figure 1 As shown, Figure 1 An image recognition system based on scan encoding is provided for an embodiment of this application. The system includes a terminal and a server, which are communicatively connected, and the server is communicatively connected to a database.

[0029] The terminals include electronic devices such as mobile phones, tablets, laptops, desktop computers, personal digital assistants, and wearable devices.

[0030] The server may be a single independent server or a server cluster.

[0031] The following will provide a detailed description of the scan-coding-based image recognition method provided in the embodiments of this application, based on the scan-coding-based image recognition system.

[0032] Please refer to Figure 2 , Figure 2 This is a schematic flowchart of a first embodiment of an image recognition method based on scan coding provided in this application. This scan coding-based image recognition method can be used in the server of a scan coding-based image recognition system.

[0033] like Figure 2 As shown, the image recognition method based on scan coding includes steps S101 to S103.

[0034] Step S101: Obtain the image to be tested and segment it based on the image segmentation algorithm to generate a target binary tree.

[0035] In this embodiment, when acquiring the image to be labeled, a small amount of labeling is required manually. Based on this small amount of labeled data, the classification model is quickly fine-tuned, and then the image to be labeled is self-labeled and classified for prediction using this classification model. Before self-labeling, the image to be labeled is segmented based on an image segmentation algorithm, dividing it into several parts and forming a target binary tree.

[0036] In one exemplary implementation, fine-tuning a classification model refers to adjusting a pre-trained model based on labeled data, avoiding training from scratch, saving significant computational resources and time, and improving computational efficiency and accuracy. In deep learning, the parameters (weights) of a pre-trained model need to be continuously trained / updated in deep networks to fit a model that achieves the expected results. However, training in deep neural networks involves large-scale models with many parameters, so training from scratch consumes significant computational resources and time. Furthermore, for complex tasks, such as object recognition with many object categories, improving model performance requires training with large datasets (e.g., large amounts of labeled image data). Alternatively, adding new object categories to an already trained model increases costs and wastes resources when the target model has high similarity to the existing model's requirements. Fine-tuning based on an existing model, however, saves considerable time and resources.

[0037] In one exemplary embodiment, the image segmentation algorithm can be a binary tree-based image segmentation method. It uses a grayscale image as the root node, and based on the consistency of grayscale image pixels, it uses a regional distance metric to perform region splitting, thereby constructing a split binary tree of the image.

[0038] Step S102: Traverse the nodes of the target binary tree to generate at least one target sequence.

[0039] In this embodiment, multiple target sequences are formed by traversing all nodes of the target binary tree. If the image has m layers of binary tree after being segmented, then 2m-1 sequences will be generated.

[0040] In one exemplary implementation, for a binary tree, there are depth-first traversal and breadth-first traversal. Depth-first traversal has three methods: preorder, inorder, and postorder. Breadth-first traversal is also known as level-order traversal. Since the definition of a tree is inherently recursive, using recursion to implement the three tree traversals is not only easy to understand but also results in concise code. However, breadth-first traversal requires the support of other data structures, such as a heap.

[0041] In this context, preorder, inorder, and postorder traversal refer to the order in which the root node is visited. Preorder traversal proceeds from the root node to the left and then the right subtree; inorder traversal proceeds from the left subtree to the root node and then the right subtree; and postorder traversal proceeds from the left subtree to the right subtree and then back to the root node. Level-order traversal simply follows the level-order order of the binary tree. For example, given a binary tree with root node 1, left subtree level 1 containing 2, level 2 containing 4 and 5, and right subtree level 1 containing 3 and level 2 containing 6, the preorder traversal order is 124536. Serialization encoding simply adds the output for empty nodes to the regular traversal. For example, for the preorder traversal result 124536, the serialization encoding output is 1, 2, 4, #, 5, #, 3, 6, #, where # represents an empty node, thus uniquely identifying the binary tree.

[0042] Step S103: Based on the pre-trained model and the pre-labeled data in the image to be tested, the target sequence is self-labeled to obtain labeling parameters, and based on the labeling parameters, the image to be tested is classified and predicted to determine the classification category corresponding to the image to be tested.

[0043] In this embodiment, in the Decoder network, for the labeled image to be tested, the binary tree of the labeled image to be tested is first segmented and serialized. Then, the pre-trained model in the Encoder network is used to train the serialized encoded data of the labeled image to be tested. The pre-trained model is fine-tuned based on a small amount of labeled data in the labeled image to be tested, and the corresponding model data is quickly located to self-label the labeled image to be tested.

[0044] In one exemplary implementation, during the serialization encoding of the image to be labeled, there may ultimately be n sequences of descriptions. These n sequences are trained using a model trained on an Encoder network, potentially generating n predicted values ​​z(z1-zn), which is equivalent to linearization. After completing the prediction training of the pre-trained model, a softmax layer can be used to train the labeling parameters of the image to be labeled, thereby identifying and classifying the category of the image. For example, in vehicle damage assessment applications, a classification model can be used to identify the damaged parts of the vehicle uploaded by the property insurance company, such as bumpers, tires, and fenders.

[0045] In this embodiment, a pre-trained model incorporating algorithms such as binary tree image encoding, serialization encoding, and self-attention encoding is used to identify and self-label the target image. While retaining the global attention characteristics of convolutional neural networks (CNNs), it can also superimpose hierarchical attention, enabling rapid self-searching, self-labeling, and unsupervised learning of samples. Furthermore, after iteratively fine-tuning the supervised learning of a small sample, the pre-trained model can be directly applied to identify the target image, reducing the cost of model usage. It can also self-iterate and optimize online, improving the application efficiency of intelligent image recognition.

[0046] The image recognition method based on scanning encoding provided in the above embodiments classifies and recognizes images through scanning encoding. It uses an image segmentation algorithm to segment the test image with a small amount of labeled data, thereby obtaining the target binary tree corresponding to the test image. This allows for full-level image scanning of the test image, hierarchically recording the correlation between images and maintaining their associative properties. By traversing all nodes of the target binary tree, a corresponding target sequence is generated. Based on the pre-labeled data in the test image, a pre-trained model self-labels the target sequence, thus completing the parameter labeling of the test image. Based on the labeling parameters, the category of the test image can be predicted, thereby completing the recognition of the test image. The pre-labeled data can be used as reference data to quickly find matching parameter models in the pre-trained model, thereby achieving rapid labeling of the test image and improving training efficiency. This application can achieve rapid matching of training model parameters and rapid self-labeling of the test image, avoiding the cumbersome training process and effectively improving the application efficiency of the image recognition model.

[0047] Please refer to Figure 3 , Figure 3 This is a schematic flowchart of a second embodiment of an image recognition method based on scan coding provided in this application.

[0048] like Figure 3 As shown, based on the above Figure 2 In the illustrated embodiment, prior to step S101, the method further includes:

[0049] S201. Obtain the training database, and based on the image segmentation algorithm, segment the training images in the training database to generate an image binary tree corresponding to each training image; wherein, the training database includes at least one of the training images.

[0050] In this embodiment, the encoder network is trained using a large amount of image data to generate a pre-trained model suitable for image recognition. The training process mainly includes binary tree encoding of images, traversal generation of serialized encoding, and a self-attention network. Through training on a large amount of image data, as well as multi-level scanning and self-attention training of the image data, an application model is finally generated.

[0051] The main function of image binary tree encoding is to perform full-level image scanning, recording the correlations between images hierarchically. Combined with self-attention network training, it ensures correlation without having to focus on the characteristics of the entire image every time. The training network can automatically collect various training images; for example, in a vehicle damage model, it can collect images related to car collisions.

[0052] Further, step S201 specifically includes:

[0053] Based on the grayscale algorithm, the training image is converted into a grayscale image. Based on the image segmentation algorithm, the grayscale image is segmented to obtain segmented images. The average pixel value of the grayscale image is used as the root node, and the segmented images are used as child nodes to form a binary tree.

[0054] Based on the image segmentation algorithm, the segmented image is segmented to obtain segmented sub-images, and the segmented sub-images are added to the binary tree as child nodes;

[0055] Based on the image segmentation algorithm, the sub-image is segmented until the smallest segmentation unit is reached, and the sub-image obtained from each segmentation is added to the binary tree as a node to generate the image binary tree.

[0056] In this embodiment, to reduce the amount of computational data, the training images can be processed using grayscale images, so each pixel represents a value between 0 and 255. The image size is unlimited, making the application wider and more applicable.

[0057] Furthermore, step S201 specifically includes:

[0058] Obtain the row and column pixel values ​​of the grayscale image, and determine the direction of image segmentation based on the comparison results of the row and column pixel values;

[0059] When the row pixel value or column pixel value corresponding to the image cutting direction is odd, supplement the corresponding row pixel value or column pixel value to obtain an even value row pixel value or column pixel value.

[0060] The grayscale image is segmented based on the even-valued row or column pixel values ​​to obtain the segmented image. Then, the segmented image is further segmented based on the image segmentation algorithm until it is segmented to the smallest segmentation unit, thereby generating the image binary tree.

[0061] In this embodiment, during image segmentation, it is necessary to ensure that the pixel values ​​in the rows and columns of the training image are even. If they are odd, a row or column can be added and assigned the value 255 (white). Then, the training image is segmented: if the number of rows is less than the number of columns, it is cut in half vertically; if the number of rows is greater than the number of columns, it is cut in half horizontally. Pooling encoding is performed on the two resulting sub-images, i.e., a global pooling layer is used to generate a mean pixel for all pixels. This results in a sequence of two values, ordered from left to right and top to bottom, such as 203 and 188. This process is repeated until the smallest pixel is reached. At this point, a binary tree is generated.

[0062] Pooling encoding refers to generating a mean pixel value using a global pooling layer on all pixels. In this embodiment, average pooling can be used for pooling encoding. The essence of a pooling layer is downsampling. Because the dimensionality of data increases significantly after convolution, and the feature map doesn't change much, multiple consecutive convolutions result in a large number of parameters. This not only greatly increases the difficulty of network training but also easily leads to overfitting. Therefore, a pooling layer is usually placed after the convolutional layer to compress the data, reduce dimensionality, and decrease the number of parameters. For images, a convolutional layer convolves a neighborhood of the image to obtain neighborhood features, while pooling integrates feature points within a small neighborhood to obtain new features. Pooling encoding is mainly used to maintain invariance (rotation, translation, scaling, etc.), remove redundant information, reduce parameters, and prevent overfitting.

[0063] Specifically, pooling is used to aggregate and statistically analyze a pixel with its surrounding data points, reducing the size of the feature map. Then, the mean or maximum value of the neighboring regions is taken to further reduce the number of parameters. Through pooling, the extracted features are also more adaptable to factors such as lighting. Pooling can fuse feature maps from the previous layer because the parameters in adjacent regions have strong correlations, and it also prevents overfitting.

[0064] S202. Traverse the nodes of the image binary tree to generate at least one standard sequence;

[0065] In this embodiment, traversal generation of serialization encoding refers to traversing the binary tree generated from the training image. If the training image has m layers of binary tree after being segmented, then 2m-1 standard sequences can be generated.

[0066] In one exemplary implementation, serialization is streaming, which is the conversion of data into a byte stream. In computer science data processing, serialization refers to the process of converting the state of a data structure or object into a usable format (e.g., saving it as a file, storing it in a buffer, or sending it over a network) so that the original state can be restored later in the same or another computer environment. When retrieving bytes according to the serialized format, it can be used to produce a copy with the same semantics as the original object.

[0067] S203. Generate the pre-trained model based on the self-attention network and the standard sequences corresponding to each training image.

[0068] In this embodiment, image training is performed using a self-attention network combined with image binary tree encoding. This ensures image correlation without having to focus on the characteristics of the entire image each time. While maintaining the accuracy of image recognition, it reduces the amount of training data, thereby improving the application efficiency of the image recognition model.

[0069] Specifically, when processing image problems, each pixel can be viewed as a three-dimensional vector, with the dimension being the number of channels in the image. Therefore, an image can also be seen as many vectors input into the model. The self-attention mechanism is similar in concept to Convolutional Neural Networks (CNNs), both aiming to prevent the network from considering only a single vector. In CNNs, the model is expected to consider a receptive field, not just a single pixel. For self-attention, the model essentially decides the shape and type of the receptive field itself. Therefore, CNNs are essentially a special case of self-attention; self-attention is a more complex version of CNNs.

[0070] Furthermore, based on the above Figure 3 In the illustrated embodiment, the step of self-labeling the target sequence based on the pre-trained model and the pre-labeled data in the image to be tested to obtain labeling parameters specifically includes:

[0071] Based on the marker data in the marker image to be tested, a detection sequence corresponding to the marker data is determined in the target sequence;

[0072] Based on the pre-trained model, a sequence matching the detection sequence is queried in the standard sequence and used as a self-labeled sequence;

[0073] Based on the pre-trained model and the self-labeled sequence, the target sequence is self-labeled to obtain the labeling parameters.

[0074] In this embodiment, before inputting the image to be labeled into the Decoder network, a small amount of data needs to be manually labeled on the image to be labeled so that the pre-trained model can quickly find the corresponding self-labeled sequence based on this small amount of data, and fine-tune the pre-trained model to achieve fast labeling of the image to be labeled.

[0075] In one exemplary implementation, during model training, a randomly initialized model is used to generate labels for augmented unlabeled images. Then, a new set of labels is obtained by clustering the unlabeled images. The model is trained again on these new label sets and optimized with cross-entropy loss. This process is repeated for many epochs to obtain the final labels and the trained model. In the self-labeling process, matching labels (i.e., self-labeling sequences) are queried based on the labeling data in the image to be labeled. The epochs corresponding to these labels are then reactivated to fine-tune the pre-trained model. Using this pre-trained model and the self-labeling sequence, the image to be labeled is automatically labeled, thus obtaining the labeling parameters. Based on these labeling parameters, the image is then classified and predicted. For example, the classification model can identify whether the damaged parts of a vehicle uploaded for insurance purposes are the bumper, tires, or fenders.

[0076] Furthermore, based on the above Figure 2 In the illustrated embodiment, the step of performing classification prediction on the image to be tested based on the labeling parameters to determine the classification category corresponding to the image to be tested specifically includes:

[0077] Based on the labeling parameters, generate a number of predicted values ​​corresponding to the target sequence;

[0078] Based on the preset output softmax layer, the predicted value is trained for multi-class classification to obtain training parameters, and the classification category is determined based on the training parameters.

[0079] In this embodiment, n sequences are generated through binary tree encoding and serialization encoding of the labeled image to be tested. These n sequences are then trained using a pre-trained model to generate n predicted values ​​z(z1-zn), which is equivalent to linearization. The predicted values ​​are then output to a softmax layer. This softmax layer is used to classify and train the self-labeled image samples, obtaining training parameters. The pre-trained model can then use these training parameters to classify and predict the labeled image to be tested, thus outputting the image recognition result.

[0080] Understandably, the last layer of a deep neural network is often a fully connected layer plus a softmax layer (for classification networks). The features extracted by the neural network from the input data are used as the input to the fully connected layer, which outputs the training results. Softmax, on the other hand, converts the training results into probabilities through mapping.

[0081] In one exemplary implementation, the function of softmax is to map an array that can have any values ​​to an interval, where each value belongs to (0, 1), and the sum of all values ​​is 1, which can be understood as a probability. For example, if the interval after softmax is [0.88, 0.12, 0], then the probability that this image belongs to the first class is P = 0.88.

[0082] Furthermore, based on the above Figure 2 In the illustrated embodiment, after step S103, the method further includes:

[0083] Obtain the target sequence and the labeling parameters corresponding to the labeled image to be tested, and use them as sample data corresponding to the classification category;

[0084] Based on the supervised learning results of the sample data, test examples are obtained, and based on the test examples, the current pre-trained model is iteratively optimized to obtain the pre-trained model.

[0085] In this embodiment, the pre-trained model can quickly collect samples, self-label, and perform unsupervised learning. After iterative fine-tuning with a small sample of supervised learning, it can be directly applied, greatly reducing the cost of model usage. It also supports online self-iterative optimization, effectively improving the application efficiency of intelligent image recognition. The processing of the test labeled images is the same as the training process of the pre-trained model. After classifying and recognizing the test labeled images, the sample data of the test labeled images can be saved as test cases and added to the model database. Furthermore, through supervised learning of the sample data, the pre-trained model can be fine-tuned, thereby achieving self-iterative optimization and improving the application efficiency of intelligent image recognition.

[0086] Please see Figure 4 , Figure 4 This is a schematic block diagram of an image recognition device based on scan encoding, provided in an embodiment of this application. This scan encoding-based image recognition device is used to execute the aforementioned scan encoding-based image recognition method. The scan encoding-based image recognition device can be configured in a terminal.

[0087] like Figure 4 As shown, the moving target detection device 300 includes: a target binary tree generation module 301, a target sequence generation module 302, and a classification category determination module 303.

[0088] The target binary tree generation module 301 is used to acquire the image to be tested and segment the image to be tested based on an image segmentation algorithm to generate a target binary tree.

[0089] The target sequence generation module 302 is used to traverse the nodes of the target binary tree and generate at least one target sequence;

[0090] The classification category determination module 303 is used to self-label the target sequence based on the pre-trained model and the pre-labeled data in the image to be tested, obtain labeling parameters, and perform classification prediction on the image to be tested based on the labeling parameters to determine the classification category corresponding to the image to be tested.

[0091] In one embodiment, the image recognition device based on scan coding further includes a pre-trained model generation module, used to acquire a training database, segment the training images in the training database based on the image segmentation algorithm, and generate an image binary tree corresponding to each training image; wherein, the training database includes at least one training image; traverse the nodes of the image binary tree to generate at least one standard sequence; and generate the pre-trained model based on the self-attention network and the standard sequence corresponding to each training image.

[0092] In one embodiment, the pre-trained model generation module is further configured to: determine the detection sequence corresponding to the label data in the target sequence based on the label data in the label image to be tested; query the standard sequence for a sequence that matches the detection sequence based on the pre-trained model, and use it as a self-labeled sequence; and self-label the target sequence based on the pre-trained model and the self-labeled sequence to obtain the labeling parameters.

[0093] In one embodiment, the pre-trained model generation module is further configured to: convert the training image into a grayscale image based on a grayscale algorithm; segment the grayscale image based on the image segmentation algorithm to obtain segmented images; construct a binary tree with the average pixel value of the grayscale image as the root node and the segmented images as child nodes; segment the segmented images based on the image segmentation algorithm to obtain sub-segments and add the sub-segments as child nodes to the binary tree; and segment the sub-segments based on the image segmentation algorithm until the smallest segmentation unit is reached, adding the sub-images obtained from each segmentation as nodes to the binary tree to generate the image binary tree.

[0094] In one embodiment, the pre-trained model generation module is further configured to obtain the row pixel values ​​and column pixel values ​​of the grayscale image, determine the image cutting direction based on the comparison results of the row pixel values ​​and the column pixel values; when the row pixel values ​​or column pixel values ​​corresponding to the image cutting direction are odd, supplement the corresponding row pixels or column pixels to obtain even-valued row pixel values ​​or column pixel values; cut the grayscale image based on the even-valued row pixel values ​​or column pixel values ​​to obtain the segmented image, and then segment the segmented image based on the image cutting algorithm until it is segmented to the smallest segmentation unit to generate the image binary tree.

[0095] In one embodiment, the classification category determination module 303 is further configured to generate a number of predicted values ​​corresponding to the target sequence based on the label parameters; perform multi-class training on the predicted values ​​based on a preset output softmax layer to obtain training parameters, and determine the classification category based on the training parameters.

[0096] In one embodiment, the image recognition device based on scan coding further includes a pre-trained model optimization module, used to obtain the target sequence and the labeling parameters corresponding to the labeled image to be tested, as sample data corresponding to the classification category; obtain test examples based on the supervised learning results of the sample data, and iteratively optimize the current pre-trained model based on the test examples to obtain the pre-trained model.

[0097] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the device and each module described above can be referred to the corresponding processes in the aforementioned embodiments of the image recognition method based on scanning encoding, and will not be repeated here.

[0098] The apparatus provided in the above embodiments can be implemented as a computer program, which can be used in, for example... Figure 5 It runs on the computer device shown.

[0099] Please see Figure 5 , Figure 5 This is a schematic block diagram illustrating the structure of a computer device according to an embodiment of this application. The computer device may be a terminal.

[0100] See Figure 5 The computer device includes a processor, memory, and network interface connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.

[0101] Non-volatile storage media can store operating systems and computer programs. These computer programs include program instructions that, when executed, cause the processor to perform any scan-encoded image recognition method.

[0102] The processor provides computing and control capabilities, supporting the operation of the entire computer device.

[0103] Internal memory provides an environment for the execution of computer programs stored in non-volatile storage media. When executed by a processor, the computer program enables the processor to perform any image recognition method based on scan coding.

[0104] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0105] It should be understood that the processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.

[0106] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps:

[0107] Obtain the image to be tested and segment it based on an image segmentation algorithm to generate a target binary tree;

[0108] Traverse the nodes of the target binary tree to generate at least one target sequence;

[0109] Based on the pre-trained model and the pre-labeled data in the image to be tested, the target sequence is self-labeled to obtain labeling parameters. Based on the labeling parameters, the image to be tested is classified and predicted to determine the classification category corresponding to the image to be tested.

[0110] In one embodiment, before acquiring the image to be tested, segmenting the image to be tested based on an image segmentation algorithm, and generating a target binary tree, the processor is also configured to:

[0111] A training database is obtained, and the training images in the training database are segmented based on the image segmentation algorithm to generate an image binary tree corresponding to each training image; wherein, the training database includes at least one training image; the nodes of the image binary tree are traversed to generate at least one standard sequence; the pre-trained model is generated based on the self-attention network and the standard sequence corresponding to each training image.

[0112] In one embodiment, the processor, based on the pre-trained model and the pre-labeled data in the labeled image to be tested, performs self-labeling on the target sequence to obtain labeling parameters, for the purpose of:

[0113] Based on the labeled data in the image to be tested, a detection sequence corresponding to the labeled data is determined in the target sequence; based on the pre-trained model, a sequence matching the detection sequence is queried in the standard sequence as a self-labeled sequence; based on the pre-trained model and the self-labeled sequence, the target sequence is self-labeled to obtain the labeling parameters.

[0114] In one embodiment, when the processor implements the image segmentation algorithm to segment the training images in the training database and generate image binary trees corresponding to each training image, it is configured to:

[0115] Based on the grayscale algorithm, the training image is converted into a grayscale image. Based on the image segmentation algorithm, the grayscale image is segmented to obtain segmented images. The average pixel value of the grayscale image is used as the root node, and the segmented images are used as child nodes to form a binary tree. Based on the image segmentation algorithm, the segmented images are further segmented to obtain sub-segments, and these sub-segments are added to the binary tree as child nodes. Based on the image segmentation algorithm, the sub-segments are segmented until the smallest segmentation unit is reached, and each sub-image obtained from the segmentation is added to the binary tree as a node to generate the image binary tree.

[0116] In one embodiment, when the processor implements the image segmentation algorithm to segment the training images in the training database and generate image binary trees corresponding to each training image, it is also configured to implement:

[0117] Obtain the row and column pixel values ​​of the grayscale image. Based on the comparison results of the row and column pixel values, determine the image cutting direction. When the row or column pixel value corresponding to the image cutting direction is odd, supplement the corresponding row or column pixels to obtain an even-valued row or column pixel value. Based on the even-valued row or column pixel values, cut the grayscale image to obtain the segmented image. Then, based on the image cutting algorithm, segment the segmented image until it is segmented to the smallest segmentation unit, generating the image binary tree.

[0118] In one embodiment, when the processor performs classification prediction on the image to be tested based on the labeling parameters to determine the classification category corresponding to the image to be tested, it is configured to:

[0119] Based on the labeling parameters, a number of predicted values ​​corresponding to the target sequence are generated; based on the preset output softmax layer, the predicted values ​​are trained for multi-class classification to obtain training parameters, and based on the training parameters, the classification category is determined.

[0120] In one embodiment, after implementing the classification prediction of the image to be tested based on the labeling parameters and determining the classification category corresponding to the image to be tested, the processor is further configured to implement:

[0121] Obtain the target sequence and the labeling parameters corresponding to the labeled image to be tested, as sample data corresponding to the classification category; based on the supervised learning results of the sample data, obtain test examples, and based on the test examples, iteratively optimize the current pre-trained model to obtain the pre-trained model.

[0122] The embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions, and the processor executing the program instructions to implement any of the image recognition methods based on scan encoding provided in the embodiments of this application.

[0123] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.

[0124] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. An image recognition method based on scan coding, characterized in that, The steps of the method include: A training database is obtained, and the training images in the training database are segmented based on an image segmentation algorithm to generate an image binary tree corresponding to each training image; wherein, the training database includes at least one training image; Traverse the nodes of the image binary tree to generate at least one standard sequence; A pre-trained model is generated based on the self-attention network and the standard sequences corresponding to each training image; Obtain the image to be tested and segment it based on the image segmentation algorithm to generate a target binary tree; By combining serialization encoding, the nodes of the target binary tree are traversed to generate at least one target sequence; Based on the pre-trained model and the pre-labeled data in the image to be tested, the target sequence is self-labeled to obtain labeling parameters. Based on the labeling parameters, the image to be tested is classified and predicted to determine the classification category corresponding to the image to be tested. The step of self-labeling the target sequence based on the pre-trained model and the pre-labeled data in the image to be tested to obtain labeling parameters includes: Based on the pre-labeled data in the image to be tested, the target sequence is queried for a label that matches the pre-labeled data to determine the detection sequence; Based on the pre-trained model, a sequence matching the detection sequence is queried in the standard sequence and used as a self-labeled sequence; Based on the pre-trained model and the self-labeled sequence, the target sequence is self-labeled to obtain the labeling parameters.

2. The image recognition method based on scan coding according to claim 1, characterized in that, The step of segmenting the training images in the training database based on the image segmentation algorithm to generate an image binary tree corresponding to each training image includes: Based on the grayscale algorithm, the training image is converted into a grayscale image. Based on the image segmentation algorithm, the grayscale image is segmented to obtain segmented images. The average pixel value of the grayscale image is used as the root node, and the segmented images are used as child nodes to form a binary tree. Based on the image segmentation algorithm, the segmented image is segmented to obtain segmented sub-images, and the segmented sub-images are added to the binary tree as child nodes; Based on the image segmentation algorithm, the sub-image is segmented until the smallest segmentation unit is reached, and the sub-image obtained from each segmentation is added to the binary tree as a node to generate the image binary tree.

3. The image recognition method based on scan coding according to claim 2, characterized in that, The step of segmenting the training images in the training database based on the image segmentation algorithm to generate an image binary tree corresponding to each training image further includes: Obtain the row and column pixel values ​​of the grayscale image, and determine the direction of image segmentation based on the comparison results of the row and column pixel values; When the row pixel value or column pixel value corresponding to the image cutting direction is odd, supplement the corresponding row pixel value or column pixel value to obtain an even value row pixel value or column pixel value. The grayscale image is segmented based on the even-valued row or column pixel values ​​to obtain the segmented image. Then, the segmented image is further segmented based on the image segmentation algorithm until it is segmented to the smallest segmentation unit, thereby generating the image binary tree.

4. The image recognition method based on scan coding according to claim 1, characterized in that, The step of classifying and predicting the classification of the labeled image based on the labeling parameters to determine the classification category corresponding to the labeled image includes: Based on the labeling parameters, generate a number of predicted values ​​corresponding to the target sequence; Based on the preset output softmax layer, the predicted value is trained for multi-class classification to obtain training parameters, and the classification category is determined based on the training parameters.

5. The image recognition method based on scan coding according to any one of claims 1-4, characterized in that, After classifying and predicting the classification category of the image to be tested based on the labeling parameters, the process further includes: Obtain the target sequence and the labeling parameters corresponding to the labeled image to be tested, and use them as sample data corresponding to the classification category; Based on the supervised learning results of the sample data, test examples are obtained, and based on the test examples, the current pre-trained model is iteratively optimized to obtain the pre-trained model.

6. An image recognition device based on scan coding, characterized in that, include: A pre-trained model generation module is used to acquire a training database, segment the training images in the training database based on an image segmentation algorithm, and generate an image binary tree corresponding to each training image; wherein, the training database includes at least one training image; traverse the nodes of the image binary tree to generate at least one standard sequence; and generate the pre-trained model based on a self-attention network and the standard sequence corresponding to each training image. The target binary tree generation module is used to acquire the image to be tested and segment the image to be tested based on an image segmentation algorithm to generate a target binary tree. The target sequence generation module is used to combine serialization encoding, traverse the nodes of the target binary tree, and generate at least one target sequence; The classification category determination module is used to self-label the target sequence based on the pre-trained model and the pre-labeled data in the image to be tested, obtain labeling parameters, and perform classification prediction on the image to be tested based on the labeling parameters to determine the classification category corresponding to the image to be tested. The classification category determination module is further configured to: query the target sequence for a label that matches the pre-labeled data in the pre-labeled image to be tested, and determine the detection sequence; query the standard sequence for a sequence that matches the detection sequence based on the pre-trained model, and use it as a self-labeled sequence; and perform self-labeling on the target sequence based on the pre-trained model and the self-labeled sequence to obtain the labeling parameters.

7. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable by the processor, wherein when the computer program is executed by the processor, it implements the steps of the image recognition method based on scan encoding as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the image recognition method based on scan coding as described in any one of claims 1 to 5.