Model training method and device, video detection method and device, electronic equipment, storage medium and computer program product

By training the detection model on video segments based on the preset object detection model, the problem of low manual annotation efficiency and accuracy is solved, and the accuracy of violent operation detection in video detection is improved.

CN118570705APending Publication Date: 2024-08-30BEIJING JINGDONG YUANSHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410753872.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

In the existing technology, the accuracy of video detection and violent sorting is low, mainly due to the low efficiency and accuracy of manual annotation of samples, resulting in poor performance of computer vision models in detection.

Method used

By obtaining sample video segments, the video segments in which the sample object changes from the contact state to other states are determined based on the preset object detection model, and these video segments are used to train the initial detection model until the training conditions are reached, and the preset detection model is obtained for Detect violent operations in the video segment to be tested.

Benefits of technology

This method reduces manual errors and fatigue and obtains a large number of high-precision samples. The trained preset detection model is more accurate in detecting violent operations and improves the accuracy of video detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570705A
    Figure CN118570705A
Patent Text Reader

Abstract

The invention provides a model method training method, a video detection method and device, electronic equipment, a storage medium and a computer program product, and relates to the technical field of video detection, and the method comprises the steps: obtaining a first sample video segment; based on a preset object detection model, determining a second sample video segment representing that a sample object is converted from a state in which the sample object is in contact with the sample object to other states in the first sample video segment; training an initial detection model based on the second sample video segment until a first training condition is reached, and obtaining a preset detection model; wherein the preset detection model is used for determining a violent operation detection result corresponding to the to-be-detected video segment. According to the embodiment of the invention, the violent operation detection accuracy of the preset detection model on the to-be-detected video segment can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of video detection technology, and in particular to a model training method, a video detection method, a device, an electronic device, a storage medium and a computer program product. Background Art

[0002] In the related technology, parcels play a vital role in logistics parks. Human violent operations during the sorting process can cause damage to parcels. At present, automatically and accurately detecting violent sorting is an important task to be solved in logistics parks. Current detection of violent sorting mostly uses videos as input, based on computer vision solutions. Computer vision-based solutions require training by annotating parcels. The current solution for annotating parcels is mainly to manually determine the video of violent operations and then manually annotate them. However, this method of determining samples, due to human errors and manual visual fatigue, will result in low efficiency and low accuracy in determining samples. Furthermore, when the computer vision model trained with the samples determined by this scheme is used for video detection, the detection effect of violent operations will be low in accuracy due to the low efficiency and low accuracy of manual operations. Summary of the invention

[0003] The embodiments of the present application provide a model training method, a video detection method, an apparatus, an electronic device, a storage medium, and a computer program product, which can improve the accuracy of detecting violent operations in videos.

[0004] The technical solution of this application is implemented as follows:

[0005] The present application provides a video detection method, including:

[0006] Obtaining a first sample video segment;

[0007] Determining, based on a preset object detection model, in the first sample video segment, a second sample video segment representing that the sample object changes from a state of contact with the sample object to another state;

[0008] The initial detection model is trained based on the second sample video segment until the first training condition is reached, thereby obtaining a preset detection model; wherein the preset detection model is used to determine a violent operation detection result corresponding to the video segment to be tested.

[0009] In the above solution, before determining in the first sample video segment based on the preset object detection model a second sample video segment representing that the sample object changes from a contact state with the sample object to another state, the method further includes:

[0010] Acquire a preset image set; wherein the preset image set includes images representing multiple states of the sample object;

[0011] Determine a first image set and a second image set in the preset image set; wherein the first image set includes images representing that the sample object and the sample item are in contact; and the second image set includes images representing that the sample object is in other states;

[0012] The initial object detection model is trained based on the first image set and the second image set until a second training condition is met, thereby obtaining the preset object detection model.

[0013] In the above solution, the second sample video segment, which is determined in the first sample video segment based on the preset object detection model and represents the transition of the sample object from the contact state with the sample object to other states, includes:

[0014] In the case where the first sample video segment includes a parent object, the video frames in the first sample video segment are processed based on the preset object detection model to obtain a first video frame set and a second video frame set; wherein the first video frame set includes video frames representing that the sample object and the sample item are in contact; the second video frame set includes video frames representing that the sample object is in other states; and the sample object belongs to the parent object;

[0015] Based on a video frame with a first predetermined position in the first video frame set or a video frame with a second predetermined position in the second video frame set, the second sample video segment is intercepted from the first sample video segment.

[0016] In the above solution, the initial detection model is trained based on the second sample video segment until the first training condition is reached to obtain the preset detection model, including:

[0017] In the case where the second sample video segment represents a violent operation of the sample object, determining a target video frame in the second sample video segment that has the best display effect of the sample object;

[0018] Based on the target video frame, marking a plurality of sample object frames in the second sample video segment to obtain a third sample video segment;

[0019] The initial detection model is trained based on the third sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

[0020] In the above solution, the step of labeling a plurality of sample object frames in the second sample video segment based on the target video frame to obtain a third sample video segment includes:

[0021] Obtaining a single-frame sample object frame corresponding to the target video frame;

[0022] The sample item is tracked in the second sample video segment along the time sequence based on the single-frame sample item frame, and a plurality of the sample item frames are marked to obtain the third sample video segment.

