Human body detection method, device and equipment and computer readable storage medium

CN117671722BActive Publication Date: 2026-08-18SF TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211048640.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-30
Publication Date
2026-08-18
Estimated Expiration
2042-08-30

AI Technical Summary

Technical Problem

[0004]本申请实施例提供一种人体检测方法、装置、设备及计算机可读存储介质,旨在解决现有的人体检测方法存在的无法利用较少的资源消耗训练得到泛化性好的人体检测模型的问题

Benefits of technology

[0043] The technical solution provided in this application, after processing the image using a trained human detection model to obtain the initial human body region, then inputs the scene sample image into the human detection model to process the scene human features and compares them with the region features of the initial human body region. Since the scene human features contain human-related feature information in different scenes, the scene human features can be used to filter out the target human body region that is more likely to be the real result from the initial human body region. While only requiring a small amount of resources to train a human detection model, the model's performance in human detection in various scenes is improved, thereby improving the model's generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117671722B_ABST
    Figure CN117671722B_ABST
Patent Text Reader

Abstract

The application provides a human body detection method, device and equipment and a computer readable storage medium. The method comprises the following steps: inputting a target image to be detected into a preset human body detection model to obtain an initial human body region; inputting the initial human body region into a trained matching model to obtain initial region features corresponding to the initial human body region; obtaining scene human body features obtained by inputting preset scene human body sample images into the matching model; and screening a target human body region from the initial human body region according to the initial region features and the scene human body features. The human body detection method provided in the application can compare the scene human body features obtained by inputting scene sample images into the human body detection model with the region features of the initial human body region, screen a target human body region that is more likely to be a real result from the initial human body region, and improve the effect of human body detection in various scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image detection technology, specifically to a human body detection method, apparatus, device, and computer-readable storage medium. Background Technology

[0002] Image detection mainly refers to identifying specific objects in an image, such as the human body, text information, etc. With the development of technology, image detection is being applied to more and more fields.

[0003] However, current mainstream deep learning-based human detection algorithms do not produce human detection models with strong generalization capabilities. This means that these algorithms are limited by the background information of the dataset; a human detection model trained in scenario A can typically only be applied to human detection tasks in the same or similar scenarios, while performing poorly in other scenarios. Furthermore, training a high-performing human detection model for each specific business scenario requires significant human and material resources for data collection and annotation, resulting in a lengthy and time-consuming process. Summary of the Invention

[0004] This application provides a human body detection method, apparatus, device, and computer-readable storage medium, aiming to solve the problem that existing human body detection methods cannot train a human body detection model with good generalization using minimal resource consumption.

[0005] On one hand, embodiments of this application provide a human body detection method, including:

[0006] The acquired target image to be detected is input into a preset human detection model to obtain the initial human body region;

[0007] The initial human body region is input into the trained matching model to obtain the initial region features corresponding to the initial human body region.

[0008] Obtain scene human features obtained by inputting a pre-set scene sample image into the matching model for processing;

[0009] Based on the initial region features and the scene human body features, a target human body region is selected from the initial human body region.

[0010] As an optional embodiment of this application, before inputting the initial human body region into the trained matching model to obtain the region features corresponding to the initial human body region, the method includes:

[0011] Obtain the human body label region and background label region in the training sample image;

[0012] The human body label region is input into a preset initial matching model to obtain the human body region features corresponding to the human body label region.

[0013] The background label region is input into the initial matching model to obtain the background region features corresponding to the background label region;

[0014] The initial matching model is trained based on the human body region features and the background region features to obtain a trained matching model.

[0015] As an optional embodiment of this application, the step of training the initial matching model based on the human body region features and the background region features to obtain a trained matching model includes:

[0016] Calculate the first feature distance between the first human body feature and the second human body feature in the human body region features;

[0017] Calculate the second feature distance between the human body region features and the background region features;

[0018] The initial matching model is updated based on the first feature distance and the second feature distance to obtain the updated matching model;

[0019] The updated matching model is set as the trained matching model only when the first feature distance and the second feature distance obtained by inputting the training sample image into the updated matching model meet the preset conditions.

[0020] As an optional embodiment of this application, before obtaining the scene human features obtained by processing the matching model by inputting a preset scene sample image into the scene human features, the method includes:

[0021] Acquire human sample images of the scene;

[0022] The human body sample image of the scene is input into the matching model to obtain reference human body features;

[0023] Clustering is performed on the reference human body features to obtain scene human body features.

