Intelligent camera model terminal training method, device, equipment and medium

Through the smart camera model self-training method, combined with multi-stage training and reliable weight technology, the problem of poor applicability of smart camera detection models in different scenarios is solved, and the detection model fine-tuning and optimization on the user side is realized, ensuring data security and detection. Accuracy.

CN113139475BActive Publication Date: 2024-09-06WUHAN SIMSHINE INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110456609.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-27
Publication Date
2024-09-06
Estimated Expiration
2041-01-27

AI Technical Summary

Technical Problem

Smart cameras are not suitable for detection models due to sample training differences in different application scenarios, and due to privacy and security considerations, they are unwilling to upload data to the server for updates, which increases hardware costs and maintenance time.

Method used

Adopting the smart camera model self-training method, by merging the preset sample set and the local real-time collected sample set, using multi-stage training and reliable weight technology, the model is trained and fine-tuned in stages to ensure that the model completes the update of the detection model on the user side. and optimization.

Benefits of technology

It achieves fine-tuning training of smart camera detection models in the expected direction without human intervention, improving detection accuracy and applicability while ensuring data security and user privacy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113139475B
    Figure CN113139475B
Patent Text Reader

Abstract

The present invention belongs to the field of image processing technology, solves the technical problem that the self-training effect is poor due to the inability to avoid wrong labels by setting a confidence threshold during the self-training process, and provides a method, device, equipment and medium for training a smart camera model terminal. The method includes: merging a preset first sample set and a second sample set collected locally in real time by a smart camera, and outputting a training sample set; training the current model in stages according to the training sample set, and outputting a verification model; wherein the staged training includes a first stage training corresponding to the model convergence and a second stage training corresponding to the model fine-tuning. The present invention also includes an apparatus, equipment and medium for executing the above method. The present invention completes network convergence through the first stage training, and then in the second training stage, the influence of wrong labels in the training process can be gradually reduced through reliable weights, thereby improving the effect of self-training.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of the invention patent application filed on January 27, 2021, with the invention name “Smart camera model self-training method, device, equipment and medium” and application number 202110109737.7. Technical Field

[0002] The present invention relates to the field of image processing technology, and in particular to a method, device, equipment and medium for self-training an intelligent camera model. Background Art

[0003] As video surveillance equipment is widely used to monitor different scenes in daily life, cameras, especially smart cameras with image analysis functions, have become a common monitoring tool in today's life monitoring management. In addition to being equipped with conventional camera shooting, this smart camera is also equipped with a chip with processor function, which can perform simple processing and analysis on the captured scene image data.

[0004] However, in the prior art, since the chips of such smart cameras have computing capabilities, in order to enable the smart cameras to adapt to multi-scenario applications, the usual practice is that such smart cameras will collect as many sample images of multiple scenes as possible before leaving the factory to train a lightweight network model and deploy it on the smart camera, so that the smart camera can be applied to different scenarios, such as: infant care management, hospital patient monitoring, school monitoring, shopping mall monitoring, garage monitoring, scenic area monitoring, farm monitoring, road traffic monitoring, etc.

[0005] Although smart cameras have collected a lot of samples for different application scenarios in advance, and a large number of sample trainings have been conducted for each scenario, when smart cameras are directly used in scenarios for monitoring, there are still large differences in the actual scenarios of different users. This makes the basic detection model obtained by a large number of trainings before the smart camera leaves the factory inapplicable and prone to large deviations. In addition, there is another way to connect the smart camera to the server, and the server provides an upgrade installation package for the basic detection model to upgrade the basic detection model of the smart camera. However, as people consider personal privacy and information security, they are unwilling to connect smart cameras to servers, and other methods such as downloading the update package of the basic detection model will increase the hardware cost of the smart camera (because existing smart cameras generally do not have interactive display interfaces such as touch screens. If interactive hardware recognition such as touch screens is set up, the cost of the smart camera will increase) and upgrade maintenance time. Summary of the invention

[0006] In view of this, the embodiments of the present invention provide a method, device, equipment and medium for self-training of an intelligent camera model to solve the technical problem that the self-training effect is poor due to the inability to avoid erroneous labels by setting a confidence threshold during the self-training process.

[0007] The technical solution adopted by the present invention is: the present invention provides a method for training a smart camera model terminal, the method comprising:

[0008] Merging a preset first sample set and a second sample set to output a training sample set, wherein the second sample set is composed of each local real-time image and each pseudo label;

[0009] The first loss function is used to perform the first stage training on the current model using the training sample set, and an intermediate training model is output, wherein the current model is obtained by randomly training a training set consisting of training samples of a plurality of application scenarios collected, and the scenarios include at least one of the following: infant care, school, playground, shopping mall, garage, farm and road;

[0010] On the basis of the intermediate training model, the second stage training is performed using the training sample set through a second loss function and reliable weights to output a verification model.

[0011] Preferably, obtaining a reliable weight corresponding to each positive sample used for training in the second stage;

[0012] Performing first-stage training on the current model using the first loss function and the training sample set, and outputting an intermediate training model;

[0013] Performing second-stage training on the current model based on the intermediate training model using the second loss function and the reliable weight, and outputting a verification model;

[0014] Among them, in each round of training of the second stage training, the reliable weights corresponding to each positive sample are independent of each other, the reliable weights are the parameters of the full channel output of the network output layer of the current model, and the current model of this training is the model obtained after the previous training; in multiple rounds of training of the intermediate training model, each round of training respectively adds the corresponding reliable weights of the current model output for each positive sample to participate in this round of training; wherein, a weight channel for outputting reliable weights is added to the network output layer, and the obtaining of the reliable weights corresponding to each positive sample for training in the second stage includes:

[0015] Obtain the mapping function and the position information of each positive sample in the training set;

[0016] According to the position information, the value corresponding to each position information in the weight channel is output, and the mapping function outputs the reliable weight of each positive sample corresponding to each value, wherein each round of training includes multiple training batches, and each positive sample corresponding to the sample belonging to the second sample set in each training batch is sorted according to the reliable weight, and a reliable weight sequence is output, and the obtaining of the reliable weight corresponding to each positive sample for training in the second stage includes:

[0017] Obtain the proportion of high reliability weights and low reliability weights in the reliability weight sequence;

[0018] According to the quantity proportion, the formula M=α*N is used to output each of the high reliability weights and each of the low reliability weights;

[0019] M is the number of high-reliability weights, α is the proportion of high-reliability weights, and N is the total number of reliable weights in the reliable weight sequence in each batch;

[0020] Among them, in each training batch, when the positive sample belongs to the second sample set, the second loss function also includes a second supervision function of the weight channel, and the second stage training of the current model is performed on the basis of the intermediate training model using the reliable weight, and the output verification model includes:

[0021] Obtaining the reliable weight sequence output by the current training batch;

[0022] According to the high reliability weights, the formula Calculate the first weight average W corresponding to each high-reliability weight in the current training batch H ;

[0023] According to the low reliability weights, the formula Calculate the second weight average W corresponding to each low reliable weight in the current training batch L ;

[0024] According to the first weighted average value W H , the second weighted average value W L And the second supervision function L w =max(0,δ-(w H -w L )), performing the current training batch by using the second loss function;

[0025] Repeat the process of obtaining the reliable weight sequence output by the current training batch until the first weight average value W is obtained. H , the second weighted average value W L And the second supervision function Lw =max(0,δ-(w H -w L )), performing the current training batch by using the second loss function until the second stage training is completed, and outputting the verification model;

[0026] Where M is the number of high-reliability weights in a training batch, N is the total number of positive samples belonging to the second sample set in a training batch, and W a is the ath reliable weight among the high reliable weights; W b is the bth reliable weight among the low reliable weights, and δ is the preset value of the weight difference;

[0027] The first supervision function is used to supervise each training batch so that the reliability weights of each positive sample belonging to the first sample set output by the weights channel after the second stage of training are completed satisfy that the reliability weights are greater than the preset value.

[0028] The second supervision function is used to supervise each training batch, so that each positive sample belonging to the second sample set output by the weights channel has the first weight average value W of the high reliability weight after the second stage of training. H The second weighted average value W corresponding to the low reliable weight L The difference is greater than δ, forcing the network to distinguish between highly reliable weights and less reliable weights.

[0029] Preferably, the step of merging the preset first sample set and the second sample set collected locally in real time by the smart camera to output the training sample set comprises:

[0030] Use smart cameras to collect local real-time images of actual application scenarios;

[0031] Detecting the local real-time image using the current model, and outputting a detection result corresponding to the local real-time image;