[0023] In the above scheme, the method further comprises:

[0024] If the sample item frame cannot be marked by tracking the sample item frame in the second sample video segment along the time sequence based on the single-frame sample item frame, copying the single-frame sample item frame to each video frame in the second sample video segment to obtain a fourth sample video segment;

[0025] The initial detection model is trained based on the fourth sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

[0026] The present application also provides a video detection method, including:

[0027] Get the video segment to be tested;

[0028] The video segment to be tested is detected based on a preset detection model to determine a violent operation detection result corresponding to the video segment to be tested; wherein the preset detection model is obtained based on sample video training; the sample video is a video segment representing the sample object changing from a contact state with a sample object to other states.

[0029] The present application also provides a model training device, including:

[0030] A first video acquisition unit, used to acquire a first sample video segment;

[0031] A video processing unit, configured to determine, based on a preset object detection model, in the first sample video segment, a second sample video segment representing that the sample object changes from a state of contact with the sample object to another state;

[0032] A training unit is used to train the initial detection model based on the second sample video segment until the first training condition is reached, thereby obtaining a preset detection model; wherein the preset detection model is used to determine the violent operation detection result corresponding to the video segment to be tested.

[0033] The embodiment of the present application also provides a video detection device, including:

[0034] A second video acquisition unit, used to acquire a video segment to be tested;

[0035] A detection unit is used to detect the video segment to be tested based on a preset detection model to determine a violent operation detection result corresponding to the video segment to be tested; wherein the preset detection model is obtained based on sample video training; the sample video is a video segment representing the sample object changing from a contact state with a sample object to other states.

[0036] An embodiment of the present application also provides an electronic device, including a first memory and a first processor, wherein the first memory stores a computer program that can be run on the first processor, and the first processor implements the steps in the model training method when executing the computer program.

[0037] An embodiment of the present application further provides an electronic device, including a second memory and a second processor, wherein the second memory stores a computer program that can be run on the second processor, and the second processor implements the steps in the video detection method when executing the computer program.

[0038] An embodiment of the present application also provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a first processor, the steps in the model training method are implemented.

[0039] The embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a second processor, the steps in the video detection method are implemented.

[0040] An embodiment of the present application also provides a computer program product, including a computer program, which implements the steps in the model training method when executed by a first processor.

[0041] An embodiment of the present application further provides a computer program product, including a computer program, which implements the steps in the video detection method when executed by a second processor.

[0042] In the embodiment of the present application, a first sample video segment is obtained; based on a preset object detection model, a second sample video segment is determined in the first sample video segment, which characterizes that the sample object changes from a contact state with a sample item to other states; based on the second sample video segment, an initial detection model is trained until the first training condition is reached, and a preset detection model is obtained; wherein the preset detection model is used to determine the violent operation detection result corresponding to the video segment to be tested. In this way, the scheme of determining the second sample video segment in which the sample object changes from a contact state with a sample item to other states based on the preset object detection model does not have the problem of manual fatigue or manual error compared to the scheme of manually determining the violent operation video in the related art, so a large number of high-precision samples can be obtained based on the scheme in the present application, and then the preset detection model obtained by training with more precise and large numbers of samples has higher accuracy in detecting violent operations corresponding to the video segment to be tested. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 An optional flowchart of the model training method provided in the embodiment of the present application;

[0044] Figure 2 An optional flowchart of the model training method provided in the embodiment of the present application;

[0045] Figure 3 An optional flowchart of the model training method provided in the embodiment of the present application;

[0046] Figure 4 An optional flowchart of the model training method provided in the embodiment of the present application;

[0047] Figure 5 An optional flowchart of the model training method provided in the embodiment of the present application;

[0048] Figure 6 An optional flowchart of the model training method provided in the embodiment of the present application;

[0049] Figure 7 An optional flow chart of a video detection method provided in an embodiment of the present application;

[0050] Figure 8 An optional effect diagram of the video detection method provided in the embodiment of the present application;

[0051] Fig. 9 A schematic diagram of the structure of a model training device provided in an embodiment of the present application;

[0052] Fig.10 A hardware entity diagram of an electronic device provided in an embodiment of the present application Figure 1 ;

[0053] Fig.11 A schematic diagram of the structure of a video detection device provided in an embodiment of the present application;

[0054] Fig.12 A hardware entity diagram of an electronic device provided in an embodiment of the present application Figure 2 . DETAILED DESCRIPTION

[0055] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application are further elaborated in detail below in conjunction with the drawings and embodiments. The described embodiments should not be regarded as limiting the present application. All other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0056] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it will be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0057] If similar descriptions of "first / second" appear in the application documents, the following instructions are added. In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0059] In the related technology, there are two ways to annotate samples. One is manual annotation, which has the following disadvantages: when the number of videos to be annotated exceeds one thousand or ten thousand, especially when faced with a large volume of business, the workload of manual annotation of samples is very time-consuming and labor-intensive, and the cost required rises sharply; secondly, long-term work may reduce the accuracy of labeled samples due to visual fatigue, etc., which will lead to lower performance of the model trained using the annotated samples.

[0060] Another semi-automatic method is not suitable for detecting samples in motion. There are currently no publicly labeled samples to use, and it is impossible to obtain the first model for subsequent updates and iterations. Even if some samples are manually labeled to train the first model, since the task is difficult and requires a large number of training samples, a model with expected performance cannot be trained with a small number of labeled samples.

