A target identification method and device, a terminal device and a readable storage medium
By introducing intra-class and inter-class constraints into the target recognition network model, the problem of insufficient robustness of training the model using the center loss function is solved, and a more efficient target recognition effect is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- UBTECH ROBOTICS CORP LTD
- Filing Date
- 2022-12-12
- Publication Date
- 2026-05-08
AI Technical Summary
In existing technologies, target recognition models trained based on the center loss function are insufficient in terms of robustness and generalization.
We employ loss functions based on intra-class and inter-class constraints to optimize the target recognition network model by constraining the intra-class distance between the image features of the target sample and the class center, as well as the inter-class distance and angle between the class centers of different classifications.
It improves the robustness and generalization of target recognition and enhances the model's ability to distinguish between different categories.
Smart Images

Figure CN115830339B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of image recognition technology, and in particular relates to a target recognition method, apparatus, terminal device and readable storage medium. Background Technology
[0002] Object recognition is an important application area of computer vision technology, and related technologies often utilize deep learning-based network models to achieve object recognition. The loss function is a crucial component of the network model. The network model is typically trained by minimizing the loss function, using data as input, to optimize the model by minimizing the error between the network model's predictions and the true values of the data. In related technologies, the center loss function is commonly used for model training, as it optimizes intra-class distance. However, in practical applications, it has been found that models trained using the center loss function often lack robustness in object recognition. Summary of the Invention
[0003] This application provides a target recognition method, apparatus, terminal device, and readable storage medium, which can improve the robustness of target recognition.
[0004] The first aspect of this application provides a target recognition method, comprising: acquiring a target image of a target to be recognized; extracting features from the target image to obtain image features in the target image; inputting the image features into a target recognition network model to obtain a recognition result of the category to which the target belongs, wherein the loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints, the intra-class constraints are used to constrain the intra-class distance between the sample image features of the sample target and the class center of the category to which the sample target belongs, and the inter-class constraints are used to constrain the inter-class distance between the class centers of different categories and / or the inter-class angle between the class centers of different categories.
[0005] A target recognition device provided in the second aspect of this application includes: an image acquisition unit for acquiring a target image of a target to be recognized; a feature extraction unit for extracting features from the target image to obtain image features in the target image; and a target recognition unit for inputting the image features into a target recognition network model to obtain a recognition result of the category to which the target to be recognized belongs. The loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. The intra-class constraints constrain the intra-class distance between the sample image features of the sample target and the class center of the category to which the sample target belongs. The inter-class constraints constrain the inter-class distance between class centers of different categories and / or the inter-class angle between class centers of different categories.
[0006] A third aspect of this application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the target recognition method described above.
[0007] A fourth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the target recognition method described above.
[0008] The fifth aspect of this application provides a computer program product that, when run on a terminal device, causes the terminal device to execute the target recognition method described in the first aspect.
[0009] In the embodiments of this application, feature extraction is performed on the target image of the target to be identified to obtain image features in the target image. Then, the image features are input into the target recognition network model to obtain the recognition result of the category to which the target belongs. The loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. Intra-class constraints are used to constrain the intra-class distance between the sample image features of the sample target and the class center of the class to which the sample target belongs. Inter-class constraints are used to constrain the inter-class distance between the class centers of different categories and / or the inter-class angle between the class centers of different categories. That is to say, during the model training process, while constraining the intra-class distance, the inter-class distance and / or inter-class angle of the class centers of different categories can be constrained to optimize the relative relationship between different categories, so that the model can better identify the differences between different categories, thereby improving the robustness and generalization of target recognition. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This is a schematic diagram illustrating the implementation process of a target recognition method provided in an embodiment of this application;
[0012] Figure 2 This is a schematic diagram of the structure of a target recognition device provided in an embodiment of this application;
[0013] Figure 3 This is a schematic diagram of the structure of the terminal device provided in the embodiments of this application. Detailed Implementation
[0014] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are protected by this application.
[0015] In related technologies, the center loss function is commonly used for model training. Model training using the center loss function mainly consists of the following steps:
[0016] First, initialize the class centers: initialize the class centers {C1, C2, ..., C} for each category in the recognition task. K}, where K represents the total number of categories in the recognition task, and C K This represents the class center of the Kth category.
[0017] Then, extract image features: for the sample image {I1,I2,...,I... N Extract the image features {f1, f2, ..., f} respectively. N}, where N represents the total number of sample images, I N Let f represent the Nth sample image. N This represents the image features of the Nth sample image.
[0018] Next, a center loss is applied to train the network model: for each sample image, its features are constrained to be close to the class center corresponding to that image. Among them, L center That is, the central loss function, C i D(f) represents the class center corresponding to the i-th image. i C i ) represents f i and C i The distance between them. During the network model training process, the class centers are optimized along with the network model, eventually reaching a stable state.
[0019] From the above central loss function L center It can be seen that the central loss function L center The constraint only requires that the image features of each sample image be close to the class center of the category to which the sample image belongs, but no constraint is imposed between the class centers of different categories.
[0020] Therefore, the center loss function only optimizes the intra-class distance, making the image features within the same category more compact, but does not optimize the relative relationship between classes. This will reduce the robustness and generalization of the features extracted by the network model. In other words, the model trained based on the center loss function often lacks robustness and generalization when performing target recognition.
[0021] In view of this, this application proposes a new target recognition method, which optimizes the loss function of the network model, so that the network model trained based on the optimized loss function can more robustly achieve target recognition.
[0022] To illustrate the technical solution of this application, specific embodiments are described below.
[0023] Figure 1 This illustration shows a schematic flowchart of a target recognition method provided in an embodiment of this application. This method can be applied to terminal devices and is suitable for situations requiring improved target recognition accuracy. The terminal device can be a smartphone, computer, in-vehicle device, monitoring equipment, or other intelligent device with target recognition requirements.
[0024] Specifically, the above target recognition method may include the following steps S101 to S103.
[0025] Step S101: Obtain the target image of the target to be identified.
[0026] The target to be identified is the object that needs to be identified, and the target image is the image obtained by acquiring the target. It should be understood that the target to be identified can be a person, vehicle, pet, or other object, and can be adjusted according to the needs of the recognition task.
[0027] In embodiments of this application, the terminal device can acquire the target image in different ways. For example, the terminal device can take a picture of the target to be identified using a camera to obtain the target image. Alternatively, the terminal device can download the target image to be identified from the network. This application does not impose any limitations on this method.
[0028] Step S102: Extract features from the target image to obtain image features in the target image.
[0029] Image features refer to the features in the target image, which can include features of different image information such as pixel values, contours, and textures in the target image, or features of the target to be identified in the target image, such as key feature points of the target to be identified.
[0030] It should be noted that this application does not restrict the feature extraction method of image features. The terminal device may use Local Binary Patterns (LBP) feature extraction algorithm, Histogram of Oriented Gradient (HOG) feature extraction algorithm, SIFT (Scale-invariant feature transform) feature point extraction algorithm, feature extraction algorithm based on deep neural network (e.g., ResNet), or other algorithms to extract image features of the target image.
[0031] Step S103: Input the image features into the target recognition network model to obtain the recognition result of the category to which the target to be recognized belongs.
[0032] In the embodiments of this application, the loss function of the target recognition network model is a function obtained based on intra-class constraints and inter-class constraints.
[0033] Intra-class constraints can be used to constrain the intra-class distance between the sample image features of a target and the class center of the target's class. Intra-class distance represents the distance between sample image features within the same class. Model training based on intra-class constraints can constrain the sample image features of each sample image to be closer to the class center of the category to which the sample image belongs.
[0034] Inter-class constraints can be used to constrain the inter-class distance between class centers of different categories, and / or the inter-class angle between class centers of different categories. Inter-class distance represents the distance between class centers of different categories, and inter-class angle represents the angle between class centers of different categories. Model training based on inter-class constraints can constrain the separation of class centers of different categories. It should be noted that since the features of the sample image are feature vectors, the obtained class centers are also essentially vectors.
[0035] More specifically, the loss value of the loss function is positively correlated with intra-class distance, negatively correlated with inter-class distance, and negatively correlated with the angle between the class centers of different classifications.
[0036] The target recognition network model is a pre-trained network model used to recognize image features. Sample images can be images used for model training, sample image features are image features extracted from the sample images, and sample targets refer to the targets in the sample images. The class center of a certain category can be the mean of the features of all sample images for that category. The methods for obtaining sample images and extracting sample image features can be found in the description of target images and image features, and will not be elaborated upon in this application.
[0037] In the embodiments of this application, feature extraction is performed on the target image of the target to be identified to obtain image features in the target image. Then, the image features are input into the target recognition network model to obtain the recognition result of the category to which the target belongs. The loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. Intra-class constraints are used to constrain the intra-class distance between the sample image features of the sample target and the class center of the class to which the sample target belongs. Inter-class constraints are used to constrain the inter-class distance between the class centers of different categories and / or the inter-class angle between the class centers of different categories. That is to say, during the model training process, while constraining the intra-class distance, the inter-class distance and / or inter-class angle of the class centers of different categories can be constrained to optimize the relative relationship between different categories, so that the model can better identify the differences between different categories, thereby improving the robustness and generalization of target recognition.
[0038] In some embodiments of this application, the above-mentioned inter-class constraints may include orthogonal constraints and / or inter-class constraints.
[0039] Orthogonal constraints can be used to constrain the interclass angle between class centers of different classifications, thereby increasing the directional differences between class centers of different classifications.
[0040] Specifically, the orthogonal constraint acting on the above loss function can be expressed as:
[0041]
[0042] Where L1 represents the sub-function corresponding to the orthogonality constraint in the above loss function, and the sub-function is a part of the loss function. K represents the total number of classifications, and C i Let C represent the class center of the i-th category. j Let |||| represent the class center of the j-th category. |||| represents the norm, i.e., || ... i || represents C i The paradigm, {x} + Let {x} represent the maximum value between x and 0. + = max{x, 0}.
[0043] From the above formula, we can see that when C i and C j The larger the angle between classes (i.e., the larger the angle between classes), the smaller the function value of the sub-function corresponding to the orthogonality constraint. During network model training, to minimize the loss function, it is necessary to make C... i and C j Optimize directions with larger included angles.
[0044] Metric constraints can be used to constrain the inter-class distance between class centers of different categories, thereby increasing the difference in distance between class centers of different categories.
[0045] Specifically, the metric constraint applied to the above loss function can be expressed as:
[0046]
[0047] Where L2 represents the sub-function corresponding to the metric constraint in the above loss function, K represents the total number of categories, and C i Let C represent the class center of the i-th category. j Let {x} represent the class center of the j-th category. + Let {x} represent the maximum value between x and 0. + =max{x, 0}, D(C i C j ) represents C i and C j The distance between them. Where, D(C) i C j ) can be achieved through C i and C j The difference is obtained by subtraction. α is a preset distance threshold, and α>0. The specific value can be adjusted according to the actual situation.
[0048] From the above formula, we can see that when C i and C j The larger the distance between classes (i.e., the larger the inter-class distance), the smaller the function value of the sub-function corresponding to the metric constraint. During network model training, to minimize the loss function, it is necessary to ensure that the distance D(C) between two class centers is minimized. i C j If the distance is greater than the distance threshold α, then C needs to be moved to make C... i and C j Optimize directions with greater distance.
[0049] Intra-class constraints can be represented as:
[0050] Where N represents the total number of sample images, f p C represents the sample image features of the p-th sample image. p D(f) represents the class center of the target object in the p-th sample image. p C p ) represents f p and C p The distance between them.
[0051] Therefore, in some implementations, the above loss function can be summarized as:
[0052]
[0053] Based on this loss function, the terminal device can acquire sample images of the target object. With the goal of minimizing the loss function, the target recognition network model is iteratively trained using these sample images until the loss value of the loss function is less than or equal to a preset loss threshold, or until the number of iterations of the target recognition network model is greater than or equal to a threshold, thus obtaining the target recognition network model. During model training, the class centers of the categories to which the target object belongs also need to be iteratively updated.
[0054] More specifically, for the sample image {I1,I2,...,I... p Extract the image features {f1, f2, ..., f} respectively. p}, where p represents the total number of sample images, I p Let f represent the p-th sample image. p Let represent the sample image features of the p-th sample image. Several images are extracted from the sample images to form a batch. This batch of sample images is then input into the recognition network model to be trained to obtain its predicted values. The loss function L is then calculated using the predicted values and the true values of the sample images. center The convergence condition of the recognition network model to be trained is that the loss value is less than or equal to the loss value threshold. If the convergence condition is that the loss value is less than or equal to the loss value threshold, then when the loss value is greater than the loss value threshold, the model parameters of the recognition network model to be trained are adjusted. During the process, the class centers of the categories to which the sample targets belong are updated according to the sample image features corresponding to the sample targets. Then, a new batch of sample images is input into the recognition network model to be trained, and so on, until the loss value is less than or equal to the loss value threshold, thus obtaining the target recognition network model. If the convergence condition is that the number of iterations is greater than or equal to the number of iterations threshold, then when the number of iterations is less than the number of iterations threshold, the model parameters of the recognition network model to be trained are adjusted. During the process, the class centers of the categories to which the sample targets belong are updated according to the sample image features corresponding to the sample targets. Then, a new batch of sample images is input into the recognition network model to be trained, and so on, until the number of iterations is greater than or equal to the number of iterations threshold, thus obtaining the target recognition network model.
[0055] Both the number of attempts threshold and the loss threshold can be adjusted according to the actual situation.
[0056] Once the target recognition network model is obtained, the terminal device can use it for target recognition. This target recognition method can be applied to fields such as pedestrian re-identification and vehicle recognition.
[0057] The target recognition method proposed in this application uses a center loss function based on orthogonal constraints and metric constraints. This can overcome the shortcomings of traditional center loss functions in that they cannot optimize inter-class differences, and enable the center loss function to more effectively increase inter-class distance and decrease intra-class distance, thereby improving the robustness and generalization of target recognition.
[0058] It should be noted that, for the sake of simplicity, the aforementioned method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders.
[0059] like Figure 2 The diagram shown is a structural schematic of a target identification device 200 provided in an embodiment of this application. The target identification device 200 is configured on a terminal device.
[0060] Specifically, the target identification device 200 may include:
[0061] Image acquisition unit 201 is used to acquire target images of the target to be identified;
[0062] Feature extraction unit 202 is used to extract features from the target image to obtain image features in the target image;
[0063] The target recognition unit 203 is used to input the image features into the target recognition network model to obtain the recognition result of the category to which the target to be recognized belongs. The loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. The intra-class constraints are used to constrain the intra-class distance between the sample image features of the sample target and the class center of the category to which the sample target belongs. The inter-class constraints are used to constrain the inter-class distance between the class centers of different categories and / or the inter-class angle between the class centers of different categories.
[0064] In some embodiments of this application, the above-mentioned inter-class constraints may include orthogonal constraints for constraining the included angle between the classes, and the orthogonal constraints may be expressed as: Where L1 represents the sub-function corresponding to the orthogonality constraint in the loss function, K represents the total number of classifications, and C i Let C represent the class center of the i-th category. j Let {x} represent the class center of the j-th category, |||| denotes the norm, and {x} + This represents the maximum value between x and 0.
[0065] In some embodiments of this application, the above-mentioned inter-class constraints may include a metric constraint for constraining the distance between the similar classes, and the metric constraint may be expressed as: Where L2 represents the sub-function corresponding to the metric constraint in the loss function, K represents the total number of categories, and C i Let C represent the class center of the i-th category. j Let {x} represent the class center of the j-th category, α be a preset distance threshold, and {x} be the class center of the j-th category. + D(C) represents the maximum value between x and 0. i C j ) represents C i and C j The distance between them.
[0066] In some embodiments of this application, the above-mentioned intra-class constraints can be expressed as: Where N represents the total number of sample images, f p C represents the sample image feature of the p-th sample image. p D(f) represents the class center of the category to which the target object in the p-th sample image belongs. p C p ) represents f p and C p The distance between them.
[0067] In some embodiments of this application, the above-mentioned loss function can be expressed as: Where N represents the total number of sample images, f p C represents the sample image feature of the p-th sample image. p D(f) represents the class center of the category to which the target object in the p-th sample image belongs. p C p ) represents f p and C p The distance between them, K represents the total number of categories, C i Let C represent the class center of the i-th category. j Let {x} represent the class center of the j-th category, |||| denotes the norm, and {x} + This represents the maximum value between x and 0, where α is a preset distance threshold, and D(C) i C j ) represents C i and C j The distance between them.
[0068] In some embodiments of this application, the target recognition device 200 may further include a model training unit, configured to: acquire sample images of the sample target; and iteratively train the recognition network model to be trained using the sample images with the goal of minimizing the loss function, until the loss value of the loss function is less than or equal to a preset loss value threshold, or until the number of iterations of the recognition network model to be trained is greater than or equal to a number threshold, thereby obtaining the target recognition network model.
[0069] In some embodiments of this application, the above-mentioned model training unit may also be specifically used to iteratively update the class center of the category to which the sample target belongs.
[0070] It should be noted that, for the sake of convenience and brevity, the specific working process of the target recognition device 200 described above can be found in the following reference: Figure 1 The corresponding process of the method will not be described in detail here.
[0071] like Figure 3 The diagram shown is a schematic of a terminal device provided in an embodiment of this application. The terminal device 3 may include: a processor 30, a memory 31, and a computer program 32 stored in the memory 31 and executable on the processor 30, such as a target recognition program. When the processor 30 executes the computer program 32, it implements the steps in the various target recognition method embodiments described above, for example... Figure 1 The steps S101 to S103 are shown. Alternatively, when the processor 30 executes the computer program 32, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 2 The image acquisition unit 201, feature extraction unit 202, and target recognition unit 203 are shown.
[0072] The computer program can be divided into one or more modules / units, which are stored in the memory 31 and executed by the processor 30 to complete this application. The one or more modules / units can be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of the computer program in the terminal device.
[0073] For example, the computer program can be divided into: an image acquisition unit, a feature extraction unit, and a target recognition unit. The specific functions of each unit are as follows: the image acquisition unit acquires a target image of the target to be recognized; the feature extraction unit extracts features from the target image to obtain image features in the target image; the target recognition unit inputs the image features into a target recognition network model to obtain the recognition result of the category to which the target belongs, wherein the loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. The intra-class constraints constrain the intra-class distance between the sample image features of the sample target and the class center of the category to which the sample target belongs, and the inter-class constraints constrain the inter-class distance between class centers of different categories and / or the inter-class angle between class centers of different categories.
[0074] The terminal device may include, but is not limited to, a processor 30 and a memory 31. Those skilled in the art will understand that... Figure 3 This is merely an example of a terminal device and does not constitute a limitation on the terminal device. It may include more or fewer components than shown, or combine certain components, or different components. For example, the terminal device may also include input / output devices, network access devices, buses, etc.
[0075] The processor 30 may be a Central Processing Unit (CPU), or 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. A general-purpose processor may be a microprocessor or any conventional processor.
[0076] The memory 31 can be an internal storage unit of the terminal device, such as a hard drive or memory. The memory 31 can also be an external storage device of the terminal device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 31 can include both internal and external storage units. The memory 31 is used to store the computer program and other programs and data required by the terminal device. The memory 31 can also be used to temporarily store data that has been output or will be output.
[0077] It should be noted that, for the sake of convenience and brevity, the structure of the terminal device described above can also be referred to the specific description of the structure in the method embodiment, which will not be repeated here.
[0078] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0079] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0080] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for various specific applications, but such implementations should not be considered beyond the scope of this application.
[0081] In the embodiments provided in this application, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0082] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0083] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0084] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.
[0085] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A target recognition method, characterized in that, include: Acquire the target image of the target to be identified; Feature extraction is performed on the target image to obtain the image features in the target image; The image features are input into the target recognition network model to obtain the recognition result of the category to which the target to be recognized belongs. The loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. The intra-class constraints are used to constrain the intra-class distance between the sample image features of the sample target and the class center of the category to which the sample target belongs. The inter-class constraints are used to constrain the inter-class distance between the class centers of different categories and / or the inter-class angle between the class centers of different categories. The inter-class constraints include orthogonal constraints for constraining the angles between the classes. These orthogonal constraints are used to increase the directional differences between the class centers of different classifications, and are expressed as follows: ; in, This represents the sub-function corresponding to the orthogonal constraint in the loss function. Indicates the total number of categories. This represents the class center of the i-th category. This represents the class center of the j-th category. Represents the norm, express The maximum value between 0 and 0.
2. The target recognition method as described in claim 1, characterized in that, The inter-class constraints include a metric constraint for constraining the inter-class distance, and the metric constraint is expressed as follows: ; in, This represents the sub-function corresponding to the metric constraint in the loss function. Indicates the total number of categories. This represents the class center of the i-th category. This represents the class center of the j-th category. The preset distance threshold, express The maximum value between 0 and 0. express and The distance between them.
3. The target recognition method as described in claim 1, characterized in that, The intra-class constraint is represented as follows: ; in, This represents the total number of sample images. Indicates the first The sample image features of the sample images, Indicates the first The class center of the category to which the target of the sample image belongs. express and The distance between them.
4. The target recognition method as described in claim 1, characterized in that, The loss function is expressed as: ; in, This represents the total number of sample images. Indicates the first The sample image features of the sample images, Indicates the first The class center of the category to which the target of the sample image belongs. express and The distance between them Indicates the total number of categories. This represents the class center of the i-th category. This represents the class center of the j-th category. Represents the norm, express The maximum value between 0 and 0. The preset distance threshold, express and The distance between them.
5. The target recognition method according to any one of claims 1 to 4, characterized in that, The training process of the target recognition network model includes: Obtain a sample image of the target sample; With the goal of minimizing the loss function, the target recognition network model is iteratively trained using the sample images until the loss value of the loss function is less than or equal to a preset loss value threshold, or until the number of iterations of the target recognition network model is greater than or equal to a number threshold, thereby obtaining the target recognition network model.
6. The target recognition method as described in claim 5, characterized in that, The iterative training process of the recognition network model to be trained using the sample images includes: The class centers of the category to which the sample target belongs are iteratively updated.
7. A target recognition device, characterized in that, include: The image acquisition unit is used to acquire the target image of the target to be identified. A feature extraction unit is used to extract features from the target image to obtain image features in the target image; A target recognition unit is used to input the image features into a target recognition network model to obtain the recognition result of the category to which the target to be recognized belongs. The loss function of the target recognition network model is a function based on intra-class constraints and inter-class constraints. The intra-class constraints constrain the intra-class distance between the sample image features of the sample target and the class center of the category to which the sample target belongs. The inter-class constraints constrain the inter-class distance between class centers of different categories and / or the inter-class angle between class centers of different categories. The inter-class constraints include orthogonal constraints constraining the inter-class angle, which increase the directional differences between class centers of different categories, expressed as: ; in, This represents the sub-function corresponding to the orthogonal constraint in the loss function. Indicates the total number of categories. This represents the class center of the i-th category. This represents the class center of the j-th category. Represents the norm, express The maximum value between 0 and 0.
8. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the target recognition method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the target recognition method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Training method of an object re-identification model and object re-identification method and device
CN110321965A