[0024] As an optional embodiment of this application, after clustering the reference human features to obtain scene human features, the method includes:

[0025] The human features in the scene are associated with the scene type corresponding to the human sample image in the scene and stored in a preset database;

[0026] The step of obtaining scene human features by inputting a pre-set scene human sample image into the matching model for processing includes:

[0027] Query a preset database to obtain scene human features associated with the scene type of the target image.

[0028] As an optional embodiment of this application, before clustering the reference human features to obtain scene human features, the method includes:

[0029] Count the number of human sample images in the scene;

[0030] If the number of images is less than a preset image number threshold, then the step of clustering the reference human features to obtain scene human features is performed.

[0031] If the number of images is greater than or equal to the number of images threshold, then a preset number of target region features are selected from the reference human body features, and the target region features are set as scene human body features.

[0032] As an optional embodiment of this application, the step of filtering the target human body region from the initial human body region based on the initial region features and the scene human body features includes:

[0033] For each initial region feature, calculate the feature distance between the initial region feature and each of the scene human body features;

[0034] The number of scene human features whose feature distance is less than a preset distance threshold is counted, and the ratio between the number of features and the number of scene human features is set as the matching degree corresponding to the initial region features.

[0035] The initial human body regions whose matching degree is greater than a preset threshold are set as the target human body regions.

[0036] On the other hand, embodiments of this application also provide a human body detection device, including:

[0037] The detection module is used to input the acquired target image to be detected into a preset human detection model to obtain the initial human body region;

[0038] An extraction module is used to input the initial human body region into a trained matching model to obtain the initial region features corresponding to the initial human body region.

[0039] The acquisition module is used to acquire scene human features obtained by inputting a preset scene sample image into the matching model for processing.

[0040] The filtering module is used to filter out target human body regions from the initial human body region based on the initial region features and the scene human body features.

[0041] On the other hand, embodiments of this application also provide a computer device, the computer device including a processor, a memory, and a computer program stored in the memory and executable on the processor, the processor executing the computer program to implement the steps in the above-described human body detection method.

[0042] On the other hand, embodiments of this application also provide a computer-readable storage medium storing a computer program, which is executed by a processor to implement the steps in the above-described human body detection method.

[0043] The technical solution provided in this application, after processing the image using a trained human detection model to obtain the initial human body region, then inputs the scene sample image into the human detection model to process the scene human features and compares them with the region features of the initial human body region. Since the scene human features contain human-related feature information in different scenes, the scene human features can be used to filter out the target human body region that is more likely to be the real result from the initial human body region. While only requiring a small amount of resources to train a human detection model, the model's performance in human detection in various scenes is improved, thereby improving the model's generalization ability. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 This is a flowchart illustrating the steps of a human body detection method provided in an embodiment of this application;

[0046] Figure 2 This application provides a schematic flowchart illustrating the steps involved in training a matching model.

[0047] Figure 3 This application provides a schematic flowchart illustrating the steps for updating an initial matching model to obtain a matching model, as shown in the embodiments of the present application.

[0048] Figure 4 This application provides a schematic diagram of a process for extracting human features from a scene, as illustrated in an embodiment of the present application.

[0049] Figure 5 This application provides a schematic flowchart illustrating the steps for associating human features in a scene with scene type in an embodiment of the present application.

[0050] Figure 6This application provides a schematic flowchart of a process for extracting human features from a scene based on the number of images, as illustrated in an embodiment of the present application.

[0051] Figure 7 This application provides a schematic flowchart illustrating the steps for selecting a target human body region from an initial human body region in an embodiment of the present application.

[0052] Figure 8 This is a schematic diagram of the structure of a human body detection device provided in an embodiment of this application;

[0053] Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0054] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of the present invention.

[0055] In this application, the term "exemplary" is used to mean "used as an example, illustration, or description." Any embodiment described as "exemplary" in this application is not necessarily to be construed as being more preferred or advantageous than other embodiments. The following description is provided to enable any person skilled in the art to implement and use the invention. Details are set forth in the following description for purposes of explanation. It should be understood that those skilled in the art will recognize that the invention can be implemented without using these specific details. In other instances, well-known structures and processes will not be described in detail to avoid obscuring the description of the invention with unnecessary detail. Therefore, the invention is not intended to be limited to the embodiments shown, but is consistent with the broadest scope of the principles and features disclosed in the embodiments of this application.

[0056] This application provides a human body detection method, apparatus, device, and computer-readable storage medium, which will be described in detail below.