[0061] This application embodiment provides a model training method, see Figure 1 , is an optional flow chart of the model training method provided in the embodiment of the present application, which will be combined with Figure 1 The steps shown are explained:

[0062] S101: Obtain a first sample video segment.

[0063] In an embodiment of the present application, the training device can obtain a first sample video segment about item sorting taken by a camera in a logistics scene.

[0064] Among them, the training device can be a server, cloud server or terminal with corresponding data processing functions and training model functions.

[0065] S102: Determine, based on a preset object detection model, in the first sample video segment, a second sample video segment representing that the sample object changes from a state of contact with the sample object to another state.

[0066] In the embodiment of the present application, the training device processes the first sample video segment through a preset object detection model to determine a second sample video segment that represents the sample object changing from a state of contact with the sample object to other states.

[0067] In the embodiment of the present application, the sample object may be a human hand or a robot hand. The sample item may include: a package or other logistics items.

[0068] In the embodiment of the present application, the training device processes the first sample video segment through a preset object processing model to determine a second sample video segment representing the transition from a person's hand holding a package to a person's hand being separated from the object.

[0069] In the embodiment of the present application, the training device may pre-acquire a public preset image set, which includes images representing the sample object in various states. A first image set for representing the contact state between the sample object and the sample article is determined in the preset image set, and a second image set for representing the sample object in other states is determined in the preset image set, and then the preset object detection model is obtained by training using the first image set and the second image set.

[0070] S103. Train the initial detection model based on the second sample video segment until the first training condition is met, and obtain a preset detection model; wherein the preset detection model is used to determine the violent operation detection result corresponding to the video segment to be tested.

[0071] In the embodiment of the present application, the training device can mark the sample object frame in the second sample video segment, and then use the video segment marked with the sample object frame to train the initial detection model until a certain number of training times is reached or the function of the initial detection model converges, and then obtain the preset detection model. The preset detection model can be used to determine the violent operation detection result corresponding to the video segment to be tested.

[0072] In the embodiment of the present application, the training device can mark the sample item frame in the second sample video segment (including the sample item frame corresponding to the sample item in the contact state with the sample object and the sample item frame corresponding to the sample object in other states), input the video frame containing the sample item frame into the initial detection model to output the corresponding detection result; compare the detection result with the real result corresponding to the video frame (the real result manually determined for the video frame) to determine the error. Based on the error, the initial detection model is updated with the reverse gradient parameters until the initial detection model reaches a certain number of training times or the function of the initial detection model converges, and the preset detection model is obtained.

[0073] Among them, the preset detection model can be a YOLO (You Only Look Once) model. In other embodiments, the preset detection model can also be other visual detection models, which is not specifically limited in the embodiments of the present application.

[0074] In the embodiment of the present application, a first sample video segment is obtained; based on a preset object detection model, a second sample video segment is determined in the first sample video segment, which characterizes that the sample object changes from a contact state with a sample item to other states; based on the second sample video segment, an initial detection model is trained until the first training condition is reached and the preset detection model is obtained; wherein the preset detection model is used to determine the violent operation detection result corresponding to the video segment to be tested. In this way, the scheme of determining the second sample video segment in which the sample object changes from a contact state with a sample item to other states based on the preset object detection model does not have the problem of manual fatigue or manual error compared to the scheme of manually determining the violent operation video in the related art, so a large number of high-precision samples can be obtained based on the scheme in the present application, and then the preset detection model obtained by training with more precise and large numbers of samples has higher accuracy in detecting violent operations on the video segment to be tested.

[0075] See also Figure 2, is an optional flow chart of the model training method provided in the embodiment of the present application, Figure 1 The process before S102 shown may also include: S201 to S203, which will be described in combination with the steps:

[0076] S201, obtaining a preset image set; wherein the preset image set includes images representing the sample object in various states.

[0077] In the embodiment of the present application, the training device can obtain a preset image set from a public academic data set, wherein the preset image set includes images representing various states of the sample object.

[0078] The preset image set may include images of four states: the sample object is in contact with the sample item, the sample object is not in contact with the sample item, the sample object is in contact with other sample objects, or the sample object is in contact with itself.

[0079] In the embodiment of the present application, a large number of low-cost training samples are required in the process of training the preset object detection model, and the training device needs to collect hand image data. Since the motion state of the object is detected, publicly labeled objects are usually used to train the model. However, objects are different from people and cars, and there is no large amount of publicly available data. However, we found that violent operations are usually performed by human hands. Therefore, when locating the operation scene in a long video, we can determine whether object labeling is required by detecting both human hands and human body at the same time. In the embodiment of the present application, human body and human hands are detected at the same time because only detecting human hands or human body will cause false alarms. Since we select target data for labeling, we do not care about the recall rate. High accuracy is more important, that is, the omission of violent operation clips does not affect the labeling efficiency, because the video data to be labeled is massive.

