A ReID model training method, a ReID pedestrian recognition method, equipment and a medium
Patent Information
- Application Number
- CN202310929840.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2026-09-25
- Estimated Expiration
- 2043-07-26
AI Technical Summary
[0006]为了克服上述缺陷,提出了本发明,提供一种,以解决或至少部分地解决现有技术中因等概率的从数据集中选取数据而导致训练出的ReID模型在识别难例样本时准确率低的技术问题
[0053]在实施本发明的技术方案中,S101、基于数据集的类采样权重,从数据集中选取部分图片作为训练子数据集;S102、基于所述训练子数据集,对ReID模型进行一次迭代训练,在当前迭代过程中,通过损失函数更新ReID模型的权重;S103、判断所述数据集中的所有图片样本是否均完成一次迭代训练;若是,则认为完成对所述数据集的一轮训练,执行步骤S104;若否,循环执行步骤S101-S102,直到所述数据集中的所有图片样本均已完成一次迭代训练;S104、判断所述数据集是否完成预设轮数的训练;若是,执行步骤S105;若否,执行步骤S106;S105、结束训练,并输出训练好的ReID模型;S106、基于训练后的数据集,更新所述类采样权重,循环执行步骤S101-S104,直至所述数据集已完成预设轮数的训练。在本发明中,训练子数据集每完成一轮训练后,就更新一次类采样权重,基于更新后的类采样权重继续对ReID模型进行训练,也就是说,选取图片样本的概率是随着ReID模型训练的进度逐渐更新的,因此,使得训练后的ReID模型具有较好的识别难例样本的能力,提高难例样本识别的准确率。
Smart Images

