Pedestrian re-identification method, device, computer-readable storage medium and terminal device
By using distribution-based triple loss function in the training process of pedestrian recognition model, the problem of inconsistent loss function for different triple convergence targets in the prior art is solved, the discriminant and robustness of model extraction features is improved, and the accuracy of pedestrian recognition is improved.
Patent Information
- Application Number
- CN202210611695.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-31
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-05-31
AI Technical Summary
In the prior art, the triple loss function based on absolute distance is not uniform for different triple convergence goals, resulting in poor discriminant and robustness of the feature extracted by the training model, and reduces the accuracy of the pedestrian re-identification results.
The distribution-based triple loss function is adopted, and the difference between the mean of the negative sample characteristic distance and the mean of the positive sample characteristic distance is constrained by the macro constraint function, the positive sample microconstraint function and the negative sample microconstraint function, and the difference between the mean of the negative sample characteristic distance and the positive sample characteristic distance is greater than the preset difference threshold, and the first feature distance and the second feature distance are adjusted to improve the discriminant and robustness of the model.
By imposing constraints on the mean of feature distances with macroscopic statistical significance, the problem of inconsistency of different triplets is alleviated, the discriminant and robustness of the model extraction features is improved, and the accuracy of pedestrian re-identification results is improved.
Smart Images