[0032] Binarizing the confidence of the detection result of the local real-time image, adding a pseudo label to the processed local real-time image, and obtaining the second sample set;

[0033] Combining the second sample set and the first sample set to obtain the training sample set;

[0034] The detection result includes at least one of the following: confidence, category information, and location information.

[0035] The present invention also provides an intelligent camera model terminal training device, comprising:

[0036] A sample data merging module: used for merging a preset first sample set and a second sample set, and outputting a training sample set, wherein the second sample set is composed of each local real-time image and each pseudo label;

[0037] A multi-stage training module: used to perform first-stage training on the current model using the training sample set through a first loss function, and output an intermediate training model, wherein the current model is obtained by randomly training a training set consisting of training samples of multiple application scenarios collected, and the scenarios include at least one of the following: infant care, school, playground, shopping mall, garage, farm and road;

[0038] Based on the intermediate training model, the second stage training is performed using the training sample set through a second loss function and a reliable weight, and a verification model is output. The present invention also provides an electronic device, comprising: at least one processor, at least one memory, and computer program instructions stored in the memory, and when the computer program instructions are executed by the processor, any of the above methods is implemented.

[0039] The present invention also provides a medium on which computer program instructions are stored, and when the computer program instructions are executed by a processor, any of the above-mentioned methods is implemented.

[0040] In summary, the beneficial effects of the present invention are as follows:

[0041] The present invention provides a method, device, equipment and medium for training a smart camera model terminal. The method combines the image data collected locally in real time by the smart camera with a preset first sample set to obtain a training sample set. The training sample set is used to train the current model in stages, and the model convergence is achieved in the first stage, and the model fine-tuning is completed in the second stage. The model can complete the fine-tuning training along the expected direction in the absence of human intervention. The fine-tuning training of the detection model can be completed directly on the user side without uploading local data to a server, thereby ensuring the security of the data and the privacy of the user. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solution of the embodiment of the present invention, the drawings required for use in the embodiment of the present invention will be briefly introduced below. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work, and these are all within the protection scope of the present invention.

[0043] Figure 1 This is a flow chart of a method for optimizing a smart camera detection model using edge computing in Example 1 of Embodiment 1 of the present invention;

[0044] Figure 2This is a schematic diagram of a process of obtaining a second sample set in Example 1 of Implementation Method 1 of the present invention;

[0045] Figure 3 This is a schematic diagram of a process of adding pseudo labels to samples in Example 1 of Implementation Method 1 of the present invention;

[0046] Figure 4 It is a schematic diagram of the process of fine-tuning the model using the third sample set in Example 1 of the first embodiment of the present invention;

[0047] Figure 5 This is a schematic diagram of a process for obtaining a target model in Example 1 of Implementation Method 1 of the present invention;

[0048] Figure 6 This is a schematic diagram of a process of obtaining a basic model of a camera in Example 1 of Implementation Mode 1 of the present invention;

[0049] Figure 7 This is a schematic diagram of a process for obtaining a target confidence threshold in Example 2 of Implementation Mode 1 of the present invention;

[0050] Figure 8 This is a schematic diagram of a process of outputting a target confidence threshold in Example 2 of Implementation Mode 1 of the present invention;

[0051] Fig. 9 This is a schematic diagram of a process for obtaining a target mAP value in Example 2 of Implementation Mode 1 of the present invention;

[0052] Fig.10 Schematic diagram of the structure of the mAP value curve in Example 2 of the first embodiment of the present invention;

[0053] Fig.11 This is a schematic diagram of a process for obtaining the mAP value of the confidence threshold in Example 2 of Implementation Method 1 of the present invention;

[0054] Fig.12 Schematic diagram of the process of calculating the mAP value in Example 2 of Implementation Mode 1 of the present invention;

[0055] Fig.13 This is a schematic diagram of a process of outputting a verification model in Example 3 of Implementation Mode 1 of the present invention;

[0056] Fig.14 It is a flow chart of the reliable weight of each positive sample in Example 3 of Implementation Mode 1 of the present invention;

[0057] Fig.15 This is a schematic diagram of the structure of the network output layer in Example 3 of Implementation Mode 1 of the present invention;

[0058] Fig.16This is a schematic diagram of a process of obtaining a high reliability weight and a low reliability weight in Example 3 of Implementation Mode 1 of the present invention;

[0059] Fig.17 It is a flow chart of the verification model corresponding to the manual label in Example 3 of the first embodiment of the present invention;

[0060] Fig.18 It is a flow chart of the verification model corresponding to the pseudo-label in Example 3 of the first embodiment of the present invention;

[0061] Fig.19 It is a structural schematic diagram of a device for continuously optimizing camera effects in Example 4 of the second real-time method of the present invention;

[0062] Fig. 20 It is a structural block diagram of a device for selecting a confidence threshold value of a sample of an intelligent camera in Example 5 of the second real-time method of the present invention;

[0063] Fig.21 It is a structural schematic diagram of a device for self-training of an intelligent camera model in Example 6 of the second real-time method of the present invention;

[0064] Fig. 22 It is a schematic diagram of the structure of an electronic device in the third embodiment of the present invention. DETAILED DESCRIPTION

[0065] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution in the embodiment of the present invention will be clearly and completely described in conjunction with the drawings in the embodiment of the present invention. It should be noted that, in this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. In the description of the present invention, it should be understood that the orientation or position relationship indicated by the terms "center", "upper", "lower", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc. is based on the orientation or position relationship shown in the drawings, which is only for the convenience of describing the present application and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present invention. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such a process, method, article or device. In the absence of further restrictions, the elements defined by the phrase "comprising..." do not exclude the presence of other identical elements in the process, method, article or device comprising the elements. If there is no conflict, the various features in the embodiments and examples of the present invention can be combined with each other, all within the scope of protection of the present invention.

[0066] Implementation Method 1

[0067] Example 1

[0068] See also Figure 1 , Figure 1 The flowchart of the method for optimizing the intelligent camera detection model by edge computing in Embodiment 1 of the present invention is as follows. The method for optimizing the intelligent camera detection model by edge computing in Embodiment 1 of the present invention includes:

[0069] S10: Acquire a preset first sample set and a second sample set collected locally in real time;

[0070] Specifically, a basic detection model that can be used in multiple application scenarios is built into the smart camera, and the basic detection model is trained by a training set A consisting of training samples of multiple application scenarios collected; the scenarios include at least one of the following: infant care, school, playground, shopping mall, garage, farm and road; samples corresponding to the target scene are obtained through specific channels, and the samples include at least one of the following: image, sound and video; the specific channels include at least one of the following: open source data sets, construction scenes, markets; wherein, the sample set A for training the basic detection model needs to be manually verified and manually labeled; multiple samples are randomly selected from the training set A as the first sample set; the samples of the second sample set are local images of the actual application scenarios collected by the smart camera, and the labels of the second sample set are set to pseudo labels.

[0071] S11: fine-tune the current model using the first sample set and the second sample set to obtain a verification model;

[0072] S12: Compare the current model with the verification model and output a target model;

[0073] Specifically, before the smart camera is put on the market, it randomly trains the training set A to output a basic detection model, which is then implanted into the smart camera. After the user installs the smart camera in the target area, during the initial use phase, the basic detection model is used to perform data processing on the local images collected by the smart camera, wherein the data processing includes detection task processing and / or classification task processing. At this time, the current model is the basic detection model. During use, the current model is fine-tuned and trained locally using the first sample set and the second sample set to obtain a verification model for this training. The processing results of the verification model and the current model on the second sample set are compared, and a target model is output based on the comparison results. Before the next fine-tuning training, the target model performs data processing on the local images collected by the smart camera.

[0074] It should be noted that: the current model is fine-tuned and trained locally through the first sample set and the second sample set, and the smart camera is trained locally. User data does not need to be uploaded to the server, which prevents the leakage of local data and improves data security. At the same time, using local images for training can improve the fit between the target model and the installation scenario of the smart camera, and ensure the accuracy of the data processing of the smart camera.

[0075] In one embodiment, see Figure 2 , the S10 comprises:

[0076] S101: Collecting local real-time images of actual application scenarios;

[0077] Specifically, after the smart camera is installed in a specific application scenario, it starts to monitor the actual application scenario and collect real-time images of the actual application scenario.

[0078] S102: Detect the local real-time image using the current model, and output a detection result corresponding to the local real-time image;