[0080] Exemplarily, the present application may use a target detection algorithm based on deep learning to locate human hands. The deep learning model requires a large number of labeled samples. In order to improve efficiency, pictures of people and human bodies are selected from public academic data sets as training data sets. The ContactHands data set may be selected as the training data set. In the ContactHands data set, it is determined that the training set includes 18,877 images and the test set includes 1,629 images. The training set contains 52,050 hand sample frames, and the test set contains 5,983 hand sample frames. In an embodiment of the present application, a preset object detection model with better performance can be trained using the ContactHands data set that includes a large number of hand sample frames.

[0081] S202, determining a first image set and a second image set in the preset image set; wherein the first image set includes images representing a contact state between the sample object and the sample item; and the second image set includes images representing other states of the sample object.

[0082] In an embodiment of the present application, since the preset image set includes images representing multiple states of the sample object, the training device can filter out images including images representing the contact state between the sample object and the sample item in the preset image set as the first image set, and filter out images including images representing other states of the sample object in the preset image set as the second image set.

[0083] In an embodiment of the present application, the training device can filter out images including hands holding objects from the preset image set as the first image set, and the training device can determine images that do not belong to the first image set in the preset image set as the second image set.

[0084] S203: Train the initial object detection model based on the first image set and the second image set until a second training condition is met, thereby obtaining the preset object detection model.

[0085] In an embodiment of the present application, the training device can train the initial object detection model based on the first image set and the second image set until a certain number of training times is reached or the function of the initial object detection model converges, thereby obtaining a preset object detection model.

[0086] In an embodiment of the present application, the training device can mark the sample frame where the sample object and the sample item are in contact in each image in the first image set, and can mark the sample frame of the sample object in each image in the second image set, and then use the first image set and the second image set with the marked sample frames to train the initial object detection model until the preset object detection model is obtained through training.

[0087] Among them, the preset object detection model can also be a YOLO model. In other embodiments, the preset object detection model can be other visual detection models, which is not specifically limited in the embodiments of the present application.

[0088] In an embodiment of the present application, after the ContactHands data set is obtained, it can be used to train a target detection model based on deep learning. Since the difficulty of detecting people and packages in different scenarios varies and the computing power support provided is also different, different models can be selected according to specific scenarios. Specifically, the ContactHands data set classifies images into four sample object states: hands holding objects, empty hands, hands in contact with oneself, and hands in contact with others. The training device can change the four categories to two categories: the first category (hands holding objects) and the second category (empty hands, hands in contact with oneself, and hands in contact with others). The training device then marks the sample boxes of hands holding objects in the first category of images, and marks the sample boxes of hands in other images, and uses the first category of images and the second category of images with marked sample boxes as samples to train the YOLO detection model.

[0089] In an embodiment of the present application, a first image set and a second image set are determined in the acquired preset image set; wherein the first image set includes images representing that the sample object and the sample article are in contact; and the second image set includes images representing that the sample object is in other states. The initial object detection model is trained based on the first image set and the second image set until the second training condition is reached, thereby obtaining the preset object detection model. In this way, the preset object detection model is trained based on the preset image set, without the need for time-consuming and laborious re-labeling of sample objects, and since the labeling of sample objects in the preset image set is pre-labeled, the human error is relatively small, and thus a high-performance preset object detection model can be obtained by rapid training using a large number of accurate samples.

[0090] See also Figure 3 , is an optional flow chart of the model training method provided in the embodiment of the present application, Figure 1 The illustrated S102 can also be implemented by: S301 to S302, which will be described in combination with the steps:

[0091] S301: When the first sample video segment includes a parent object, process video frames in the first sample video segment based on the preset object detection model to obtain a first video frame set and a second video frame set.

[0092] In the embodiment of the present application, when the parent object in the first sample video segment is detected, the training device processes the video frames in the first sample video segment through a preset object detection model, and divides the video frames in the first sample video segment into a first video frame set and a second video frame set. The first video frame set includes video frames representing that the sample object and the sample item are in contact; the second video frame set includes video frames representing that the sample object is in other states. The sample object belongs to the parent object.

[0093] In the embodiment of the present application, the sample object may include a human hand or a robot. When the sample object is a human hand, the parent object may be a person. When the sample object is a robot, the parent object may be a robot.

[0094] In some other embodiments, the training device may extract frames from the first sample video segment, input the extracted video frames into a preset object detection model, and the preset object detection model outputs a first video frame set and a second video frame set.

[0095] S302: Based on a video frame with a first predetermined position in the first video frame set or a video frame with a second predetermined position in the second video frame set, extract the second sample video segment from the first sample video segment.

[0096] In the embodiment of the present application, the training device may take the video frame of the first predetermined position in the first video frame set as the center point and intercept the second sample video segment in the first sample video segment. Alternatively, the training device may take the video frame of the second predetermined position in the second video frame set as the center point and intercept the second sample video segment in the first sample video segment.

[0097] Exemplarily, the training device may use the last ranked video frame in the first video frame set as the center point and cut out a second sample video segment of a certain length from the first sample video segment.

[0098] In the embodiment of the present application, the training device can input the preset object detection model into the video frame in the first video segment to detect whether the video frame contains a person and a human hand. To detect a person, a public pre-trained object detection model is used for prediction. If a video frame contains both a person and a human hand, and the state of the hand in the frame changes from holding a package to another state, it is considered that the package has left the hand. The video clips 2 seconds before and 1 second after the frame are used as the second sample video segment.

