Portrait detection model training method and device, electronic device, and storage medium
By fusing planar images and fisheye images to generate fused fisheye images, a human image detection model is trained, which solves the problem of low accuracy in human image detection in fisheye images, improves detection accuracy and robustness, reduces annotation time, and enhances training efficiency.
Patent Information
- Application Number
- CN202311212666.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-18
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-09-18
AI Technical Summary
Existing human image detection models struggle to accurately detect human images in fisheye images, primarily due to the difficulty in labeling caused by fisheye image distortion, the inability of the bounding boxes to adapt to the angle of the human image, the long label acquisition time, and the insufficient amount of data, resulting in low detection accuracy.
By acquiring planar images and fisheye images, they are fused into a fused fisheye image. The fused fisheye image is then used to train a human detection model. The fused fisheye image contains more human targets, reducing annotation time, enriching training samples, and mitigating overfitting issues.
It improves the accuracy and robustness of the human image detection model in fisheye images, reduces annotation time, improves training efficiency, and enhances the model's generalization ability.
Smart Images

Figure CN117456298B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent recognition technology, and more specifically, to a training method for a human face detection model, a human face detection method, a training device for a human face detection model, an electronic device, and a non-volatile computer-readable storage medium. Background Technology
[0002] With the development of artificial intelligence, facial recognition is widely used in various fields. Early facial recognition required human assistance, which was inefficient. Current facial recognition methods can use deep learning to build facial recognition models, enabling automatic recognition and achieving higher detection efficiency.
[0003] However, human figures in fisheye images are subject to certain distortions. Currently, most deep learning methods for human figure recognition are trained on planar images, making it difficult to accurately detect human figures in fisheye images. Summary of the Invention
[0004] This application provides a training method for a human face detection model, a human face detection method, a training device for a human face detection model, an electronic device, and a non-volatile computer-readable storage medium.
[0005] The training method for the human image detection model according to the embodiments of this application includes: acquiring at least one first image and at least one second image, wherein the first image is a planar image containing a human image and the second image is a fisheye image containing a human image; acquiring a fused fisheye image based on the first image and the second image, wherein the fused fisheye image contains the human image in the first image and the second image; and training the human image detection model using the fused fisheye image.
[0006] The training apparatus for the human face detection model according to embodiments of this application includes: an acquisition module, a fusion module, and a training module. The acquisition module is used to acquire at least one first image and at least one second image, wherein the first image is a planar image containing a human face, and the second image is a fisheye image containing a human face. The fusion module is used to acquire a fused fisheye image based on the first image and the second image, wherein the fused fisheye image contains the human face from both the first image and the second image. The training module is used to train the human face detection model using the fused fisheye image.
[0007] The human face detection method according to the embodiments of this application includes: training a human face detection model using the training method of the human face detection model described in any embodiment of this application, and performing human face detection using the trained human face detection model.
[0008] The electronic device according to embodiments of this application includes a memory and a processor. The memory is used to store computer programs; the processor is used to execute the computer programs stored in the memory to implement the above-described training method for the human face detection model, and / or to implement the above-described human face detection method.
[0009] The non-volatile computer-readable storage medium of this application includes a computer program that, when executed by one or more processors, causes the one or more processors to implement the above-described training method for the human face detection model and / or to implement the above-described human face detection method.
[0010] The training method of the portrait detection model in this application uses a fused fisheye image obtained from a first image and a second image to train the portrait detection model. Since the fused fisheye image contains a richer number of portraits than a regular fisheye image, it can enrich the training samples for portrait detection, making the trained portrait detection model more robust, which can alleviate the overfitting problem of the portrait detection model to a certain extent and improve the portrait detection accuracy of the portrait detection model.
[0011] Additional aspects and advantages of embodiments of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of embodiments of this application. Attached Figure Description
[0012] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, wherein:
[0013] Figure 1 This is a flowchart illustrating the training method of a human face detection model according to certain embodiments of this application;
[0014] Figure 2 This is a schematic diagram of the structure of a training device for a human face detection model according to certain embodiments of this application;
[0015] Figure 3 This is a schematic diagram of a scenario for acquiring fused fisheye images according to certain embodiments of this application;
[0016] Figure 4 This is a schematic diagram of a scene in which the first image of certain embodiments of this application is mapped to a ring-shaped image;
[0017] Figure 5 This is another schematic diagram illustrating the acquisition of fused fisheye images in some embodiments of this application;
[0018] Figure 6 This is a schematic diagram illustrating a scenario for acquiring stitched images according to certain embodiments of this application;
[0019] Figure 7This is a schematic diagram of an irregularly shaped annotation box of a fused fisheye image according to certain embodiments of this application;
[0020] Figure 8 This is a schematic diagram of a scenario in which a first portrait annotation frame is mapped to a second portrait annotation frame in certain embodiments of this application;
[0021] Figure 9 This is a schematic diagram of a multi-channel rotating attention module of a human face detection network according to certain embodiments of this application;
[0022] Figure 10 This is a schematic diagram of the structure of an electronic device according to certain embodiments of this application;
[0023] Figure 11 This is a schematic diagram illustrating the connection state of a computer-readable storage medium and a processor according to certain embodiments of this application. Detailed Implementation
[0024] The embodiments of this application are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the embodiments of this application, and should not be construed as limiting the embodiments of this application.
[0025] Current face detection models are typically trained on planar images containing people, making it difficult to accurately detect faces in fisheye images, which contain distortions. While training face detection models using fisheye images can improve their accuracy, the use of fisheye images for training presents challenges such as annotation difficulties, difficulty in adapting bounding boxes to the face angle, and long label acquisition times. This makes it difficult to easily obtain a large number of labeled fisheye images to build a dataset for training face detection models. With insufficient data, it is difficult to further improve the accuracy of face detection models trained on such models.
[0026] Please see Figure 1 This application provides a method for training a human face detection model, enabling the trained model to detect human faces in fisheye images more accurately. The training method for the human face detection model includes:
[0027] S01: Obtain at least one first image and at least one second image, wherein the first image is a planar image containing a human figure and the second image is a fisheye image containing a human figure;
[0028] S02: Obtain a fused fisheye image based on the first image and the second image, the fused fisheye image containing the human image from the first image and the second image; and
[0029] S03: Train a human image detection model using fused fisheye images.
[0030] Fisheye images can include wide-angle images with a field of view greater than 100°, fisheye lens images, panoramic images, and other images with a large field of view. The human figures in these images often have a certain degree of barrel distortion, and it is difficult to accurately detect the distorted human figures using human figure detection models.
[0031] A fused fisheye image is an image obtained by fusing a first image and a second image, simulating the distortion of a fisheye image. The fused fisheye image, while containing a human figure, also exhibits barrel distortion similar to a regular fisheye image. Based on this, fused fisheye images can be used to simulate regular fisheye images for training human detection models.
[0032] On the one hand, the fusion of fisheye images includes the human figures in the first and second images, which means it contains more human figures than the second image. Compared with training the human figure detection model using fisheye images, this is more conducive to enriching the training samples for human figure detection. The trained human figure detection model has better robustness and can alleviate the overfitting problem of the human figure detection model to a certain extent.
[0033] On the other hand, compared with planar images, the annotation of human figures in fisheye images is more complex and time-consuming. In the fused fisheye image obtained by using the first and second images, the annotation of some human figures comes from the second image and the annotation of some human figures comes from the first image. This makes the average annotation time of each human figure in the fused fisheye image shorter than the human figure annotation time in the regular fisheye image, so as to improve the efficiency of model training.
[0034] In summary, the training method for the human image detection model in this application utilizes a fused fisheye image obtained from the first image and the second image to train the human image detection model. Since the fused fisheye image contains a richer number of human images than a regular fisheye image, it can enrich the training samples for human image detection, making the trained human image detection model more robust, which can alleviate the overfitting problem of the human image detection model to a certain extent and improve the human image detection accuracy of the human image detection model.
[0035] Please see Figure 2 This application also provides a training device 10 for a human face detection model. The training device 10 can execute the steps in the above-described training method S01, S02, and S03 for the human face detection model, so that the trained human face detection model can detect human faces in fisheye images more accurately.
[0036] The training device 10 for the human image detection model includes an acquisition module 11, a fusion module 12, and a training module 13. The acquisition module 11 executes the steps in method S01, the fusion module 12 executes the steps in method S02, and the training module 13 executes the steps in method S03. Specifically, the acquisition module 11 acquires at least one first image and at least one second image, where the first image is a planar image containing a human image, and the second image is a fisheye image containing a human image; the fusion module 12 acquires a fused fisheye image based on the first and second images, where the fused fisheye image contains the human image from both the first and second images; and the training module 13 trains the human image detection model using the fused fisheye image.
[0037] The training method of the human image detection model of this application will be further explained below with reference to the accompanying drawings.
[0038] In conventional fisheye images, the center typically exhibits relatively large imaging distortion, while the distortion is relatively small at the periphery. The degree of distortion of a human subject at the periphery of a fisheye image is similar to that in a planar image. Therefore, when simulating a fisheye image using a first and second image to obtain a fused fisheye image, the human subject from the first image can be placed at the periphery of the fused fisheye image, and the human subject from the second image can be placed near the center. This allows the fused fisheye image to better simulate the distortion of a conventional fisheye image and include more human subjects.
[0039] Based on this, in some embodiments, step S02 of the training method for the human image detection model includes: obtaining a fused fisheye image based on the first image and the second image, the fused fisheye image containing the human image from the first image and the second image, including:
[0040] S021: Obtain a preset fisheye region, which includes an annular region and a circular region, with the circular region being adjacent to the inner periphery of the annular region;
[0041] S022: Map the first image onto the annular region to obtain an annular image;
[0042] S023: Map the second image onto the circular region to obtain a circular image; and
[0043] S024: Obtain a fused fisheye image based on the annular and circular images.
[0044] Please combine Figure 2In some embodiments, the fusion module 12 can also be used to perform the methods in S021, S022, S023, and S024. That is, the fusion module 12 can also be used to obtain a preset fisheye region, which includes an annular region and a circular region, with the circular region adjacent to the inner periphery of the annular region; map a first image onto the annular region to obtain an annular image; map a second image onto the circular region to obtain a circular image; and obtain a fused fisheye image based on the annular image and the circular image.
[0045] Please see Figure 3 The periphery of the fisheye region is preset to be a ring-shaped area. In the fused fisheye image, this ring-shaped area is filled by a ring-shaped image mapped from the first image. The imaging distortion of this ring-shaped image closely resembles the imaging distortion of the outer ring of a conventional fisheye image, thus using a curved planar image as the periphery of the fused fisheye image to simulate a conventional fisheye image. The area near the center of the fisheye region is preset to be a circular region. In the fused fisheye image, this circular region is filled by a circular image mapped from the second image, so that the area near the center of the fused fisheye image exhibits the imaging distortion of a conventional fisheye image. In this way, the overall imaging distortion of the fused fisheye image is made to approximate that of a conventional fisheye image.
[0046] In this design, the circular region is attached to the inner perimeter of the annular region. Consequently, the circular image is inscribed within the inner perimeter of the annular image to form a fused fisheye image. Thus, in the fused fisheye image, there are no unfilled pixel regions between the annular and circular images, reducing the invalid training regions in the fused fisheye image.
[0047] Mapping the first image to the circular region means mapping the pixels of the first image to the circular region. The number of first images mapped can be 1, 2, 3, 4, 5, or more, and so on. Similarly, mapping the second image to the circular region means mapping the pixels of the second image to the circular region. The number of second images mapped can be 1, 2, 3, 4, 5, or more, and so on.
[0048] In one embodiment, the extent of the annular region and the extent of the circular region are determined by the size of the fused fisheye image. Assuming the diameter of the fused fisheye image is 2R, and the minimum bounding rectangle of the fused fisheye image is a rectangle with a side length of 2R, then correspondingly, the preset fisheye region can be set as a rectangular region with a side length of 2R, so that the preset fisheye region can include the circular region with a diameter of 2R.
[0049] In some implementations, step S022: mapping the first image to the annular region to obtain an annular image includes:
[0050] S0221: Set the first planar image, the first planar image is rectangular;
[0051] S0222: Multiple first images are mosaicked onto a first planar image to obtain a second planar image, the second planar image including a first portrait bounding box; and
[0052] S0223: Perform coordinate transformation on the pixels of the second planar image according to the coordinate mapping formula to obtain a ring image, the ring image including the second portrait annotation box.
[0053] Please combine Figure 2 In some embodiments, the fusion module 12 can also be used to perform the methods in S0221, S0222, and S0223. That is, the fusion module 12 can also be used to set a first planar image; to mosaic multiple first images onto the first planar image to obtain a second planar image, the second planar image including a first portrait bounding box; and to perform coordinate transformation on the pixels of the second planar image according to a coordinate mapping formula to obtain a ring image, the ring image including a second portrait bounding box.
[0054] Please see Figure 4 To map the first image onto the annular region, a rectangular first planar image can be set according to the size of the annular region to obtain a rectangular second planar image. Then, the second planar image is bent into an annular shape to obtain the annular image. Assuming the outer diameter of the annular region is 2R and the diameter of the circular region is R, the width of the annular region is R / 2, and the circumference of the outer ring of the annular region is 2πR. The corresponding width of the first planar image is 2πR, and its height is R / 2.
[0055] In one embodiment, when filling a rectangular area with a width of 2πR and a height of R / 2 using multiple first images, each first image can be adjusted to a height of R / 2 by scaling, cropping, or other methods. Then, one of the first images is filled to the leftmost edge of the unfilled area within the rectangular region. The next first image is then filled to the leftmost edge of the currently unfilled area within the rectangular region, and this process is repeated until the entire rectangular region is filled. If the width of the last first image to be filled is greater than the width of the currently unfilled area, the width of the last first image to be filled can be adaptively cropped to make it the same as the width of the currently unfilled area, thus preventing the last first image to be filled from exceeding the boundary of the rectangular region after filling.
[0056] After the second planar image is obtained, coordinate conversion can be performed on the pixel coordinates of the second planar image according to a preset coordinate mapping formula, so as to obtain coordinates of pixels of the second planar image corresponding to the annular region, thereby mapping the pixels of the second planar image to the annular region to obtain an annular image. Assuming that a coordinate of a pixel point Pa in the rectangular filled image is (Xa, Ya), and a coordinate of a pixel point Pb corresponding to the pixel point Pa after being mapped to the annular image is (Xb, Yb), the coordinate (Xb, Yb) of the pixel point Pb can be calculated according to the following Formula 1 and Formula 2.
[0057] Formula 1:
[0058] Formula 2:
[0059] Formula 3:
[0060] Formula 4: r = Ya;
[0061] Herein, θ represents a mapping polar angle, r represents a mapping polar radius, and R represents a radius of the fused fisheye image. As such, calculation of mapping the first image to the annular image is relatively simple, and mapping efficiency is high.
[0062] In the foregoing embodiments, the mapping manner of the first image is introduced with an example in which an outer ring diameter of the annular region is 2R and a diameter of the circular region is R. In other embodiments, a size ratio between the annular region and the circular region in the preset fisheye region may be set as required.
[0063] Refer to Figure 5 , in still another embodiment, assuming that an outer ring diameter of the annular region is 3R / 2 and a diameter of the circular region is R, a ring width of the annular region is R / 4, and an outer ring perimeter of the annular region is 3πR / 2. Correspondingly, when the annular image is obtained, the plurality of first images may be filled into a rectangular region with a width of 3πR / 2 and a height of R / 4 to obtain a rectangular filled image, and then the rectangular filled image is bent into an annular image to be filled into the annular region.
[0064] By analogy, assuming that a width of the constructed rectangular region is w and a height of the constructed rectangular region is h, for an annular region with an outer ring diameter of 2μ2R and an inner ring diameter of 2μ1R, a rectangular region with a width w = μ2-μ1 and a height h = 2πμ2R may be constructed, such that after an image is filled into the rectangular region, the image may be mapped into an annular image with an outer ring diameter of 2μ2R and an inner ring diameter of 2μ1R according to the foregoing Formula 1 and Formula 2. Herein, 0 < μ1 < μ2 < R. As such, for an annular region with any ring width whose outer ring diameter does not exceed 2R, a matching rectangular region can be constructed.
[0065] In some implementations, step S023: mapping the second image onto a circular region to obtain a circular image includes:
[0066] S0231: Preprocess the second image to obtain a preprocessed image. The size of the preprocessed image is the same as the size of the circular region. The preprocessing includes scaling and cropping.
[0067] S0232: Mosaic the preprocessed image to a circular region to obtain a circular image.
[0068] Please combine Figure 2 In some embodiments, the fusion module 12 can also be used to perform the methods in S0231 and S0232. That is, the fusion module 12 can also be used to preprocess the second image to obtain a preprocessed image, the size of which is the same as the size of the circular region, the preprocessing including scaling and cropping; and to embed the preprocessed image into the circular region to obtain a circular image.
[0069] Please see Figure 3 If the size of the second image is the same as the size of the circular region, the second image can be directly mosaicked into the circular region to obtain a circular image. If the size of the second image is different from the size of the circular region, a preprocessed image of the same size as the circular region can be obtained by preprocessing the second image, and then the preprocessed image can be mosaicked into the circular region to obtain a circular image. Preprocessing methods include scaling, cropping, stitching, rotation, etc., which are not limited here. Furthermore, if the size of the second image is the same as the size of the circular region, the angle of the second image can also be adjusted by rotating it in the preprocessing step, and then the angle-adjusted second image can be mosaicked into the circular region to obtain a circular image.
[0070] Please see Figure 3 In one embodiment, only one second image can be mapped to a circular region to obtain a circular image. This reduces the number of portraits that need to be annotated in the fisheye image, improving the efficiency of training the portrait detection model. For example, if the effective region (the area containing pixels) of the second image is circular, the pixels of the effective region can be adjusted to the same extent as the circular region through scaling, cropping, etc., to fill the circular region and form a circular image. If the effective region of the second image is not circular, a circular region can be cropped from the effective region of the second image, and then the pixels of the cropped circular region can be filled into the circular region, or scaled and then filled into the circular region to form a circular image.
[0071] Please see Figure 6In another embodiment, multiple second images can be stitched together into a single preprocessed image, which is then mapped onto a circular region to obtain a circular image. This results in a preprocessed image containing more human figures, increasing the number of human figures with fisheye-like distortions in the fused fisheye image and enriching the training samples for human figure detection. For example, if a second image contains only a human figure in its upper half, the upper half of this second image can be cropped; if another second image contains only a human figure in its lower half, the lower half of this second image can be cropped; then the cropped upper and lower halves of the image can be stitched together to obtain a preprocessed image with more human figures.
[0072] Please see Figure 3 In some implementations, the ratio of the diameter of the circular region to the outer diameter of the annular region ranges from [0.50, 0.75]. Assuming the diameter of the circular region is R1 and the outer diameter of the annular region is R2, then the range of R1 / R2 is [0.50, 0.75]. For example, the value of R1 / R2 can be 0.50, 0.55, 0.60, 0.65, 0.70, 0.75, etc., which will not be listed here. The smaller the ratio of R1 / R2, the smaller the proportion of the circular image and the larger the proportion of the annular image in the fused fisheye image. The annular image is formed by stitching together multiple first images and then mapping them. The annular image contains more human figures than the circular image. When the proportion of the annular image in the fused fisheye image is larger, the proportion of human figures in the fused fisheye image is larger, making it easier for the human detection model to detect the human figures in the fused fisheye image. The larger the R1 / R2 ratio, the greater the proportion of circular images and the smaller the proportion of annular images in the fused fisheye image. When the proportion of fisheye images in the fused fisheye image is greater, the proportion of fisheye distortion in the fused fisheye image is also greater, making it easier to guide the human image detection model to detect human images in fisheye distortion images.
[0073] Please see Figure 7 In some implementations, the human figures in both the first and second images are labeled with bounding boxes to facilitate subsequent training and validation of the human figure detection model. For example, a bounding box is a frame that includes the head and shoulders of the human figure. A bounding box is a frame with a horizontal width and a vertical height. The calculation method for bounding box annotation is relatively mature, the annotation process is relatively convenient, and the IoU (Intersection over Union) calculation technology for bounding boxes is relatively mature, making it easy to calculate quickly and accurately, thus improving the efficiency of human figure detection model training. The area between the head and shoulders of the human figure encompasses most of the features of the human figure. On the one hand, the head and shoulders can basically be captured by the fisheye lens, and on the other hand, the shape of the head and shoulders in the fisheye image is relatively consistent with that in a planar image.
[0074] Furthermore, the area between the head and shoulders is close to that of a rectangle. When using a positive frame to mark the head and shoulders, the head and shoulders of the portrait will not be too tilted relative to the positive frame, thus avoiding the introduction of too much background information within the positive frame.
[0075] When the second image is mapped to a circular image, if a cropping method is used, the shape and size of the portrait in the original second image are the same as those in the mapped circular image. In this case, the shape and size of the frame corresponding to the portrait in the circular image are also the same as those in the second image. If a scaling method is used, the shape of the portrait in the original second image is the same as that in the mapped circular image, but the size is scaled accordingly. In this case, the shape and size of the frame corresponding to the portrait in the circular image are also the same as those in the second image.
[0076] Please combine Figure 7 and Figure 8 Suppose that a person in the first image is labeled with a first portrait bounding box, and this first portrait bounding box is a rectangular frame. When the first image is mapped to a ring-shaped image, the first portrait bounding box will be mapped to a non-rectangular, irregularly shaped bounding box. For example, the coordinates of the four corner points of a certain first portrait bounding box in the first image are (x, y ... tl ,y tl ), (x tr ,y tr ), (x bl ,y bl ), (x br ,y br According to equations one and two above, the coordinates of the four corner points mapped to the annular region are (x′) and (x′). tl ,y′ tl ), (x′ tr ,y′ tr ), (x′ bl ,y′ bl ), (x′ br ,y′ br The irregularly shaped bounding boxes are then enclosed within the circular area. Compared to the regular bounding boxes, the annotation process for irregularly shaped bounding boxes is more complex, and the rotation angle of the irregularly shaped bounding boxes relative to the regular bounding boxes at different positions within the entire annular area is unstable. There may be irregularly shaped bounding boxes at multiple angles, and the IoU values corresponding to the irregularly shaped bounding boxes at different positions may vary significantly during subsequent IoU calculations. This may require more rounds of training and consume more training time.
[0077] Based on this, in the training method of the human face detection model, step S0223: performing coordinate transformation on the pixels of the second plane image according to the coordinate mapping formula to obtain a ring image, including:
[0078] S02231: Obtain the coordinates of the first corner point, which represents the corner point of the first portrait annotation box;
[0079] S02232: Perform coordinate transformation on the coordinates of the first corner point according to the coordinate mapping formula to obtain the coordinates of the second corner point;
[0080] S02233: Obtain the irregular shape annotation box based on the coordinates of the second corner point; and
[0081] S02234: Obtain the second portrait annotation frame based on the smallest bounding rectangle of the irregular annotation frame.
[0082] Please combine Figure 2 In some embodiments, the fusion module 12 can also be used to execute the methods in S02231, S02232, S02233, and S02234. That is, the fusion module 12 can also be used to obtain the coordinates of a first corner point, which represents the corner point of a first portrait annotation box; perform coordinate transformation on the coordinates of the first corner point according to the coordinate mapping formula to obtain the coordinates of a second corner point; obtain the irregular annotation box according to the coordinates of the second corner point; and obtain the second portrait annotation box according to the minimum bounding rectangle of the irregular annotation box.
[0083] Please see Figure 7 and Figure 8 After the first image is mosaicked onto the first planar image to obtain the second planar image, the portrait bounding box in the first image is also mosaicked into the second planar image, becoming the first portrait bounding box in the second planar image. When the second planar image is curved into a curved image, the first portrait bounding box is also curved accordingly, forming an irregular bounding box. Calculating the intersection-union ratio (IUU) of irregular bounding boxes is more difficult and requires more computational resources. Furthermore, irregular bounding boxes tend to introduce more background information, resulting in a relative reduction in the portrait information within the irregular bounding box. In contrast, the IUU calculation method for regular bounding boxes is more mature and does not easily introduce background information. The minimum bounding rectangle of the irregular bounding box is a regular bounding box, and the area within the minimum bounding rectangle of the irregular bounding box can still contain the head and shoulders of the portrait. Therefore, the minimum bounding rectangle of the irregular bounding box can be used as the second bounding box for labeling the portrait in the annular image.
[0084] For example, the coordinates of the first corner points corresponding to the four corner points of the first portrait annotation frame are (x... tl ,y tl ), (x tr ,y tr ), (x bl ,y bl ), (x br ,y br According to formulas one and two of the coordinate mapping formulas mentioned above, the coordinates of the first corner point can be converted to the coordinates of the second corner point. The coordinates of the four corner points of the irregularly shaped annotation box are (x, y, y) and (x, y, y). t′ l ,y t ′ l ), (x t ′ r ,y t ′ r ), (x′ bl ,y′ bl ), (x′ br ,y′ br Let the top-left corner of the smallest bounding rectangle of the irregular annotation box be (x). min ,y min The lower right corner of the smallest bounding rectangle is (x max ,y max If x min y min 、(x max y max The results can be obtained from the following formula five.
[0085] Equation 5: x min =min(x′) tl ,x′ tr ,x′ bl ,x′ br );y min =min(y′) tl ,y′ tr ,y′ bl ,y′ br );
[0086] x max =max(x′) tl ,x′ tr ,x′ bl ,x′ br );y max =max(y′) tl ,y′ tr ,y′ bl ,y′ br ).
[0087] The top-left corner of the smallest bounding rectangle of the irregular shape is obtained as (x min ,y min ) and the lower right corner is marked (x max ,y max After that, according to the upper left subscript (x) min ,y min ) and the subscript (x) max ,y maxThe generated rectangle is the smallest bounding rectangle of the irregular annotation box, which is also the second portrait annotation box.
[0088] In one embodiment, the coordinates of the minimum bounding rectangle [(x min ,y min ),(x max ,y max The label output is a planar image.
[0089] In some implementations, the human image detection model includes a pre-built human image detection network, which includes, but is not limited to, convolutional neural networks such as R-CNN, YOLO, and Detr. In the training method of the human image detection model, step S03: training the human image detection model using fused fisheye images includes:
[0090] S031: In one round of training, the fused fisheye image is input into the human face detection network to obtain the training feature map, and the training loss is obtained based on the training feature map. The updated weight value is calculated based on the training loss. The updated weight value is the weight parameter of the convolution kernel in the human face detection network.
[0091] S032: If the number of training epochs is less than the preset number of epochs, update the preset weight values of the portrait detection network according to the updated weight values to obtain the updated portrait detection network, and perform a new round of training using the new fused fisheye image and the updated portrait detection network; and
[0092] S033: If the number of training rounds is greater than or equal to the preset number of rounds, the latest updated weight value is used as the target weight value of the human face detection network to output the trained human face detection network.
[0093] Please combine Figure 2 In some embodiments, the training module 13 can also be used to execute the methods in S031, S032, and S033. That is, the training module 13 can also be used in one round of training to input the fused fisheye image into the portrait detection network to obtain a training feature map, obtain a training loss based on the training feature map, and calculate an updated weight value based on the training loss; if the number of training rounds is less than a preset number of rounds, update the preset weight value of the portrait detection network based on the updated weight value to obtain an updated portrait detection network, and perform a new round of training using the new fused fisheye image and the updated portrait detection network; and if the number of training rounds is greater than or equal to the preset number of rounds, use the latest updated weight value as the target weight value of the portrait detection network to output the trained portrait detection network.
[0094] The human face detection network initially has preset weight values. During the first round of training, a fused fisheye image is input into the network, and a training feature map is obtained based on the preset weight values. The training loss is then calculated based on the training feature map. New weight values are calculated using backpropagation based on the training loss, i.e., updated weight values are calculated. After updating the preset weight values of the human face detection network with the updated weight values, one round of training is completed.
[0095] In subsequent training epochs, new fused fisheye images are continuously input into the portrait detection network to obtain new training feature maps based on the latest updated weight values. New training losses are then calculated based on these feature maps, and updated weight values are obtained for the current epoch based on the newly calculated training loss. If the number of training epochs is less than a preset number, after updating the preset weight values using the updated weight values, new fused fisheye images are input into the updated portrait detection network for a new round of training. If the number of training epochs is greater than or equal to the preset number, the latest updated weight values obtained in the latest training epoch are used as the target weight values to update the portrait detection network, and the updated portrait detection network is output as the trained portrait detection network.
[0096] Please see Figure 9 In one embodiment, the human face detection network can use YOLOv5s as the backbone network, replacing all convolutional layers in the YOLOv5s network except for the attention layers with multi-channel rotational attention modules. The multi-channel rotational attention module consists of depthwise separable convolutional layers, first-order convolutional layers, full-scale max-pooling layers, and fully connected layers. Specifically, the depthwise separable convolutional layers have a 3x3 kernel size, 4 groups, and a stride of 1; the first-order convolutional layers have a 1x1 kernel size, a stride of 1, and the number of output channels is 4 times the number of input channels. Thus, the backbone network increases the number of channels using depthwise separable convolutional layers and first-order convolutional layers. Increasing the number of channels facilitates the human face detection network in learning human face features from different angles, enabling it to learn features of rotated human faces. Furthermore, based on the characteristics of depthwise separable convolutional layers, the number of parameters required for convolution calculation can be reduced while increasing the number of channels, avoiding the introduction of excessive additional parameters due to the increased number of channels.
[0097] Based on the YOLOv5s network described above, in the training method of the portrait detection model, step S031, which involves inputting the fused fisheye image into the portrait detection network to obtain training feature maps, includes:
[0098] S0311: Input the fused fisheye image into the attention layer to obtain the attention image.
[0099] S0312: Focus on the input image depth-separable convolutional layer to obtain the first convolutional image;
[0100] S0313: Input the first convolutional image into a first-order convolutional layer to obtain the second convolutional image. The number of channels in the second convolutional image is greater than the number of channels in the image of interest.
[0101] S0314: Input the second convolutional image into the global max pooling layer to obtain the first pooling image;
[0102] S0315: Input the first pooling image into the fully connected layer to obtain multiple candidate features; and
[0103] S0316: Obtain the training feature map based on the candidate feature with the largest attention weight among multiple candidate features.
[0104] Please combine Figure 2 In some embodiments, the training module 13 can also be used to execute the methods in S0311, S0312, S0313, S0314, S0315, and S0316. That is, the training module 13 can also be used to input the fused fisheye image into the attention layer to obtain the attention image, input the attention image into the depthwise separable convolutional layer to obtain the first convolutional image; input the first convolutional image into a first-order convolutional layer to obtain the second convolutional image, wherein the number of channels of the second convolutional image is greater than the number of channels of the attention image; input the second convolutional image into a global max pooling layer to obtain the first pooling image; input the first pooling image into a fully connected layer to obtain multiple candidate features; and obtain a training feature map based on the candidate feature with the largest attention weight among the multiple candidate features.
[0105] In the steps S0311, S0312, S0313, S0314, S0315, and S0316 above, the concept of "image" in the interest image, first convolutional image, second convolutional image, and first pooling image refers to the pixel processing results of the convolutional and pooling layers. For example, "first convolutional image" refers to the pixel processing result output after the depth-separable convolutional layer is processed, and does not mean an actual existing image.
[0106] The focus layer of the YOLOv5s network is used to downsample the fused fisheye image to output a focus image, thereby reducing the parameters and computational cost of the human face detection model, while increasing the receptive field. This improves the computational efficiency and speed of the human face detection model, as well as its accuracy and recall.
[0107] The depthwise separable convolutional layer has a 3x3 kernel size, 4 groups, and a stride of 1, which expands the number of channels in the input image of interest by a factor of 4, resulting in 4 groups of first convolutional images. Then, a first-order convolutional layer with a 1x1 kernel size and a stride of 1 outputs a second convolutional image based on the 4 groups of first convolutional images. This integrates the 4 groups of first images into a single second convolutional image with 4 times the number of channels as the image of interest, thus enhancing the human image detection network's ability to learn rotation features. In this embodiment, the depthwise separable convolutional layer has 4 groups, ensuring that the number of channels in the acquired second convolutional image is 4 times the number of channels as the image of interest. In other embodiments, the number of groups in the depthwise separable convolutional layer can be any integer greater than 1, ensuring that the acquired second convolutional image has more channels than the image of interest, thereby enhancing the human image detection network's ability to learn rotation features.
[0108] The global max pooling layer outputs a first pooled image from the input second convolutional image. Compared to average pooling, global max pooling is more effective at preserving human features. The fully connected layer outputs multiple candidate features from the input first pooled image. The candidate feature with the highest attention weight participates in the subsequent calculations of the neck and head modules in the human image detection model. The neck and head modules output training feature maps based on the candidate feature with the highest weight. The attention weights can be configured based on rotated human features. By selecting the candidate feature with the highest attention weight from multiple candidate features for subsequent calculations, the number of channels expanded in the depthwise separable convolutional layers and first-order convolutional layers can be compressed, and more rotational features can be preserved, making the preserved candidate features rotationally invariant.
[0109] In some implementations, step S031, which involves obtaining the training loss based on the training feature map and calculating the updated weight value based on the training loss, is achieved by calculating the updated weight value using a backpropagation algorithm, so as to update the preset weights of the human face detection network using the updated weight value.
[0110] In one embodiment, the training loss includes the target loss, the class loss, and the bounding box loss. The target loss and the class loss can be calculated using the BCE (Binary Cross Entropy) loss function. For example, let the target loss be L. obj The category loss is L cls Detection frame loss L box Target loss L obj and category loss L cls It can be calculated using the following formulas three and four respectively.
[0111] Equation 3:
[0112] Equation 4:
[0113] In equations three and four, y obj This indicates whether the human image target label exists; if the human image target exists, then y obj The value is 1; if the human figure does not exist, then y... obj The value is 0. This characterizes the probability of a human figure being predicted by the human detection network. cls The category label represents the image of a person. cls The value is 1 if the category is not human, and 0 if the category is not human. The probability that the category predicted by the human face detection network is human.
[0114] Detection frame loss L box The loss function GIoU (Generalized Intersection over Union) can be used for calculation, which can be obtained through the following formula five.
[0115] Equation 5:
[0116] In Equation 5, I represents the intersection area of the predicted bounding box and the label bounding box, U represents the union area of the predicted bounding box and the label bounding box, and A represents the area of the smallest bounding rectangle of the predicted bounding box and the label bounding box. Here, the predicted bounding box is the image annotation box covering the head and shoulders of the predicted human figure in the training feature map, and the label bounding box is the image annotation box fused from the fisheye image, including a second image annotation box for the annular image portion and a third image annotation box for the circular image portion.
[0117] Assuming the training loss is L, the training loss L can be calculated using the following formula (6).
[0118] Equation 6: L = λ obj ·L obj +λ cls ·L cls +λ box ·L box .
[0119] In equation six, λ obj Characterizing L obj The weight, λ cls Characterizing L cls The weight, λ box Characterizing L box The weights are then calculated. After calculating the training loss L, the updated weight values can be calculated using the backpropagation algorithm.
[0120] In some implementations, when the training rounds reach a preset number of rounds, the latest updated weight values are saved as target weight values to output the trained portrait detection network. After obtaining the trained portrait detection network, the training method for the portrait detection model further includes step S04: testing the trained portrait detection model.
[0121] Step S04: Testing the trained human image detection model, including:
[0122] S041: Obtain at least one planar verification image and at least one fisheye verification image as a comprehensive verification set;
[0123] S042: Input the images from the comprehensive validation set into the trained portrait detection model to obtain test feature maps;
[0124] S043: Non-maximum suppression and decoding frame processing are applied to the test feature map to obtain the detection results; and
[0125] S044: Obtain target parameters based on the detection results. Target parameters include at least one of the following: detection accuracy, recall rate, and confidence level.
[0126] Please combine Figure 2 In some embodiments, the training device 10 for the human face detection model further includes a testing module 14, which can be used to perform the methods in steps S041, S042, S043, and S044 described above. That is, the testing module 14 can be used to acquire at least one planar verification image and at least one fisheye verification image as a comprehensive verification set; input the images in the comprehensive verification set into the trained human face detection model to obtain test feature maps; perform non-maximum suppression and decoding box processing on the test feature maps to obtain detection results; and obtain target parameters based on the detection results, wherein the target parameters include at least one of the detection metrics precision, recall, and confidence.
[0127] In one embodiment, the first and second images acquired in step S01 are divided into a training set and a validation set according to a preset ratio. The images in the training set are used to train the human image detection model, and the images in the validation set are used to test the trained human image detection model. For example, an equal number of planar images and fisheye images are taken from the dataset as the first and second images, respectively. Multiple first images are divided into planar images at a 9:1 ratio to obtain a planar training set and a planar validation set, with the planar validation set containing at least one planar validation image. Similarly, multiple first images are divided into fisheye images at a 9:1 ratio to obtain a fisheye training set and a fisheye validation set, with the fisheye validation set containing at least one fisheye validation image. The planar training set and the fisheye training set are then integrated into a comprehensive training set, and the planar validation set and the fisheye validation set are integrated into a comprehensive validation set. The comprehensive training set and the comprehensive validation set are used to train and validate the human image detection model, respectively.
[0128] After inputting images from the comprehensive validation set into the trained portrait detection model, the model outputs corresponding test feature maps. Detection results are obtained by applying non-maximum suppression and bounding box processing to these test feature maps. Target parameters such as precision, recall, and confidence are then calculated based on these results, determining the performance of the portrait detection model. The methods used for obtaining detection results through non-maximum suppression and bounding box processing, as well as the methods for calculating target parameters such as precision, recall, and confidence, are relatively mature computational methods in this field and will not be further explained here.
[0129] In one embodiment, when testing a trained portrait detection model, video images can be extracted frame by frame from a video, and these video images can be input frame by frame into the trained portrait detection model to obtain a test feature map. Detection results are then obtained based on the test feature map, and confidence scores are calculated based on the detection results. If the confidence score is greater than 0.5, the detection bounding boxes of the test feature map are output; these detection bounding boxes are annotation boxes used to label the portrait.
[0130] This application also provides a human face detection method, which includes:
[0131] S08: Training a human face detection model using human face training methods; and
[0132] S09: Use a trained human detection model to perform human detection.
[0133] The portrait training method in step S08 can be any of the portrait training methods described in the above embodiments.
[0134] Step S09: Perform face detection using the trained face detection model, including:
[0135] S091: Obtain the image to be detected, which may include a planar image or a fisheye image;
[0136] S092: Input the image to be detected into the trained portrait detection model; and
[0137] S093: Obtain the detection bounding box output by the human image detection model. The detection bounding box is used to indicate the human image in the image to be detected.
[0138] When training the portrait detection model, the fused fisheye image used is obtained by mapping planar images and fisheye images. The fused fisheye image contains portrait features from both the planar image and the fisheye image, so that the trained portrait detection model can be applied to portrait detection of both planar and fisheye images. In this way, regardless of whether the image to be detected input to the portrait detection model is a planar image or a fisheye image, the portrait detection model can output a relatively accurate detection box to indicate the portrait in the image.
[0139] Please see Figure 10 This application also provides an electronic device 100, which includes a memory 20 and a processor 40. The memory 20 stores a computer program, and the processor 40 can execute the computer program stored in the memory 20 to implement the steps of the face detection model training method in the above embodiments, such as executing the face detection model training method in steps S01, S02, S03, and S04 of the above embodiments. The processor 40 can also execute the computer program stored in the memory 20 to implement the steps of the face detection method in the above embodiments, such as executing the face detection method in steps S08 and S9 of the above embodiments. The electronic device 100 includes, but is not limited to, mobile phones, cameras, camcorders, laptops, tablets, smartwatches, monitoring equipment, drones, unmanned vehicles, and smart home devices.
[0140] Please see Figure 11 This application also provides a non-volatile computer-readable storage medium 400 containing a computer program 401. When the computer program 401 is executed by one or more processors 40, the one or more processors 40 are caused to perform a training method for a human face detection model according to any of the above embodiments, such as performing the training method for a human face detection model in steps 01, 02, 03, and 04 of the above embodiments; the one or more processors 40 may also be caused to perform a human face detection method according to any of the above embodiments, such as performing the human face detection method in steps 08 and 09 of the above embodiments.
[0141] In the description of this specification, the references to terms such as "some embodiments," "in one example," "exemplarily," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0142] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the function involved, as will be understood by those skilled in the art to which embodiments of this application pertain.
[0143] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A training method for a human face detection model, characterized in that, include: Acquire at least one first image and at least one second image, wherein the first image is a planar image containing a human figure and the second image is a fisheye image containing a human figure; A fused fisheye image is obtained based on the first image and the second image, wherein the fused fisheye image contains the human figures in the first image and the second image; and The fused fisheye images were used to train a human image detection model; The step of obtaining a fused fisheye image based on the first image and the second image includes: Obtain a preset fisheye region, which includes an annular region and a circular region, wherein the circular region is adjacent to the inner periphery of the annular region; The first image is mapped onto the annular region to obtain an annular image; Map the second image onto the circular region to obtain a circular image; and The fused fisheye image is obtained based on the annular image and the circular image.
2. The training method for the human face detection model according to claim 1, characterized in that, The step of mapping the first image onto the annular region to obtain an annular image includes: A first planar image is set, and the first planar image is rectangular; Multiple first images are mosaicked onto a first planar image to obtain a second planar image, the second planar image including a first portrait bounding box; and The coordinates of the pixels in the second planar image are transformed according to the coordinate mapping formula to obtain the annular image, which includes a second portrait annotation box.
3. The training method for the human face detection model according to claim 2, characterized in that, The coordinate mapping formula includes: Equation 1: ; Formula 2: ; Equation 3: ;and Equation 4: ; in, Characterizes the polar angle of the mapping. R represents the polar radius of the mapped image, (Xa, Ya) represents the pixel coordinates of the second planar image, and (Xb, Yb) represents the pixel coordinates of the annular image.
4. The training method for the human face detection model according to claim 2, characterized in that, The step of performing coordinate transformation on the pixels of the second planar image according to the coordinate mapping formula to obtain the annular image includes: Obtain the coordinates of the first corner point, where the coordinates of the first corner point represent the corner point of the first portrait annotation box; The coordinates of the first corner point are transformed according to the coordinate mapping formula to obtain the coordinates of the second corner point; Obtain the irregular shape annotation box based on the coordinates of the second corner point; and The second portrait annotation frame is obtained based on the smallest bounding rectangle of the irregular annotation frame.
5. The training method for the human face detection model according to claim 1, characterized in that, The step of mapping the second image onto the circular region to obtain a circular image includes: The second image is preprocessed to obtain a preprocessed image, the size of which is the same as the size of the circular region. The preprocessing includes scaling and cropping. The preprocessed image is mosaicked into the circular region to obtain the circular image.
6. The training method for the human face detection model according to claim 1, characterized in that, The ratio of the diameter of the circular region to the outer diameter of the annular region is in the range of [0.50, 0.75].
7. The training method for the human face detection model according to claim 1, characterized in that, The portrait detection model includes a pre-built portrait detection network, and training the portrait detection model using the fused fisheye images includes: In one round of training, the fused fisheye image is input into the portrait detection network to obtain a training feature map, and the training loss is obtained based on the training feature map. The updated weight value is calculated based on the training loss. The updated weight value is the weight parameter of the convolution kernel in the portrait detection network. If the number of training epochs is less than the preset number of epochs, the preset weight values of the portrait detection network are updated according to the updated weight values to obtain the updated portrait detection network, and a new round of training is performed using the new fused fisheye image and the updated portrait detection network; and If the number of training rounds is greater than or equal to the preset number of rounds, the latest updated weight value is used as the target weight value of the portrait detection network to output the trained portrait detection network.
8. The training method for the human face detection model according to claim 7, characterized in that, The portrait detection network includes an attention layer, a depthwise separable convolutional layer, a first-order convolutional layer, a global max pooling layer, and a fully connected layer. The step of inputting the fused fisheye image into the portrait detection network to obtain training feature maps includes: The fused fisheye image is input into the attention layer to obtain the attention image; The image of interest is input into a depth-separable convolutional layer to obtain a first convolutional image; The first convolutional image is input into a first-order convolutional layer to obtain a second convolutional image, wherein the number of channels in the second convolutional image is greater than the number of channels in the image of interest. The second convolutional image is input into a global max pooling layer to obtain the first pooling image; The first pooled image is input into a fully connected layer to obtain multiple candidate features; and The training feature map is obtained based on the candidate feature with the largest attention weight among multiple candidate features.
9. The training method for the human face detection model according to claim 7, characterized in that, The training method for the portrait detection model further includes: testing the trained portrait detection model, wherein the tested trained portrait detection model includes: Obtain at least one planar verification image and at least one fisheye verification image as a comprehensive verification set; The images in the comprehensive validation set are input into the trained portrait detection model to obtain test feature maps; The detection result is obtained by performing nonmaximum suppression and decoding frame processing on the test feature map; and The target parameters are obtained based on the detection results, and the target parameters include at least one of the detection indicators precision, recall rate and confidence.
10. A method for detecting human faces, characterized in that, The human image detection model is trained using the training method of any one of claims 1 to 9, and the trained human image detection model is used for human image detection.
11. The human face detection method according to claim 10, characterized in that, The step of using the trained human image detection model to perform human image detection includes: Acquire an image to be detected, which may include a planar image or a fisheye image; The image to be detected is input into the trained portrait detection model; and Obtain the detection bounding box output by the portrait detection model, which is used to indicate the portrait in the image to be detected.
12. A training device for a human face detection model, characterized in that, include: The acquisition module is used to acquire at least one first image and at least one second image, wherein the first image is a planar image containing a human figure and the second image is a fisheye image containing a human figure; A fusion module is configured to obtain a fused fisheye image based on the first image and the second image, the fused fisheye image containing the human figures in the first image and the second image; and Training module, which is used to train a portrait detection model using the fused fisheye images; The fusion module is also used to obtain a preset fisheye region, which includes an annular region and a circular region, with the circular region being adjacent to the inner periphery of the annular region; and to map the first image onto the annular region to obtain an annular image. The second image is mapped onto the circular region to obtain a circular image; and the fused fisheye image is obtained based on the annular image and the circular image.
13. An electronic device, characterized in that, include: The memory is used to store computer programs; and A processor for executing a computer program stored in the memory to implement the steps of the training method for the human face detection model as described in any one of claims 1 to 9, or to implement the steps of the human face detection method as described in any one of claims 10 to 11.
14. A non-volatile computer-readable storage medium comprising a computer program, which, when executed by one or more processors, implements the steps of a training method for a human face detection model as claimed in any one of claims 1 to 9, or implements the steps of a human face detection method as claimed in any one of claims 10 to 11.
Citation Information
Patent Citations
Object detection for distorted images
US20200134331A1
Systems and methods for training machine models with augmented data
US20220108130A1