[0057] like Figure 1 As shown, Figure 1 This application provides a flowchart illustrating the steps of a human body detection method, specifically including steps 101 to 104:

[0058] 101. Input the acquired target image to be detected into the preset human detection model to obtain the initial human body region.

[0059] In this embodiment, the target image to be detected usually refers to an image containing people and background that needs to be detected in different scenarios, such as pedestrian detection on the road, consumer detection in a store, etc. This embodiment will not elaborate on the target image obtained.

[0060] In this embodiment, the preset human detection model refers to a neural network model trained based on deep learning. Unlike conventional models trained using sample images from specific scenarios, the human detection model in this embodiment is trained using sample images from various different scenarios. This results in a human detection model with a certain degree of generalization, but it cannot guarantee the accuracy of the detected human body region. In other words, the initial human body region obtained by inputting the target image into this human detection model will have a certain error compared to the actual human body region in the image.

[0061] Specifically, as a feasible embodiment of this application, the human detection model can employ a conventional object detection network, such as the commonly used YOLOv5-X model. Of course, choosing other object detection networks as the human detection model is also feasible, and will not be elaborated upon in this embodiment.

[0062] 102. The initial human body region is input into a trained matching model to obtain the initial region features corresponding to the initial human body region. Based on this, to filter more accurate human body regions from the initial human body regions detected by the human body detection model, this embodiment of the application provides inputting the initial human body region into a trained matching model to obtain the initial region features corresponding to the initial human body region. The trained matching model can shorten the feature distance between human images and exclude the feature distance between the human image and the background, thereby facilitating the subsequent filtering of more accurate human body regions based on the feature distance between the scene human features extracted from scene sample images and the initial region features. Specifically, for ease of understanding, the following... Figure 2 This paper provides an implementation scheme for training a matching model, which can be found in subsequent sections. Figure 2 And its explanations and descriptions.

[0063] 103. Obtain the scene human features obtained by inputting a preset scene sample image into the matching model for processing.

[0064] In this embodiment, after training the matching model, scene human features for different scenarios can be extracted by inputting sample images corresponding to different scenarios into the matching model. Specific implementation schemes for obtaining scene human features can be found in subsequent sections. Figure 4 And its explanations and descriptions.

[0065] 104. Based on the initial region features and the scene human features, select the target human region from the initial human region.

[0066] In this embodiment, as described above, since the matching model can shorten the distance between human body data and widen the distance between the human body and background data, by comparing the initial region features and the scene human body features, it can be determined whether an initial human body region detected by the human detection model is a real human body region or a misjudged background region. Specifically, the filtering is based on the distance between features; the specific implementation scheme can be found in subsequent sections. Figure 7 And its explanations and descriptions.

[0067] The technical solution provided in this application, after processing the image using a trained human detection model to obtain the initial human body region, then inputs the scene sample image into the human detection model to process the scene human features and compares them with the region features of the initial human body region. Since the scene human features contain human-related feature information in different scenes, the scene human features can be used to filter out the target human body region that is more likely to be the real result from the initial human body region. While only requiring a small amount of resources to train a human detection model, the model's performance in human detection in various scenes is improved, thereby improving the model's generalization ability.

[0068] like Figure 2 As shown, Figure 2 A flowchart illustrating the steps of training a matching model, as provided in an embodiment of this application, is described in detail below.

[0069] This application provides an implementation scheme for training a matching model based on deep learning, specifically including steps 201-204:

[0070] 201, obtain the human body label region and background label region in the training sample image.

[0071] In this embodiment, the training sample images typically refer to pre-collected images of various scenes containing human bodies. Furthermore, the human body label region is the area where the human body is located, pre-marked using the smallest bounding rectangle. The background label region, on the other hand, is a randomly selected area outside the human body area that does not contain any part of the human body. Generally, the size ratio of the background label region and the human body label region should be kept basically consistent; for example, a common aspect ratio is 3:1.

[0072] 202. Input the human body label region into the preset initial matching model to obtain the human body region features corresponding to the human body label region.

[0073] In this embodiment of the application, the human body label region is input into a preset initial matching model for processing, and the human body region features corresponding to the human body label region can be obtained.

[0074] Specifically, as a feasible embodiment of this application, the initial matching model can be a neural network model based on the ResNet50 architecture. Furthermore, to relax the memory requirements during model training and avoid limitations on the number of samples selected in a single training iteration, all BN (batch normalization) layers in the ResNet50 architecture can be replaced with GN (group normalization) layers.