[0079] Specifically, the collected local real-time images are sent to the current model, and the current model outputs the detection results corresponding to each local image. The detection results include at least one of the following: confidence, category information, and location information; based on the detection results, the recall rate and accuracy rate corresponding to each confidence threshold can be calculated.

[0080] For the classification task of category information, in one application embodiment: the local real-time images collected by the intelligent camera are analyzed by the current model to obtain the category of each image; and the corresponding category label is added according to the category to which each image belongs.

[0081] For the detection task, in one application embodiment, positive samples corresponding to the first category and / or the second category... and / or the Nth category are found in the local real-time image of the monitored target area taken by the smart camera, and the current model processes the local real-time image, outputs the positive samples required by the composite category in the local real-time image, and outputs the corresponding detection results; the detection results include at least one of the following: location information, confidence, category information, etc.; wherein the category information includes at least one of the following: people, animals, movable objects, fixed objects, fixed objects attached to mobile objects, etc.

[0082] It should be noted that:

[0083] For classification tasks, positive samples are samples corresponding to the target category;

[0084] For detection tasks, positive samples are targets corresponding to all positions marked in advance in the sample.

[0085] S103: performing binarization processing on the detection result corresponding to the local real-time image, and using the processing result as a pseudo label of the local real-time image;

[0086] Specifically, the confidence of each positive sample is binarized according to the confidence threshold, and the processed detection result is used as a pseudo label of the local real-time image;

[0087] See also Figure 3 , the S103 includes:

[0088] S1031: Obtaining the confidence and confidence threshold of each positive sample in the detection results of each local real-time image;

[0089] Specifically, the smart camera inputs the collected local real-time image into the current model and outputs the detection result of the real-time image; for example, the current model determines a target in the local real-time image as a "person" with a confidence of 0.6; that is, the credibility of the target as a "person" is 0.6, that is, the confidence is 0.6; at the same time, the confidence threshold is obtained, and the confidence is used to indicate the credibility of the detection result, and the confidence threshold is used to determine the truth or falsehood of the detection result; for example, if the confidence threshold is 0.7, if the confidence in the detection result is 0.6, it means that the detection result is not feasible. Specifically, the sampling step of the confidence threshold can be set, and a set of confidence thresholds can be obtained according to the sampling step, and the mAP values ​​corresponding to each confidence threshold are compared to determine the final confidence threshold.

[0090] S1032: Compare each of the confidences with the confidence threshold, reset each of the confidences according to the comparison result, and output the processed detection result as a pseudo label of the local real-time image;

[0091] If the confidence is greater than or equal to the confidence threshold, the confidence is set to 1; if the confidence is less than the confidence threshold, the confidence is set to 0.

[0092] Specifically, according to the confidence threshold, the confidence in the detection result is binarized. For example, when the target object is judged to be a "person", the confidence threshold is 0.7. If the confidence is less than 0.7, the confidence of the target being judged as a "person" is set to "0", and the detection result of the positive sample is updated; if the confidence is greater than or equal to 0.7, the confidence of the target being judged as a "person" is set to "1", and the updated detection result is made and saved as a pseudo label for the real-time image.

[0093] S104: The local real-time images and the pseudo labels form the second sample set.

[0094] In one embodiment, see Figure 4 , the S11 comprises:

[0095] S111: Obtain the first loss function, the second loss function, and the reliable weights corresponding to each positive sample;

[0096] Specifically, the first loss function is used for training in the first stage to calculate the loss value of each sample, thereby completing the fine-tuning training of the model, and the second loss function is used for training in the second stage to calculate the loss value of each sample and complete the final training of the model; taking the yolov3 loss function as an example, the first loss function includes;

[0097] Coordinate loss:

[0098]

[0099] Class loss:

[0100]

[0101] Confidence loss:

[0102]

[0103] Among them, L coord , L cls , L conf represent coordinate error, category error and confidence error respectively, Indicates whether the jth candidate box in the i-th grid in the application scene data obtained by the smart camera is a positive sample for the data processing task. If yes, Otherwise 0.

[0104] Get the first loss function = L coord +L cls +L conf .

[0105] The second loss function is:

[0106] Coordinate loss:

[0107]

[0108] Class loss:

[0109]

[0110] Confidence loss:

[0111]

[0112] Weight channel loss:

[0113] Including, the first supervision function:

[0114] And, the second supervision function: L w =max(0,δ-(w H -w L ))

[0115] Among them, L coord , L cls , L conf Represent coordinate error, category error and confidence error respectively, L w and L' w Represent the reliable weight error loss of the target in the second sample set and the target in the first sample set, respectively. Indicates whether the jth candidate box of the i-th grid in the application scene data obtained by the smart camera is a positive sample. If yes, Otherwise, it is 0; w ij represents the reliable weight of the positive sample of the jth candidate box in the i-th grid, x and y represent the horizontal and vertical coordinates of the center point of the selection box, w and n represent the width and height of the selection box, C represents the category, P represents the confidence, S is the number of grids in the network output layer, B is the fixed reference box, λ is a constant, and δ is the preset value of the weight difference.

[0116] S112: Merge the first sample set and the second sample set to output a third sample set;

[0117] Specifically, a first sample set preset in the smart camera and a second sample set corresponding to the local real-time image collected by the smart camera are merged to obtain a training sample set, which is recorded as a third sample set.

[0118] S113: Performing first-stage training on the current model using the third sample set through a first loss function, and outputting an intermediate training model;

[0119] Specifically, the loss value of each positive sample is calculated using the first loss function, and then the current model is fine-tuned so that each sample in the third sample set achieves network convergence, and an updated model is obtained, which is recorded as an intermediate training model. The first loss function and the third sample set are used to perform the first phase of training on the detection model. This is based on the actual detection results of each sample by the detection model, and the loss value calculated from the actual detection results is used for fine-tuning training without any external intervention. Therefore, the first phase of training can naturally complete the convergence of the model and ensure the stability of the current model in the subsequent training process.

[0120] S114: Based on the intermediate training model, perform second-stage training using the third sample set through a second loss function and the reliable weights, and output the verification model.

[0121] Specifically, based on the intermediate training model, the second stage training is continued by the second loss function and the reliable weights corresponding to each positive sample in the third sample set, and finally the verification model is output; wherein, the training of the model is divided into multiple rounds of training, so after each round of training, the current model is updated once; when the next round of training is carried out, the updated current model outputs new reliable weights for each sample in the third sample set; then the current model of this round is fine-tuned again by the second loss function and the corresponding new reliable weights, and the model after completing this round of training is updated. After completing the predetermined multiple rounds of training, the verification model is output.

[0122] It should be noted that: each round of training includes multiple training batches; each time a training batch is completed, the model is updated once, so the current model corresponding to each training batch is different, where the training batch is: a small batch of data is selected from the sample set for training. In other words, in each round of training in the second stage, the reliable weights corresponding to each positive sample in each training batch are calculated by different models. Through multiple rounds of training, the influence of unreliable labels in pseudo-labels on the training process is reduced, where unreliable labels are pseudo-labels that are obviously different from the majority and difficult to fit positive samples.

[0123] In one embodiment, in S11, data enhancement is further performed on the first sample set and / or the second sample set, wherein the data enhancement includes at least one of the following: image rotation, mosaic material parameters, color gamut conversion, and image cropping.

[0124] Specifically, during the training process, the same sample set is trained multiple times using data enhancement technology. In one training, the image angle is randomly rotated within the image angle rotation range, and / or the image is randomly cropped within the size range corresponding to the image cropping, and / or the image color gamut is randomly adjusted within the color gamut adjustment range, and / or the image is mosaic processed within the image mosaic material parameter increase range, to obtain the first sample set and the second sample set after data enhancement, and then the first sample set and the second sample set are trained to output the corresponding verification model. Through data enhancement, it can be ensured that the trained model is more accurate in judging the same target in different states, thereby improving the detection accuracy and robustness of the smart camera in the target scene.

[0125] When performing data enhancement, two or more image data enhancement methods are usually used. When all four methods are used, the processing order must be sorted. It is preferred to rotate the image first, then crop the image, then perform color gamut conversion, and finally perform mosaic processing according to the mosaic material parameters. Doing so can not only greatly reduce the amount of data processing, but also minimize data distortion in data enhancement.

[0126] Specifically, during the training process, the same sample set is trained multiple times using data enhancement. In one training, the angle of the image is rotated within the image angle rotation range, preferably the image is rotated to a specified angle, and then the image is cropped after the size of the image to be cropped is determined, and then the color gamut of the image is adjusted within the color gamut adjustment range, and then the image is mosaic processed according to the image mosaic material parameters within the image mosaic material parameter increase range to obtain the first sample set and the second sample set after data enhancement, and then the first sample set and the second sample set are trained to output the corresponding verification model. Through data enhancement, it can be ensured that the trained model is more accurate in judging the same target in different states, thereby improving the detection accuracy and robustness of the smart camera in the target scene.

