Target identification method and device, equipment and storage medium
By training the target recognition model and using the enhanced sample images after marking and misalignment adjustment, the problem of low target recognition accuracy in the prior art is solved, and higher recognition accuracy and anti-interference ability are achieved.
Patent Information
- Application Number
- CN202411722675.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-04-18
AI Technical Summary
In the prior art, the target recognition accuracy is low, which can easily lead to false locking and misidentification of background or irrelevant objects as the target.
By marking the area of interest in the initial sample image and misaligning the pixels, an enhanced sample image is generated, a sample image collection is constructed, and the target recognition model is trained.
It improves the accuracy and accuracy of target recognition, enhances the generalization performance and anti-interference ability of the model, and reduces the probability of false locking.
Smart Images

Figure CN119850905A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a target recognition method, device, equipment and storage medium. Background Art
[0002] With the rapid development of artificial intelligence technology, computer vision has become a key technology in many fields such as autonomous driving, security monitoring and medical diagnosis. In these applications, target recognition technology plays a vital role, requiring accurate identification and location of specific targets in complex and changing environments.
[0003] In the prior art, target recognition is usually performed through traditional machine learning algorithms and deep learning models. However, the prior art often encounters the problem of false locking during the target recognition process, that is, the background or irrelevant objects are mistakenly recognized as the target, resulting in low target recognition accuracy. Summary of the invention
[0004] The present invention provides a target recognition method, device, equipment and storage medium, which are used to solve the defect of low target recognition accuracy in the prior art and achieve the purpose of improving the target recognition accuracy.
[0005] The present invention provides a target recognition method, comprising: Obtain an image to be recognized; Inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; Among them, the target recognition model is obtained by training the initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target. The enhanced sample image is obtained by dislocating the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
[0006] According to a target recognition method provided by the present invention, the target recognition model is trained based on the following method: For each of the initial sample images, identifying and marking a focus area in the initial sample image by a self-attention mechanism; Performing misalignment adjustment on the pixels of the focus area to obtain an enhanced sample image corresponding to the initial sample image; Constructing the sample image set based on each of the initial sample images and each of the enhanced sample images; Inputting the sample images in the sample image set into the feature extraction module of the initial target recognition model to obtain the sample features output by the feature extraction module; Inputting the sample features into the classification module of the initial target recognition model to obtain a predicted target recognition result output by the classification module; Based on the predicted target recognition result and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain the target recognition model.
[0007] According to a target recognition method provided by the present invention, the identifying and marking of the focus area in the initial sample image by the self-attention mechanism includes: Extracting features from the initial sample image to obtain image features; Determining, by the self-attention mechanism, an importance score of each image region in the initial sample image based on the image features and the target recognition task type; The image region corresponding to the highest importance score is determined as the focus region.
[0008] According to a target recognition method provided by the present invention, the pixel displacement adjustment of the focus area is performed to obtain an enhanced sample image corresponding to the initial sample image, including: Performing misalignment adjustment on the pixels of the focus area based on a preset number of pixels in a target direction to obtain a reference sample image, wherein the target direction includes at least one of the following: a horizontal direction, a vertical direction, and a diagonal direction; Performing a target transformation on the reference sample image to obtain the enhanced sample image, wherein the target transformation includes at least one of the following: rotation, scaling, and flipping.
[0009] According to a target recognition method provided by the present invention, the method further includes: In the case of receiving a feedback message indicating that the target recognition result is wrong, the model parameters of the target recognition model are fine-tuned based on the image to be recognized and the correct recognition result of the image to be recognized.
[0010] According to a target recognition method provided by the present invention, the model parameters of the initial target recognition model are adjusted based on the predicted target recognition result and the target recognition label of the corresponding sample image to obtain the target recognition model, including: Based on the predicted target recognition result representing the recognized target and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain a reference recognition model, the enhanced sample images corresponding to the predicted target recognition result representing the unrecognized target in the sample image set are deleted to obtain a remaining image set, the model parameters of the reference recognition model are adjusted based on the remaining sample images in the remaining image set, and the above steps are repeated until the target recognition model is obtained.
[0011] According to a target recognition method provided by the present invention, the feature extraction module includes a convolutional neural network, and the classification module includes a support vector machine.
[0012] The present invention also provides a target recognition device, comprising: An acquisition module, used for acquiring an image to be recognized; An input module, used for inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; Among them, the target recognition model is obtained by training the initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target. The enhanced sample image is obtained by dislocating the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, any of the target recognition methods described above is implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the target recognition method described in any one of the above is implemented.
[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the target recognition methods described above.
[0016] The target recognition method, device, equipment and storage medium provided by the present invention can obtain a target recognition result output by the target recognition model by acquiring an image to be recognized and inputting the image to be recognized into a target recognition model, wherein the target recognition model is obtained by training an initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target, and the enhanced sample image is obtained by dislocating and adjusting the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target. Since the focus area containing the sample target in the initial sample image can be marked, when the target recognition model is trained, the model will focus more on the content of the focus area, so that the trained target recognition model can avoid misidentifying the background or other irrelevant objects as the target to be recognized when performing target recognition, thereby improving the accuracy of target recognition. In addition, the pixels in the area of interest are adjusted by the offset augmentation technology, and the obtained enhanced sample image is also added to the sample image set for training the target recognition model. This can enhance the generalization performance and anti-interference ability of the trained target recognition model, so that the target recognition model can better cope with targets at different angles and positions, while reducing the probability of false locking, further improving the accuracy of target recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A schematic diagram of a flow chart of a target recognition method provided by an embodiment of the present invention.
[0019] Figure 2 A schematic diagram of the structure of a target recognition device provided by an embodiment of the present invention.
[0020] Figure 3 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0022] With the rise of deep learning, Convolutional Neural Network (CNN) has become the mainstream method for target recognition. Pure CNN models such as ResNet, YOLO and Faster R-CNN can automatically learn the hierarchical features of images, and are therefore widely used in various target recognition tasks. However, although the pure CNN model is powerful in feature learning, CNN is easily affected by noise and background interference, resulting in false locks, and will mistakenly identify background or irrelevant objects as the target to be identified, thereby reducing the recognition precision and accuracy of the target.
[0023] In view of the above problems, an embodiment of the present invention proposes a target recognition method, in which, when training a target recognition model, the initial sample image will be marked with a focus area, and the pixels in the focus area will be adjusted by offset, so as to obtain an enhanced sample image. Since the focus area contains sample targets, when the target recognition model is subsequently trained, attention can be focused on the focus area, so that the target recognition model can lock the target more accurately when performing target recognition and avoid false locking. In addition, by adjusting the pixels in the focus area by offset, a plurality of enhanced sample images are obtained, and the enhanced sample images are added to the training samples, so that the generalization ability and anti-interference ability of the target recognition model can be enhanced. Therefore, when the target is recognized by the target recognition model, the precision and accuracy of the target recognition can be improved.
[0024] The target recognition method provided by the embodiment of the present invention is described below. The embodiment of the present invention can be applicable to scenarios where target recognition is required, such as autonomous driving, security monitoring, and medical diagnosis. The execution subject of the method can be an electronic device such as a camera device, a terminal device, a computer, a server, a server cluster, or a specially designed target recognition device, or a target recognition device set in the electronic device, which can be implemented by software, hardware, or a combination of the two.
[0025] Figure 1 A flow chart of a target recognition method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes: Step 101: Obtain an image to be recognized.
[0026] In this embodiment, the image to be identified may be an image captured in real time by a camera device, or may be an image captured in advance and stored in a database.
[0027] Step 102: Input the image to be recognized into the target recognition model to obtain the target recognition result output by the target recognition model.
[0028] Among them, the target recognition model is obtained by training the initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target. The enhanced sample image is obtained by dislocating the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
[0029] In this step, the acquired image to be identified can be input into a pre-trained target recognition model, so that the target in the image to be identified can be identified by the target recognition model to obtain a target recognition result. The target includes a vehicle, a pedestrian, or a traffic sign. The target recognition result includes whether there is a target in the image to be identified, or the type of the target contained in the image to be identified.
[0030] The above-mentioned target recognition model is obtained after training the constructed initial target recognition model based on each training sample in the sample image set. Among them, the sample image set includes at least one initial sample image and at least one enhanced sample image corresponding to each initial sample image. Specifically, after image acquisition for the sample target, at least one initial sample image containing the sample target can be obtained. For each initial sample image, a focus mechanism can be used to determine and mark the focus area in the initial sample image, wherein the focus area is a relatively important area of the initial sample image, or a part that needs to be focused on. For example, for the face recognition task, the focus area in the initial sample image includes the user's facial area, and for the pedestrian tracking task, the focus area in the initial sample image is the area including the pedestrian. It should be understood that since the area containing the sample target in the initial sample image is marked, when the target recognition model is trained, the model will pay more attention to the content of the focus area, and when the target recognition is performed later, it will focus on the area containing the target in the image to be recognized, thereby avoiding false locking of the target.
[0031] Furthermore, after marking the region of interest in each initial sample image, the pixels of the region of interest are adjusted by dislocation enhancement technology, thereby obtaining at least one enhanced sample image corresponding to the initial sample image. The obtained enhanced sample image is added to the sample image set for training the target recognition model, which can enhance the generalization performance and anti-interference ability of the trained target recognition model, so that the target recognition model can better cope with targets at different angles and positions, while reducing the probability of false locking.
[0032] The target recognition method provided by the embodiment of the present invention can obtain the target recognition result output by the target recognition model by acquiring the image to be recognized and inputting the image to be recognized into the target recognition model, wherein the target recognition model is obtained by training the initial target recognition model based on the sample image set, the sample image set includes at least one enhanced sample image and at least one initial sample image containing the sample target, the enhanced sample image is obtained by dislocation adjustment of the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target. Since the focus area containing the sample target in the initial sample image can be marked, when the target recognition model is trained, the model will focus more on the content of the focus area, so that the trained target recognition model can avoid the situation of misidentifying the background or other irrelevant objects as the target to be recognized when performing target recognition, thereby improving the accuracy of target recognition. In addition, the pixels of the focus area are dislocated by dislocation enhancement technology, and the obtained enhanced sample image is also added to the sample image set for training the target recognition model, which can enhance the generalization performance and anti-interference ability of the trained target recognition model, so that the target recognition model can better cope with targets at different angles and positions, while reducing the probability of false locking, further improving the accuracy of target recognition.
[0033] Exemplarily, based on the above embodiment, the target recognition model is trained based on the following method: For each initial sample image, the focus area in the initial sample image is identified and marked through the self-attention mechanism, and the pixels in the focus area are offset and adjusted to obtain an enhanced sample image corresponding to the initial sample image. Based on each initial sample image and each enhanced sample image, a sample image set is constructed, and the sample images in the sample image set are input into the feature extraction module of the initial target recognition model to obtain the sample features output by the feature extraction module, and the sample features are input into the classification module of the initial target recognition model to obtain the predicted target recognition result output by the classification module. Based on the predicted target recognition result and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain the target recognition model.
[0034] Specifically, for each initial sample image, the focus mechanism can be used to identify the focus area in the initial sample image. The focus area is the most important part of the initial sample image. Focusing on the focus area can lock the target more accurately, avoid false locks, and better identify and understand the target. For example, when the focus area in the initial sample image is identified and marked by the self-attention mechanism, the initial sample image can be feature extracted to obtain image features. The importance score of each image area in the initial sample image is determined based on the image features and the target recognition task type through the self-attention mechanism, and the image area corresponding to the highest importance score is determined as the focus area.
[0035] Specifically, the input initial sample image can be analyzed and feature extracted by the deep learning model to obtain the image features output by the deep learning model, wherein the image features may include, for example, color, texture, and shape. These image features can be used to better understand the image and provide a basis for subsequent analysis of the content of each area in the initial sample image.
[0036] After extracting the image features, the self-attention mechanism is used to analyze and evaluate the image features of different image regions in the initial sample image based on the image features and the task type of target recognition, thereby obtaining the importance score of each image region, which is used to determine the position of the focus, that is, the position of the focus region. For example, the image region corresponding to the highest importance score can be determined as the focus region in the initial sample image.
[0037] For example, for the task of face recognition, the self-attention mechanism can be used to analyze that the importance of facial features in the initial sample image is relatively high. Therefore, the importance score of the facial area can be set to a higher value, so that the facial area is the determined focus area.
[0038] In the above method, due to different task types, the areas that need to be focused on are different. Therefore, the importance scores of each image area in the initial sample image can be determined based on the image features and the target recognition task type, and the image area corresponding to the highest importance score is determined as the focus area. Therefore, the focus area related to the target recognition task type can be determined specifically, making the determined focus area more accurate. In addition, the focus area can be dynamically adjusted based on the target recognition task type to cope with changes in different scenes and targets, ensuring that the target can still be accurately identified in a complex background.
[0039] After determining the area of interest in the initial sample image, the pixels of the area of interest may be adjusted by dislocation enhancement to obtain at least one enhanced sample image corresponding to the initial sample image. For example, the pixels of the area of interest may be adjusted by dislocation based on a preset number of pixels in a target direction to obtain a reference sample image, where the target direction includes at least one of the following: horizontal direction, vertical direction, and diagonal direction, and then the reference sample image may be subjected to a target transformation to obtain an enhanced sample image, where the target transformation includes at least one of the following: rotation, scaling, and flipping.
[0040] Specifically, the preset number of pixels is set according to actual conditions or experience, for example, it can be set according to the size of the region of interest. When the region of interest is large, the value of the preset number of pixels can be large, and when the region of interest is small, the value of the preset number of pixels can be small. By fine-tuning the misalignment adjustment of the pixels in the region of interest according to the preset number of pixels in at least one direction of the horizontal direction, the vertical direction, and the diagonal direction, more misaligned reference sample images are created.
[0041] In addition, the obtained reference sample image may be subjected to at least one transformation operation of rotation, scaling and flipping to generate a plurality of enhanced sample images.
[0042] In the above method, the offset adjustment method is adopted at different positions and angles to generate reference sample images by changing the pixel positions in the focus area. When the model is subsequently trained through these sample images, the model can learn the target's expression form in different situations, thereby improving the robustness of the target recognition model. In addition, the reference sample image can also be subjected to target transformation to obtain enhanced sample images under different transformations, thereby further improving the generalization ability of the target recognition model.
[0043] After obtaining the enhanced sample images corresponding to each initial sample image, each initial sample image and the corresponding enhanced sample image can be added to the sample image set as training samples for model training. Specifically, each sample image in the sample image set is input into the feature extraction module of the initial target recognition model to obtain the sample features output by the feature extraction module.
[0044] Among them, the feature extraction module includes a convolutional neural network (CNN). CNN is a deep learning model that can efficiently extract and classify features of sample images. CNN consists of multiple convolutional layers, pooling layers, and fully connected layers. Each layer has some trainable parameters for extracting and processing the features of sample images. The convolutional layer is the core layer of CNN and is used to extract features from the input sample image. The convolutional layer includes multiple convolution kernels, each of which can extract the features of a certain area in the input sample image. The convolution kernel performs a convolution operation on the input sample image to obtain a feature map. Each pixel in the feature map represents the features of a certain area in the input sample image. The convolution operation is shown in the following formula (1): (1) in, Represents the value of the output feature map at position (i, j), which is the result of the convolution operation. Represents the pixel value of the sample image at position (i+m, j+n), represents the weight value of the convolution kernel at position (m, n), M and N represent the width and height of the convolution kernel, and b represents the bias. The convolution operation can effectively reduce the number of parameters in the model, thereby avoiding overfitting.
[0045] The pooling layer is used to downsample the feature map to reduce the size of the feature map. Commonly used pooling operations include maximum pooling and average pooling. Among them, the maximum pooling operation is shown in formula (2): (2) in, Represents the value of the output feature map at position (i, j), Indicates that the input feature map is at position The pixel value of the input feature map is represented by S, the step size is K, and the size of the pooling window is m and n. The offset of the pooling window on the input feature map can help the model better adapt to different input sizes and position changes, and can also reduce the amount of calculation of the model.
[0046] The fully connected layer is used to map the summarized features into the target output. Commonly used fully connected layers include softmax layer and sigmoid layer. The softmax layer is shown in formula (3): (3) in, represents the probability that the model predicts that the input belongs to the i-th category, Represents the original prediction value of the model for the i-th category in the last fully connected layer. Indicates that Converted to a positive number, K represents the sum of categories, and j represents the jth category. The softmax function can map the input vector to a probability distribution so that each element of the output vector represents the probability of a certain category.
[0047] Furthermore, in this embodiment, after obtaining the sample features, the sample features are input into the classification module of the initial target recognition model to obtain the predicted target recognition result output by the classification module, wherein the classification module can use a support vector machine (SVM), that is, use SVM in CNN to classify the feature map of the convolutional layer.
[0048] Among them, SVM is a supervised learning algorithm that can be used for classification and regression problems. SVM maps input data into a high-dimensional space and continuously updates the system. Due to changes in targets and scenes, the system needs to be continuously updated to improve recognition accuracy and speed. Therefore, real-time feedback and adaptive learning algorithms are needed to continuously update the system. In a high-dimensional space, SVM constructs an optimal hyperplane to separate data of different categories. The goal of SVM is to maximize the interval between the hyperplane and data of different categories, so that the model has better generalization ability. The mathematical model of SVM is shown in formula (4): (4) Among them, w represents the normal vector of the hyperplane, b represents the intercept of the hyperplane, It indicates the optimization of w and b, that is, the objective function is minimized by finding the optimal w and b. C indicates the penalty coefficient. represents the features of the i-th sample image, represents the label of the i-th sample image. The optimization problem of SVM can be solved by the Lagrangian dual problem.
[0049] The sample images in the sample image set are input into the feature extraction module CNN. After being processed by the convolution layer and the pooling layer, the feature map F, i.e., the sample features, can be efficiently extracted, avoiding the complexity of manual feature extraction. The sample features are then input into the classification module SVM for classification to obtain the predicted target recognition results. The accuracy of the recognition results and the robustness of the target recognition model can be ensured by SVM. Among them, the input of the classification module SVM can be the entire feature map F or a part of the feature map.
[0050] Based on the predicted target recognition results and the target recognition labels of the corresponding sample images that are pre-labeled, the loss information can be determined, and the model parameters of the initial target recognition model can be adjusted based on the loss information. The above process is repeated until the obtained model converges or the number of repetitions reaches a preset number of times, and the final model is determined as the target recognition model.
[0051] In this embodiment, by identifying and marking the area of interest in the initial sample image, the target recognition model will focus on the most important part of the initial sample image, so that the model obtained after training can more accurately identify and locate the target, thereby avoiding false locking. In addition, by adjusting the pixels of the area of interest and adding the obtained enhanced sample image to the model training, the generalization and robustness of the target recognition model obtained after training can be improved. Furthermore, since the feature extraction module includes a convolutional neural network and the classification module includes a support vector machine, after combining the two, the powerful feature extraction capability of deep learning and the efficient classification capability of machine learning can be integrated to form an efficient and accurate target recognition process.
[0052] Exemplarily, based on the above embodiments, when adjusting the model parameters of the initial target recognition model based on the predicted target recognition result and the target recognition label of the corresponding sample image to obtain the target recognition model, it can be performed in the following manner: Based on the predicted target recognition results representing the recognized targets and the target recognition labels of the corresponding sample images, the model parameters of the initial target recognition model are adjusted to obtain a reference recognition model, and the enhanced sample images corresponding to the predicted target recognition results representing the unrecognized targets in the sample image set are deleted to obtain a remaining image set. The model parameters of the reference recognition model are adjusted based on the remaining sample images in the remaining image set, and the above steps are repeated until the target recognition model is obtained.
[0053] Specifically, in the first round of training, the sample images in the sample image set are input into the initial target recognition model, the sample features are extracted by the feature extraction module, and the classification is performed by the classification module. After the predicted target recognition result is obtained, it may happen that when the pixels in the focus area are misaligned or the reference sample image is transformed, the target cannot be recognized based on the adjusted or transformed sample image. Therefore, the loss information can be determined based only on the predicted target recognition result that can recognize the target and the target recognition label of the corresponding sample image, and the model parameters of the initial target recognition model are adjusted based on the loss information. In the subsequent iteration process, the enhanced sample images corresponding to the predicted target recognition results that characterize the unrecognized target in the predicted target recognition results of the previous prediction can be deleted from the sample image set, that is, the useless training samples are deleted to obtain the remaining image set, and then the remaining sample images in the remaining image set are input into the model obtained in the previous time, and the model parameters are adjusted iteratively until the number of iterations reaches the preset number or the obtained model converges, and the final model is determined as the target recognition model.
[0054] In this embodiment, since the enhanced sample images corresponding to the predicted target recognition results representing the unrecognized targets can be deleted from the sample image set, useless training samples can be deleted. The enhanced sample images corresponding to the predicted target recognition results representing the recognized targets can be used to participate in model training, which can reduce the amount of calculation and improve the training efficiency of the target recognition model.
[0055] Exemplarily, based on the above embodiments, during the process of target recognition through the target recognition model, when a feedback message indicating that the target recognition result is wrong is received, the model parameters of the target recognition model are fine-tuned based on the image to be recognized and the correct recognition results of the image to be recognized.
[0056] Specifically, after the target recognition model outputs the target recognition result, if it is found through manual correction or the like that the recognition result is inconsistent with the actual situation, the user will input a feedback message, which includes the correct recognition result of the image to be recognized. The image to be recognized is used as a training sample, and the correct recognition result is used as the label corresponding to the training sample, and the model parameters of the target recognition model are re-fine-tuned for adaptive learning.
[0057] In this embodiment, through the above-mentioned real-time feedback and adaptive learning mechanism, the purpose of continuously optimizing the target recognition model according to the recognition results and environmental changes can be achieved. The introduction of this mechanism can ensure the long-term stability and accuracy of the target recognition model, especially when processing dynamic scenes, the target recognition accuracy is high.
[0058] The target recognition device provided by the present invention is described below. The target recognition device described below and the target recognition method described above can be referenced to each other.
[0059] Figure 2 A schematic diagram of the structure of a target recognition device provided by an embodiment of the present invention, referring to Figure 2 As shown, the target recognition device 200 includes: An acquisition module 11 is used to acquire an image to be recognized; An input module 12, used for inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; Among them, the target recognition model is obtained by training the initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target. The enhanced sample image is obtained by dislocating the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
[0060] In an exemplary embodiment, the target recognition model is trained based on the following method: For each of the initial sample images, identifying and marking a focus area in the initial sample image by a self-attention mechanism; Performing misalignment adjustment on the pixels of the focus area to obtain an enhanced sample image corresponding to the initial sample image; Constructing the sample image set based on each of the initial sample images and each of the enhanced sample images; Inputting the sample images in the sample image set into the feature extraction module of the initial target recognition model to obtain the sample features output by the feature extraction module; Inputting the sample features into the classification module of the initial target recognition model to obtain a predicted target recognition result output by the classification module; Based on the predicted target recognition result and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain the target recognition model.
[0061] In an example embodiment, identifying and marking the focus area in the initial sample image by a self-attention mechanism includes: Performing feature extraction on the initial sample image to obtain image features; Determining, by the self-attention mechanism, an importance score of each image region in the initial sample image based on the image features and the target recognition task type; The image region corresponding to the highest importance score is determined as the focus region.
[0062] In an example embodiment, the step of performing misalignment adjustment on the pixels of the focus area to obtain an enhanced sample image corresponding to the initial sample image includes: Performing misalignment adjustment on the pixels of the focus area based on a preset number of pixels in a target direction to obtain a reference sample image, wherein the target direction includes at least one of the following: a horizontal direction, a vertical direction, and a diagonal direction; Performing a target transformation on the reference sample image to obtain the enhanced sample image, wherein the target transformation includes at least one of the following: rotation, scaling, and flipping.
[0063] In an exemplary embodiment, the apparatus further comprises: an adjustment module, wherein: The adjustment module is used to fine-tune the model parameters of the target recognition model based on the image to be recognized and the correct recognition result of the image to be recognized when receiving a feedback message indicating that the target recognition result is wrong.
[0064] In an example embodiment, adjusting the model parameters of the initial target recognition model based on the predicted target recognition result and the target recognition label of the corresponding sample image to obtain the target recognition model includes: Based on the predicted target recognition result representing the recognized target and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain a reference recognition model, the enhanced sample images corresponding to the predicted target recognition result representing the unrecognized target in the sample image set are deleted to obtain a remaining image set, the model parameters of the reference recognition model are adjusted based on the remaining sample images in the remaining image set, and the above steps are repeated until the target recognition model is obtained.
[0065] In an example embodiment, the feature extraction module includes a convolutional neural network and the classification module includes a support vector machine.
[0066] The device of this embodiment can be used to execute the method of any embodiment in the target recognition method side embodiment. Its specific implementation process and technical effects are similar to those in the target recognition method side embodiment. For details, please refer to the detailed introduction in the target recognition method side embodiment, which will not be repeated here.
[0067] Figure 3 A schematic diagram of the physical structure of an electronic device provided by an embodiment of the present invention, such as Figure 3As shown, the electronic device may include: a processor 310, a communication interface 320, a memory 330 and a communication bus 340, wherein the processor 310, the communication interface 320 and the memory 330 communicate with each other through the communication bus 340. The processor 310 may call the logic instructions in the memory 330 to execute the target recognition method, which includes: obtaining an image to be recognized; inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; wherein the target recognition model is obtained by training an initial target recognition model based on a sample image set, wherein the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target, wherein the enhanced sample image is obtained by dislocation adjustment of pixels of a focus area marked in the initial sample image, wherein the focus area includes the sample target.
[0068] In addition, the logic instructions in the above-mentioned memory 330 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0069] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the target recognition method provided by the above-mentioned methods, and the method includes: obtaining an image to be recognized; inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; wherein the target recognition model is obtained by training an initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target, and the enhanced sample image is obtained by staggering the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
[0070] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the target recognition method provided by the above-mentioned methods, the method comprising: obtaining an image to be recognized; inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; wherein the target recognition model is obtained by training an initial target recognition model based on a sample image set, the sample image set comprising at least one enhanced sample image and at least one initial sample image containing a sample target, the enhanced sample image being obtained by offset adjustment of pixels of a focus area marked in the initial sample image, the focus area including the sample target.
[0071] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0072] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A target recognition method, characterized in that: include: Obtain an image to be recognized; Inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; Among them, the target recognition model is obtained by training the initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target. The enhanced sample image is obtained by dislocating the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
2. The target recognition method according to claim 1, characterized in that: The target recognition model is trained based on the following method: For each of the initial sample images, identifying and marking a focus area in the initial sample image by a self-attention mechanism; Performing misalignment adjustment on the pixels of the focus area to obtain an enhanced sample image corresponding to the initial sample image; Constructing the sample image set based on each of the initial sample images and each of the enhanced sample images; Inputting the sample images in the sample image set into the feature extraction module of the initial target recognition model to obtain the sample features output by the feature extraction module; Inputting the sample features into the classification module of the initial target recognition model to obtain a predicted target recognition result output by the classification module; Based on the predicted target recognition result and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain the target recognition model.
3. The target recognition method according to claim 2, characterized in that: The identifying and marking the focus area in the initial sample image by the self-attention mechanism includes: Performing feature extraction on the initial sample image to obtain image features; Determining, by the self-attention mechanism, an importance score of each image region in the initial sample image based on the image features and the target recognition task type; The image region corresponding to the highest importance score is determined as the focus region.
4. The target recognition method according to claim 2, characterized in that: The step of performing misalignment adjustment on the pixels of the focus area to obtain an enhanced sample image corresponding to the initial sample image includes: Performing misalignment adjustment on the pixels of the focus area based on a preset number of pixels in a target direction to obtain a reference sample image, wherein the target direction includes at least one of the following: a horizontal direction, a vertical direction, and a diagonal direction; Performing a target transformation on the reference sample image to obtain the enhanced sample image, wherein the target transformation includes at least one of the following: rotation, scaling, and flipping.
5. The target recognition method according to any one of claims 1 to 4, characterized in that: The method further comprises: In the case of receiving a feedback message indicating that the target recognition result is wrong, the model parameters of the target recognition model are fine-tuned based on the image to be recognized and the correct recognition result of the image to be recognized.
6. The target recognition method according to any one of claims 2 to 4, characterized in that: The step of adjusting the model parameters of the initial target recognition model based on the predicted target recognition result and the target recognition label of the corresponding sample image to obtain the target recognition model includes: Based on the predicted target recognition result representing the recognized target and the target recognition label of the corresponding sample image, the model parameters of the initial target recognition model are adjusted to obtain a reference recognition model, the enhanced sample images corresponding to the predicted target recognition result representing the unrecognized target in the sample image set are deleted to obtain a remaining image set, the model parameters of the reference recognition model are adjusted based on the remaining sample images in the remaining image set, and the above steps are repeated until the target recognition model is obtained.
7. The target recognition method according to any one of claims 2 to 4, characterized in that: The feature extraction module includes a convolutional neural network, and the classification module includes a support vector machine.
8. A target recognition device, characterized in that: include: An acquisition module, used for acquiring an image to be recognized; An input module, used for inputting the image to be recognized into a target recognition model to obtain a target recognition result output by the target recognition model; Among them, the target recognition model is obtained by training the initial target recognition model based on a sample image set, and the sample image set includes at least one enhanced sample image and at least one initial sample image containing a sample target. The enhanced sample image is obtained by dislocating the pixels of the focus area marked in the initial sample image, and the focus area includes the sample target.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the target recognition method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the target recognition method according to any one of claims 1 to 7 is implemented.