[0075] 203. Input the background label region into the initial matching model to obtain the background region features corresponding to the background label region.

[0076] In this embodiment of the application, similar to step 202 above, the background label region is input into a preset initial matching model for processing, and the human body region features corresponding to the background label region can be obtained.

[0077] 204. Based on the human body region features and the background region features, the initial matching model is trained to obtain a trained matching model.

[0078] In this embodiment, by training the initial matching model using the feature distance between human body region features and background region features, the trained model can effectively increase the feature distance between the human body and the background data. Furthermore, by using the feature distance between human body region features corresponding to different human body label regions to train the initial matching model, the trained model can effectively decrease the feature distance between the human body and the human body data. For a detailed implementation process, please refer to the subsequent sections. Figure 3 And its explanations and descriptions.

[0079] like Figure 3 As shown, Figure 3 This application provides a flowchart illustrating the steps for updating an initial matching model to obtain a matching model, specifically including steps 301 to 304:

[0080] 301. Calculate the first feature distance between the first human body feature and the second human body feature in the human body region features.

[0081] In this embodiment, after obtaining multiple human body region features based on different human body label regions, the feature distance between different human body region features can reflect the training effect of the model. Specifically, the smaller the feature distance between the first human body feature and the second human body feature, the more effectively the matching model can shorten the distance between human figures, and the better the training effect of the matching model.

[0082] Specifically, the feature distance can be calculated using Euclidean distance, or it can be calculated using cosine similarity. In this embodiment, the specific implementation scheme for calculating the feature distance will not be elaborated here.

[0083] 302, Calculate the second feature distance between the human body region features and the background region features.

[0084] In this embodiment, similar to step 301 above, after obtaining the human body region features and background region features based on the human body label region and background label region respectively, the second feature distance between the human body region features and the background region features can also reflect the training effect of the model. Specifically, the larger the second feature distance between the human body region features and the background region features, the more effectively the matching model can widen the distance between the human figure and the background, and the better the training effect of the matching model. Of course, the feature distance can also be calculated using the Euclidean distance or cosine similarity method provided above, which will not be elaborated here in this embodiment.

[0085] 303. Update the initial matching model based on the first feature distance and the second feature distance to obtain the updated matching model.

[0086] In this embodiment of the application, based on the foregoing description of the first feature distance and the second feature distance, the following loss function is constructed:

[0087] L triplet =max(D(a,p)-D(a,n)+M,0)

[0088] Among them, L triplet This represents the model's loss value. 'a' is the first human feature corresponding to the first human body label region, 'p' is the second human feature corresponding to the second human body label region, and 'n' is the background region feature corresponding to the background label region. 'D' represents the calculation of feature distance; that is, D(a, p) represents the first feature distance between the first and second human body features in the human body region features. Similarly, D(a, n) is the second feature distance between the human body region features and the background region features. Furthermore, 'M' is the edge parameter; specifically, in this embodiment, 'M' is set to 1.

[0089] As can be seen from the loss function provided above, the greater the distance between the first feature (i.e., the smaller the value) and the closer the distance between the second feature (i.e., the larger the value), the larger the loss value and the worse the model performance. Conversely, the closer the distance between the first feature and the greater the distance between the second feature, the smaller the loss value and the better the model performance. Based on this, updating the parameters in the matching model using the backpropagation algorithm and the aforementioned loss value enables the updated matching model to narrow the feature distances between image features in the portrait region and widen the feature distances between image features in the portrait and background regions.

[0090] 304, until the first feature distance and the second feature distance obtained by inputting the training sample image into the updated matching model meet the preset conditions, the updated matching model is set as the trained matching model.

[0091] In this embodiment, after updating the matching model, the training sample image is input into the updated matching model again to obtain the updated first feature distance and second feature distance. The loss value is then calculated again based on the loss function provided in step 303, until the calculated loss value is consistently less than a preset threshold. At this point, the updated matching model can be set as the trained matching model for subsequent feature matching processing. It should be noted that updating the matching model requires iterative updates, i.e., repeating steps 301-304. This embodiment will not elaborate further.

[0092] In this embodiment, the initial detection model is trained based on the predicted human body region, the human body label region, and the background label region. That is, the model's loss function takes into account the differences between the predicted human body region and the human body label region, as well as the differences between the predicted human body region and the background label region. This allows the final trained human detection model to both reduce the distance between human figures and reduce the distance between human figures and the background, thereby improving the detection effect of scene human features obtained by processing scene sample images using the human detection model to assist in human detection of target images.