[0127] In one embodiment, see Figure 5 , the S12 comprises:

[0128] S121: Obtain a first detection result corresponding to the detection of the local image by the current model;

[0129] S122: Obtain a second detection result corresponding to the detection of the local image by the verification model;

[0130] S123: Compare the first detection result and the second detection result, and output a target model.

[0131] Specifically, after completing a fine-tuning training of the current model, the target model detects the local real-time image collected by the smart camera to obtain the corresponding second detection result, and compares the second detection result with the first detection result corresponding to the model before fine-tuning, and selects the model corresponding to the detection result with good effect as the target model. In other words, if the first detection result is better than the second detection result, the current model is not updated; if the second detection result is better than the first detection result, the current model is updated to the verification model, and the data collected by the smart camera is processed by the updated verification model; such as: the current model is model "0" and the verification model is model "1", then the current model is updated to model "1". In an application embodiment, the first output result of the current model and the second output result of the verification model can be directly obtained by returning the user.

[0132] In one embodiment, the fine-tuning training also includes a fine-tuning threshold; after reaching the fine-tuning threshold, the default effect has reached the best, and no further training will be performed if the shooting scene does not change; wherein the fine-tuning threshold is the output result corresponding to the current model after multiple trainings, which is better than the second output result corresponding to the verification model trained each time. This can reduce unnecessary training times and energy consumption, and also extend the service life of the smart camera.

[0133] In one embodiment, see Figure 6 , before S10, including:

[0134] S1: Obtain sample data of the chip computing power, task type and at least one application scenario of the smart camera;

[0135] Specifically, chip computing power refers to the data processing capability of the chip built into the smart camera. Task types include classification tasks and detection tasks.

[0136] S2: Establishing a basic detection model according to the chip computing power, the task type and the sample data;

[0137] Specifically, the sample data is randomly trained according to the data processing parameters and the task type to obtain a basic detection model, wherein corresponding output nodes are set in the network output layer for different tasks, and the output nodes output the detection results of the corresponding task types.

[0138] S3: Filter the sample data and output the first sample set;

[0139] Specifically, the sample data is 2m images of the target scene, and n images are randomly selected from them as the first sample set, where m and n are both positive integers.

[0140] S4: pre-installing the first sample set and the basic detection model into the smart camera.

[0141] Specifically, before the smart camera is tested or enters the market, the basic detection model and the corresponding first sample set are implanted in the smart camera, and then the smart camera is placed in the actual application scenario. Initially, the local real-time images collected by the smart camera are processed with the basic detection model. During use, the first sample data and the second sample data are used to fine-tune the current model to complete the model update and improve the detection effect of the model.

[0142] The method of using edge computing to optimize the smart camera detection model of this embodiment is adopted to obtain a first sample set preset in the smart camera and a second sample set corresponding to the local image data collected by the smart camera, and the first sample set and the second sample set are used to fine-tune the currently used model locally to complete the update of the current model and output the verification model; the detection effects of the local image data of the verification model and the current model are compared, and the target model is output; by training locally using local real-time images of actual application scenarios combined with the preset first sample set, the fit between the target model and the actual application scenario is improved, and the accuracy of detection is improved; at the same time, local training on the device side can protect user privacy and improve data security.

[0143] Example 2

[0144] In Example 1, the confidence threshold is used to filter pseudo labels to reduce erroneous labels such as missing labels and wrong labels in pseudo labels. When the confidence threshold is set unreasonably, it will lead to erroneous labels such as missing labels and wrong labels in pseudo labels, which will eventually affect the accuracy of the target model after fine-tuning training. Therefore, Example 2 of the present invention proposes further improvement on the confidence threshold in S1031 on the basis of Example 1, and proposes a method for selecting a confidence threshold for self-training of a smart camera. In one embodiment, please refer to Figure 7 , the method comprising:

[0145] S20: Obtain the sampling step length of the test sample set and the confidence threshold;

[0146] Specifically, multiple samples are randomly selected from the training sample set A as the test sample set. Each sample in the test set A is manually verified and manually labeled. At the same time, the sampling step of the confidence threshold is obtained, and a set of confidence thresholds is output through the sampling step.

[0147] Sampling step: Set the sampling interval points of the confidence threshold within the value range of the confidence threshold, and the interval distance corresponding to two adjacent confidence thresholds; for example: the confidence threshold is 0 to 1, and the sampling step is 0.2; then the sampling points of the confidence threshold are 0, 0.2, 0.4, 0.6, 0.8 and 1.

[0148] S21: Testing the current model using the test sample set, and outputting the detection results in the test sample set;

[0149] Specifically, the detection result may be for the test sample set, or for each sample in the test sample set, or for each positive sample in each sample; the detection result includes at least one of the following: confidence, location information, and category information.

[0150] S22: outputting mAP values ​​corresponding to the confidence thresholds corresponding to the sampling step length and the detection result;

[0151] Specifically, the detection results of the test sample set under different confidence thresholds, the positive samples of each category will obtain the corresponding AP value (average precision, AP); the average precision value (mean average precision, mAP) of the AP value of each category can be obtained from the AP values ​​of all categories; that is, the mAP value corresponding to the confidence threshold is obtained.

[0152] S23: Outputting a target confidence threshold of the current model according to each of the mAP values.

[0153] Specifically, each mAP value is compared, and the confidence threshold corresponding to the finally selected mAP value is used as the target confidence threshold.

[0154] In one embodiment, see Figure 8 , the S23 comprises:

[0155] S231: Compare the mAP values ​​and output a target mAP value;

[0156] Specifically, all mAP values ​​are compared, and the mAP value that meets the requirements is screened out as the target mAP value.

[0157] In one embodiment, see Fig. 9 , the S231 includes:

[0158] S2311: Obtain a group of confidence thresholds corresponding to the sampling step length of the confidence threshold, recorded as a first confidence threshold group;

[0159] Specifically, a sampling step length of the confidence threshold is set, and a group of confidence thresholds is output according to the sampling step length of the confidence threshold, which is recorded as a first confidence threshold group.

[0160] S2312: According to the mAP values ​​corresponding to the confidence thresholds in the first confidence threshold group, output the confidence threshold corresponding to the maximum mAP value as a reference confidence threshold, and a previous confidence threshold and a next confidence threshold adjacent to the reference confidence threshold;

[0161] Specifically, the mAP values ​​corresponding to the confidence thresholds are compared to obtain the maximum mAP value; the confidence threshold corresponding to the maximum mAP value is used as the reference confidence threshold, and the previous confidence threshold and the next confidence threshold adjacent to the reference confidence threshold are obtained.

[0162] S2313: reducing the sampling step size, and outputting a first confidence threshold interval between the previous confidence threshold and the reference confidence threshold and a second confidence threshold interval between the reference confidence threshold and the next confidence threshold;

[0163] Specifically, the interval corresponding to the previous confidence threshold and the reference confidence threshold is recorded as the first confidence threshold interval, and the interval corresponding to the next confidence threshold and the reference confidence threshold is recorded as the second confidence threshold interval. After obtaining the reference confidence threshold, the sampling step size is adjusted, and a new set of confidence thresholds is obtained according to the adjusted sampling step size; the confidence thresholds belonging to the first confidence threshold interval and the second confidence threshold interval are taken out.

[0164] S2314: Obtain confidence thresholds of the first confidence threshold interval and the second confidence threshold interval to obtain a new first confidence threshold group;

[0165] S2315: Repeat S2312 to S2314 until the target mAP value is output.

[0166] Specifically, after obtaining the confidence thresholds of the first confidence threshold interval and the second confidence threshold interval, these confidence thresholds are combined into a new first confidence threshold group, and then the mAP values ​​corresponding to each confidence threshold are compared again, and a new reference confidence threshold is output. The process is repeated multiple times, and the reference confidence threshold output is finally used as the target confidence threshold. This method can ensure that the mAP value corresponding to the target confidence threshold is the maximum value of the mAP curve corresponding to the current model, and the use of this target confidence threshold can ensure that the accuracy and recall rate corresponding to the detection result are the most reasonable.

[0167] In one embodiment, in S2313, the next sampling step is 1 / 2 of the previous sampling step.

