A method of intelligent image cropping based on lightweight portrait detection

Through a lightweight image intelligent cropping method that combines portrait detection and photography principles, it solves the problem of missing information and slow speed in portrait photo cropping, achieves fast and beautiful cropping effects, is suitable for mobile devices, and significantly improves cropping efficiency. and image quality.

CN114882560BActive Publication Date: 2024-09-24FUZHOU UNIV
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202210503278.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-10
Publication Date
2024-09-24
Estimated Expiration
2042-05-10

Smart Images

  • Figure CN114882560B
    Figure CN114882560B
Patent Text Reader

Abstract

The present invention relates to an image intelligent cropping method based on lightweight portrait detection, comprising the following steps: step S1: constructing a lightweight portrait detection network based on the anchor-free one-stage detection idea; step S2: performing portrait detection on an input image according to the constructed lightweight portrait detection network to obtain the position information of the portrait; step S3: according to the position information of the portrait, using the photography composition principle to constrain the overall composition of the image, while clarifying the portrait boundary information, retaining the complete information of key figures, and without laying anchors, realizing the rapid cropping of portrait pictures. The automatic cropping algorithm designed by the present invention for the characteristics of portrait photos takes into account the differences between portrait pictures and landscape pictures, combines portrait detection with photography principles, and can therefore quickly and effectively process portrait pictures and retain the complete information of key portraits.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of automatic image cropping, and in particular to an intelligent image cropping method based on lightweight portrait detection. Background Art

[0002] The image intelligent cropping algorithm refers to cropping an image given a viewport size or aspect ratio, so that the cropped result conforms to the viewport or aspect ratio, while ensuring that the most relevant or interesting part is within the viewport. It can improve the visual quality of the image and has a wide range of applications in many fields. The intelligent cropping algorithm can provide professional advice for image editing and save a lot of time for image post-processing; it can also help individuals quickly and accurately identify the important content in the image, and has important applications in the generation of image thumbnails. Compared with directly shrinking the entire image to fit the viewport, intelligent cropping can generate more ideal thumbnails for users.

[0003] At present, the algorithms in the field of intelligent image cropping can be roughly divided into attention-based methods and aesthetic-based methods. Attention-based methods obtain the area containing the main information through saliency detection, but do not consider aesthetic factors, and the cropping results lack beauty; aesthetic-based methods preset a large number of candidate frames, and then introduce an aesthetic scoring mechanism to score each candidate frame, and output the highest-scoring one. The cropping results have a certain aesthetic appeal, but the setting of a large number of candidate frames is very time-consuming. These existing cropping methods have good effects when processing landscape images, but when processing portrait photos, there is a problem of cropping the main character or cutting off part of the main character's body parts. Portraits account for a large proportion of daily photography and are the main body of users recording their daily lives through social media. If the key person information is missing due to improper cropping methods, the impact on the final cropping effect is very large, and users are usually unacceptable. In order to solve the problems of missing portrait information and slow cropping speed in existing automatic cropping methods, it is necessary to invent a new method for cropping portrait images to ensure that the cropping results are both beautiful and retain key information, and the cropping speed is fast. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide an image intelligent cropping method based on lightweight portrait detection, an automatic cropping algorithm designed according to the characteristics of portrait photos, taking into account the differences between portrait pictures and landscape pictures, and combining portrait detection with photography principles. Therefore, it can quickly and effectively process portrait pictures and retain the complete information of key portraits.

[0005] To achieve the above object, the present invention adopts the following technical solution:

[0006] An image intelligent cropping method based on lightweight portrait detection includes the following steps:

[0007] Step S1: construct a lightweight portrait detection network based on the anchor-free one-stage detection idea;

[0008] Step S2: Performing portrait detection on the input image according to the constructed lightweight portrait detection network to obtain the position information of the portrait;

[0009] Step S3: According to the position information of the portrait, the overall composition of the image is constrained by using the principles of photographic composition, while the portrait boundary information is clarified, the complete information of the key figures is retained, and no anchors are laid, so as to achieve fast cropping of the portrait image.

[0010] Furthermore, the lightweight portrait detection network includes four parts: backbone, upsample, neck, and head.