[0093] like Figure 4 As shown, Figure 4 This application provides a flowchart illustrating the steps for extracting human features from a scene, specifically including steps 401 to 403:

[0094] 401, Obtain human sample images of the scene.

[0095] In this embodiment, the human body sample image of the scene is similar to the human body label region in the training sample image. It is usually a human body region image in various scenes, which can enrich the feature information of the human body features extracted in the scene later.

[0096] Of course, as an optional embodiment of this application, although the acquired scene human sample images are human images in various scenes, they can be divided into different sets according to different scene types, thereby obtaining scene human features corresponding to different scene types. This facilitates the subsequent selection of the corresponding scene human features based on the scene type corresponding to the target image. Specific implementation schemes can be found in the following sections. Figure 5 And its explanations and descriptions.

[0097] 402. Input the human body sample image of the scene into the matching model to obtain reference human body features.

[0098] In this embodiment of the application, human body sample images of scenes containing human bodies are input into a trained matching model, and the resulting reference human body features can reflect human body-related feature information in different scenes.

[0099] 403. Cluster the reference human body features to obtain scene human body features.

[0100] In this embodiment of the application, the obtained reference human body features are clustered based on the kmeans clustering algorithm, and similar reference human body features are clustered into the same set. Then, for each set, the average feature of the reference human body features in the set is used as the scene human body feature.

[0101] Furthermore, considering that the k-means clustering algorithm may consume more resources when the data volume is too large, in order to save resource costs, as an optional embodiment of this application, clustering is used to obtain scene human features when the data volume is small, while when the data volume is large, several reference human features are randomly selected as scene human features. Specific implementation schemes can be found in subsequent sections. Figure 6 And its explanations and descriptions.

[0102] like Figure 5 As shown, Figure 5 This application provides a flowchart illustrating the steps for associating human features in a scene with a scene type, specifically including steps 501-502:

[0103] 501. The human features of the scene are associated with the scene type corresponding to the human sample image of the scene and stored in a preset database.

[0104] 502. Query the preset database to obtain the scene human features associated with the scene type of the target image.

[0105] In this embodiment, by pre-associating scene human features with scene human sample images and storing them in a preset database, the associated scene human features can be retrieved from the preset database using the scene type of the target image. Furthermore, since these scene human features are obtained by processing scene human sample images of the same scene type as the target image, the extracted scene human features contain richer feature information related to the scene type, and a more accurate target human region can be obtained during subsequent filtering.

[0106] like Figure 6 As shown, Figure 6 This application provides a flowchart illustrating the steps for extracting human features from a scene based on the number of images, specifically including steps 601-603:

[0107] 601. Count the number of human sample images in the scene and determine whether the number of images is less than a preset image number threshold. If yes, proceed to step 602; otherwise, proceed to step 603.

[0108] In this embodiment, if the number of scene human sample images is large, meaning the number of reference human features is large, clustering algorithms would consume significant resources. Therefore, the number of scene sample images can be compared with a preset image number threshold to determine if there are too many scene sample images. Specifically, the image number threshold can be set to 5000.

[0109] 602, Cluster the reference human body features to obtain scene human body features.

[0110] In this embodiment of the application, if the number of images is less than the preset image number threshold, it indicates that the number of scene sample images is small. At this time, the reference human body features can be clustered to obtain more accurate scene human body features.

[0111] 603. Select a preset number of target region features from the reference human body features, and set the target region features as scene human body features.

[0112] In this embodiment of the application, if the number of images is greater than the preset image number threshold, it indicates that there are a large number of human body sample images in the scene. At this time, a preset number of target region features can be selected from the reference human body features. For example, a certain number of features can be selected as human body features in the scene by random selection.

[0113] like Figure 7 As shown, Figure 7 A flowchart illustrating the steps for selecting a target human body region from an initial human body region, as provided in this application embodiment, is described in detail below.

[0114] In this embodiment of the application, a scheme for filtering target human body region features based on feature distance is provided, specifically including steps 701 to 703:

[0115] 701. For each initial region feature, calculate the feature distance between the initial region feature and each of the scene human body features.

[0116] In this embodiment, the feature distance between each initial region feature and each scene human body feature is calculated. This feature distance is similar to the aforementioned feature distance and can be calculated using Euclidean distance or pre-calculated using similarity; details will not be elaborated further in this embodiment.