[0168] Specifically, the sampling step length is adjusted as follows: the next sampling step length is 1 / 2 of the previous sampling step length, so that there is only one new confidence threshold in the first confidence threshold interval and the second confidence threshold interval of each round, and the confidence threshold is always located at the midpoint corresponding to the first confidence threshold interval or the second confidence threshold interval; then the mAP value corresponding to the new confidence threshold is directly compared with the mAP value corresponding to the previous reference confidence threshold to determine the new reference confidence threshold and the adjacent confidence threshold, wherein each round of mAP value comparison is performed at most twice to obtain a new reference confidence threshold, thereby reducing the amount of data processing and improving computational efficiency. Please participate Fig.10, let b be the sampling step size before adjustment, a be the sampling step size after adjustment, and a be 1 / 2 of b; when the sampling step size is b, the mAP value of the corresponding confidence threshold is point "●", at this time, the mAP value corresponding to the reference confidence threshold is point B, the mAP value corresponding to the previous confidence threshold is point D, and the mAP value corresponding to the next confidence threshold is point F, then adjust the sampling step size to a, and obtain points "○" and "●", the mAP value corresponding to the confidence threshold in the first confidence threshold interval is point C, and the mAP value corresponding to the confidence threshold in the second confidence threshold interval is point A, compare the mAP values ​​of points A and C with the mAP value of point B, and take the confidence threshold corresponding to the largest mAP value as the new reference confidence threshold; repeat this process, and finally obtain the target confidence threshold, reduce the amount of data processing, and improve the computational efficiency. In a real-time manner, if the mAP value of point A is greater than the mAP value of point B, the mAP values ​​of point C and point B are no longer compared, and the confidence threshold corresponding to point A is used as the new reference confidence threshold; if the mAP value of point A is less than the mAP value of point B, the mAP values ​​of point B and point C are compared. If the mAP value of point C is also less than the mAP value of point B, the confidence threshold corresponding to point B is still the reference confidence threshold. At this time, the sampling step size is adjusted to a / 2, and the process is repeated to finally obtain the target confidence threshold.

[0169] S232: According to the target mAP value, a confidence threshold corresponding to the target mAP value is used as the target confidence threshold.

[0170] In one embodiment, see Fig.11 , the S22 comprises:

[0171] S221: Outputting the accuracy and recall of each category corresponding to each confidence threshold according to each confidence threshold and the detection result of each sample in the test sample set;

[0172] Specifically, the detection result includes at least one of the following: the number of positive samples, location information, confidence and category information; the accuracy and recall rate of the current model for detecting each category in the test sample set is determined according to the confidence threshold; different confidence thresholds correspond to different accuracy and recall rates.

[0173] S222: Outputting mAP values ​​corresponding to each confidence threshold one by one according to the precision and the recall corresponding to each category.

[0174] In one embodiment, see Fig.12 , the S221 includes:

[0175] S2211: According to the test result, the formula Output the accuracy rate corresponding to each category;

[0176] S2212: According to the test result, the formula Output the recall rate corresponding to each category;

[0177] S2213: outputting mAP values ​​corresponding to each confidence threshold one by one according to the precision and the recall corresponding to each category;

[0178] Among them, TP is the confidence level in the detection result of the positive sample greater than the confidence threshold; FP is the confidence level in the detection result of the positive sample less than the confidence threshold; FN is the corresponding positive sample not detected at the corresponding position; Precision is the accuracy rate, and Recall is the recall rate.

[0179] In one embodiment, the S13 includes:

[0180] The first step is to obtain the confidence of each positive sample in the test sample set and the confidence thresholds corresponding to the sampling step length;

[0181] The second step is to sort the confidence of each positive sample and output the confidence sequence;

[0182] The third step is to perform percentage sampling on the confidence sequence to obtain multiple sampling confidences;

[0183] In the fourth step, the mAP value corresponding to each sampling confidence level is compared with the mAP value corresponding to each confidence threshold, and the confidence level corresponding to the maximum mAP value is output as the target confidence threshold.

[0184] Specifically, the test sample set is input into the current model, the current model detects each sample and outputs the detection result; the confidence of each positive sample in the detection result is sorted, and the confidence corresponding to multiple sampling points is obtained according to the percentage sampling, which is recorded as the sampling confidence; for example: 10 positive samples are detected, and a confidence sequence of length 10 is obtained. The confidence at the 2nd, 4th, 6th, 8th, and 10th positions is taken out, and then the mAP values ​​corresponding to these 5 confidences and multiple confidence thresholds corresponding to the sampling step are compared, and the confidence threshold corresponding to the largest mAP value or the sampling confidence is selected as the target confidence threshold.

[0185] The smart camera self-training confidence threshold selection method of this embodiment is adopted to obtain multiple confidence thresholds by setting the sampling step size, and the current model is used to test the test sample set and output the detection result; the mAP value corresponding to each confidence threshold is obtained from the detection result, and all mAP values ​​are compared, and the confidence threshold corresponding to the maximum mAP value is output as the target confidence threshold, which can make the accuracy and recall rate of the detection result optimal. When it is necessary to fine-tune the detection model, the confidence threshold can be determined directly locally by this method, which can reduce the erroneous labels such as missing labels and wrong labels in the pseudo-labels, improve the quality of pseudo-labels, and improve the effect of detection model training. This method does not need to upload local data to the server, and can ensure data security and user privacy.

[0186] Example 3

[0187] In Example 1 and Example 2, setting a reasonable confidence threshold can reduce the number of erroneous labels such as missing labels and wrong labels in the pseudo-labels; however, there will still be erroneous labels such as missing labels and wrong labels in the filtered pseudo-labels. If the current model is directly fine-tuned and trained, the updated model will still be affected by the erroneous labels, resulting in low detection accuracy of the updated model. Therefore, Example 3 of the present invention further improves the fine-tuning training of the current model using the first sample set and the second sample set in S11 from another perspective on the basis of Example 1 and / or Example 2 of the present invention, and proposes a method for self-training of the intelligent camera detection model. In one embodiment, please refer to Fig.13 , the method comprising:

[0188] S30: Obtaining a training sample set, a first loss function, a second loss function, and a reliable weight corresponding to each positive sample in the training sample set for training the current model of the smart camera;

[0189] Specifically, a basic detection model that can be used in multiple application scenarios is built into the smart camera. The basic detection model is trained by a training set A consisting of training samples collected from multiple application scenarios; the training sample set includes multiple samples randomly selected from the training set A (hereinafter referred to as the first sample set) and multiple samples obtained from the actual application scenarios of the smart camera installation (hereinafter referred to as the second sample set); and after the training sample set is obtained and sent to the current model, the model network layer outputs reliable weights for each positive sample, as well as the first loss function of the first stage training in fine-tuning training and the second loss function of the second stage training.

[0190] It should be noted that the current model can be the basic detection model or the trained model; that is, when training is performed for the first time based on the training sample set, the current model is the basic detection model. When training is performed for the second time based on the new training sample set, if the model trained for the first time is better than the basic detection model, then the current model of the second training is the verification model obtained for the first training; if the model trained for the first time is worse than the basic detection model, then the current model of the second training is still the basic detection model, and so on. The current model during the Nth training can be the training verification model obtained during the N-1th training, or the current model corresponding to the N-1th fine-tuning training.

[0191] In one embodiment, see Fig.14 , adding a weight channel for outputting reliable weights to the network output layer, the S30 includes:

[0192] For details, see Fig.15 , add a weights channel to the target detection network to output the weight channel of reliable weights; the left side is the output layer of the common target detection network, the bbox channel indicates the target position, the confidence channel is the target foreground confidence, and the classes channel is the probability that the target belongs to each category. The right side is the network output with the weights channel added. After the target detection network completes the detection of any sample, the output of the weights channel passes through the activation function to obtain the reliable weights of each positive sample in the sample.

[0193] It should be noted that the current model's data processing tasks for application scenarios acquired by smart cameras include: detection tasks and classification tasks; for different task weights channels, corresponding output nodes will be added to output the reliable weights of each positive sample.

[0194] S301: Obtaining the mapping function and the position information of each positive sample in the training set in a one-to-one correspondence;

[0195] Specifically, the samples acquired by the smart camera are gridded, and when a target at a certain position is detected to meet the target object of the data processing task, the position information of the target is obtained; the mapping function may be a Sigmoid function.

[0196] S302: Outputting the values ​​corresponding to the respective position information in the weight channel according to the position information, and outputting the reliable weights of the respective positive samples corresponding to the respective values ​​by the mapping function.