Figure CN114937287B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of pedestrian re-identification, and in particular, relates to a pedestrian re-identification method, apparatus, computer-readable storage medium and terminal device. Background Art
[0002] Person re-identification, also known as pedestrian re-identification, is a technology that uses computer vision technology to determine whether there is a specific pedestrian in an image or video sequence.
[0003] In the process of pedestrian re-identification technology developing from traditional metric learning to deeper and wider deep neural network learning, distance measurement is indispensable. Pedestrian re-identification technology needs to be able to effectively narrow the distance between the same category and increase the distance between different categories in the feature space. Based on the distance metric, researchers have proposed many loss functions for supervised network learning. Among them, the triple loss function based on absolute distance is the most widely used loss function, and in general, it can achieve good training results.
[0004] However, the triplet loss function based on absolute distance has different convergence targets for different triplets, which results in poor discriminability and robustness of the features extracted by the trained model, reducing the accuracy of the pedestrian re-identification results. Summary of the invention
[0005] In view of this, embodiments of the present application provide a pedestrian re-identification method, apparatus, computer-readable storage medium, and terminal device to solve the problem of low accuracy of pedestrian re-identification methods in the prior art.
[0006] A first aspect of an embodiment of the present application provides a pedestrian re-identification method, which may include:
[0007] Get the pending person re-identification task;
[0008] Using a preset pedestrian re-identification model to process the pedestrian re-identification task to obtain a pedestrian re-identification result;
[0009] Among them, the loss function used by the pedestrian re-identification model during the model training process is a preset distribution-based triplet loss function; the distribution-based triplet loss function constrains the difference between the mean of the negative sample feature distance and the mean of the positive sample feature distance to be greater than a preset difference threshold; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature.
[0010] In a specific implementation of the first aspect, the distribution-based triplet loss function further constrains the first feature distance to decrease to the mean of the positive sample feature distances, and the second feature distance to increase to the mean of the negative sample feature distances; the first feature distance is a positive sample feature distance greater than the mean of the positive sample feature distances, and the second feature distance is a negative sample feature distance less than the mean of the negative sample feature distances.
[0011] In a specific implementation of the first aspect, the distribution-based triplet loss function includes a macro constraint function, a positive sample micro constraint function, and a negative sample micro constraint function;
[0012] The macro constraint function is used to constrain the difference between the mean of the feature distance of the negative samples and the mean of the feature distance of the positive samples to be greater than the difference threshold;
[0013] The positive sample microscopic constraint function is used to constrain the first characteristic distance to be reduced to the mean value of the positive sample characteristic distance;
[0014] The negative sample microscopic constraint function is used to constrain the second characteristic distance to increase to the mean value of the negative sample characteristic distance.
[0015] In a specific implementation of the first aspect, the distribution-based triple loss function is:
[0016]
[0017] Among them, L macro is the macro constraint function, is the positive sample microscopic constraint function, is the negative sample micro-constraint function, λ is the preset weight coefficient, L triplet_distribution is the distribution-based triplet loss function.
[0018] In a specific implementation of the first aspect, the macro constraint function is:
[0019]
[0020] Among them, N ap is the number of positive sample feature pairs, N an is the number of negative sample feature pairs, i and j are serial subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, α is the difference threshold, {*} + =max{*,0}, max is the maximum value function.
[0021] In a specific implementation of the first aspect, the positive sample microscopic constraint function is:
[0022]
[0023] Among them, N ap is the number of positive sample feature pairs, is the number of positive sample feature pairs whose distance is greater than the mean of the positive sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
[0024] In a specific implementation of the first aspect, the negative sample microscopic constraint function is:
[0025]
[0026] Among them, N an is the number of negative sample feature pairs, is the number of negative sample feature pairs whose distance is less than the mean of the negative sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
[0027] A second aspect of an embodiment of the present application provides a pedestrian re-identification device, which may include:
[0028] A task acquisition module is used to obtain pending person re-identification tasks;
[0029] A pedestrian re-identification module is used to process the pedestrian re-identification task using a preset pedestrian re-identification model to obtain a pedestrian re-identification result; wherein the loss function used by the pedestrian re-identification model in the model training process is a preset distribution-based triplet loss function; the distribution-based triplet loss function constrains the difference between the mean of the negative sample feature distance and the mean of the positive sample feature distance to be greater than a preset difference threshold; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature.
[0030] In a specific implementation of the second aspect, the distribution-based triplet loss function also constrains the first feature distance to decrease to the mean of the positive sample feature distances, and the second feature distance to increase to the mean of the negative sample feature distances; the first feature distance is a positive sample feature distance greater than the mean of the positive sample feature distances, and the second feature distance is a negative sample feature distance less than the mean of the negative sample feature distances.
[0031] In a specific implementation of the second aspect, the distribution-based triplet loss function may include a macro constraint function, a positive sample micro constraint function, and a negative sample micro constraint function;
[0032] The macro constraint function is used to constrain the difference between the mean of the feature distance of the negative samples and the mean of the feature distance of the positive samples to be greater than the difference threshold;
[0033] The positive sample microscopic constraint function is used to constrain the first characteristic distance to be reduced to the mean value of the positive sample characteristic distance;
[0034] The negative sample microscopic constraint function is used to constrain the second characteristic distance to increase to the mean value of the negative sample characteristic distance.
[0035] In a specific implementation of the second aspect, the distribution-based triple loss function is:
[0036]
[0037] Among them, L macro is the macro constraint function, is the positive sample microscopic constraint function, is the negative sample micro-constraint function, λ is the preset weight coefficient, L triplet_distribution is the distribution-based triplet loss function.
[0038] In a specific implementation of the second aspect, the macro constraint function is:
[0039]
[0040] Among them, N ap is the number of positive sample feature pairs, N an is the number of negative sample feature pairs, i and j are serial subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, α is the difference threshold, {*} + =max{*,0}, max is the maximum value function.
[0041] In a specific implementation of the second aspect, the positive sample microscopic constraint function is:
[0042]
[0043] Among them, N ap is the number of positive sample feature pairs, is the number of positive sample feature pairs whose distance is greater than the mean of the positive sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
[0044] In a specific implementation of the second aspect, the negative sample microscopic constraint function is:
[0045]
[0046] Among them, N an is the number of negative sample feature pairs, is the number of negative sample feature pairs whose distance is less than the mean of the negative sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
[0047] A third aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned pedestrian re-identification methods are implemented.
[0048] The fourth aspect of an embodiment of the present 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 implements the steps of any one of the above-mentioned pedestrian re-identification methods when executing the computer program.
[0049] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on a terminal device, the terminal device executes the steps of any one of the above-mentioned pedestrian re-identification methods.
[0050] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the loss function used in the model training process of the embodiments of the present application is a preset distribution-based triplet loss function; the distribution-based triplet loss function constrains the difference between the mean of the negative sample feature distance and the mean of the positive sample feature distance to be greater than a preset difference threshold; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature. Through the embodiments of the present application, constraints are no longer imposed on each triplet separately, but constraints are imposed on the mean of the positive sample feature distance and the mean of the negative sample feature distance with macroscopic statistical significance, which effectively alleviates the disadvantage of the triplet loss function based on absolute distance in the prior art that the convergence targets for different triplets are not unified, and the features extracted by the trained model are more discriminative and robust, thereby improving the accuracy of the pedestrian re-identification results. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 is a schematic diagram of a triplet image;
[0053] Figure 2 Schematic diagram of the distribution of positive sample feature pairs and negative sample feature pairs;
[0054] Figure 3 This is a flow chart of an embodiment of a pedestrian re-identification method in an embodiment of the present application;
[0055] Figure 4 This is a structural diagram of an embodiment of a pedestrian re-identification device in an embodiment of the present application;
[0056] Figure 5 This is a schematic block diagram of a terminal device in an embodiment of the present application. DETAILED DESCRIPTION
[0057] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0058] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.
[0059] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0060] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0061] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0062] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0063] The loss function is an integral part of the deep network model. During the model training process, the loss function enhances the model's feature representation ability by minimizing the error between the model's predicted value and the true value. In fine-grained recognition visual tasks such as person re-identification, the loss function usually optimizes both the inter-class distance and the intra-class distance at the same time, thereby enhancing the model's discriminability and robustness.
[0064] The triplet loss function is the most common loss function in visual tasks and is often used in tasks such as face recognition, image classification, and person re-identification. The input of the triplet loss function is a feature triple {f a , f p , f n}, where f a 、f p and f nThey are respectively the reference image feature, the positive sample image feature and the negative sample image feature in the triplet. The reference image feature and the positive sample image feature can constitute a positive sample feature pair, and the reference image feature and the negative sample image feature can constitute a negative sample feature pair. Figure 1 Shown is a schematic diagram of a triplet of images, where each group of images is, from left to right, a reference image, a positive sample image, and a negative sample image.
[0065] The triplet loss function based on absolute distance constrains the negative sample feature distance D(f a ,f n ) and the positive sample feature distance D(f a ,f p ) is greater than the preset difference threshold, thereby achieving the optimization goal of increasing the intra-class similarity and reducing the inter-class similarity. Among them, the positive sample feature distance is the distance between the reference image feature and the positive sample image feature, and the negative sample feature distance is the distance between the reference image feature and the negative sample image feature.
[0066] The formula of the triplet loss function based on absolute distance is as follows:
[0067]
[0068] Among them, N tp is the number of triples, i is the serial number subscript, D is the distance function, α is the difference threshold, {*} + =max{*,0}, max is the maximum value function, L triplet is the triplet loss function based on absolute distance.
[0069] In model training, the computational complexity of using all triples to train the model is O(N 3 ), where N is the number of images in the training data set. Therefore, in order to improve the training efficiency of the model, the strategy of hard example mining is often used to select triples, as shown below. Under the strategy of hard example mining, the formula of the triple loss function based on absolute distance is:
[0070]
[0071] Among them, min is the minimum function, j is the serial number subscript, P and A are the number of pedestrians in a training batch and the number of images of each pedestrian, respectively.
[0072] Since the triplet loss function based on absolute distance only constrains the difference between the feature distance of negative samples and the feature distance of positive samples, but does not impose constraints on the image features themselves. In addition, randomness is inevitably introduced when constructing a batch of training data. These reasons lead to deviations in the decision boundaries of feature triplets optimized by the triplet loss function based on absolute distance.
[0073] For example, when the value of α is set to 0.4, for Figure 1 For the triplet images in (a) and (b), since their inter-class similarity and intra-class similarity are both high, after the model training is completed, the negative sample feature distance and positive sample feature distance of the triplet may be 0.5 and 0.1 respectively, and the decision boundary is 0.4; Figure 1 For the triplet images in (c) and (d), due to their low inter-class similarity, the negative sample feature distance and positive sample feature distance of the triplet may be 0.9 and 0.3 respectively after the model training, and the decision boundary is 0.6. This means that even if different triplets meet the constraints of the loss function, their decision boundaries are significantly different. The fundamental reason for the above phenomenon is that the traditional triplet loss function based on absolute distance only imposes constraints on feature triplets alone, and does not directly constrain image features, resulting in inconsistent convergence targets for different triplets.
[0074] Compared with the traditional triplet loss function based on absolute distance, which increases the inter-class distance and reduces the intra-class distance by constraining each triplet individually, the distribution-based triplet loss function proposed in the embodiment of the present application accomplishes similar functions from the perspective of macroscopic feature point distribution. In short, the distribution-based triplet loss function may include a macroscopic constraint function, which constrains the difference between the mean of the feature distance of the negative samples and the mean of the feature distance of the positive samples to be greater than a preset difference threshold, as shown below:
[0075]
[0076] Among them, N ap is the number of positive sample feature pairs, N an is the number of negative sample feature pairs, L macro is the macro constraint function.
[0077] Compared with the traditional triplet loss function L based on absolute distance triplet In comparison, L macro It has the following two advantages: First, the computational complexity is low, L triplet Need to calculate the loss of all triplets, and L macro Only the loss of a triplet and the mean of the two feature pairs need to be calculated. triplet Constraints are imposed on each triple, and the sampling of triples is random, while L macro Constraints are only imposed on the means of the positive sample feature pairs and the negative sample feature pairs, so the constraints are more stable.
[0078] Figure 2(a) shows the distribution diagram of positive sample feature pairs and negative sample feature pairs after the triple loss function constraint based on absolute distance. Figure 2 (b) shows the distribution diagram of positive sample feature pairs and negative sample feature pairs after applying macro constraints, where white circles and black circles represent positive sample feature pairs and negative sample feature pairs, respectively, white triangles and black triangles represent the mean of positive sample feature pairs and the mean of negative sample feature pairs, respectively, and arrows represent the optimization direction. It can be seen that macro constraints can increase the distance between positive sample feature pairs and negative sample feature pairs, but the distribution of positive sample feature pairs and negative sample feature pairs is still loose, resulting in inconsistent convergence of intra-class distance and inter-class distance.
[0079] Considering the above-mentioned deficiencies of macro constraints, constraints from a micro perspective that are complementary to macro constraints are also proposed in the embodiments of the present application:
[0080]
[0081]
[0082] Among them, N ap is the number of positive sample feature pairs, is the number of positive sample feature pairs whose distance is greater than the mean of the positive sample feature distance, N an is the number of negative sample feature pairs, is the number of negative sample feature pairs whose distance is less than the mean of the negative sample feature distance, is the positive sample microscopic constraint function, is the negative sample micro-constraint function.
[0083] The first feature distance is constrained to be reduced to the mean of the positive sample feature distances, wherein the first feature distance is a positive sample feature distance greater than the mean of the positive sample feature distances, and the positive sample feature distances that are already less than or equal to the mean of the positive sample feature distances are not constrained; accordingly, The second feature distance is constrained to increase to the mean of the negative sample feature distances, wherein the second feature distance is the negative sample feature distance that is less than the mean of the negative sample feature distances, and no constraint is imposed on the negative sample feature distances that are already greater than or equal to the mean of the negative sample feature distances.
[0084] It implicitly requires that the distances of all positive sample feature pairs are similar; accordingly, It implicitly requires that the distances of all negative sample feature pairs are similar. In this way, the convergence targets of all positive sample feature pairs are consistent, and the convergence targets of all negative sample feature pairs are also consistent.
[0085] In a specific implementation of the embodiment of the present application, the macro constraint function, the positive sample micro constraint function and the negative sample micro constraint function can be comprehensively considered in the distribution-based triple loss function, that is:
[0086]
[0087] Wherein, λ is a preset weight coefficient, and its specific value can be set according to actual conditions, and is not specifically limited in the embodiment of the present application. triplet_distribution is the distribution-based triplet loss function.
[0088] Figure 2 (c) shows a schematic diagram of the distribution of positive sample feature pairs and negative sample feature pairs after applying macro constraints and micro constraints at the same time. It can be seen that macro constraints can increase the distance between positive sample feature pairs and negative sample feature pairs, while micro constraints can make the distribution more compact and continue to increase the distance between positive sample feature pairs and negative sample feature pairs.
[0089] During the model training process of the pedestrian re-identification model, the above-mentioned distribution-based triplet loss function can be used to obtain a pedestrian re-identification model that is more discriminative and robust to image features.
[0090] After obtaining the person re-identification model, we can apply it to the actual person re-identification task. Figure 3 , an embodiment of a pedestrian re-identification method in the embodiment of the present application may include:
[0091] Step S301: Obtain a pedestrian re-identification task to be processed.
[0092] Step S302: Use the pedestrian re-identification model to process the pedestrian re-identification task to obtain a pedestrian re-identification result.
[0093] In summary, the loss function used in the model training process of the embodiment of the present application is a preset distribution-based triplet loss function; the distribution-based triplet loss function constrains the difference between the mean of the negative sample feature distance and the mean of the positive sample feature distance to be greater than a preset difference threshold; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature. Through the embodiment of the present application, constraints are no longer imposed on each triplet separately, but constraints are imposed on the mean of the positive sample feature distance and the mean of the negative sample feature distance with macroscopic statistical significance, which effectively alleviates the disadvantage of the triplet loss function based on absolute distance in the prior art that the convergence targets for different triplets are not unified, and the features extracted by the trained model are more discriminative and robust, thereby improving the accuracy of the pedestrian re-identification results.
[0094] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0095] Corresponding to the pedestrian re-identification method described in the above embodiment, Figure 4 A structural diagram of an embodiment of a pedestrian re-identification device provided in an embodiment of the present application is shown.
[0096] In this embodiment, a pedestrian re-identification device may include:
[0097] A task acquisition module 401 is used to acquire a pedestrian re-identification task to be processed;
[0098] The pedestrian re-identification module 402 is used to use a preset pedestrian re-identification model to process the pedestrian re-identification task to obtain a pedestrian re-identification result; wherein the loss function used by the pedestrian re-identification model in the model training process is a preset distribution-based triplet loss function; the distribution-based triplet loss function constrains the difference between the mean of the negative sample feature distance and the mean of the positive sample feature distance to be greater than a preset difference threshold; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature.
[0099] In a specific implementation of an embodiment of the present application, the distribution-based triplet loss function also constrains the first feature distance to decrease to the mean of the positive sample feature distances, and the second feature distance to increase to the mean of the negative sample feature distances; the first feature distance is a positive sample feature distance greater than the mean of the positive sample feature distances, and the second feature distance is a negative sample feature distance less than the mean of the negative sample feature distances.
[0100] In a specific implementation of the embodiment of the present application, the distribution-based triplet loss function may include a macro constraint function, a positive sample micro constraint function, and a negative sample micro constraint function;
[0101] The macro constraint function is used to constrain the difference between the mean of the feature distance of the negative samples and the mean of the feature distance of the positive samples to be greater than the difference threshold;
[0102] The positive sample microscopic constraint function is used to constrain the first characteristic distance to be reduced to the mean value of the positive sample characteristic distance;
[0103] The negative sample microscopic constraint function is used to constrain the second characteristic distance to increase to the mean value of the negative sample characteristic distance.
[0104] In a specific implementation of the embodiment of the present application, the distribution-based triple loss function is:
[0105]
[0106] Among them, L macro is the macro constraint function, is the positive sample microscopic constraint function, is the negative sample micro-constraint function, λ is the preset weight coefficient, L triplet_distribution is the distribution-based triplet loss function.
[0107] In a specific implementation of the embodiment of the present application, the macro constraint function is:
[0108]
[0109] Among them, N ap is the number of positive sample feature pairs, N an is the number of negative sample feature pairs, i and j are serial subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, α is the difference threshold, {*} + =max{*,0}, max is the maximum value function.
[0110] In a specific implementation of the embodiment of the present application, the positive sample microscopic constraint function is:
[0111]
[0112] Among them, N ap is the number of positive sample feature pairs, is the number of positive sample feature pairs whose distance is greater than the mean of the positive sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
[0113] In a specific implementation of the embodiment of the present application, the negative sample microscopic constraint function is:
[0114]
[0115] Among them, N an is the number of negative sample feature pairs, is the number of negative sample feature pairs whose distance is less than the mean of the negative sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
[0116] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0117] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0118] Figure 5 A schematic block diagram of a terminal device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0119] like Figure 5 As shown, the terminal device 5 of this embodiment includes: a processor 50, a memory 51, and a computer program 52 stored in the memory 51 and executable on the processor 50. When the processor 50 executes the computer program 52, the steps in the above-mentioned various pedestrian re-identification method embodiments are implemented, such as Figure 3 Alternatively, when the processor 50 executes the computer program 52, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 4 The functions of modules 401 to 402 are shown.
[0120] Exemplarily, the computer program 52 may be divided into one or more modules / units, which are stored in the memory 51 and executed by the processor 50 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 52 in the terminal device 5.
[0121] The terminal device 5 can be a computing device such as a mobile phone, a tablet computer, a desktop computer, a notebook, a PDA, a robot, etc. Those skilled in the art will understand that Figure 5It is only an example of the terminal device 5 and does not constitute a limitation of the terminal device 5. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the terminal device 5 may also include input and output devices, network access devices, buses, etc.
[0122] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) 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, etc.
[0123] The memory 51 may be an internal storage unit of the terminal device 5, such as a hard disk or memory of the terminal device 5. The memory 51 may also be an external storage device of the terminal device 5, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the terminal device 5. Further, the memory 51 may also include both an internal storage unit of the terminal device 5 and an external storage device. The memory 51 is used to store the computer program and other programs and data required by the terminal device 5. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0124] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by 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 embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0125] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0126] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example 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 performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0127] In the embodiments provided in the present 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 only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0128] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0129] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0130] If the integrated module / unit is implemented in the form of 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, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased 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 storage media do not include electric carrier signals and telecommunication signals.
[0131] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such 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 application, and should all be included in the protection scope of the present application.
Claims
1. A pedestrian re-identification method, characterized in that: include: Get the pending person re-identification task; Using a preset pedestrian re-identification model to process the pedestrian re-identification task to obtain a pedestrian re-identification result; The loss function used by the pedestrian re-identification model in the model training process is a preset distribution-based triplet loss function; The distribution-based triplet loss function is: Among them, L macro is a macro constraint function, which is used to constrain the difference between the mean of the feature distance of negative samples and the mean of the feature distance of positive samples to be greater than the preset difference threshold. is the positive sample microscopic constraint function, which is used to constrain the first feature distance to be reduced to the mean value of the positive sample feature distance. is the negative sample micro-constraint function, which is used to constrain the second feature distance to increase to the mean of the negative sample feature distance, λ is the preset weight coefficient, L triplet_distribution is the distribution-based triplet loss function, the first feature distance is a positive sample feature distance greater than the mean of the positive sample feature distances, the second feature distance is a negative sample feature distance less than the mean of the negative sample feature distances; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature.
2. The pedestrian re-identification method according to claim 1, characterized in that: The macro constraint function is: Among them, N ap is the number of positive sample feature pairs, N an is the number of negative sample feature pairs, i and j are serial subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, α is the difference threshold, {*} + =max{*,0}, max is the maximum value function.
3. The pedestrian re-identification method according to claim 1, characterized in that: The positive sample microscopic constraint function is: Among them, N ap is the number of positive sample feature pairs, is the number of positive sample feature pairs whose distance is greater than the mean of the positive sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
4. The pedestrian re-identification method according to claim 1, characterized in that: The negative sample microscopic constraint function is: Among them, N an is the number of negative sample feature pairs, is the number of negative sample feature pairs whose distance is less than the mean of the negative sample feature distance, i and j are serial number subscripts, and f a 、f p and f n are the benchmark image features, positive sample image features and negative sample image features respectively, D is the distance function, {*} + =max{*,0}, max is the maximum value function.
5. A pedestrian re-identification device, characterized in that: include: A task acquisition module is used to obtain pending person re-identification tasks; A pedestrian re-identification module, used to process the pedestrian re-identification task using a preset pedestrian re-identification model to obtain a pedestrian re-identification result; wherein the loss function used by the pedestrian re-identification model in the model training process is a preset distribution-based triplet loss function; The distribution-based triplet loss function is: Among them, L macro is a macro constraint function, which is used to constrain the difference between the mean of the feature distance of negative samples and the mean of the feature distance of positive samples to be greater than the preset difference threshold. is the positive sample microscopic constraint function, which is used to constrain the first feature distance to be reduced to the mean value of the positive sample feature distance. is the negative sample micro-constraint function, which is used to constrain the second feature distance to increase to the mean of the negative sample feature distance, λ is the preset weight coefficient, L triplet_distribution is the distribution-based triplet loss function, the first feature distance is a positive sample feature distance greater than the mean of the positive sample feature distances, the second feature distance is a negative sample feature distance less than the mean of the negative sample feature distances; the positive sample feature distance is the distance between the reference image feature and the positive sample image feature; the negative sample feature distance is the distance between the reference image feature and the negative sample image feature.
6. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the pedestrian re-identification method according to any one of claims 1 to 4 are implemented.
7. 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, the steps of the pedestrian re-identification method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Face verification method and device based on Triplet Loss, computer device and storage medium
CN108009528A
Pedestrian re-identification method and device, equipment and storage medium
CN113569657A