[0117] 702, count the number of scene human features whose feature distance is less than a preset distance threshold, and set the ratio between the number of features and the number of scene human features as the matching degree corresponding to the initial region features.

[0118] In this embodiment of the application, taking Euclidean distance as an example, if the feature distance is less than a preset distance threshold, it indicates that the initial region feature and the scene human body feature are sufficiently similar. Therefore, the ratio between the number of features and the number of scene human body features can reflect the probability that the initial region feature is a feature of a real human body region, that is, the probability that the initial human body region is a real human body region. The larger the ratio, the more likely the initial region feature is a feature of a real human body region, that is, the more likely the initial human body region is a real human body region.

[0119] 703, set the initial human body region whose matching degree is greater than the preset threshold corresponding to the initial region feature as the target human body region.

[0120] In this embodiment of the application, as described above, the matching degree corresponding to the initial region features can reflect the probability that the initial human body region is a real human body region. Therefore, the initial human body region with a matching degree greater than a preset threshold can be set as the target human body region. Specifically, the preset threshold can be 0.5, that is, the initial human body region with a feature distance less than a preset distance threshold between itself and more than half of the scene human body features can be set as the target human body region.

[0121] To better understand the human body detection method provided in the embodiments of this application, the following will be combined with the foregoing. Figures 1 to 7 The provided embodiments offer a complete implementation scheme for a human detection method, from model training to model application, as detailed below.

[0122] 1) Collect a large human body dataset, where the data must meet the following requirements: a. various scenes, b. human figures in the image. Label the data in this dataset using the minimum bounding rectangle to mark the locations of the human figures. Name this dataset dataset A.

[0123] 2) Cropping data from dataset A yields crop images of the human body and the background. When cropping the background, the following requirements must be met: a. The cropped background data must not contain any part of the human body; b. The background crop image and the human body crop image must maintain a roughly consistent size ratio, i.e., h:w ∈ [1:3] in the crop image. At this point, the human body data and background database are complete and named dataset B.

[0124] 3) Collect I datasets containing human images from different scenes, and these scenes are all different from the scene in dataset A. These test datasets will be used for model inference;

[0125] 4) First, classify dataset A according to the ratio of training data:validation data = 8:2, train the YOLOv5-X model, and obtain the basic detection model;

[0126] 5) Then train the matching model on dataset B. Note that: a. All BN (batch norm) layers in the ResNet50 architecture used in the matching model are replaced with GN (group norm) layers. The num_groups parameter in the GN layer is set to 32, and the feature vector dimension input to the triplet loss is defined as 512-dimensional; b. The margin parameter in the triplet loss is set to 1.0; where triplet loss is the loss function provided in step 303 above.

[0127] 6) Use the previously trained model to infer the human data in dataset B, obtaining a 512-dimensional human feature vector for each human image, i.e., scene human features. Use these human feature vectors to construct a highly diverse human feature library. In this human feature library, each 512-dimensional vector represents an abstract human feature. Specifically, the k-means clustering algorithm can be used to cluster m feature vectors as scene human features. Of course, if the amount of human data in dataset B is large (i.e., the dataset is highly diverse), the random select method can be used, i.e., randomly selecting m human features from the human feature library as scene human features.

[0128] 7) After training the model, when it is necessary to perform human detection on the target image, first input the target image into the trained YOLOv5-X detection model (i.e., human detection model) to perform preliminary human localization, and then crop the data according to the bounding box points obtained by regression to obtain the human data region (i.e., the initial human region) as perceived by the detection model.

[0129] 8) Obtain the corresponding region image from the target image based on the initial human body region and input it into the trained matching module to obtain a 512-dimensional embedding vector for subsequent matching. Then, calculate the feature distance between the embedding vector of each region image and the m scene human features obtained in step 6). If the distance is greater than a preset distance threshold, it is recorded as 1; otherwise, it is recorded as 0. Finally, calculate the sum of the embedding vector and the m scene human features, and set the threshold to m / 2. If sum >= (m / 2), that is, more than half of the number of features with a feature distance greater than the preset distance threshold are greater than half of the m scene human features, then the region image represented by the embedding vector is considered to be the background, i.e., the initial human body region is a misjudged human body region. Conversely, if sum < (m / 2), that is, more than half of the number of features with a feature distance less than the preset distance threshold are less than half of the m scene human features, then the region image represented by the embedding vector is considered to be a human body, i.e., the initial human body region is a real human body region.

[0130] 9) Filter out the areas that the matching module considers to be background, and output the coordinates of the areas that the matching module considers to be human bodies in the original image to obtain accurate filtering results.