[0197] Specifically, after detecting the target object that meets the data processing task, the network channel corresponding to the output layer of the target detection network outputs the corresponding detection result for the target; a pseudo label of the positive sample corresponding to the position is made according to the confidence, position information and category information of the inspection result; at the same time, the weights channel outputs the value corresponding to the position information, which is mapped by the Sigmoid function to output the reliable weight of the positive sample at the position.

[0198] It should be noted that: the confidence of the sample can be further processed, such as: setting a confidence threshold and then performing binarization processing; using the processed detection result as a pseudo label; please refer to Example 2 for the specific implementation method, which will not be repeated here.

[0199] In one embodiment, each round of training includes multiple training batches. In S10, the training sample set includes a preset first sample set and a locally collected second sample set. The positive samples corresponding to the samples belonging to the second sample set in each training batch are sorted according to reliable weights, and a reliable weight sequence is output.

[0200] Specifically, during the first stage training and the second stage training, each round of training includes multiple training batches (training batch is: small batch data selected from the sample set for training); the samples in each training batch include samples from the first sample set and / or the second sample set, such as: each training batch includes Q samples, y samples are from the first sample set, and z samples are from the second sample set, where Q = y + z; Q, y, z are all integers greater than or equal to 0; in each round of training, the weights channel outputs the corresponding reliable weight according to the reliability of each positive sample in the second sample set, which can be understood as giving lower reliable weights to the pseudo-labels corresponding to the positive samples that are different from the majority and difficult to fit, and higher reliable weights to the reliable positive samples; then the reliable weights are sorted to obtain a reliable weight sequence.

[0201] It should be noted that the labels of the positive samples in the first sample set in the training sample set are artificial labels, and the labels in the second sample set are pseudo labels.

[0202] In one embodiment, see Fig.16 , the S30 includes:

[0203] S303: Obtaining the proportion of the high reliability weight and the low reliability weight in the reliability weight sequence;

[0204] S304: Outputting the high reliability weights and the low reliability weights according to the quantity proportions by the formula M=α*N;

[0205] M is the number of high-reliability weights, α is the proportion of high-reliability weights, and N is the total number of reliable weights in the reliable weight sequence in each batch.

[0206] Specifically, the reliability weights corresponding to all positive samples belonging to the second sample set in each training batch are sorted in descending order; assuming that the proportion of high reliability weights is α, and the proportion of low reliability weights is 1-α, the number of high reliability weights is obtained by the formula M=α*N.

[0207] S31: Performing first-stage training on the current model using the training sample set through the first loss function, and outputting an intermediate training model;

[0208] Specifically, the first loss function is used to calculate the original loss value of the training sample set; then the current model is fine-tuned according to the original loss value to achieve network convergence, thereby ensuring the integrity of the current model, and outputting the intermediate training model for the next stage of training; the pseudo-labels include correct labels and incorrect labels.

[0209] S32: Performing second-stage training on the current model based on the intermediate training model using the second loss function and the reliable weight, and outputting a verification model;

[0210] In each round of training in the second stage of training, the reliable weights corresponding to the positive samples are independent of each other.

[0211] Specifically, after completing the first stage of training for the current model, an intermediate training model after network convergence is obtained by training all samples, and then the second stage of training is continued on the basis of the intermediate training model by the second loss function and the reliable weights corresponding to each positive sample, and finally the verification model is output; wherein, each round of training in the second stage of training will output the reliable weights corresponding to each positive sample, and the reliable weights of each positive sample are combined with the second loss function to adjust the current model to achieve model update; after multiple rounds of training in the second stage of training are completed, the verification model is output; that is, the second stage of training is continued according to the second loss function and the different reliable weights corresponding to each round, and through multiple rounds of training, the influence of unreliable labels in the pseudo-labels in the training process is reduced, and finally the target training model is output; wherein, the unreliable labels are pseudo-labels corresponding to positive samples that are obviously different from the majority and difficult to fit.

[0212] It should be noted that the reliable weights of each positive sample in each round of training are independent; that is, in the current round of training, the reliable weights corresponding to the output of the current model for each positive sample participate in the current round of model training; in the next round of training, the reliable weights corresponding to the output of the current model for each positive sample corresponding to the next round participate in the next previous round of model training; there is no mapping relationship between the reliable weights of any two rounds of training.

[0213] It should be noted that each round of training includes multiple training batches, and the model is updated once each training batch is completed. That is to say, in each training batch, the model corresponding to the reliable weights of each positive sample output is different. At the same time, the reliable weights of each positive sample in each training batch are independent of each other.

[0214] In one embodiment, see Fig.17 , in each training batch, when the positive sample belongs to the first sample set, the second loss function includes the first supervision function of the weight channel, and the S32 includes:

[0215] Specifically, the first supervision function is used to supervise each training batch so that the reliable weights of each positive sample belonging to the first sample set output by the weights channel after the second stage of training are completed satisfy that the reliable weights are greater than the preset value. The first loss function can ensure that the positive samples with artificial labels have very high reliable weights, thereby minimizing the loss value of the positive samples with artificial labels during model fine-tuning training.

[0216] S321: Obtain the reliable weight of each positive sample output by the current training batch;

[0217] Specifically, after the samples of the first sample set of the current training batch are sent to the current model, the weights channel of the network output layer outputs the corresponding reliable weights for each positive sample.

[0218] S322: According to each of the reliable weights and the first supervision function Perform the current training batch by using the second loss function;

[0219] Specifically, according to the reliable weight of each positive sample and the first supervision function, the parameters of the current model are adjusted through the first loss function to complete the update of the current model by the current training batch.

[0220] S323: Repeat S321 to S322 until the second stage training is completed and the verification model is output;

[0221] Specifically, under the action of the first supervision function, the second training stage uses multiple rounds of training to make the reliable weights of the positive samples of the first sample set output by the weights channel of the final target training model as a whole greater than the preset value γ of the reliable weights; that is, most of the reliable weights of the positive samples in the first sample set in the final output are greater than γ, and a very small part may be less than γ; thereby ensuring that the overall loss of the positive samples of the first sample set is small.

[0222] Where y is the total number of positive samples belonging to the first sample set in a training batch, γ is the preset value of the reliability weight, and W c represents the reliable weight of the cth positive sample.

[0223] In one embodiment, see Fig.18 , in each training batch, when the positive sample belongs to the sample of the second sample set, the second loss function includes the second supervision function of the weight channel, and the S32 includes:

[0224] Specifically, the second supervision function is used to supervise each training batch so that each positive sample belonging to the second sample set output by the weights channel has the first weight average value W of the high reliability weight after the second stage of training. H The second weighted average value W corresponding to the low reliable weight L The difference is greater than δ, forcing the network to distinguish between high-reliability weights and low-reliability weights; achieving a gradual reduction in the reliable weights of erroneous labels in pseudo-labels during training; and improving the accuracy of model self-training.

[0225] S324: Obtain the reliable weight sequence output by the current training batch;

[0226] Specifically, after the samples of the second sample set of the current training batch are sent to the current model, the weights channel of the network output layer outputs the corresponding reliable weights for each positive sample, and then sorts the reliable weights to obtain a reliable weight sequence; the detection result includes at least one of the following: confidence information, category information and location information.

[0227] S325: According to the high reliability weights, the formula Calculate the first weight average W corresponding to each high-reliability weight in the current training batch H ;

[0228] S326: According to the low reliability weights, the formula Calculate the second weight average W corresponding to each low reliable weight in the current training batch L ;

[0229] S327: Based on the first weighted average value W H , the second weighted average value W L And the second supervision function L w =max(0,δ-(w H -w L )), performing the current training batch by using the second loss function;

[0230] S328: Repeat S324 to S327 until the second stage training is completed and the verification model is output;

[0231] Where M is the number of high-reliability weights in a training batch, N is the total number of positive samples belonging to the second sample set in a training batch, and W a is the ath reliable weight among the high reliable weights; W b is the bth reliable weight among the low reliable weights, and δ is the preset value of the weight difference.

[0232] Specifically, in the second supervision function L w =max(0,δ-(w H -w L )), through multiple rounds of training in the second training phase, the first weight average value W of the high-reliability weight output by the weights channel of the final target training model is H The second weighted average value W corresponding to the low reliable weight L The difference is greater than δ; the network is forced to distinguish between high-reliability weights and low-reliability weights; the influence of unreliable labels in pseudo-labels during the training process is reduced, and the target training model is finally output.

[0233] In one embodiment, in S20, the first loss function includes at least one of the following: coordinate loss, category loss and confidence loss; the second loss function includes at least one of the following: coordinate loss, category loss, confidence loss and weight channel loss.