[0099] In an embodiment of the present application, when the first sample video segment includes a parent object, the video frames in the first sample video segment are processed based on the preset object detection model to obtain a first video frame set and a second video frame set. The second sample video segment is intercepted in the first sample video segment based on the video frame of the first predetermined position in the first video frame set, or the video frame of the second predetermined position in the second video frame set. In this way, the scheme of intercepting the second sample video segment based on the video frame during the transition of the contact state between the sample object and the sample object can utilize the characteristics of the separation of human hands and objects in violent operations to accurately intercept the second sample video segment that can more accurately characterize the violent operation.

[0100] See also Figure 4 , is an optional flow chart of the model training method provided in the embodiment of the present application, Figure 1 The illustrated S103 can also be implemented by: S401 to S403, which will be described in combination with the steps:

[0101] S401: When the second sample video segment represents a violent operation, determine a target video frame in the second sample video segment that has the best display effect of the sample object.

[0102] In the embodiment of the present application, the user can determine whether there is a video content of a violent operation in the second sample video segment. If the second sample video segment includes a violent operation, a target video frame with the best sample item display effect is determined in the second sample video segment based on the user operation.

[0103] Among them, the best display effect of the sample object can be understood as: the sample object is centered, the sample object is not blocked, and the target video frame is in the middle position or starting position during the violent operation.

[0104] In the embodiment of the present application, after obtaining the second sample video segment, it is manually determined whether it is a violent operation. If so, any frame in the video that is violently operated is selected as the target video frame, and then the package that is violently operated in the frame is marked. Considering the subsequent operation, the package position of the selected frame is preferably more eye-catching (such as centered), without occlusion or less occlusion. In addition, it is best that the marked frame is located in the middle or starting position of the violent operation process.

[0105] S402: Mark multiple sample object frames in the second sample video segment based on the target video frame to obtain a third sample video segment.

[0106] In the embodiment of the present application, the training device can obtain the sample object frame corresponding to the target video frame, and mark multiple sample object frames in each video frame in the second sample video segment based on the sample object frame to obtain a third video segment.

[0107] S403: Train the initial detection model based on the third sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

[0108] In an embodiment of the present application, the training device can train the initial detection model based on the third sample video segment. After the training is completed, the model training can be continued using the third sample video segment obtained next time until a predetermined number of training times is reached or the function of the initial detection model converges, thereby obtaining a preset detection model.

[0109] In an embodiment of the present application, when the second sample video segment includes a violent operation, a target video frame with the best display effect of the sample item is determined in the second sample video segment. Based on the target video frame, multiple sample item frames are annotated in the second sample video segment to obtain a third sample video segment. The initial detection model is trained based on the third sample video segment until a predetermined number of training times is reached to obtain the preset detection model. Since the sample items in the target video frame with the best display effect are clearer, a sample item frame annotation scheme in the second sample video segment based on the target video frame with the best display effect can obtain a more accurate sample item frame, and then a preset detection model with better performance can be trained using a more accurate sample item frame.

[0110] See also Figure 5 , is an optional flow chart of the model training method provided in the embodiment of the present application, Figure 4 The illustrated S402 can also be implemented by: S501 to S502, which will be described in combination with the steps:

[0111] S501: Obtain a single-frame sample object frame corresponding to the target video frame.

[0112] In an embodiment of the present application, the training device can obtain a single-frame sample object frame corresponding to the target video frame based on the user's operation.

[0113] S502: Track the sample item in the second sample video segment along the time sequence based on the single-frame sample item frame, and mark a plurality of the sample item frames to obtain the third sample video segment.

[0114] In an embodiment of the present application, after obtaining a single-frame sample item frame, a target tracking algorithm can be used in combination with the single-frame sample item frame to track and annotate the sample item in the second sample video segment along the time sequence, and multiple sample item frames can be annotated in the video frame of the second sample video segment to obtain a third sample video segment.

[0115] In an embodiment of the present application, if the sample item is tracked in the second sample video segment along the time sequence based on the single-frame sample item frame and the sample item frame cannot be labeled, the single-frame sample item frame is copied to each video frame in the second sample video segment to obtain a fourth sample video segment; the initial detection model is trained based on the fourth sample video segment until a predetermined number of training times is reached, and the preset detection model is obtained.

[0116] In the embodiment of the present application, the forward and backward tracking in time sequence is performed based on the single-frame sample item frame corresponding to the target video frame: using the existing target tracking algorithm, the single-frame sample item frame is used as input, and the tracking is performed forward and backward in time sequence in the second sample video segment until the sample item disappears or becomes stationary, and multiple sample item frames are annotated in the second sample video segment to obtain the third sample video segment. When there is no tracking result, the single-frame sample item frame is copied on the front and back time sequence video frames. Since the package in the violent operation may have large visual changes, such as a clear package at the beginning, and then the motion is blurred due to horizontal throwing, the tracking model sometimes cannot track it, then the frame of the annotated single frame is copied and pasted, and then manually calibrated. Manual verification and calibration: Finally, the annotated frame obtained by tracking is manually verified. According to the experimental results, the tracking effect is often good and very little manpower is required.