[0131] To better implement the human body detection method provided in the embodiments of this application, a human body detection device is also provided in the embodiments of this application, such as... Figure 8 As shown, Figure 8 This is a schematic diagram of a human body detection device provided in an embodiment of this application. Specifically, the human body detection device includes:

[0132] The detection module 801 is used to input the acquired target image to be detected into a preset human body detection model to obtain an initial human body region;

[0133] Extraction module 802 is used to input the initial human body region into the trained matching model to obtain the initial region features corresponding to the initial human body region;

[0134] The acquisition module 803 is used to acquire scene human features obtained by inputting a preset scene sample image into the matching model for processing.

[0135] The filtering module 804 is used to filter out target human body regions from the initial human body regions based on the initial region features and the scene human body features.

[0136] As an optional embodiment of this application, the extraction module described above is further configured to acquire human body label regions and background label regions in training sample images before inputting the initial human body region into the trained matching model to obtain the region features corresponding to the initial human body region; input the human body label regions into the preset initial matching model to obtain the human body region features corresponding to the human body label regions; input the background label regions into the initial matching model to obtain the background region features corresponding to the background label regions; and train the initial matching model based on the human body region features and the background region features to obtain a trained matching model.

[0137] As an optional embodiment of this application, the extraction module is further configured to calculate a first feature distance between the first human feature and the second human feature in the human body region features; calculate a second feature distance between the human body region features and the background region features; update the initial matching model according to the first feature distance and the second feature distance to obtain an updated matching model; and set the updated matching model as a trained matching model when the first feature distance and the second feature distance obtained by inputting the training sample image into the updated matching model meet the preset conditions.

[0138] As an optional embodiment of this application, the above-mentioned acquisition module is further configured to acquire scene human body sample images before acquiring scene human body features obtained by inputting a preset scene sample image into the matching model; input the scene human body sample image into the matching model to obtain reference human body features; and cluster the reference human body features to obtain scene human body features.

[0139] As an optional embodiment of this application, the above-mentioned acquisition module is further configured to associate the scene human features with the scene type corresponding to the scene human sample image and store them in a preset database; query the preset database to obtain the scene human features associated with the scene type of the target image.

[0140] As an optional embodiment of this application, the above-mentioned acquisition module is further used to count the number of images of the scene human sample images; if the number of images is less than a preset image number threshold, the reference human features are clustered to obtain scene human features; if the number of images is greater than or equal to the image number threshold, a preset number of target region features are selected from the reference human features, and the target region features are set as scene human features.

[0141] As an optional embodiment of this application, the above-mentioned filtering module is used to calculate the feature distance between the initial region feature and each scene human body feature for each initial region feature; count the number of scene human body features whose feature distance is less than a preset distance threshold, and set the ratio between the number of features and the number of scene human body features as the matching degree corresponding to the initial region feature; and set the initial human body region whose matching degree corresponding to the initial region feature is greater than the preset threshold as the target human body region.

[0142] This application also provides a computer device, such as... Figure 9 As shown, Figure 9 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application.

[0143] The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps in the human body detection method of any embodiment of this application.

[0144] Specifically, a computer device may include components such as a processor 901 with one or more processing cores, a memory 902 with one or more storage media, a power supply 903, and an input unit 904. Those skilled in the art will understand that... Figure 9 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:

[0145] The processor 901 is the control center of the computer device. It connects various parts of the computer device via various interfaces and lines, and performs various functions and processes data by running or executing software programs and / or modules stored in the memory 902, and by calling data stored in the memory 902, thereby providing overall monitoring of the computer device. Optionally, the processor 901 may include one or more processing cores; preferably, the processor 901 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 901.

[0146] The memory 902 can be used to store software programs and modules. The processor 901 executes various functional applications and data processing by running the software programs and modules stored in the memory 902. The memory 902 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 902 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 902 may also include a memory controller to provide the processor 901 with access to the memory 902.

[0147] The computer device also includes a power supply 903 that supplies power to the various components. Preferably, the power supply 903 can be logically connected to the processor 901 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 903 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0148] The computer device may also include an input unit 904, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0149] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 901 in the computer device loads the executable files corresponding to the processes of one or more computer programs into the memory 902 according to the following instructions, and the processor 901 runs the application program stored in the memory 902, thereby implementing the steps in any of the human body detection methods provided in the embodiments of this application.