[0234] Specifically, taking the yolov3 loss function as an example, the first loss function includes:

[0235] Coordinate loss:

[0236]

[0237] Class loss:

[0238]

[0239] Confidence loss:

[0240]

[0241] Among them, L coord , L cls , L conf represent coordinate error, category error and confidence error respectively, Indicates whether the jth candidate box in the i-th grid in the application scene data obtained by the smart camera is a positive sample for the data processing task. If yes, Otherwise 0.

[0242] Get the first loss function = L coord +L cls +L conf .

[0243] The second loss function is:

[0244] Coordinate loss:

[0245]

[0246] Class loss:

[0247]

[0248] Confidence loss:

[0249]

[0250] Weight channel loss:

[0251] Including, the first supervision function:

[0252] And, the second supervision function: L w =max(0,δ-(w H -w L ))

[0253] Get the second loss function = L coord +L cls +L conf +σL w +θL' w .

[0254] Among them, L coord , L cls , L conf Represent coordinate error, category error and confidence error respectively, L w and L' w Represent the reliable weight error loss of the target in the second sample set and the target in the first sample set, respectively. Indicates whether the jth candidate box of the i-th grid in the application scene data obtained by the smart camera is a positive sample. If yes, Otherwise, it is 0; w ij represents the reliable weight of the positive sample of the jth candidate box in the i-th grid, x and y represent the horizontal and vertical coordinates of the center point of the selection box, w and n represent the width and height of the selection box, C represents the category, P represents the confidence, S is the number of grids in the network output layer, B is the fixed reference selection box, λ, σ, θ are constants, and δ is the preset value of the weight difference.

[0255] By adopting the self-training method of the smart camera model of this embodiment, the smart camera detects the training sample set composed of locally collected image data, directly uses the first loss function to calculate the loss value of each sample locally, and then performs the first stage of fine-tuning training on the detection model to complete the convergence of the model so that the model can be trained locally. After completing the first stage of training, the second stage of training is performed on the detection model by introducing reliable weights and the second loss function. Under the action of the reliable weights and the second loss function, the model can complete the fine-tuning training along the expected direction in the absence of human intervention. The fine-tuning training of the detection model is achieved directly on the user side without uploading local data to the server, thereby ensuring the security of the data and the privacy of the user.

[0256] Implementation Method 2

[0257] Example 4

[0258] Embodiment 4 of the present invention also provides a device for optimizing the intelligent camera detection model using edge computing, such as Fig.19 As shown, including:

[0259] Data acquisition module: used to obtain a preset first sample set and a second sample set corresponding to the local image data collected by the smart camera;

[0260] Model training module: used to fine-tune the current model using the first sample set and the second sample set to obtain a verification model;

[0261] Model verification module: used to compare the current model with the verification model and output the target model.

[0262] The device of the present embodiment adopts edge computing to optimize the smart camera detection model, obtains a first sample set preset in the smart camera and a second sample set corresponding to the local image data collected by the smart camera, uses the first sample set and the second sample set to fine-tune the currently used model locally, completes the update of the current model, and outputs the verification model; compares the detection effects of the local image data of the verification model and the current model, and outputs the target model; improves the fit between the target model and the actual application scenario and improves the accuracy of detection by training locally using local real-time images of actual application scenarios combined with the preset first sample set; at the same time, local training on the device side can protect user privacy and improve data security.

[0263] Example 5

[0264] In Example 4, pseudo labels are screened by using a confidence threshold to reduce erroneous labels such as missing labels and wrong labels in the pseudo labels. When the confidence threshold is set unreasonably, it will lead to erroneous labels such as missing labels and wrong labels in the pseudo labels, which will ultimately affect the accuracy of the target model after fine-tuning training. Therefore, based on Example 4, a corresponding sub-device for further improving the confidence threshold is proposed.

[0265] See also Fig. 20 ,include:

[0266] Sample data module: used to obtain the sampling step of the test sample set and confidence threshold;

[0267] Data detection module: used to test the current model using the test sample set, and output the detection results corresponding to each positive sample in the test sample set;

[0268] Data processing module: used for outputting mAP values ​​corresponding to each confidence threshold value corresponding to the sampling step length and the detection result;

[0269] Target output module: used to output the target confidence threshold of the current model according to each mAP value.

[0270] The intelligent camera sample confidence threshold selection device of this embodiment is used to obtain multiple confidence thresholds by setting the sampling step size, and the current model is used to test the test sample set and output the detection result; the mAP value corresponding to each confidence threshold is obtained from the detection result, and all mAP values ​​are compared, and the confidence threshold corresponding to the maximum mAP value is output as the target confidence threshold, which can make the accuracy and recall rate of the detection result optimal. When it is necessary to fine-tune the detection model, the confidence threshold can be determined directly locally by this method, which can reduce the erroneous labels such as missing labels and wrong labels in the pseudo-labels, improve the quality of pseudo-labels, and improve the effect of detection model training. This method does not need to upload local data to the server, and can ensure data security and user privacy.

[0271] Example 6

[0272] In Example 4 and Example 5, setting a reasonable confidence threshold can reduce erroneous labels such as missing labels and wrong labels in pseudo labels; however, there will still be erroneous labels such as missing labels and wrong labels in the filtered pseudo labels. If the current model is directly fine-tuned and trained, the updated model will still be affected by the erroneous labels, resulting in low detection accuracy of the updated model. Therefore, based on Example 4 and / or Example 5, it is further proposed to further improve the fine-tuning training of the current model using the first sample set and the second sample set in the fine-tuning training of the model;

[0273] See also Fig.21 ,include:

[0274] Training data module: used to obtain a training sample set, a first loss function, a second loss function and a reliable weight corresponding to each positive sample in the training sample set for training the current model of the smart camera;

[0275] A first training module: used to perform a first-stage training on the current model using the training sample set through the first loss function, and output an intermediate training model;

[0276] A second training module: used for performing second-stage training on the current model based on the intermediate training model by using the second loss function and the reliable weight, and outputting a verification model;

[0277] In each round of training in the second stage of training, the reliable weights corresponding to the positive samples are independent of each other.

[0278] Using the device for self-training the smart camera model of this embodiment, the smart camera detects the training sample set composed of locally collected image data, directly uses the first loss function to calculate the loss value of each sample locally, and then performs the first stage of fine-tuning training on the detection model to complete the convergence of the model so that the model can be trained locally. After completing the first stage of training, the detection model is trained for the second stage by introducing reliable weights and the second loss function. Under the action of the reliable weights and the second loss function, the model can complete the fine-tuning training along the expected direction in the absence of human intervention. The fine-tuning training of the detection model is achieved directly on the user side without uploading local data to the server, thereby ensuring data security and user privacy.

[0279] Implementation method three:

[0280] The present invention provides an electronic device and a storage medium, such as Fig. 22 As shown, the system comprises at least one processor, at least one memory and computer program instructions stored in the memory.

[0281] Specifically, the above-mentioned processor may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of an embodiment of the present invention, and the electronic device includes at least one of the following: a smart camera, a mobile device with a smart camera, and a wearable device with a smart camera.

[0282] The memory may include a large capacity memory for data or instructions. By way of example and not limitation, the memory may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. Where appropriate, the memory may include a removable or non-removable (or fixed) medium. Where appropriate, the memory may be inside or outside a data processing device. In a particular embodiment, the memory is a non-volatile solid-state memory. In a particular embodiment, the memory includes a read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM) or a flash memory or a combination of two or more of these.

[0283] The processor reads and executes computer program instructions stored in the memory to implement any one of the methods for optimizing the intelligent camera detection model using edge computing, the sample confidence threshold selection method, and the model self-training method in the above-mentioned embodiment mode 1.

[0284] In one example, the electronic device may further include a communication interface and a bus, wherein the processor, the memory, and the communication interface are connected via the bus and communicate with each other.

[0285] The communication interface is mainly used to implement communication between the modules, devices, units and / or equipment in the embodiments of the present invention.

[0286] Bus includes hardware, software or both, and the parts of electronic equipment are coupled to each other.For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In suitable cases, bus may include one or more buses. Although the embodiment of the present invention describes and shows a specific bus, the present invention considers any suitable bus or interconnection.

[0287] In summary, the embodiments of the present invention provide a method for optimizing an intelligent camera detection model using edge computing, a sample confidence threshold selection method, a model self-training method, an apparatus, a device, and a storage medium.

[0288] It should be clear that the present invention is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present invention is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present invention.