Figure CN117079309B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of pedestrian re-identification technology, specifically providing a ReID model training method, a ReID pedestrian identification method, device, and medium. Background Technology
[0002] Person re-identification (ReID) is a technology that uses computer vision to determine whether a specific person exists in an image or video sequence. It has received widespread attention and application in academia and industry, and plays an important role in an increasing number of application scenarios, such as pedestrian tracking and area search.
[0003] In existing technologies, the PK sampling method is usually used to train the ReID model. That is, P categories are selected with equal probability from all categories in the dataset, and K images are selected with equal probability from each of the P categories to form P*K samples for subsequent ReID model training.
[0004] However, for pedestrian re-identification tasks, the number of good examples in the dataset is much greater than the number of difficult examples. The PK sampling method selects data with equal probability, which will result in the number of difficult examples being selected being less than the number of good examples. Therefore, the trained ReID model has a low accuracy when identifying difficult examples.
[0005] Accordingly, a new ReID model training scheme is needed in this field to solve the above problems. Summary of the Invention
[0006] To overcome the above-mentioned shortcomings, this invention is proposed to provide a solution to, or at least partially solve, the technical problem in the prior art where the accuracy of the ReID model trained by selecting data from the dataset with equal probability is low when identifying difficult samples.
[0007] In a first aspect, the present invention provides a ReID model training method, the method comprising the following steps:
[0008] S101. Based on the class sampling weights of the dataset, select a subset of images from the dataset as the training subset;
[0009] S102. Based on the training subset dataset, perform one iteration of training on the ReID model. During the current iteration, update the weights of the ReID model using the loss function.
[0010] S103. Determine whether all image samples in the dataset have completed one iteration of training; if yes, consider that one round of training on the dataset has been completed and proceed to step S104; if no, repeat steps S101-S102 until all image samples in the dataset have completed one iteration of training.
[0011] S104. Determine whether the dataset has completed the preset number of training rounds; if yes, proceed to step S105; if no, proceed to step S106.
[0012] S105. End training and output the trained ReID model;
[0013] S106. Based on the trained dataset, update the class sampling weights and repeat steps S101-S104 until the dataset has completed a preset number of training rounds.
[0014] In one technical solution of the above ReID model training method, the dataset contains several categories, each category corresponds to a different target to be identified, and each category contains several images; the class sampling weights include inter-class sampling weights and intra-class sampling weights;
[0015] The class sampling weights based on the dataset, which select a subset of images from the dataset as the training subset, specifically include:
[0016] S1011. Select a category from the dataset with equal probability;
[0017] S1012. Select P-1 categories from the dataset according to the inter-class sampling weights corresponding to a category;
[0018] S1013. Select one image from the selected class P-1 with equal probability;
[0019] S1014. According to the intra-class sampling weights corresponding to each category, sample K-1 images within each category;
[0020] S1015. A batch of P*K images is formed as a training subset.
[0021] In one technical solution of the above ReID model training method, the class sampling weights include: inter-class sampling weights;
[0022] The method includes obtaining inter-class sampling weights based on the following formula:
[0023]
[0024] in, This represents the inter-class sampling weights for the i-th class of image samples. Let represent the probability of the i-th class of image samples. This represents the total weight of all image samples. The value is 1.
[0025] In one technical solution of the above ReID model training method, the class sampling weights include: intra-class sampling weights;
[0026] The method includes obtaining intra-class sampling weights based on the following formula:
[0027]
[0028] in, This represents the within-class sampling weight of the i-th image sample. Let represent the probability of the i-th class of image samples. This represents the total weight of all image samples. The value is 1.
[0029] In one technical solution of the above ReID model training method, the method further includes determining the loss function based on the features of any image sample in the training subset, the features of different category image samples with the highest similarity to it, the features of the same category image samples with the lowest similarity to it, and the following formula:
[0030]
[0031] Where Loss is the loss function, and cos is the cosine distance. For the i-th image sample in the training set, For training focus and Features of the most similar image samples from different categories. For training focus and Features of images of the same category with the lowest similarity. These are the training parameters.
[0032] In one technical solution of the above ReID model training method, updating the class sampling weights based on the trained dataset includes:
[0033] Determine the features of each image sample in the trained dataset;
[0034] Based on the features of each image sample, determine the class average features under different categories;
[0035] Update the inter-class sampling weights based on the class average features and the following formula:
[0036]
[0037] in, For the updated inter-class sampling weights, The inter-class sampling weights before the update are given, and cos is the cosine distance. For smoothing coefficients, The average feature under category X, This represents the average feature under category Y.
[0038] In one technical solution of the above ReID model training method, updating the class sampling weights based on the trained dataset further includes:
[0039] Determine the features of each image sample in the trained dataset;
[0040] Based on the features of each image sample, determine the average features of the same category;
[0041] Update the within-class sampling weights based on the class average features and the following formula:
[0042]
[0043] in, For the updated intra-class sampling weights, The values represent the intra-class sampling weights before the update, and cos represents the cosine distance. For smoothing coefficients, For the i-th image sample in the category, Let be the feature of the j-th image sample in the category.
[0044] In a second aspect, the present invention provides a ReID pedestrian identification method, comprising:
[0045] Acquire the image to be recognized;
[0046] The image to be identified is identified based on the trained ReID model;
[0047] The ReID model is trained using any one of the ReID model training methods described in the technical solution of the ReID model training method.
[0048] In a third aspect, the present invention provides an electronic device comprising:
[0049] processor;
[0050] The memory is adapted to store multiple lines of program code, which are adapted to be loaded and run by the processor to perform the ReID model training method as described in any one of the above-described ReID model training method technical solutions, or the ReID pedestrian recognition method as described in any one of the ReID pedestrian recognition method technical solutions.
[0051] In a fourth aspect, the present invention provides a computer-readable storage medium storing a plurality of program codes adapted to be loaded and run by a processor to perform any one of the technical solutions for the ReID model training method described above, or any one of the technical solutions for the ReID pedestrian recognition method.
[0052] The above-described technical solutions of the present invention have at least one or more of the following beneficial effects:
[0053] In implementing the technical solution of the present invention, S101: Based on the class sampling weights of the dataset, select a portion of images from the dataset as a training subset; S102: Based on the training subset, perform one iteration of training on the ReID model, updating the weights of the ReID model through a loss function during the current iteration; S103: Determine whether all image samples in the dataset have completed one iteration of training; if yes, consider one round of training on the dataset complete, and execute step S104; if no, repeat steps S101-S102 until all image samples in the dataset have completed one iteration of training; S104: Determine whether the dataset has completed a preset number of training rounds; if yes, execute step S105; if no, execute step S106; S105: End training and output the trained ReID model; S106: Based on the trained dataset, update the class sampling weights, repeat steps S101-S104 until the dataset has completed a preset number of training rounds. In this invention, the class sampling weights are updated once after each round of training of the training subset. The ReID model is then trained again based on the updated class sampling weights. In other words, the probability of selecting image samples is gradually updated as the ReID model training progresses. Therefore, the trained ReID model has a better ability to identify difficult samples and improves the accuracy of difficult sample identification. Attached Figure Description
[0054] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Furthermore, similar numbers in the drawings are used to denote similar components, wherein:
[0055] Figure 1 This is a flowchart of the main steps of the ReID model training method of the present invention;
[0056] Figure 2 This is the present invention. Figure 1 Detailed flowchart of step S101;
[0057] Figure 3This is a flowchart of the steps of a ReID model training method according to an embodiment of the present invention;
[0058] Figure 4 This is a flowchart of the main steps of the ReID pedestrian recognition method of the present invention;
[0059] Figure 5 This is a main structural block diagram of an electronic device used to execute the ReID model training method or the ReID pedestrian recognition method of the present invention. Detailed Implementation
[0060] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.
[0061] In the description of this invention, "module" and "processor" can include hardware, software, or a combination of both. A module can include hardware circuitry, various suitable sensors, communication ports, memory, and may also include software components, such as program code, or a combination of software and hardware. A processor can be a central processing unit, microprocessor, image processor, digital signal processor, or any other suitable processor. The processor has data and / or signal processing capabilities. The processor can be implemented in software, in hardware, or a combination of both. Non-transitory computer-readable storage media includes any suitable medium capable of storing program code, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B, or A and B. The terms "at least one A or B" or "at least one of A and B" have a similar meaning to "A and / or B" and can include only A, only B, or A and B. The singular terms "a" or "this" can also include plural forms.
[0062] Please see the appendix Figure 1 , Figure 1 This is a flowchart of the main steps of the ReID model training method according to the present invention.
[0063] like Figure 1 As shown, this invention provides a ReID model training method, which includes the following steps:
[0064] S101. Based on the class sampling weights of the dataset, select a subset of images from the dataset as the training subset;
[0065] S102. Based on the training subset dataset, perform one iteration of training on the ReID model. During the current iteration, update the weights of the ReID model using the loss function.
[0066] S103. Determine whether all image samples in the dataset have completed one iteration of training; if yes, consider that one round of training on the dataset has been completed and proceed to step S104; if no, repeat steps S101-S102 until all image samples in the dataset have completed one iteration of training.
[0067] S104. Determine whether the dataset has completed the preset number of training rounds; if yes, proceed to step S105; if no, proceed to step S106.
[0068] S105. End training and output the trained ReID model;
[0069] S106. Based on the trained dataset, update the class sampling weights and repeat steps S101-S104 until the dataset has completed a preset number of training rounds.
[0070] In this invention, the class sampling weights are updated once after each round of training of the training subset. The ReID model is then trained again based on the updated class sampling weights. In other words, the probability of selecting image samples is gradually updated as the ReID model training progresses. Therefore, the trained ReID model has a better ability to identify difficult samples and improves the accuracy of difficult sample identification.
[0071] In one implementation, please refer to the appendix. Figure 2 , Figure 2 This is the present invention. Figure 1 Detailed flowchart of step S101.
[0072] like Figure 2 As shown, the dataset contains several categories, each corresponding to a different target to be identified, and each category contains several images; the class sampling weights include inter-class sampling weights and intra-class sampling weights;
[0073] The class sampling weights based on the dataset, which select a subset of images from the dataset as the training subset, specifically include:
[0074] S201. Select a category from the dataset with equal probability;
[0075] S202. Select P-1 categories from the dataset according to the inter-class sampling weights corresponding to a category;
[0076] S203. Select one image from the selected class P-1 with equal probability;
[0077] S204. According to the intra-class sampling weights corresponding to each category, sample K-1 images within each category;
[0078] S205. A batch of P*K images is formed as a training subset.
[0079] In one implementation, the class sampling weights include: inter-class sampling weights;
[0080] The method includes obtaining inter-class sampling weights based on the following formula:
[0081]
[0082] in, This represents the inter-class sampling weights for the i-th class of image samples. Let represent the probability of the i-th class of image samples. This represents the total weight of all image samples. The value of is 1.
[0083] In one implementation, the class sampling weights include: intra-class sampling weights;
[0084] The method includes obtaining intra-class sampling weights based on the following formula:
[0085]
[0086] in, This represents the within-class sampling weight of the i-th image sample. Let represent the probability of the i-th class of image samples. This represents the total weight of all image samples. The value of is 1.
[0087] One point to note is that, regardless of whether the sampling weights are between classes or within classes, during the first round of training of the ReID model, and All are initialized to 1, meaning that image samples are selected from the dataset with equal probability.
[0088] Combining the inter-class sampling weights and intra-class sampling weights mentioned above, the following will explain in detail how to select a subset of images from the dataset as a training sub-dataset based on the class sampling weights.
[0089] Specifically, one category is randomly selected from multiple categories in the dataset. Based on the inter-class sampling weight, P-1 categories are selected from the multiple categories. That is, a total of P categories are selected. Then, one image sample is selected from each of the P categories. Based on the intra-class sampling weight, K-1 image samples are selected from the P categories. Then, P*K images form a batch, which is used as the training subset.
[0090] It is worth noting that when randomly selecting a category from multiple categories, the category is preferentially selected from those categories that have not yet been trained in the current round with equal probability. If all categories have been trained, then all categories are selected with equal probability. Similarly, when selecting an image sample from each of the above P categories, the image sample is preferentially selected from those that have not yet been trained in the current round with equal probability. If all categories have been trained, then all samples in that category are selected with equal probability.
[0091] In one implementation, in step S102, the method further includes determining a loss function based on the features of any image sample in the training subset, the features of different category image samples with the highest similarity to them, and the features of the same category image samples with the lowest similarity to them, and the following formula:
[0092]
[0093] Where Loss is the loss function, and cos is the cosine distance. For the i-th image sample in the training set, For training focus and Features of the most similar image samples from different categories. For training focus and Features of images of the same category with the lowest similarity. These are the training parameters.
[0094] For example, The value can be 0.3.
[0095] However, in practical applications, The value can be adjusted according to the actual situation, and no specific limit is set here, in order to meet the needs of different scenarios.
[0096] In one implementation, in step S106 above, updating the class sampling weights based on the trained dataset includes:
[0097] Determine the features of each image sample in the trained dataset;
[0098] Based on the features of each image sample, determine the class average features under different categories;
[0099] Update the inter-class sampling weights based on the class average features and the following formula:
[0100]
[0101] in, For the updated inter-class sampling weights, The inter-class sampling weights before the update are given, and cos is the cosine distance. For smoothing coefficients, The average feature under category X, This represents the average feature under category Y.
[0102] For example, The value can be 0.3.
[0103] However, in practical applications, The value is generally between 0 and 1, and can be adjusted according to the actual situation. No specific limit is set here to meet the needs of different scenarios.
[0104] Furthermore, after determining the features of each image sample in the training dataset, the average features of the image samples under each category can be obtained.
[0105] In one implementation, updating the class sampling weights based on the trained dataset further includes:
[0106] Determine the features of each image sample in the trained dataset;
[0107] Based on the features of each image sample, determine the average features of the same category;
[0108] Update the within-class sampling weights based on the class average features and the following formula:
[0109]
[0110] in, For the updated intra-class sampling weights, The values represent the intra-class sampling weights before the update, and cos represents the cosine distance. For smoothing coefficients, For the i-th image sample in the category, Let be the features of the j-th image sample in the category.
[0111] For example, The value can be 0.2.
[0112] However, in practical applications, The value is generally between 0 and 1, and can be adjusted according to the actual situation. No specific limit is set here to meet the needs of different scenarios.
[0113] Furthermore, after determining the features of each image sample in the training dataset, the average features of image samples in the same category can be used to obtain the class average features.
[0114] To illustrate the ReID model training method described above, this invention provides an embodiment, please refer to the appendix. Figure 3 .
[0115] Figure 3 This is a flowchart illustrating the steps of a ReID model training method according to an embodiment of the present invention. Figure 3 As shown, the ReID model training method according to this embodiment includes the following steps:
[0116] For example, let's take the inter-class sampling weights and intra-class sampling weights during the first round of training of the ReID model as initial inter-class sampling weights and initial intra-class sampling weights, respectively, as an example for explanation.
[0117] S301. Select a class from the dataset with equal probability. According to the initial inter-class sampling weight, select P-1 classes from the dataset. In the selected P-1 classes, select an image with equal probability. According to the initial intra-class sampling weight, sample K-1 images in each class. Form a batch of P*K images as a training subset.
[0118] S302. Train the ReID model once using the training subset dataset. During the current iteration, update the weights of the ReID model using the loss function.
[0119] The expression for the loss function can be found above and will not be repeated here.
[0120] S303. Determine whether all image samples in the dataset have completed one iteration of training; if yes, proceed to step S304; if no, repeat steps S301-S302.
[0121] S304. Continue to determine whether the dataset has completed the preset number of training rounds; if yes, proceed to step S305; if no, proceed to step S306.
[0122] S305. End training and output the trained ReID model;
[0123] S306. Update the inter-class sampling weights and intra-class sampling weights. Select one class from the dataset with equal probability. According to the updated inter-class sampling weights, select P-1 classes from the dataset. In the selected P-1 classes, select one image with equal probability. According to the updated intra-class sampling weights, sample K-1 images in each class. Form a batch of P*K images as a training subset. Repeat steps S302 to S304 until the dataset has completed the preset number of training rounds.
[0124] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.
[0125] All of the above-mentioned optional technical solutions can be combined in any way to form the optional embodiments of this application, and will not be described in detail here.
[0126] Please see the appendix Figure 4 , Figure 4 This is a flowchart of the steps of a ReID pedestrian identification method according to the present invention;
[0127] like Figure 4 As shown, the present invention also provides a ReID pedestrian recognition method, comprising the following steps:
[0128] S401. Obtain the image to be recognized;
[0129] S402. Recognize the image to be recognized based on the trained ReID model;
[0130] The ReID model is trained based on any one of the ReID model training methods described above.
[0131] Furthermore, the present invention also provides an electronic device. Please refer to the appendix. Figure 5 , Figure 5 This is a block diagram of the main structure of an electronic device used to implement the ReID model training method and the ReID pedestrian recognition method of the present invention.
[0132] like Figure 5 As shown, in one embodiment of the electronic device according to the present invention, the electronic device 500 includes a processor 501 and a memory 502. The memory 502 may be configured to store program code 503 for executing the driving device positioning method of the above-described method embodiments. The processor 501 may be configured to execute the program code 503 in the memory 502. The program code 503 includes, but is not limited to, program code 503 for executing the driving device positioning method of the above-described method embodiments. For ease of explanation, only the parts related to the embodiments of the present invention are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of the present invention.
[0133] For example, processor 501 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 it may be any conventional processor.
[0134] The memory 502 can be an internal storage unit of an electronic device, such as a hard drive or RAM; it can also be an external storage device, such as a plug-in hard drive, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory can include both internal and external storage units. The memory is used to store computer programs and other programs and data required by the electronic device. It can also be used to temporarily store data that has been output or will be output.
[0135] In some possible implementations, the electronic device may include multiple processors and memories. The program code 503 executing the driving device positioning method of the above method embodiments can be divided into multiple subroutines, each of which can be loaded and run by a processor to perform different steps of the driving device positioning method of the above method embodiments. Specifically, each subroutine can be stored in a different memory, and each processor can be configured to execute programs in one or more memories to jointly implement the driving device positioning method of the above method embodiments; that is, each processor executes different steps of the driving device positioning method of the above method embodiments to jointly implement the driving device positioning method of the above method embodiments.
[0136] The aforementioned multiple processors can be processors deployed on the same device. For example, the aforementioned electronic device can be a high-performance device composed of multiple processors, and the aforementioned multiple processors can be processors configured on that high-performance device. Alternatively, the aforementioned multiple processors can also be processors deployed on different devices. For example, the aforementioned electronic device can be a server cluster, and the aforementioned multiple processors can be processors on different servers within the server cluster.
[0137] Electronic devices can be desktop computers, laptops, handheld computers, and cloud servers, such as the aforementioned driving devices, mobile terminals, and driving device positioning systems. Electronic devices may include, but are not limited to, processors and memory. Those skilled in the art will understand that... Figure 5 This is merely an example of an electronic device and does not constitute a limitation on the electronic device. It may include more or fewer components than illustrated, or combine certain components, or different components. For example, an electronic device may also include input / output devices, network access devices, buses, etc.
[0138] Furthermore, the present invention also provides a computer-readable storage medium. In one embodiment of the computer-readable storage medium according to the present invention, the computer-readable storage medium can be configured to store a program for performing the driving device positioning method of the above-described method embodiments. This program can be loaded and run by a processor to implement the above-described driving device positioning method. For ease of explanation, only the parts related to the embodiments of the present invention are shown; for specific technical details not disclosed, please refer to the method section of the embodiments of the present invention. The computer-readable storage medium can be a storage device device comprising various electronic devices. Optionally, in the embodiments of the present invention, the computer-readable storage medium is a non-transitory computer-readable storage medium.
[0139] 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.
[0140] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in connection with the embodiments of this invention 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 each specific application, but such implementation should not be considered beyond the scope of this invention.
[0141] In the embodiments provided by this invention, it should be understood that the disclosed electronic devices and methods can be implemented in other ways. For example, the electronic device 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. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0142] 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.
[0143] Furthermore, the functional units in the various embodiments of the present invention 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.
[0144] If integrated modules / units are implemented as software functional units and sold or used as independent products, they 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 of the present invention 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 may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. Computer-readable media may include: any entity or device capable of carrying 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 a computer-readable medium may be appropriately added to or subtracted 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 may not include electrical carrier signals and telecommunication signals.
[0145] The relevant user personal information that may be involved in the various embodiments of this application is processed in strict accordance with the requirements of laws and regulations, following the principles of legality, legitimacy, and necessity, based on the reasonable purpose of the business scenario, and includes personal information that users actively provide or that is generated as a result of using the product / service, as well as personal information obtained with user authorization.
[0146] The personal information of users processed by the applicant will vary depending on the specific product / service scenario and will be based on the specific scenario in which the user uses the product / service. This may involve the user's account information, device information, driving information, vehicle information, or other related information. The applicant will treat the user's personal information and its processing with a high degree of diligence.
[0147] The applicant attaches great importance to the security of users' personal information and has taken reasonable and feasible security protection measures that meet industry standards to protect users' information and prevent unauthorized access, disclosure, use, modification, damage or loss of personal information.
[0148] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.
Claims
1. A ReID model training method, characterized in that, The method includes the following steps: S101. Based on the class sampling weights of the dataset, select a subset of images from the dataset as the training subset; S102. Based on the training subset dataset, perform one iteration of training on the ReID model. During the current iteration, update the weights of the ReID model using the loss function. S103. Determine whether all image samples in the dataset have completed one iteration of training; if yes, consider that one round of training on the dataset has been completed and proceed to step S104; if no, repeat steps S101-S102 until all image samples in the dataset have completed one iteration of training. S104. Determine whether the dataset has completed the preset number of training rounds; if yes, proceed to step S105; if no, proceed to step S106. S105. End training and output the trained ReID model; S106. Based on the trained dataset, update the class sampling weights, and repeat steps S101-S104 until the dataset has completed a preset number of training rounds; the dataset contains several categories, each category corresponds to a different target to be identified, and each category contains several images; the class sampling weights include inter-class sampling weights and intra-class sampling weights. The class sampling weights based on the dataset, which select a subset of images from the dataset as the training subset, specifically include: S1011. Select a category from the dataset with equal probability; S1012. Select P-1 categories from the dataset according to the inter-class sampling weights corresponding to a category; S1013. Select one image from the selected class P-1 with equal probability; S1014. According to the intra-class sampling weights corresponding to each category, sample K-1 images within each category; S1015. A batch of P*K images is formed as a training subset; the update of the class sampling weights based on the trained dataset includes: Determine the features of each image sample in the trained dataset; Based on the features of each image sample, determine the class average features under different categories; Update the inter-class sampling weights based on the class average features and the following formula: in, For the updated inter-class sampling weights, The inter-class sampling weights before the update are given, and cos is the cosine distance. For smoothing coefficients, The average feature under category X, The average feature under category Y; the update of the class sampling weights based on the trained dataset further includes: Determine the features of each image sample in the trained dataset; Based on the features of each image sample, determine the average features of the same category; Update the within-class sampling weights based on the class average features and the following formula: in, For the updated intra-class sampling weights, The values represent the intra-class sampling weights before the update, and cos represents the cosine distance. For smoothing coefficients, For the i-th image sample in the category, Let be the feature of the j-th image sample in the category.
2. The ReID model training method according to claim 1, characterized in that, The method further includes determining a loss function based on the features of any image sample in the training subset, the features of the different category image samples with the highest similarity to it, the features of the same category image samples with the lowest similarity to it, and the following formula: Where Loss is the loss function, and cos is the cosine distance. For the i-th image sample in the training set, For training focus and Features of the most similar image samples from different categories. For training focus and Features of images of the same category with the lowest similarity. These are the training parameters.
3. A ReID pedestrian recognition method, characterized in that, include: Acquire the image to be recognized; The image to be identified is identified based on the trained ReID model; The ReID model is trained based on the ReID model training method described in any one of claims 1-2.
4. An electronic device, characterized in that, include: Memory; processor; The memory is adapted to store multiple lines of program code, characterized in that the program code is adapted to be loaded and run by the processor to perform the ReID model training method according to any one of claims 1-2, or the ReID pedestrian recognition method according to claim 3.
5. A computer-readable storage medium storing a plurality of program codes, characterized in that, The program code is adapted to be loaded and run by a processor to perform the ReID model training method of any one of claims 1-2, or the ReID pedestrian recognition method of claim 3.