[0011] Furthermore, the feature extraction part of the backbone adopts the lightweight network mobilenetv2, and the base_out2, base_out5, base_out9, and base_out17 layers of the backbone part are respectively fused with the P1, P2, P3, and P4 layers of the upsampling part to perform the same-scale feature fusion to strengthen the feature extraction; at this time, the network structure is a MISO structure, and the output of P4 is directly used for prediction.

[0012] Furthermore, the upsample part adopts grouped convolution.

[0013] Furthermore, the neck part introduces a dilated convolution residual module, which generates output features with multiple receptive fields by stacking multiple convolution blocks with different dilation rates to expand the receptive field of base_out17.

[0014] Furthermore, the head part directly predicts the center point and width and height of the object based on the idea of ​​the anchor-free algorithm, retains the three prediction quantities of category prediction, width and height prediction, and center point prediction, and on this basis, introduces the IOU loss and trains the position information as a whole.

[0015] Furthermore, the step S2 is specifically as follows:

[0016] Step S21: pre-process the bounding box and score information and add an offset;

[0017] Step S22: After preprocessing the bounding box, the lightweight portrait detection network identifies the main person in the image.

[0018] Furthermore, the step S3 is specifically as follows:

[0019] Step S31: using the detected main character information and improved photography composition rules to constrain the cropping process;

[0020] Step S32: Analyze the specific position information of the portrait in the original image, and select appropriate photography composition principles for cropping according to different situations.

[0021] Furthermore, the basic forms of computer image design composition include golden section, rule of thirds, triangle, diagonal line, motion blank, center law, and balance and stability law.

[0022] Furthermore, the step S32 is specifically: constraining the composition of the sorted image in combination with the principles of photographic composition, and the specific method for cropping a single portrait is: setting two quantities, vertical and horizontal, to represent the portrait position information, analyzing the position of the center point of the portrait in the main character and the original image, and then determining the values ​​of vertical and horizontal. Then, selecting appropriate photographic composition rules according to the portrait position information, and cropping the image in combination with the portrait boundary information, to ensure the integrity of the portrait information and the aesthetics of the cropping result.

[0023] Compared with the prior art, the present invention has the following beneficial effects:

[0024] 1. The automatic cropping algorithm designed by the present invention is based on the characteristics of portrait photos. It takes into account the differences between portrait pictures and landscape pictures and combines portrait detection with photography principles. Therefore, it can process portrait pictures quickly and effectively and retain the complete information of key portraits.

[0025] 2. The present invention does not involve any preset candidate frames. Whether in the portrait detection part or the automatic cropping part, the complicated candidate frame laying work and some time-consuming post-processing operations are omitted. Therefore, the parameter amount and inference time of the entire model are very short, which is very friendly to mobile devices and can quickly feedback the cropping results to the user. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a flow chart of the method of the present invention;

[0027] Figure 2 It is a portrait detection network designed in the first stage of an embodiment of the present invention;

[0028] Figure 3 This is a comparison chart of the cropping effects of a single portrait;

[0029] Figure 4 , Figure 5 A comparison of the cropping effects of multiple portraits. DETAILED DESCRIPTION

[0030] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0031] Please refer to Figure 1 The present invention provides an image intelligent cropping method based on lightweight portrait detection, comprising the following steps:

[0032] Step S1: construct a lightweight portrait detection network based on the anchor-free one-stage detection idea;

[0033] Step S2: Performing portrait detection on the input image according to the constructed lightweight portrait detection network to obtain the position information of the portrait;

[0034] Step S3: According to the position information of the portrait, the overall composition of the image is constrained by using the principles of photographic composition, while the portrait boundary information is clarified, the complete information of the key figures is retained, and no anchors are laid, so as to achieve fast cropping of the portrait image.

[0035] In this embodiment, the Figure 2 The lightweight portrait detection network shown in the figure is built based on the idea of ​​an anchor-free one-stage detection algorithm. The network can be divided into four parts: backbone, upsample, neck, and head. The specific network structure design is as follows:

[0036] 1. Backbone feature extraction part: The feature extraction part uses the lightweight network MobileNetV2, which has very few model parameters and very fast inference speed, making it very suitable for use in mobile scenarios. However, for detection tasks, the lightweight feature extraction part will inevitably lead to a decrease in detection accuracy. Unlike other large feature extraction networks such as Resnet, the backbone network uses the MobileNetV2 lightweight network, which mainly affects the depth and receptive field of the model. The receptive field of the model is extremely important for detection performance. How to improve the receptive field of the model while ensuring the lightweight of the network is the key issue to be solved in this embodiment.

[0037] Therefore, in this embodiment, the base_out2, base_out5, base_out9, and base_out17 layers of the backbone part are respectively fused with the P1, P2, P3, and P4 layers of the upsampling part to enhance feature extraction. At this time, the network structure is a MISO structure (multiple input and single output), and the divide-and-conquer strategy is not used. Instead, the output of P4 is directly used for prediction to avoid the memory burden caused by the complexity of the divide-and-conquer structure.

[0038] 2. The upsampling part uses group convolution, which further reduces the network parameters compared to ordinary convolution, making the model more lightweight.

[0039] 3. In the neck part, the fusion of features of the same scale during upsampling is not enough to make up for the accuracy problem caused by the lightweight backbone, and a larger receptive field is required for feature extraction. Therefore, the present invention introduces an expanded convolution residual module in the neck part, and generates output features with multiple receptive fields by stacking multiple convolution blocks with different expansion rates to expand the receptive field of base_out17 and strengthen feature extraction. In the neck part, 1*1 convolution is first used to reduce the dimension of the channel and reduce the amount of calculation, and then 3*3 convolution is used to refine the semantic context information, and then the number of output channels is adjusted through 1*1 convolution operation. This paper stacks 5 expanded residual convolution blocks with different expansion rates, and the expansion rates are 2, 4, 6, 8, and 10 respectively, with output features of multiple receptive fields, covering all target scales. Experiments have proved that this module significantly improves the accuracy of the model.

[0040] 4. Head part, based on the idea of ​​anchor-free algorithm, this embodiment directly predicts the center point of the object and its width and height to improve the detection speed. Therefore, the three prediction quantities of category prediction, width and height prediction, and center point prediction are retained. On this basis, the present invention introduces IOU loss, and trains the position information as a whole, which can obtain the training effect more accurately. In addition, when any sample is input, the IOU value is between 0-1. This natural normalization loss enables the model to have stronger multi-scale image processing capabilities. Therefore, this part of the loss introduced can optimize the prediction ability of the model.

[0041] In this embodiment, after the first stage of portrait detection, complete portrait information is obtained and input into the next stage of automatic cropping, specifically;

[0042] Preprocess the bounding box, score and other information, and add an offset to prevent the cropped portrait from being too close to the edge, making the overall composition too compact and causing a visual sense of oppression.

[0043] After preprocessing the bounding box, the model will identify the main characters in the image. Since the detected portraits are not necessarily the main characters that the user is paying attention to (such as passers-by that are inevitable when taking pictures), the algorithm first determines the main characters and then crops the image based on the main characters, which can highlight the user's visual attention points and enhance the composition effect.

[0044] Next, the detected main character information and improved photography composition rules are used to constrain the cropping process. The basic forms of computer image design composition include golden section, rule of thirds, triangle, diagonal line, motion blank, center rule, balanced stability and other rules.

[0045] In this embodiment, the specific position information of the portrait in the original image is analyzed, and appropriate photographic composition principles are selected for cropping according to different situations. First, the center point of the main character is found based on the bounding box and score information of the main character, and then the position of the center in the image is analyzed to select appropriate photographic composition rules. The aspect ratio of the cropping result is also very important for the overall composition, so finally, combined with the overall composition, the aspect ratio of the picture is automatically adjusted to avoid the cropping result being too wide or too narrow, so as to obtain a visual sense of balance. In short, the algorithm can obtain a cropping result with high-quality composition while ensuring the integrity of the portrait information.