[0289] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present invention are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0290] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for training a smart camera model terminal, characterized in that: The method comprises: Merging a preset first sample set and a second sample set to output a training sample set, wherein the second sample set is composed of each local real-time image and each pseudo label; The first loss function is used to perform the first stage training on the current model using the training sample set, and an intermediate training model is output, wherein the current model is obtained by randomly training a training set consisting of training samples of a plurality of application scenarios collected, and the scenarios include at least one of the following: infant care, school, playground, shopping mall, garage, farm and road; Based on the intermediate training model, performing second-stage training using the training sample set through a second loss function and reliable weights, and outputting a verification model; Wherein, based on the intermediate training model, the second stage training is performed using the training sample set through the second loss function and the reliable weight, and the output verification model also includes: Obtaining reliable weights corresponding to each positive sample for training in the second stage; Performing first-stage training on the current model using the first loss function and the training sample set, and outputting an intermediate training model; Performing second-stage training on the current model based on the intermediate training model using the second loss function and the reliable weight, and outputting a verification model; Among them, in each round of training of the second stage training, the reliable weights corresponding to each positive sample are independent of each other, the reliable weights are the parameters of the full channel output of the network output layer of the current model, and the current model of this training is the model obtained after the previous training; in multiple rounds of training of the intermediate training model, each round of training respectively adds the corresponding reliable weights of the current model output for each positive sample to participate in this round of training; wherein, a weight channel for outputting reliable weights is added to the network output layer, and the obtaining of the reliable weights corresponding to each positive sample for training in the second stage includes: Obtain the mapping function and the position information of each positive sample in the training set; According to the position information, the value corresponding to each position information in the weight channel is output, and the mapping function outputs the reliable weight of each positive sample corresponding to each value, wherein each round of training includes multiple training batches, and each positive sample corresponding to the sample belonging to the second sample set in each training batch is sorted according to the reliable weight, and a reliable weight sequence is output, and the obtaining of the reliable weight corresponding to each positive sample for training in the second stage includes: Obtain the proportion of high reliability weights and low reliability weights in the reliability weight sequence; According to the quantity proportion, the formula A=α*B is used to output each of the high reliability weights and each of the low reliability weights; A is the number of high-reliability weights, α is the proportion of high-reliability weights, and B is the total number of reliable weights in the reliable weight sequence in each batch; Among them, in each training batch, when the positive sample belongs to the second sample set, the second loss function also includes a second supervision function of the weight channel, and the second stage training of the current model is performed on the basis of the intermediate training model using the reliable weight, and the output verification model includes: Obtaining the reliable weight sequence output by the current training batch; According to the high reliability weights, the formula Calculate the first weight average W corresponding to each high-reliability weight in the current training batch H ; According to the low reliability weights, the formula Calculate and obtain the second weight average W corresponding to each low reliability weight in the current training batch L ; According to the first weighted average value W H , the second weighted average value W L And the second supervision function , performing the current training batch through the second loss function; Repeat the process of obtaining the reliable weight sequence output by the current training batch until the first weight average value W is obtained. H , the second weighted average value W L And the second supervision function , performing the current training batch through the second loss function until the second stage training is completed, and outputting the verification model; Where M is the number of high-reliability weights in a training batch, N is the total number of positive samples belonging to the second sample set in a training batch, and W a is the ath reliable weight among the high reliable weights; W b is the bth reliable weight among the low reliable weights, and δ is the preset value of the weight difference; The first supervision function is used to supervise each training batch, so that the overall reliable weights of each positive sample belonging to the first sample set output by the weights channel after the second stage of training are completed meet the reliable weight greater than the preset value; The second supervision function is used to supervise each training batch, so that the first weight average value W of each positive sample belonging to the second sample set output by the weights channel after the second stage of training is completed H The second weighted average value W corresponding to the low reliable weight L The difference between is greater than δ, forcing the network to distinguish between highly reliable weights and less reliable weights.

2. The intelligent camera model terminal training method according to claim 1, characterized in that: The step of combining the preset first sample set and the second sample set collected locally in real time by the smart camera to output the training sample set includes: Use smart cameras to collect local real-time images of actual application scenarios; Detecting the local real-time image using the current model, and outputting a detection result corresponding to the local real-time image; Binarizing the confidence of the detection result of the local real-time image, adding a pseudo label to the processed local real-time image, and obtaining the second sample set; Combining the second sample set and the first sample set to obtain the training sample set; The detection result includes at least one of the following: confidence, category information, and location information.

3. A smart camera model terminal training device, characterized in that: include: A sample data merging module: used for merging a preset first sample set and a second sample set, and outputting a training sample set, wherein the second sample set is composed of each local real-time image and each pseudo label; A multi-stage training module: used to perform first-stage training on the current model using the training sample set through a first loss function, and output an intermediate training model, wherein the current model is obtained by randomly training a training set consisting of training samples of multiple application scenarios collected, and the scenarios include at least one of the following: infant care, school, playground, shopping mall, garage, farm and road; Based on the intermediate training model, performing second-stage training using the training sample set through a second loss function and reliable weights, and outputting a verification model; Wherein, based on the intermediate training model, the second stage training is performed using the training sample set through the second loss function and the reliable weight, and the output verification model also includes: Obtaining reliable weights corresponding to each positive sample for training in the second stage; Performing first-stage training on the current model using the first loss function and the training sample set, and outputting an intermediate training model; Performing second-stage training on the current model based on the intermediate training model using the second loss function and the reliable weight, and outputting a verification model; Among them, in each round of training of the second stage training, the reliable weights corresponding to each positive sample are independent of each other, the reliable weights are the parameters of the full channel output of the network output layer of the current model, and the current model of this training is the model obtained after the previous training; in multiple rounds of training of the intermediate training model, each round of training respectively adds the corresponding reliable weights of the current model output for each positive sample to participate in this round of training; wherein, a weight channel for outputting reliable weights is added to the network output layer, and the obtaining of the reliable weights corresponding to each positive sample for training in the second stage includes: Obtain the mapping function and the position information of each positive sample in the training set; According to the position information, the value corresponding to each position information in the weight channel is output, and the mapping function outputs the reliable weight of each positive sample corresponding to each value, wherein each round of training includes multiple training batches, and each positive sample corresponding to the sample belonging to the second sample set in each training batch is sorted according to the reliable weight, and a reliable weight sequence is output, and the obtaining of the reliable weight corresponding to each positive sample for training in the second stage includes: Obtain the proportion of high reliability weights and low reliability weights in the reliability weight sequence; According to the quantity proportion, the formula A=α*B is used to output each of the high reliability weights and each of the low reliability weights; A is the number of high-reliability weights, α is the proportion of high-reliability weights, and B is the total number of reliable weights in the reliable weight sequence in each batch; Among them, in each training batch, when the positive sample belongs to the second sample set, the second loss function also includes a second supervision function of the weight channel, and the second stage training of the current model is performed on the basis of the intermediate training model using the reliable weight, and the output verification model includes: Obtaining the reliable weight sequence output by the current training batch; According to the high reliability weights, the formula Calculate the first weight average W corresponding to each high-reliability weight in the current training batch H ; According to the low reliability weights, the formula Calculate and obtain the second weight average W corresponding to each low reliability weight in the current training batch L ; According to the first weighted average value W H , the second weighted average value W L And the second supervision function , performing the current training batch through the second loss function; Repeat the process of obtaining the reliable weight sequence output by the current training batch until the first weight average value W is obtained. H , the second weighted average value W L And the second supervision function , performing the current training batch through the second loss function until the second stage training is completed, and outputting the verification model; Where M is the number of high-reliability weights in a training batch, N is the total number of positive samples belonging to the second sample set in a training batch, and W a is the ath reliable weight among the high reliable weights; W b is the bth reliable weight among the low reliable weights, and δ is the preset value of the weight difference; The first supervision function is used to supervise each training batch, so that the overall reliable weights of each positive sample belonging to the first sample set output by the weights channel after the second stage of training are completed meet the reliable weight greater than the preset value; The second supervision function is used to supervise each training batch, so that the first weight average value W of each positive sample belonging to the second sample set output by the weights channel after the second stage of training is completed H The second weighted average value W corresponding to the low reliable weight L The difference between is greater than δ, forcing the network to distinguish between highly reliable weights and less reliable weights.

4. An electronic device, characterized in that: include: At least one processor, at least one memory and computer program instructions stored in the memory, when the computer program instructions are executed by the processor, implement the method according to any one of claims 1-2.

5. A storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 2 is implemented.