[0117] In the embodiment of the present application, a single-frame sample item frame corresponding to the target video frame is obtained. Based on the single-frame sample item frame, the sample item is tracked in the second sample video segment along the time sequence, and multiple sample item frames are annotated to obtain the third sample video segment. Since the sample items in the target video frame with the best display effect are clearer, the single-frame sample item frame has a higher accuracy, and then a more accurate single-frame sample item frame can be used to track multiple accurate sample item frames, and a more accurate sample item frame can be used to train a preset detection model with better performance.

[0118] See also Figure 6 , which is an optional flow chart of the model training method provided in the embodiment of the present application, will be described in combination with the steps:

[0119] S11. Hand data collection.

[0120] In an embodiment of the present application, the training device can obtain a hand dataset based on the ContactHands dataset in a public academic dataset. The ContactHands dataset has 18,877 images in the training set and 1,629 images in the test set. The training set contains 52,050 hand instances, and the test set contains 5,983 hand instances.

[0121] S12. Train a hand detection model.

[0122] In the embodiment of the present application, the training device can classify the hand instances in the hand data set into two categories: the first category (hands holding objects) and the second category (empty hands, hands in contact with oneself, and hands in contact with others). The training device then marks sample frames of hands holding objects in the first category of images, and marks sample frames of hands in other images, and uses the first category of images and the second category of images with marked sample frames as samples to train the YOLO detection model.

[0123] S13. Obtaining a job video clip based on two detection models.

[0124] In an embodiment of the present application, the training device can use an existing human body detection model to detect a video segment including a person, and then use a trained hand detection model to detect a video segment of a violent operation (ie, a second sample video segment).

[0125] S14. Manually label a single frame.

[0126] In the embodiment of the present application, the training device determines a video frame in the working video segment that has the best display effect of the sample object, and obtains the single-frame sample object frame corresponding to the frame.

[0127] S15. Performing forward and backward tracking in time sequence based on the marked packages.

[0128] In the embodiment of the present application, the training device can use the determined single-frame sample object frame as the input of the target tracking algorithm, and then track and annotate the previous and next sample object frames in the second sample object frame in time sequence to obtain a third sample video segment.

[0129] S16. When there is no tracking result, copy the annotation box in the previous and next time series.

[0130] In the embodiment of the present application, when there is no tracking result, the marked frame is copied in the previous and next time sequence: because the package in the violent operation may have large visual changes, for example, it is a clear package at the beginning, but then the motion is blurred due to the horizontal projection, which causes the tracking model to sometimes fail to track, the frame of the marked single frame is copied and pasted, and then manually calibrated.

[0131] S17. Manual verification and calibration.

[0132] In the embodiment of the present application, the annotation boxes obtained by tracking are ultimately verified manually. According to experimental results, the tracking effect is often good and very little manpower is required.

[0133] See also Figure 7 , which is an optional flow chart of the video detection method provided in the embodiment of the present application, will be described in combination with the steps:

[0134] S601: Obtain a video segment to be tested.

[0135] In an embodiment of the present application, the video detection device can obtain a video segment to be tested of item sorting in a logistics scenario.

[0136] Among them, the video detection device can be a model training device, or it can be another device that establishes a connection with the model training device. After the model training device trains to obtain a preset detection model, it is transmitted to the video detection device.

[0137] S602. Detect the video segment to be tested based on a preset detection model to determine a violent operation detection result corresponding to the video segment to be tested; wherein the preset detection model is obtained based on sample video training; and the sample video is a video segment representing the transition of a sample object from a contact state with a sample object to other states.

[0138] In an embodiment of the present application, the video detection device can process the acquired video frames in the video segment to be tested through a preset detection model, determine the proportion of video frames that meet the violent operation requirements among multiple video frames, and then determine the violent operation detection result of the video segment to be tested based on the proportion.

[0139] In some other embodiments, the preset detection model can also determine whether it is a violent operation by the distance between the sample item and the sample object. The preset detection model can also determine whether it is a violent operation by the moving coordinates of the highest displacement point of the target item.

[0140] Exemplary, combined Figure 8 , is a video frame in the video segment to be tested, wherein the target object may be a human hand 100, and the target item may be a package 101. Whether it is a violent operation can be determined by the moving coordinates of the highest displacement point of the package 101, thereby determining the violent operation detection result.

[0141] In the embodiment of the present application, the scheme of determining the second sample video segment in which the sample object changes from the contact state with the sample object to other states based on the preset object detection model does not have the problem of manual fatigue or manual error compared to the scheme of manually determining the violent operation video in the related art. Therefore, a large number of high-precision samples can be obtained based on the scheme in the present application, and then the preset detection model obtained by training with more accurate and large numbers of samples has higher accuracy in detecting violent operations in the video segment to be tested.

[0142] See also Fig. 9 , which is a structural diagram of the model training device provided in an embodiment of the present application.

[0143] The embodiment of the present application also provides a model training device 600, including: a first video acquisition unit 601, a video processing unit 602 and a training unit 603.

[0144] A first video acquisition unit 601 is used to acquire a first sample video segment;

[0145] The video processing unit 602 is used to determine, based on a preset object detection model, in the first sample video segment, a second sample video segment representing that the sample object changes from a contact state with the sample object to other states;

[0146] The training unit 603 is used to train the initial detection model based on the second sample video segment until the first training condition is reached, thereby obtaining a preset detection model; wherein the preset detection model is used to determine the violent operation detection result corresponding to the video segment to be tested.