[0046] In this embodiment, the experimental results are as follows Figure 3 , Figure 4 , Figure 5 As shown. It can be seen that Figure 3 It is obviously a group, and the cropping result should retain the portrait information of the entire group. After being processed by the cropping method of the present invention, the overall composition of the image is significantly improved, unnecessary background information is removed, and the complete information of the key characters is retained, so that the portrait theme is visually highlighted; at the same time, the overall image conforms to the central law in the composition principle of photography, and the aspect ratio is also improved. Compared with before cropping, the image quality is improved. Figure 4 and Figure 5 These are the cropping results of some single portraits. Due to the difference in the composition of the original images, different photographic principles were used for cropping. The cropping results have been greatly improved in composition, while also retaining complete portrait information.

[0047] The above description is only a preferred embodiment of the present invention. All equivalent changes and modifications made according to the scope of the patent application of the present invention should fall within the scope of the present invention.

Claims

1. An image intelligent cropping method based on lightweight portrait detection, characterized in that: The following steps are involved: Step S1: construct a lightweight portrait detection network based on the anchor-free one-stage detection idea; Step S2: Performing portrait detection on the input image according to the constructed lightweight portrait detection network to obtain the position information of the portrait; Step S3: According to the position information of the portrait, the overall composition of the image is constrained by using the composition principle of photography, while the portrait boundary information is clarified, the complete information of the key figures is retained, and no anchors are laid, so as to realize the rapid cropping of the portrait image; The lightweight portrait detection network includes four parts: backbone, upsample, neck, and head; The feature extraction part of the backbone adopts the lightweight network mobilenetv2, and the base_out2, base_out5, base_out9, and base_out17 layers of the backbone part are respectively fused with the P1, P2, P3, and P4 layers of the upsampling part to enhance feature extraction; the network structure at this time is a MISO structure, and the output of P4 is directly used for prediction; The upsampling part adopts grouped convolution; The neck part introduces an expanded convolution residual module, which generates output features with multiple receptive fields by stacking multiple convolution blocks with different expansion rates, so as to expand the receptive field of base_out17 and strengthen feature extraction; the neck part first uses 1*1 convolution to reduce the channel dimension and reduce the amount of calculation, then uses 3*3 convolution to refine the semantic context information, and then adjusts the number of output channels through 1*1 convolution operation; The head part is based on the idea of ​​anchor-free algorithm, directly predicts the center point and width and height of the object, retains the three prediction quantities of category prediction, width and height prediction, and center point prediction, and on this basis, introduces IOU loss to train the position information as a whole; The step S3 is specifically as follows: Step S31: using the detected main character information and improved photography composition rules to constrain the cropping process; Step S32: analyzing the specific position information of the portrait in the original picture, and selecting appropriate photography composition principles for cropping according to different situations; The step S32 is specifically as follows: constraining the composition of the overall image in combination with the principles of photographic composition, and the specific method for cropping a single portrait is as follows: setting two quantities, vertical and horizontal, to represent the portrait position information, analyzing the position of the center point of the portrait in the main character and the original image, and then determining the vertical and horizontal values; then selecting appropriate photographic composition rules according to the portrait position information, and cropping the image in combination with the portrait boundary information to ensure the integrity of the portrait information and the aesthetics of the cropping result.

2. The image intelligent cropping method based on lightweight portrait detection according to claim 1 is characterized in that: The step S2 is specifically as follows: Step S21: pre-process the bounding box and score information and add an offset; Step S22: After preprocessing the bounding box, the lightweight portrait detection network identifies the main person in the image.

3. The method for intelligent image cropping based on lightweight portrait detection according to claim 2 is characterized in that: The photography composition rules include the golden ratio, the rule of thirds, triangles, diagonal lines, motion blanks, the law of center, and the law of balance and stability.

Citation Information

Patent Citations

  • Pedestrian detection system and method based on improved YOLOv3 algorithm

    CN111898432A

  • Target detection method, target detection framework and related equipment

    CN111931764A

  • SLAM loopback detection method based on semantic features

    CN114067128A

  • Method for auto-cropping of images

    WO2018090355A1

  • Construction method for multi-scale lightweight face detection model and face detection method based on model

    WO2019223254A1