Method and apparatus for training distance prediction models
By obtaining key point information and distance information of face images from the training data set, we build and train a distance prediction model, which solves the problem of poor accuracy and high cost of distance detection between detection equipment and pedestrians, and achieves more efficient distance prediction. .
Patent Information
- Application Number
- CN202011516873.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-21
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2040-12-21
AI Technical Summary
Existing distance detection methods between detection equipment and pedestrians have problems of poor accuracy and high cost.
By obtaining the facial key point coordinate information and distance information in the user's face image from the training data set, using the initial distance prediction model to construct a loss function based on this information, and training, the target distance prediction model is obtained to improve the accuracy of distance detection. Accuracy and compatibility.
It improves the accuracy, generalization and robustness of model training, reduces the cost of model training, and solves the problems of poor accuracy and high cost of distance detection between detection equipment and pedestrians.
Smart Images

Figure CN113780045B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a method and device for training a distance prediction model. Background Art
[0002] With the widespread application of intelligent hardware, detecting the distance between the device and pedestrians can enable the device to automatically avoid pedestrians, or automatically interact with pedestrians at a close distance, etc. At present, the main methods for detecting the distance between the device and the user are: detecting the distance between the device and the pedestrian based on a camera that can output depth information or a camera that can perform face recognition.
[0003] However, current methods for detecting the distance between a device and a pedestrian suffer from poor accuracy and high cost. Summary of the invention
[0004] The present disclosure provides a method, an apparatus, an electronic device, and a computer-readable storage medium for training a distance prediction model.
[0005] According to a first aspect of the present disclosure, a method for training a distance prediction model is provided, comprising: obtaining coordinate information of at least two facial key points in a user's facial image and distance information between the user and a shooting device of the corresponding facial image from a training data set; using an initial distance prediction model to determine a predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points in the facial image; using the distance information and the predicted distance to construct a loss function of the initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model.
[0006] In some embodiments, the method includes: obtaining detection data of a facial image, wherein the detection data includes at least one of the following: posture information of the head in the facial image, coordinate information of a detection frame, and the detection frame is used to detect the facial image; using an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image, including: using an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image and the detection data of the facial image.
[0007] In some embodiments, the method includes: obtaining augmented data of a facial image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two facial key points of the facial image, and a distance between a key point of the facial image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the facial image; using an initial distance prediction model to determine a predicted distance between a user and a shooting device based on coordinate information of at least two facial key points of the facial image, including: using an initial distance prediction model to determine a predicted distance between a user and a shooting device based on coordinate information of at least two facial key points of the facial image and the augmented data of the facial image.
[0008] According to a second aspect of the present disclosure, a method for determining distance is provided, comprising: in response to detecting an instruction for indicating a detection distance, obtaining coordinate information of at least two facial key points in a facial image of a target user; obtaining a target distance prediction model, wherein the target distance prediction model is determined based on the following steps: using distance information and predicted distance to construct a loss function of an initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the distance information is obtained from a training data set, and the predicted distance is determined based on the coordinate information of at least two facial key points in the facial image in the training data set; using the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image.
[0009] In some embodiments, the method includes: obtaining detection data of a facial image of a target user, wherein the detection data includes at least one of the following: posture information of the head in the facial image of the target user, coordinate information of a detection frame, and the detection frame is used to detect the facial image of the target user; using coordinate information of at least two facial key points in the facial image of the target user, and a target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image, including: using coordinate information of at least two facial key points in the facial image of the target user, detection data of the facial image of the target user, and a target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image.
[0010] In some embodiments, the method includes: obtaining augmented data of a facial image of a target user, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two facial key points in the facial image of the target user, and a distance between a key point of the facial image of the target user and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the facial image of the target user; using coordinate information of at least two facial key points in the facial image of the target user and a target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image, including: using coordinate information of at least two facial key points in the facial image of the target user, the augmented data of the facial image of the target user, and a target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image.
[0011] In some embodiments, the method further includes: in response to determining that the distance between the target user and the corresponding facial image capturing device is less than a preset distance threshold, generating an instruction for instructing the interactive device to initiate interaction, and / or an instruction for instructing the device to avoid obstacles.
[0012] According to a third aspect of the present disclosure, a device for training a distance prediction model is provided, comprising: a first acquisition unit, configured to acquire coordinate information of at least two facial key points in a user's facial image and distance information between the user and a shooting device of the corresponding facial image from a training data set; a prediction unit, configured to adopt an initial distance prediction model to determine a predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points in the facial image; a construction unit, configured to adopt the distance information and the predicted distance to construct a loss function of the initial distance prediction model; and a training unit, configured to adopt the loss function to train the initial distance prediction model to obtain a trained target distance prediction model.
[0013] In some embodiments, the device includes: a second acquisition unit, configured to acquire detection data of a face image, wherein the detection data includes at least one of the following: posture information of the head in the face image, coordinate information of a detection frame, and the detection frame is used to detect the face image; a prediction unit, including: a first prediction module, configured to adopt an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two face key points of the face image and the detection data of the face image.
[0014] In some embodiments, the device includes: a third acquisition unit, configured to acquire augmented data of a face image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two face key points of the face image, and a distance between a key point of the face image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the face image; a prediction unit, including: a second prediction module, configured to adopt an initial distance prediction model to determine the predicted distance between the user and the shooting device based on coordinate information of at least two face key points of the face image and the augmented data of the face image.
[0015] According to a fourth aspect of the present disclosure, a device for determining distance is provided, comprising: a first target acquisition unit, configured to acquire coordinate information of at least two facial key points in a facial image of a target user in response to detecting an instruction for indicating a detection distance; a model acquisition unit, configured to acquire a target distance prediction model, wherein the target distance prediction model is determined based on the following steps: using distance information and predicted distance to construct a loss function of an initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the distance information is acquired from a training data set, and the predicted distance is determined based on the coordinate information of at least two facial key points in the facial image in the training data set; a determination unit, configured to determine the distance between the target user and a shooting device of the corresponding facial image using the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model.
[0016] In some embodiments, the device includes: a second target acquisition unit, configured to acquire detection data of a target user's facial image, wherein the detection data includes at least one of the following: head posture information in the target user's facial image, coordinate information of a detection frame, and the detection frame is used to detect the target user's facial image; a determination unit, including: a first determination module, configured to use coordinate information of at least two facial key points in the target user's facial image, detection data of the target user's facial image, and a target distance prediction model to determine the distance between the target user and the corresponding facial image shooting device.
[0017] In some embodiments, the device includes: a third target acquisition unit, configured to acquire augmented data of a target user's facial image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two facial key points in the target user's facial image, and a distance between a key point of the target user's facial image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the target user's facial image; a determination unit, including: a second determination unit, configured to determine the distance between the target user and a corresponding facial image shooting device using coordinate information of at least two facial key points in the target user's facial image, augmented data of the target user's facial image, and a target distance prediction model.
[0018] In some embodiments, the device also includes: a generation unit, configured to generate an instruction for instructing the interactive device to start interaction, and / or an instruction for instructing the device to avoid obstacles in response to determining that the distance between the target user and the corresponding facial image shooting device is less than a preset distance threshold.
[0019] According to the fifth aspect of the present disclosure, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for training a distance prediction model as provided in the first aspect or implement the method for determining a distance as provided in the second aspect.
[0020] According to the sixth aspect of the present disclosure, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method for training a distance prediction model provided in the first aspect is implemented or the method for determining a distance as provided in the second aspect is implemented.
[0021] The method and device for training a distance prediction model provided by the present disclosure obtain the coordinate information of at least two facial key points in a user's facial image and the distance information between the user and the corresponding facial image shooting device from a training data set; adopt an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points in the facial image; adopt the distance information and the predicted distance to construct a loss function of the initial distance prediction model; adopt the loss function to train the initial distance prediction model to obtain a trained target distance prediction model, which can improve the accuracy, generalization and robustness of model training, and can also improve the compatibility of model training and reduce the cost of model training.
[0022] The technology according to the present application solves the problems of poor accuracy and high cost in the current method of detecting the distance between a device and a pedestrian.
[0023] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0025] Figure 1 is an exemplary system architecture diagram to which embodiments of the present application may be applied;
[0026] Figure 2 is a flowchart of an embodiment of a method for training a distance prediction model according to the present application;
[0027] Figure 3 is a flow chart of an embodiment of a method for determining distance according to the present application;
[0028] Figure 4 is a structural schematic diagram of an embodiment of a device for training a distance prediction model according to the present application;
[0029] Figure 5 is a schematic structural diagram of an embodiment of a device for determining distance according to the present application;
[0030] Figure 6 It is a block diagram of an electronic device used to implement the method for training a distance prediction model in an embodiment of the present application. DETAILED DESCRIPTION
[0031] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0032] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of a method for training a distance prediction model or an apparatus for training a distance prediction model of the present application can be applied.
[0033] like Figure 1As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0034] The user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various client applications can be installed on the terminal devices 101, 102, 103, such as navigation applications, autonomous driving applications, chat applications, shopping applications, financial applications, image applications, video applications, etc.
[0035] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting receiving server messages, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers and desktop computers, devices used in cars to avoid pedestrians or obstacles, etc.
[0036] Terminal devices 101, 102, 103 can be hardware or software. When terminal devices 101, 102, 103 are hardware, they can be various electronic devices. When terminal devices 101, 102, 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, multiple software modules for providing distributed services), or they can be implemented as a single software or software module. No specific limitation is made here.
[0037] Terminal devices 101, 102, and 103 can obtain the coordinate information of at least two facial key points in the user's facial image and the distance information between the user and the corresponding facial image shooting device from the training data set; use an initial distance prediction model, and based on the coordinate information of at least two facial key points in the facial image, predict the predicted distance between the user and the facial image shooting device; then, use the above distance information and the above predicted distance to construct a loss function of the initial distance prediction model, and use the loss function to train the initial distance prediction model to obtain a trained target distance prediction model.
[0038] It should be noted that the method for training the distance prediction model provided in the embodiments of the present disclosure is generally executed by the server 105 , and accordingly, the device for training the distance prediction model is generally arranged in the server 105 .
[0039] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0040] Continue to refer Figure 2 , shows a process 200 of an embodiment of a method for training a distance prediction model according to the present disclosure, comprising the following steps:
[0041] Step 201: Obtain coordinate information of at least two facial key points in a facial image of a user from a training data set, as well as distance information between the user and a shooting device of the corresponding facial image.
[0042] In this embodiment, the execution body of the method for training the distance prediction model (for example Figure 1 The device 105 shown in the figure can obtain the coordinate information of at least two facial key points in the user's facial image in the training data set and the distance information between the user and the corresponding shooting device when shooting the facial image through wired or wireless means.
[0043] In this embodiment, the coordinate information of the facial key points may be the coordinate information of the facial features such as the eyes and nose, or the coordinate information of the edge points of the facial image contour, etc.; the coordinate information of the facial key points may be the two-dimensional position coordinates of the facial key points in the captured image, for example, the coordinate values of the facial key points in the x-direction and the y-direction in a rectangular coordinate system with the center point of the captured image (or any other preset point) as the origin and pixels (or any other preset size) as the unit. The coordinate information of the facial key points may also be the two-dimensional position coordinates of the facial key points in a face detection frame used to detect the facial image in the captured image.
[0044] In this embodiment, the distance information between the user and the corresponding facial image shooting device can be the actual distance between the user's location and the shooting device's location when shooting the picture containing the facial image, or the distance after data processing / size transformation, or it can be a distance identifier corresponding to the actual distance, for example, the distance within 0-10 meters is identified as "A", the distance within 10.01 meters-20 meters is identified as "B", and so on.
[0045] Step 202: using an initial distance prediction model, based on coordinate information of at least two facial key points in the facial image, determine a predicted distance between the user and the camera.
[0046] In this embodiment, an untrained initial distance prediction model can be obtained, and the coordinate information of at least two facial key points in the facial image can be input into the initial distance prediction model to obtain the predicted distance between the user and the corresponding facial image shooting device output by the initial distance prediction model.
[0047] Step 203, using the distance information and the predicted distance, constructing a loss function of the initial distance prediction model.
[0048] In this embodiment, the predicted distance output by the initial distance prediction model is compared with the actual distance information obtained from the training data set, and a loss function of the initial distance prediction model is constructed based on the comparison result, wherein the loss function is used to train the initial distance prediction model so that the prediction result of the initial distance prediction model gradually fits the actual distance information.
[0049] Step 204: Use the loss function to train the initial distance prediction model to obtain a trained target distance prediction model.
[0050] In this embodiment, the initial distance prediction model is trained according to the constructed loss function, and the trained distance prediction model is used to predict the distance between the user and the corresponding facial image shooting device. The loss function is reconstructed according to the obtained predicted distance and distance information, and the model is continued to be trained using the reconstructed loss function. After the number of training times reaches a preset number of times or the loss value between the predicted distance and the distance information reaches a preset threshold, multiple rounds of iterative training are stopped, and a trained target distance prediction model is obtained.
[0051] The method for training a distance prediction model provided in this embodiment obtains coordinate information of at least two facial key points in a user's facial image and distance information between the user and a shooting device of the corresponding facial image from a training data set, and then uses an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points in the facial image; uses the distance information and the predicted distance to construct a loss function of the initial distance prediction model, and uses the loss function to train the initial distance prediction model to obtain a trained target distance prediction model, so that the face recognition model and the distance prediction model can be trained separately to avoid mutual interference caused by simultaneous training of multi-task models; the training data does not depend on the shooting environment data to avoid interference of environmental factors on training and application of the model, thereby improving the accuracy, generalization and robustness of model training; in addition, the training of the prediction model does not depend on hardware configuration, which can improve the compatibility of model training and reduce the cost of model training.
[0052] Optionally, the method for training a distance prediction model includes: obtaining detection data of a facial image, wherein the detection data includes at least one of the following: posture information of the head in the facial image, coordinate information of a detection box, and the detection box is used to detect the facial image; using an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image, including: using an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image and the detection data of the facial image.
[0053] In this embodiment, detection data of a facial image can be obtained, and coordinate information of at least two facial key points of the facial image and the detection data of the facial image can be input into an initial distance prediction model to use the initial distance prediction model to determine the predicted distance between the user and the corresponding facial image capturing device.
[0054] In this embodiment, the detection data may include posture information of the head in the face image, for example, the tilt direction, tilt angle, twist direction or twist angle of the head in the face image, etc., which can be used to characterize the head posture; the detection data may include coordinate information of a detection frame used to detect key points in the captured picture, the face image or the face image, for example, when identifying the face image in the captured picture, the upper left vertex and the lower right vertex (or any other vertex) of the square detection frame of the face image are the coordinate values in the x direction and the y direction in a rectangular coordinate system with the center point of the captured picture (or any other preset point) as the origin and pixels (or any other preset size) as the unit.
[0055] In this embodiment, the detection data of the face image is used as the training data for training the initial distance prediction model, which can improve the accuracy of the training of the initial distance prediction model.
[0056] Optionally, the method for training a distance prediction model includes: obtaining augmented data of a facial image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two facial key points of the facial image, and a distance between a key point of the facial image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the facial image; using an initial distance prediction model to determine a predicted distance between a user and a shooting device based on coordinate information of at least two facial key points of the facial image, including: using an initial distance prediction model to determine a predicted distance between a user and a shooting device based on coordinate information of at least two facial key points of the facial image and the augmented data of the facial image.
[0057] In this embodiment, augmented data of the facial image can be obtained, and the coordinate information of at least two facial key points of the facial image and the augmented data of the facial image can be input into the initial distance prediction model to use the initial distance prediction model to determine the predicted distance between the user and the corresponding facial image capturing device.
[0058] In this embodiment, the augmented data may include size information of a detection frame used to detect a facial image, for example, the width or height of a square detection frame. The augmented data may include the distance between at least two facial key points in a facial image, for example, the distance between a left eye and a right eye in a facial image, or the number of pixels between every two facial features in a facial image. The augmented data may include the distance between a key point of a facial image and any vertex and / or any edge of a detection frame, for example, the distance or number of pixels between the left corner of a mouth in a facial image and the upper left vertex (or any other vertex or any edge) of a square detection frame for detecting the facial image in a captured image.
[0059] In this embodiment, the augmented data of the face image is used as the training data for training the initial distance prediction model, which can shorten the convergence time of the model to improve the efficiency of training the initial distance prediction model, and also improve the robustness of the trained model.
[0060] Optionally, the coordinates of the facial key points, the coordinates of the detection frame, the size of the detection frame, the distance between the facial key points, or the distance between the facial key points and any vertex / edge of the detection frame can be normalized according to the size of the original image to increase the speed of model training and improve the compatibility of the model after training.
[0061] Further references Figure 3 , shows a process 300 of an embodiment of a method for determining a distance according to the present disclosure, comprising the following steps:
[0062] Step 301, in response to detecting an instruction for indicating a detection distance, obtaining coordinate information of at least two facial key points in a facial image of a target user.
[0063] In this embodiment, when the execution subject of the method for determining the distance (for example Figure 1After the device 105 shown in the figure detects the instruction for indicating the detection distance, the coordinate information of at least two key points in the face image of the target user can be obtained. The instruction for indicating the detection distance can be an instruction generated when the camera of the terminal device captures a person and sent to the server for detecting the distance between the captured person and the camera of the terminal device; the instruction for indicating the detection distance can also be an instruction generated after the device is started, for example, an instruction for indicating the distance between the pedestrian and the self-driving car generated after the self-driving car is started.
[0064] In this embodiment, a facial image of a target user in a captured image can be obtained from a picture captured by a camera of a terminal device, and coordinate information of at least two key points in the facial image of the target user can be obtained through a pre-trained key point extraction model or a key point positioning method.
[0065] Step 302, obtaining a target distance prediction model, wherein the target distance prediction model is determined based on the following steps: using distance information and predicted distance to construct a loss function of an initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the distance information is obtained from a training data set, and the predicted distance is determined based on coordinate information of at least two facial key points of a facial image in the training data set.
[0066] In this embodiment, a target distance prediction model can be obtained, and the target distance prediction model is determined based on the following steps: using the predicted distance and distance information to construct a loss function of the initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the predicted distance is determined based on the coordinate information of at least two facial key points of the face image in the training data set, and the distance information is obtained from the training data set.
[0067] Step 303: using the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model, determine the distance between the target user and the corresponding facial image shooting device.
[0068] In this embodiment, the coordinate information of at least two key points of the acquired facial image of the target user can be input into the target distance prediction model to obtain the distance between the target user output by the target distance prediction model and the shooting device that shoots the facial image of the target user.
[0069] The method for determining distance provided in this embodiment, when an instruction for indicating the detection distance is detected, obtains the coordinate information of at least two facial key points in the facial image of the target user, and obtains the target distance prediction model, uses the coordinate information of at least two facial key points and the target distance prediction model to determine the distance between the target user and the corresponding facial image shooting device, divides the object detection or face recognition step and the distance prediction into different stages / steps / models, can simplify the model training steps, reduce the difficulty of model deployment, and reduce the demand for computing resources of the prediction system; in addition, because the distance prediction model does not contain image feature information, it can improve the security of sensitive information during data transmission, and avoid the influence of the quality of the captured image on the prediction result, thereby improving the accuracy of distance determination and the robustness and security of the system.
[0070] Optionally, the method for determining the distance includes: obtaining detection data of a facial image of a target user, wherein the detection data includes at least one of the following: posture information of the head in the facial image of the target user, coordinate information of a detection frame, and the detection frame is used to detect the facial image of the target user; using coordinate information of at least two facial key points in the facial image of the target user, and a target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image, including: using coordinate information of at least two facial key points in the facial image of the target user, the detection data of the facial image of the target user, and a target distance prediction model to determine the distance between the target user and a shooting device of the corresponding facial image.
[0071] In this embodiment, detection data of the target user's facial image can be obtained, and the coordinate information of at least two key points of the target user's facial image and the detection data of the target user's facial image can be input into a target distance prediction model to determine the distance between the target user and the corresponding facial image capturing device using the target distance prediction model.
[0072] In this embodiment, the detection data of the target user's facial image may include the target user's head posture information in the facial image, for example, the tilt direction, tilt angle, twist direction or twist angle of the head in the facial image, and other information that can be used to characterize the head posture; the detection data of the target user's facial image may include coordinate information of a detection frame used to detect the facial image or key points of the facial image in the captured picture, for example, when identifying the facial image in the captured picture, the upper left vertex and lower right vertex (or other arbitrary vertices) of the square detection frame of the facial image are the values in the x direction and y direction in a rectangular coordinate system with the center point of the captured picture (or any other preset point) as the origin and pixels (or any other preset size) as the unit.
[0073] In this embodiment, the detection data of the face image of the target user is used as the input data of the target distance prediction model, which can improve the accuracy of determining the distance.
[0074] Optionally, the method for determining the distance includes: obtaining augmented data of the target user's facial image, wherein the augmented data includes at least one of the following: size information of a detection frame, the distance between at least two facial key points in the target user's facial image, and the distance between the key points of the target user's facial image and any vertex and / or any edge of the detection frame, the detection frame being used to detect the target user's facial image; using coordinate information of at least two facial key points in the target user's facial image and a target distance prediction model to determine the distance between the target user and a corresponding facial image shooting device, including: using coordinate information of at least two facial key points in the target user's facial image, the augmented data of the target user's facial image and a target distance prediction model to determine the distance between the target user and the corresponding facial image shooting device.
[0075] In this embodiment, augmented data of the target user's facial image can be obtained, and the coordinate information of at least two facial key points of the target user's facial image and the augmented data of the target user's facial image can be input into a target distance prediction model to determine the distance between the target user and the corresponding facial image capturing device using the target distance prediction model.
[0076] In this embodiment, the augmented data of the target user's facial image may include size information of a detection frame used to detect the target user's facial image, for example, the width or height of a square detection frame. The augmented data may include the distance between at least two facial key points in the target user's facial image, for example, the distance between the left eye and the right eye in the facial image, or the number of pixels between every two facial features in the facial image. The augmented data may include the distance between the key points of the target user's facial image and any vertex and / or any edge of the detection frame, for example, the distance or number of pixels between the left corner of the mouth in the facial image and the upper left vertex (or other arbitrary vertex or arbitrary edge) of the square detection frame of the facial image in the detection shot.
[0077] In this embodiment, the augmented data of the target user's facial image is used as input data of the target distance prediction model, which can reduce the calculation time of the target distance prediction model and improve the efficiency of determining the distance.
[0078] Optionally, the method for determining distance also includes: in response to determining that the distance between the target user and the corresponding facial image shooting device is less than a preset distance threshold, generating an instruction for instructing the interactive device to start interaction, and / or an instruction for instructing the device to avoid obstacles.
[0079] In this embodiment, when the device for human-computer interaction with the user determines that the distance between the target user and the corresponding shooting device installed on the device for shooting the target user's face image is less than a preset distance threshold, an instruction for instructing the human-computer interaction device to interact with the target user can be generated. When the device that can travel automatically (such as an autonomous driving car, a sweeping robot, or a navigation robot) determines that the distance between the target user and the corresponding shooting device for shooting the target user's face image is less than a preset distance threshold, an instruction for instructing the device that can travel automatically to avoid the target user can be generated.
[0080] In this embodiment, when it is determined based on relevant data of the target user's facial image that the distance between the target user and the shooting device is less than a preset distance, generating instructions for instructing the interactive device to perform human-computer interaction can improve the convenience of the user in using the device, and generating instructions for instructing the device to avoid the target user can avoid the device from causing damage to the surrounding environment during movement, thereby ensuring the safety of the user.
[0081] Further references Figure 4 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for training a distance prediction model. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0082] like Figure 4 As shown, the apparatus 400 for training the distance prediction model of this embodiment includes: a first acquisition unit 401, a prediction unit 402, a construction unit 403, and a training unit 404. The first acquisition unit is configured to acquire the coordinate information of at least two facial key points in the face image of the user and the distance information between the user and the corresponding face image shooting device from the training data set; the prediction unit is configured to use the initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points in the face image; the construction unit is configured to use the distance information and the predicted distance to construct the loss function of the initial distance prediction model; the training unit is configured to use the loss function to train the initial distance prediction model to obtain the trained target distance prediction model.
[0083] In some embodiments, the device includes: a second acquisition unit, configured to acquire detection data of a face image, wherein the detection data includes at least one of the following: posture information of the head in the face image, coordinate information of a detection frame, and the detection frame is used to detect the face image; a prediction unit, including: a first prediction module, configured to adopt an initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two face key points of the face image and the detection data of the face image.
[0084] In some embodiments, the device includes: a third acquisition unit, configured to acquire augmented data of a face image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two face key points of the face image, and a distance between a key point of the face image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the face image; a prediction unit, including: a second prediction module, configured to adopt an initial distance prediction model to determine the predicted distance between the user and the shooting device based on coordinate information of at least two face key points of the face image and the augmented data of the face image.
[0085] Each unit in the above device 400 is similar to the reference Figure 2 Therefore, the operations, features and technical effects described above for the method for training a distance prediction model are also applicable to the device 400 and the units contained therein, and will not be described in detail here.
[0086] Further references Figure 5 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a device for determining a distance. Figure 3 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0087] like Figure 5As shown, the device 500 for determining the distance of this embodiment includes: a first target acquisition unit 501, a model acquisition unit 502, and a determination unit 503. The first target acquisition unit is configured to acquire the coordinate information of at least two facial key points in the facial image of the target user in response to detecting an instruction for indicating the detection distance; the model acquisition unit is configured to acquire a target distance prediction model, wherein the target distance prediction model is determined based on the following steps: using the distance information and the predicted distance to construct a loss function of the initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the distance information is acquired from a training data set, and the predicted distance is determined based on the coordinate information of at least two facial key points in the facial image in the training data set; the determination unit is configured to use the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model to determine the distance between the target user and the corresponding facial image shooting device.
[0088] In some embodiments, the device includes: a second target acquisition unit, configured to acquire detection data of a target user's facial image, wherein the detection data includes at least one of the following: head posture information in the target user's facial image, coordinate information of a detection frame, and the detection frame is used to detect the target user's facial image; a determination unit, including: a first determination module, configured to use coordinate information of at least two facial key points in the target user's facial image, detection data of the target user's facial image, and a target distance prediction model to determine the distance between the target user and the corresponding facial image shooting device.
[0089] In some embodiments, the device includes: a third target acquisition unit, configured to acquire augmented data of a target user's facial image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two facial key points in the target user's facial image, and a distance between a key point of the target user's facial image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the target user's facial image; a determination unit, including: a second determination unit, configured to determine the distance between the target user and a corresponding facial image shooting device using coordinate information of at least two facial key points in the target user's facial image, augmented data of the target user's facial image, and a target distance prediction model.
[0090] In some embodiments, the device also includes: a generation unit, configured to generate an instruction for instructing the interactive device to start interaction, and / or an instruction for instructing the device to avoid obstacles in response to determining that the distance between the target user and the corresponding facial image shooting device is less than a preset distance threshold.
[0091] Each unit in the above device 500 is similar to the reference Figure 3 Therefore, the operations, features and technical effects described above for the method for determining the distance are also applicable to the device 500 and the units included therein, and will not be described in detail here.
[0092] According to an embodiment of the present application, the present application also provides an electronic device and a readable storage medium.
[0093] like Figure 6 , is a block diagram of an electronic device 600 for training a distance prediction model according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0094] like Figure 6 As shown, the electronic device includes: one or more processors 601, a memory 602, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 601 is taken as an example.
[0095] The memory 602 is a non-transitory computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the method for training a distance prediction model provided in the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the method for training a distance prediction model provided in the present application.
[0096] The memory 602 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the method for training the distance prediction model in the embodiment of the present application (for example, the attached Figure 4 The processor 601 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 602, that is, the method for training the distance prediction model in the above method embodiment is implemented.
[0097] The memory 602 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the electronic device for extracting video clips, etc. In addition, the memory 602 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 602 may optionally include a memory remotely arranged relative to the processor 601, and these remote memories may be connected to the electronic device for extracting video clips via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0098] The electronic device for training the distance prediction model may further include: an input device 603, an output device 604, and a bus 605. The processor 601, the memory 602, the input device 603, and the output device 604 may be connected via the bus 605 or in other ways. Figure 6 The connection via bus 605 is taken as an example.
[0099] The input device 603 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device for extracting video clips, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator rod, one or more mouse buttons, a trackball, a joystick, and other input devices. The output device 604 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor). The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0100] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0101] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0102] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0103] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0104] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0105] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0106] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A method for training a distance prediction model, comprising: Acquire coordinate information of at least two facial key points in a facial image of a user from a training data set, and distance information between the user and a camera of the corresponding facial image; Using an initial distance prediction model, based on coordinate information of at least two facial key points in the facial image, determining a predicted distance between the user and the camera; Using the distance information and the predicted distance, constructing a loss function of the initial distance prediction model; The loss function is used to train the initial distance prediction model to obtain a trained target distance prediction model.
2. The method according to claim 1, wherein: The method comprises: Acquire detection data of the face image, wherein the detection data includes at least one of the following: posture information of the head in the face image, and coordinate information of a detection frame, the detection frame being used to detect the face image; The method of using the initial distance prediction model to determine the predicted distance between the user and the shooting device based on coordinate information of at least two facial key points of the facial image includes: The initial distance prediction model is used to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image and the detection data of the facial image.
3. The method according to claim 1, wherein: The method comprises: Acquire augmented data of the face image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two face key points of the face image, and a distance between a key point of the face image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the face image; The method of using the initial distance prediction model to determine the predicted distance between the user and the shooting device based on coordinate information of at least two facial key points of the facial image includes: The initial distance prediction model is used to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image and the augmented data of the facial image.
4. A method for determining distance, comprising: In response to detecting an instruction for indicating a detection distance, obtaining coordinate information of at least two facial key points in a facial image of a target user; Obtaining a target distance prediction model, wherein the target distance prediction model is determined based on the following steps: using distance information and predicted distance to construct a loss function of an initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the distance information is obtained from a training data set, and the predicted distance is determined based on coordinate information of at least two facial key points of a facial image in the training data set; The distance between the target user and a shooting device of the corresponding face image is determined by using the coordinate information of at least two face key points in the face image of the target user and the target distance prediction model.
5. The method according to claim 4, wherein: The method comprises: Acquire detection data of the face image of the target user, wherein the detection data includes at least one of the following: posture information of the head in the face image of the target user and coordinate information of a detection frame, the detection frame being used to detect the face image of the target user; The method of using the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model to determine the distance between the target user and the corresponding facial image capturing device includes: The distance between the target user and a shooting device of the corresponding face image is determined by using the coordinate information of at least two face key points in the face image of the target user, the detection data of the face image of the target user, and the target distance prediction model.
6. The method according to claim 4, wherein: The method comprises: Acquire augmented data of the face image of the target user, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two face key points in the face image of the target user, and a distance between a key point of the face image of the target user and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the face image of the target user; The method of using the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model to determine the distance between the target user and the corresponding facial image capturing device includes: The distance between the target user and a shooting device of the corresponding facial image is determined by using coordinate information of at least two facial key points in the facial image of the target user, augmented data of the facial image of the target user, and the target distance prediction model.
7. The method according to any one of claims 4 to 6, wherein: The method further comprises: In response to determining that the distance between the target user and the corresponding facial image shooting device is less than a preset distance threshold, an instruction for instructing the interactive device to start interaction and / or an instruction for instructing the device to avoid obstacles is generated.
8. A device for training a distance prediction model, comprising: A first acquisition unit is configured to acquire coordinate information of at least two facial key points in a facial image of a user and distance information between the user and a shooting device of the corresponding facial image from a training data set; A prediction unit configured to use an initial distance prediction model to determine a predicted distance between the user and the camera based on coordinate information of at least two facial key points in the facial image; A construction unit configured to construct a loss function of the initial distance prediction model using the distance information and the predicted distance; The training unit is configured to adopt the loss function to train the initial distance prediction model to obtain a trained target distance prediction model.
9. The device according to claim 8, wherein: The device comprises: A second acquisition unit is configured to acquire detection data of the face image, wherein the detection data includes at least one of the following: posture information of the head in the face image, and coordinate information of a detection frame, the detection frame being used to detect the face image; The prediction unit comprises: The first prediction module is configured to use the initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image and the detection data of the facial image.
10. The device according to claim 8, wherein: The device comprises: a third acquisition unit, configured to acquire augmented data of the face image, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two face key points of the face image, and a distance between a key point of the face image and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the face image; The prediction unit comprises: The second prediction module is configured to use the initial distance prediction model to determine the predicted distance between the user and the shooting device based on the coordinate information of at least two facial key points of the facial image and the augmented data of the facial image.
11. An apparatus for determining distance, comprising: A first target acquisition unit is configured to acquire coordinate information of at least two facial key points in a facial image of a target user in response to detecting an instruction for indicating a detection distance; The model acquisition unit is configured to acquire a target distance prediction model, wherein the target distance prediction model is determined based on the following steps: using distance information and predicted distance to construct a loss function of an initial distance prediction model; using the loss function to train the initial distance prediction model to obtain a trained target distance prediction model; wherein the distance information is acquired from a training data set, and the predicted distance is determined based on coordinate information of at least two facial key points of a facial image in the training data set; The determination unit is configured to use the coordinate information of at least two facial key points in the facial image of the target user and the target distance prediction model to determine the distance between the target user and the shooting device of the corresponding facial image.
12. The device according to claim 11, wherein The device comprises: a second target acquisition unit, configured to acquire detection data of the face image of the target user, wherein the detection data includes at least one of the following: head posture information in the face image of the target user and coordinate information of a detection frame, the detection frame being used to detect the face image of the target user; The determining unit comprises: The first determination module is configured to use the coordinate information of at least two facial key points in the facial image of the target user, the detection data of the facial image of the target user and the target distance prediction model to determine the distance between the target user and the corresponding facial image shooting device.
13. The device according to claim 11, wherein: The device comprises: a third target acquisition unit, configured to acquire augmented data of the face image of the target user, wherein the augmented data includes at least one of the following: size information of a detection frame, a distance between at least two face key points in the face image of the target user, and a distance between a key point of the face image of the target user and any vertex and / or any edge of the detection frame, wherein the detection frame is used to detect the face image of the target user; The determining unit comprises: The second determination unit is configured to use the coordinate information of at least two facial key points in the facial image of the target user, the augmented data of the facial image of the target user and the target distance prediction model to determine the distance between the target user and the shooting device of the corresponding facial image.
14. The device according to any one of claims 11 to 13, wherein: The device also includes: A generating unit is configured to generate an instruction for instructing the interactive device to start interaction and / or an instruction for instructing the device to avoid obstacles in response to determining that the distance between the target user and the corresponding facial image shooting device is less than a preset distance threshold.
15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 7.