[0147] In an embodiment of the present application, the video processing unit 602 in the model training device 600 is used to obtain a preset image set; wherein the preset image set includes images representing multiple states of the sample object; a first image set and a second image set are determined in the preset image set; wherein the first image set includes images representing a contact state between the sample object and the sample item; and the second image set includes images representing other states of the sample object; the training unit 603 in the model training device 600 is used to train the initial object detection model based on the first image set and the second image set, and stop when the second training condition is reached to obtain the preset object detection model.

[0148] In an embodiment of the present application, the video processing unit 602 in the model training device 600 is used to process the video frames in the first sample video segment based on the preset object detection model to obtain a first video frame set and a second video frame set when the first sample video segment includes a parent object; wherein the first video frame set includes video frames representing that the sample object and the sample item are in contact; the second video frame set includes video frames representing that the sample object is in other states; the sample object belongs to the parent object; based on the video frame with a first predetermined position in the first video frame set, or the video frame with a second predetermined position in the second video frame set, the second sample video segment is intercepted in the first sample video segment.

[0149] In the embodiment of the present application, the training unit 603 in the model training device 600 is used to determine the target video frame with the best display effect of the sample object in the second sample video segment when the second sample video segment represents a violent operation;

[0150] Based on the target video frame, marking a plurality of sample object frames in the second sample video segment to obtain a third sample video segment;

[0151] The initial detection model is trained based on the third sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

[0152] In the embodiment of the present application, the training unit 603 in the model training device 600 is used to obtain a single-frame sample object frame corresponding to the target video frame;

[0153] The sample item is tracked in the second sample video segment along the time sequence based on the single-frame sample item frame, and a plurality of the sample item frames are marked to obtain the third sample video segment.

[0154] In the embodiment of the present application, the training unit 603 in the model training device 600 is used to copy the single-frame sample item frame to each video frame in the second sample video segment to obtain a fourth sample video segment if the sample item frame cannot be labeled while tracking the sample item frame in the second sample video segment along the time sequence based on the single-frame sample item frame;

[0155] The initial detection model is trained based on the fourth sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

[0156] It should be noted that, in the embodiment of the present application, if the above-mentioned model training method is implemented in the form of a software function module, and when it is sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the relevant technology can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to make a video detection device (which can be a personal computer, etc.) perform all or part of the method described in each embodiment of the present application. And the aforementioned storage medium includes: various media that can store program code, such as a U disk, a mobile hard disk, a read-only memory (Read Only Memory, ROM), a disk or an optical disk. In this way, the embodiment of the present application is not limited to any specific hardware and software combination.

[0157] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps in the model training device method are implemented.

[0158] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0159] It should be noted that Fig.10 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Fig.10 As shown, an embodiment of the present application provides an electronic device 700, including a first memory 702 and a first processor 701, wherein the first memory 702 stores a computer program that can be run on the first processor 701, and the first processor 701 implements the steps in the above method when executing the program, wherein;

[0160] The first processor 701 generally controls the overall operations of the electronic device 700 .

[0161] The first memory 702 is configured to store instructions and applications executable by the first processor 701, and can also cache data to be processed or processed by the processor 701 and various modules in the electronic device 700 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0162] Correspondingly, an embodiment of the present application also provides a computer program product, including a computer program, which can be executed by the first processor 701 of the electronic device 700 to complete the steps in the model training device 600 method.

[0163] See also Fig.11 , is a schematic diagram of the structure of the video detection device provided in an embodiment of the present application.

[0164] The embodiment of the present application further provides a video detection device 800 , including: a second video acquisition unit 801 and a detection unit 802 .

[0165] The second video acquisition unit 801 is used to acquire a video segment to be tested;

[0166] The detection unit 802 is used to detect the video segment to be tested based on a preset detection model to determine the violent operation detection result corresponding to the video segment to be tested; wherein the preset detection model is obtained based on sample video training; the sample video is a video segment representing the sample object changing from a contact state with a sample object to other states.

[0167] Correspondingly, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the method of the video detection device 800 are implemented.

[0168] It should be noted here that the description of the above storage medium and device embodiments is similar to the description of the above method embodiments, and has similar beneficial effects as the method embodiments. For technical details not disclosed in the storage medium and device embodiments of this application, please refer to the description of the method embodiments of this application for understanding.

[0169] It should be noted that Fig.12 A hardware entity diagram of an electronic device provided in an embodiment of the present application, such as Fig.12As shown, an embodiment of the present application provides an electronic device 900, including a second memory 902 and a second processor 901, wherein the second memory 902 stores a computer program that can be run on the second processor 901, and the second processor 901 implements the steps in the above method when executing the program, wherein;

[0170] The second processor 901 generally controls the overall operation of the electronic device 900 .

[0171] The second memory 902 is configured to store instructions and applications executable by the second processor 901, and can also cache data to be processed or processed by the processor 901 and various modules in the electronic device 900 (for example, image data, audio data, voice communication data, and video communication data), which can be implemented through flash memory (FLASH) or random access memory (Random Access Memory, RAM).

[0172] Correspondingly, an embodiment of the present application further provides a computer program product, including a computer program, which can be executed by the second processor 901 of the electronic device 900 to complete the steps in the method of the video detection device 800.