[0150] Therefore, embodiments of this application provide a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk, etc. A computer program is stored on the computer-readable storage medium, and when executed by a processor, the computer program implements the steps of any of the human body detection methods provided in embodiments of this application.

[0151] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed descriptions of other embodiments above, which will not be repeated here.

[0152] In practice, each of the above units or structures can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units or structures, please refer to the previous method embodiments, which will not be repeated here.

[0153] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0154] The above provides a detailed description of a human body detection method provided by the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.

Claims

1. A method for human body detection, characterized in that, include: The acquired target image to be detected is input into a preset human detection model to obtain the initial human body region; The initial human body region is input into the trained matching model to obtain the initial region features corresponding to the initial human body region. Obtain scene human features obtained by inputting a pre-set scene human sample image into the matching model for processing; The scene human body sample images include human body region images in various scenes; Based on the initial region features and the scene human body features, a target human body region is selected from the initial human body region; The step of filtering out the target human body region from the initial human body region based on the initial region features and the scene human body features includes: For each initial region feature, calculate the feature distance between the initial region feature and each of the scene human body features; The number of scene human features whose feature distance is less than a preset distance threshold is counted, and the ratio between the number of features and the number of scene human features is set as the matching degree corresponding to the initial region features. The initial human body regions whose matching degree is greater than a preset threshold are set as the target human body regions.

2. The human body detection method according to claim 1, characterized in that, Before inputting the initial human body region into the trained matching model to obtain the region features corresponding to the initial human body region, the method includes: Obtain the human body label region and background label region in the training sample image; The human body label region is input into a preset initial matching model to obtain the human body region features corresponding to the human body label region. The background label region is input into the initial matching model to obtain the background region features corresponding to the background label region; The initial matching model is trained based on the human body region features and the background region features to obtain a trained matching model.

3. The human body detection method according to claim 2, characterized in that, The step of training the initial matching model based on the human body region features and the background region features to obtain a trained matching model includes: Calculate the first feature distance between the first human body feature and the second human body feature in the human body region features; Calculate the second feature distance between the human body region features and the background region features; The initial matching model is updated based on the first feature distance and the second feature distance to obtain the updated matching model; The updated matching model is set as the trained matching model only when the first feature distance and the second feature distance obtained by inputting the training sample image into the updated matching model meet the preset conditions.

4. The human body detection method according to claim 1, characterized in that, Before obtaining the scene human features obtained by inputting a pre-set scene sample image into the matching model, the method includes: Acquire human sample images of the scene; The human body sample image of the scene is input into the matching model to obtain reference human body features; Clustering is performed on the reference human body features to obtain scene human body features.

5. The human body detection method according to claim 4, characterized in that, After clustering the reference human body features to obtain scene human body features, the method includes: The human features in the scene are associated with the scene type corresponding to the human sample image in the scene and stored in a preset database; The step of obtaining scene human features by inputting a pre-set scene human sample image into the matching model for processing includes: Query a preset database to obtain scene human features associated with the scene type of the target image.

6. The human body detection method according to claim 4, characterized in that, Before clustering the reference human body features to obtain the scene human body features, the method includes: Count the number of human sample images in the scene; If the number of images is less than a preset image number threshold, then the step of clustering the reference human features to obtain scene human features is performed. If the number of images is greater than or equal to the number of images threshold, then a preset number of target region features are selected from the reference human body features, and the target region features are set as scene human body features.

7. A human body detection device, characterized in that, include: The detection module is used to input the acquired target image to be detected into a preset human detection model to obtain the initial human body region; An extraction module is used to input the initial human body region into a trained matching model to obtain the initial region features corresponding to the initial human body region. The acquisition module is used to acquire scene human features obtained by inputting a preset scene human sample image into the matching model for processing. The scene human body sample images include human body region images in various scenes; The filtering module is used to filter out target human regions from the initial human regions based on the initial region features and the scene human features; The step of filtering out the target human body region from the initial human body region based on the initial region features and the scene human body features includes: For each initial region feature, calculate the feature distance between the initial region feature and each of the scene human body features; The number of scene human features whose feature distance is less than a preset distance threshold is counted, and the ratio between the number of features and the number of scene human features is set as the matching degree corresponding to the initial region features. The initial human body regions whose matching degree is greater than a preset threshold are set as the target human body regions.

8. A computer device, characterized in that, The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, the processor executing the computer program to implement the steps of the human body detection method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the steps of the human body detection method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Image label acquisition method and device, storage medium and server

    CN110569380A