[0173] It should be understood that "one embodiment" or "an embodiment" mentioned throughout the specification means that specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. It should be understood that in various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The above-mentioned sequence numbers of the embodiments of the present application are only for description and do not represent the advantages and disadvantages of the embodiments.

[0174] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are 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 other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0175] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as: multiple units or components can be combined, or can be integrated into another system, or some features can be ignored, or not executed. In addition, the coupling, direct coupling, or communication connection between the components shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.

[0176] The units described above as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units; they may be located in one place or distributed on multiple network units; some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0177] In addition, all functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the above-mentioned integrated units may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0178] A person skilled in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium includes: a mobile storage device, a read-only memory (ROM), a magnetic disk or an optical disk, and other media that can store program codes.

[0179] Alternatively, if the above-mentioned integrated unit of the present application is implemented in the form of a software function module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application can be essentially or partly embodied in the form of a software product that contributes to the relevant technology. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a mobile storage device, a ROM, a magnetic disk, or an optical disk.

[0180] The above is only an implementation method of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A model training method, characterized in that: include: Obtaining a first sample video segment; Determining, based on a preset object detection model, in the first sample video segment, a second sample video segment representing that the sample object changes from a state of contact with the sample object to another state; The initial detection model is trained based on the second sample video segment until the first training condition is reached, thereby obtaining a preset detection model; wherein the preset detection model is used to determine a violent operation detection result corresponding to the video segment to be tested.

2. The model training method according to claim 1, characterized in that: Before determining in the first sample video segment based on the preset object detection model a second sample video segment representing that the sample object changes from a contact state with the sample object to another state, the method further includes: Acquire a preset image set; wherein the preset image set includes images representing multiple states of the sample object; Determine a first image set and a second image set in the preset image set; wherein the first image set includes images representing that the sample object and the sample item are in contact; and the second image set includes images representing that the sample object is in other states; The initial object detection model is trained based on the first image set and the second image set until a second training condition is met, thereby obtaining the preset object detection model.

3. The model training method according to claim 2, characterized in that: The second sample video segment indicating that the sample object changes from the contact state with the sample object to other states is determined in the first sample video segment based on the preset object detection model, and includes: In the case where the first sample video segment includes a parent object, the video frames in the first sample video segment are processed based on the preset object detection model to obtain a first video frame set and a second video frame set; wherein the first video frame set includes video frames representing that the sample object and the sample item are in contact; the second video frame set includes video frames representing that the sample object is in other states; and the sample object belongs to the parent object; Based on a video frame with a first predetermined position in the first video frame set or a video frame with a second predetermined position in the second video frame set, the second sample video segment is intercepted from the first sample video segment.

4. The model training method according to any one of claims 1 to 3, characterized in that: The initial detection model is trained based on the second sample video segment until the first training condition is reached, thereby obtaining a preset detection model, including: In the case where the second sample video segment represents a violent operation, determining a target video frame in the second sample video segment that has the best display effect of the sample object; Based on the target video frame, marking a plurality of sample object frames in the second sample video segment to obtain a third sample video segment; The initial detection model is trained based on the third sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

5. The model training method according to claim 4, characterized in that: The step of labeling a plurality of sample object frames in the second sample video segment based on the target video frame to obtain a third sample video segment includes: Obtaining a single-frame sample object frame corresponding to the target video frame; The sample item is tracked in the second sample video segment along the time sequence based on the single-frame sample item frame, and a plurality of the sample item frames are marked to obtain the third sample video segment.

6. The model training method according to claim 5, characterized in that: The method further comprises: If the sample item frame cannot be marked by tracking the sample item frame in the second sample video segment along the time sequence based on the single-frame sample item frame, copying the single-frame sample item frame to each video frame in the second sample video segment to obtain a fourth sample video segment; The initial detection model is trained based on the fourth sample video segment until a predetermined number of training times is reached, thereby obtaining the preset detection model.

7. A video detection method, characterized in that: include: Get the video segment to be tested; Detecting the video segment to be tested based on a preset detection model, and determining a violent operation detection result corresponding to the video segment to be tested; wherein the preset detection model is obtained based on sample video training; The sample video is a video segment representing the sample object changing from a contact state with the sample item to other states.

8. A model training device, characterized in that: include: A first video acquisition unit, used to acquire a first sample video segment; A video processing unit, configured to determine, based on a preset object detection model, in the first sample video segment, a second sample video segment representing that the sample object changes from a state of contact with the sample object to another state; A training unit is used to train the initial detection model based on the second sample video segment until the first training condition is reached, thereby obtaining a preset detection model; wherein the preset detection model is used to determine the violent operation detection result corresponding to the video segment to be tested.

9. A video detection device, characterized in that: include: A second video acquisition unit, used to acquire a video segment to be tested; A detection unit is used to detect the video segment to be tested based on a preset detection model to determine a violent operation detection result corresponding to the video segment to be tested; wherein the preset detection model is obtained based on sample video training; the sample video is a video segment representing the sample object changing from a contact state with a sample object to other states.

10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program executable on the processor, and the processor implements the steps of the method according to any one of claims 1 to 6 or the steps of the method according to claim 7 when executing the computer program.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6, or implements the steps of the method according to claim 7.

12. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the computer program implements the steps of the method according to any one of claims 1 to 6, or implements the steps of the method according to claim 7.