Image processing method, device and computer readable storage medium
By detecting target objects or edge features in the image and using the image rendering model for style conversion, the problem of unstable image processing in the existing technology is solved and the effect and accuracy of image processing are improved.
Patent Information
- Application Number
- CN202311641201.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-01
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-12-01
AI Technical Summary
When converting image styles with existing image processing methods, it is prone to situations where there are no people or other objects in the input image but objects exist in the generated image, or objects exist but do not exist in the generated image, resulting in unstable processing effects and affecting image quality.
By detecting the target object in the image to be processed, extracting object posture features or image edge features, determining control information based on these features, and using the image rendering model to perform style conversion to ensure the stability of the generated image.
It improves the stability and effect of image processing, avoids the situation of no target objects, generates images that better meet business needs, and improves the accuracy and diversity of image processing.
Smart Images

Figure CN117649335B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image processing method, device and computer-readable storage medium. Background Art
[0002] With the rapid development of computer technology, the demand for image processing is increasing. For example, an image rendering model based on a diffusion model can be used to convert the image of a real scene input by the user into an image in a comic style or other style, thereby enhancing the fun and diversity of the content created by the user, and further enhancing the attractiveness of the created content.
[0003] In the process of research and practice of existing technologies, it was found that in the existing image processing methods that use image drawing models to perform image style conversion to generate images, it is very easy for the input image to contain no objects such as people but the image generated by the image drawing model contains objects, or the input image contains objects but the image generated by the image drawing model does not contain objects. The image processing effect is very likely to be unstable, resulting in poor image processing effect. Summary of the invention
[0004] The embodiments of the present application provide an image processing method, device, and computer-readable storage medium, which can effectively improve the stability of images generated using an image rendering model, thereby improving the image processing effect.
[0005] The present application provides an image processing method, including:
[0006] Perform target object detection on the image to be processed;
[0007] When it is detected that there is a target object in the image to be processed, extracting an object posture feature of the target object from the image to be processed, and determining control information corresponding to the image to be processed based on the object posture feature;
[0008] When it is detected that the target object does not exist in the image to be processed, image edge features are extracted from the image to be processed, and control information corresponding to the image to be processed is determined based on the image edge features;
[0009] An image rendering model is used to perform target style conversion on the image to be processed based on the control information to obtain a target image under the target style corresponding to the image to be processed.
[0010] Accordingly, an embodiment of the present application provides an image processing device, including:
[0011] An object detection unit, used for detecting a target object in an image to be processed;
[0012] A first determining unit is configured to extract an object posture feature of the target object from the image to be processed when detecting that the target object exists in the image to be processed, and determine control information corresponding to the image to be processed based on the object posture feature;
[0013] A second determining unit is configured to extract image edge features from the image to be processed when it is detected that the target object does not exist in the image to be processed, and determine control information corresponding to the image to be processed based on the image edge features;
[0014] An image generation unit is used to use an image rendering model to perform a target style conversion on the image to be processed based on the control information to obtain a target image under a target style corresponding to the image to be processed.
[0015] In one embodiment, the image processing apparatus further includes a first style conversion description information determining unit, configured to:
[0016] Identifying object attribute information of the target object in the image to be processed;
[0017] Determine first target style conversion description information of the image to be processed based on the object attribute information and the first style conversion description information, where the first style conversion description information is style conversion description information preset for the image carrying the target object;
[0018] The first determining unit is configured to:
[0019] Based on the object posture feature and the first target style conversion description information, control information corresponding to the image to be processed is determined.
[0020] In one embodiment, the object attribute information includes one or more information of the number of objects, the object category, and the object posture of the target object.
[0021] In one embodiment, the second determining unit is configured to:
[0022] Acquire second style transfer description information, where the second style transfer description information is style transfer description information preset for an image that does not carry a target object;
[0023] The image edge feature and the second style conversion description information are determined as control information corresponding to the image to be processed.
[0024] In one embodiment, when the target object exists in the image to be processed, the image generating unit includes:
[0025] An image conversion subunit, configured to perform a target style conversion on the image to be processed based on the control information by using an image rendering model, so as to obtain an initial converted image under the target style corresponding to the image to be processed;
[0026] A target part detection subunit, used for performing target part detection on the initial conversion image;
[0027] A size information acquisition subunit, configured to acquire size information of a region where the target part is located in the initial conversion image if a target part is detected in the initial conversion image;
[0028] The image restoration subunit is used to use the image restoration model to restore the target part in the initial conversion image to obtain a target image when the size information meets the size determination condition corresponding to the image restoration.
[0029] In one embodiment, the image restoration subunit includes:
[0030] A part detection module, used to identify a target detection frame where the target part is located in the image to be processed, and target part feature information identified in the target part based on the target detection frame;
[0031] A first extraction module is used to extract a target area image from the initial conversion image based on the target detection frame and input it into an image restoration model, mark the area where the target part is located in the target area image, and obtain target area information and input it into the image restoration model;
[0032] A second extraction module is used to extract the characteristic information of the target part through the restoration control model, and obtain the control feature to input into the image restoration model;
[0033] An image restoration module, configured to perform a restoration process on a target area in the target area image based on the control feature, the target area image and the target area information through the image restoration model to obtain a restored target area image;
[0034] The image fusion module is used to perform image fusion processing on the restored target area image and the initial conversion image to obtain a target image of the image to be processed in the target style.
[0035] In one embodiment, the image fusion module is used to:
[0036] Determining a fusion region in the initial conversion image based on the target region image;
[0037] The restored target area image is pasted to the initial conversion image based on the fusion area to obtain a target image of the image to be processed in the target style.
[0038] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any image processing method provided in the embodiment of the present application.
[0039] In addition, an embodiment of the present application also provides a computer device, including a processor and a memory, wherein the memory stores an application program, and the processor is used to run the application program in the memory to implement the image processing method provided in the embodiment of the present application.
[0040] The embodiment of the present application also provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the image processing method provided in the embodiment of the present application.
[0041] The embodiment of the present application performs target object detection on the image to be processed; when it is detected that there is a target object in the image to be processed, the object posture feature of the target object is extracted from the image to be processed, and the control information corresponding to the image to be processed is determined based on the object posture feature; when it is detected that there is no target object in the image to be processed, the image edge feature is extracted from the image to be processed, and the control information corresponding to the image to be processed is determined based on the image edge feature; the image drawing model is used to perform target style conversion on the image to be processed based on the control information to obtain the target image under the target style corresponding to the image to be processed. In this way, the image type of the image to be processed is determined by detecting whether there is a target object in the image to be processed, and different types of image features are extracted from the image to be processed according to whether there is a target object in the image to be processed, so as to determine the control information matching the current image type, and the image drawing model is guided to perform target style conversion on the image to be processed according to the determined control information, so as to effectively improve the stability of the image generated by the image drawing model, thereby improving the image processing effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0043] Figure 1 It is a schematic diagram of an implementation scenario of an image processing method provided in an embodiment of the present application;
[0044] Figure 2 It is a flowchart of an image processing method provided in an embodiment of the present application;
[0045] Figure 3 It is a schematic diagram of the overall process of an image processing method provided by an embodiment of the present application;
[0046] Figure 4 It is a schematic diagram of a region expansion of an image processing method provided in an embodiment of the present application;
[0047] Figure 5 is a structural schematic diagram of an image processing device provided in an embodiment of the present application;
[0048] Figure 6 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0050] The embodiments of the present application provide an image processing method, device and computer-readable storage medium. The image processing device can be integrated in a computer device, which can be a server or a terminal.
[0051] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.
[0052] See also Figure 1 , taking the image processing device integrated into a computer device as an example, Figure 1A schematic diagram of an implementation scenario of the image processing method provided in an embodiment of the present application, wherein the computer device can be a server or a terminal, and the computer device can perform target object detection on an image to be processed; when it is detected that there is a target object in the image to be processed, the object posture features of the target object are extracted from the image to be processed, and control information corresponding to the image to be processed is determined based on the object posture features; when it is detected that there is no target object in the image to be processed, the image edge features are extracted from the image to be processed, and control information corresponding to the image to be processed is determined based on the image edge features; an image drawing model is used to perform target style conversion on the image to be processed based on the control information, so as to obtain a target image under the target style corresponding to the image to be processed.
[0053] It should be noted that Figure 1 The implementation environment scenario diagram of the image processing method shown is only an example. The implementation environment scenario of the image processing method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0054] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0055] This embodiment will be described from the perspective of an image processing apparatus. The image processing apparatus may be integrated into a computer device, which may be a server. This application does not limit this.
[0056] See also Figure 2 , Figure 2 : is a flow chart of an image processing method provided in an embodiment of the present application. The image processing method comprises:
[0057] In step 101, target object detection is performed on the image to be processed.
[0058] The image to be processed may be an image to be processed, or may be an image to be converted into other styles, for example, an image to be converted into other styles such as traditional Chinese comic style, ink painting style, etc.
[0059] Optionally, the image to be processed may be an image with objects such as people and animals as the main subject, or may be an image with scenes such as scenery and buildings as the main subject.
[0060] There are many ways to detect the target object in the image to be processed. For example, a target detection algorithm can be used to detect whether there is a target object in the image to be processed.
[0061] The target object may be a person, an animal or other object, and the number of the target objects may be one or more, which may be set according to actual conditions. The target detection algorithm may be, for example, an R-CNN algorithm (full name Region-CNN), a Fast R-CNN algorithm, a YOLO algorithm (full name You Look once) or other target detection algorithms.
[0062] Optionally, the target object may be an object that is a main body in the image to be processed. For example, when there is an object with a relatively small size in the image to be processed, the object may be ignored, so that it can be considered that there is no target object in the image to be processed.
[0063] In step 102, when it is detected that there is a target object in the image to be processed, an object posture feature of the target object is extracted from the image to be processed, and control information corresponding to the image to be processed is determined based on the object posture feature.
[0064] Among them, the object posture feature can be information that characterizes the posture of the target object present in the image to be processed, for example, the object posture feature can be information describing the position of the skeleton key points of the target object in the image to be processed and the connection relationship between different skeleton key points. The control information can be information for controlling the style conversion of the image to be processed, and according to the control information, the image rendering model can be guided to convert the image to be processed into an image that matches the information such as the posture described in the control information. The image rendering model can be a model for image rendering based on artificial intelligence (AI) technology, for example, it can be a diffusion model such as a stable diffusion model (Stable Diffusion, referred to as SD model).
[0065] There are many ways to extract the object posture features of the target object in the image to be processed. For example, human posture estimation algorithms such as posture estimation network (Open pose), instance segmentation algorithm (Mask RCNN), regional multi-person pose estimation (RMPE, or AlphaPose) can be used to extract posture features of the image to be processed, so as to obtain object posture features that characterize the posture of the target object in the image to be processed.
[0066] Among them, there can be multiple ways to determine the control information corresponding to the image to be processed based on the object posture features. For example, the object attribute information of the target object can be identified in the image to be processed, and the first target style conversion description information of the image to be processed can be determined based on the object attribute information and the first style conversion description information. Thus, the control information corresponding to the image to be processed can be determined based on the object posture features and the first target style conversion description information.
[0067] The object attribute information may be information describing the object attribute of the target object, and the object attribute may be information describing the nature and characteristics of the target object. For example, the object attribute information may include one or more information of the number of target objects, the object category, and the object posture of the target object. The number of objects may be information describing the number of target objects in the image to be processed, and the object category may be information describing the category of the target object, for example, it may include information such as the gender and age of the target object, and the object posture may be information describing the posture of the target object in the image to be processed, for example, it may include postures such as sitting, standing, and lying on the side. The first style conversion description information may be prompt information for performing style conversion on the image to be processed, and the first style conversion description information may be style conversion description information preset for the image carrying the target object, that is, when the target object exists in the image to be processed, the first style conversion description information may be determined as prompt information for performing style conversion on the image to be processed. The first target style conversion description information may be prompt information for performing style conversion on the image to be processed in which the target object exists.
[0068] Among them, based on the object attribute information and the first style transfer description information, there can be multiple ways to determine the first target style transfer description information of the image to be processed. For example, the object attribute information and the first style transfer description information can be spliced to obtain the first target style transfer description information.
[0069] Optionally, there may be multiple ways to identify the object attribute information of the target object in the image to be processed. For example, when performing target object detection on the image to be processed, attribute recognition may be performed on the target object detected in the image to be processed at the same time, thereby obtaining the object attribute information of the target object.
[0070] In one embodiment, assuming that the target object is a person, please refer to Figure 3 , Figure 3It is a schematic diagram of the overall process of an image processing method provided by an embodiment of the present application. A user inputs an image to be processed, thereby obtaining the image to be processed, and performing human attribute detection on the image to be processed, thereby detecting whether there is a human body in the image to be processed. When it is detected that there is a human body in the image to be processed, object attribute information such as the number, gender, and posture of the human body in the image to be processed can be identified, thereby splicing a preset first style conversion description information and the object attribute information to obtain a first target style conversion description information, and at the same time, the object posture features of the target object can be extracted from the image to be processed, and then the first target style conversion description information and the object posture features can be determined as control information for style conversion of the image to be processed.
[0071] In step 103, when it is detected that there is no target object in the image to be processed, image edge features are extracted from the image to be processed, and control information corresponding to the image to be processed is determined based on the image edge features.
[0072] The image edge feature may be information describing the distribution of edge lines in the image to be processed, for example, an edge image of the image to be processed, the edge image may be an image containing edge lines in the image to be processed, and the edge lines may be lines generated by edges such as the edge between the object and the background in the image to be processed, the edge between objects in the image, etc. For example, it may be a line drawing extracted from the image to be processed, etc. The control information may be information for controlling the style conversion of the image to be processed, and according to the control information, the image rendering model may be guided to convert the image to be processed into an image matching the posture or edge information described in the control information.
[0073] There are many ways to extract image edge features from the image to be processed. For example, edge detection algorithms such as edge detection model (Canny) and edge detection network (HED) can be used to perform edge detection on the image to be processed to obtain image edge features of the image to be processed.
[0074] There are many ways to determine the control information corresponding to the image to be processed based on the image edge features. For example, the second style conversion description information can be obtained, and the image edge features and the second style conversion description information can be determined as the control information corresponding to the image to be processed.
[0075] The second style conversion description information is the style conversion description information preset for the image that does not carry the target object, that is, when the target object does not exist in the image to be processed, the second style conversion description information can be determined as the prompt information for style conversion of the image to be processed. The first style conversion description information can be the style conversion description information used when the target object exists in the image to be processed, and can be the prompt information for style conversion of the image to be processed with the object as the main body. The second style conversion description information can be the style conversion description information used when the target object does not exist in the image to be processed, and can be the prompt information for style conversion of the image to be processed of the scene type.
[0076] In one embodiment, please continue to refer to Figure 3 When it is detected that there is no human body in the image to be processed, the second style conversion description information of the preset scene type can be obtained, and at the same time, the image edge features can be extracted from the image to be processed, so that the second style conversion description information and the image edge features can be determined as the control information corresponding to the image to be processed when there is no target object. Optionally, when it is detected that there is a human body in the image to be processed, it is detected whether the object posture features are extracted, and when the object posture features of the target object extracted from the image to be processed are not obtained, the image edge features can be extracted from the image to be processed, so that the second style conversion description information and the image edge features can be determined as the control information corresponding to the image to be processed when there is no target object.
[0077] In one embodiment, the image rendering model can be trained, wherein the training of the diffusion model is to learn the process of step-by-step denoising. It can be assumed that the number of steps required for denoising from random Gaussian noise to a target image is N steps, and the similarity with the original image is given as S (the value range can be 0-1, for example, it can be 0.5 or 0.45, etc.), and an initialized original image I is given, and an initialized noise image I' is obtained by adding N*(1-S) steps of Gaussian noise to the image I, as the basis for denoising generation. At this time, the image I' has the basic structural information of the original image. Then, the style conversion description information corresponding to the target style is set, and the final prompt information is determined in combination with the object attribute information detected in the original image, and the image rendering model is guided to perform denoising generation based on the image I' based on the prompt information, so as to obtain an image in the target style after denoising.
[0078] Optionally, in actual model deployment, a training sample sampling algorithm (dpm_solver++) can be used to ensure the stability of image generation effects when the number of training steps is relatively small.
[0079] In step 104, the image rendering model is used to perform target style conversion on the image to be processed based on the control information to obtain a target image in a target style corresponding to the image to be processed.
[0080] The target style may be the style of an image to be generated based on the image to be processed, that is, the process of performing style conversion on the image to be processed may refer to converting the image to be processed into an image in the target style, and the target style may be a comic style, ink painting style, etc. The target image may be an image obtained by performing style conversion on the image to be processed, that is, an image obtained by converting the image to be processed into the target style.
[0081] There are many ways to use an image drawing model to perform target style conversion on the image to be processed based on the control information to obtain a target image under the target style corresponding to the image to be processed. For example, the image drawing model can be used to extract features of the image to be processed and the style conversion description information in the control information to obtain image features and style conversion text features, and the image features and the style conversion text features can be fused to obtain image features after style conversion. Based on the object posture features or image edge features in the control information and the image features after style conversion, the image drawing model can be used to perform target style conversion on the image to be processed to obtain the target image under the target style corresponding to the image to be processed.
[0082] Among them, the image feature can be a feature that characterizes the image to be processed, the style conversion text feature can be information used to generate a target image under the target style corresponding to the image to be processed, and can be information that characterizes the style conversion description information in the control information, and the image feature after style conversion can be a feature obtained by fusing the image feature and the style conversion text feature.
[0083] There are many ways to fuse image features and style-converted text features. For example, image features and style-converted text features may be added to obtain style-converted image features.
[0084] In this way, the image type of the image to be processed is determined by detecting whether there is a target object in the image to be processed. When the target object exists in the image to be processed, the object posture features can be extracted from the image to be processed to determine the control information that matches the image with the object as the main body, so that when the style conversion is performed on the image to be processed, a target image that matches the posture of the target object in the image to be processed can be generated, thereby avoiding the situation where the target image generated does not contain the target object when the target object exists in the image to be processed. When the target object does not exist in the image to be processed, image edge features are extracted from the image to be processed to determine the control information that matches the scene type of the image, thereby when the style conversion is performed on the image to be processed, a target image that matches the scene of the target object in the image to be processed can be generated, thereby avoiding the situation where the target object does not exist in the image to be processed but the target image generated contains the target object. Therefore, when guiding the image drawing model to perform target style conversion on the image to be processed according to the control information corresponding to different image types, for the image to be processed with the target object, the drawing of the image drawing model can be controlled based on the object posture feature, which is weak supervision information containing a small amount of point information in the image to be processed, giving the image drawing model more drawing freedom, so that a variety of rich target images matching the posture of the target object in the image to be processed can be generated. When there is no target object in the image to be processed, the image edge feature, which is strong supervision information containing more information related to the image to be processed, can be used to control the drawing of the image drawing model to generate a target image that is more in line with the scene of the image to be processed. In this way, more accurate and adaptive control of the image generation process of the image drawing model can be achieved, and a target image matching the business needs is obtained, which effectively improves the stability of the image generated by the image drawing model, thereby improving the image processing effect.
[0085] Optionally, when there is a target object in the image to be processed, an image drawing model is used to perform target style conversion on the image to be processed based on control information, and there may be multiple ways to obtain a target image under the target style corresponding to the image to be processed. For example, an image drawing model can be used to perform target style conversion on the image to be processed based on control information to obtain an initial conversion image under the target style corresponding to the image to be processed, and target part detection is performed on the initial conversion image. If the target part is detected in the initial conversion image, size information of the area where the target part is located in the initial conversion image is obtained. When the size information meets the size judgment condition corresponding to the image restoration, the image restoration model is used to restore the target part in the initial conversion image to obtain the target image.
[0086] Among them, the initial conversion image can be an image obtained by performing target style conversion on the image to be processed based on control information using an image rendering model, and the target part can be a part of the target object that needs to be repaired, for example, it can be a face, hand, etc. The size information can be information describing the size of the target part in the initial conversion image, or it can be information describing the size of the target part in the image to be processed. For example, the size information can be the length and width of the area where the target part is located, or it can be the area ratio of the area where the target part is located, that is, the ratio of the area of the area where the target part is located to the area of the initial conversion image or the image to be processed, etc. The size judgment condition can be a pre-set condition for judging whether the target part needs to be repaired according to the size information of the target part. For example, it can be judged whether the target part in the initial conversion image or the image to be processed is small according to the size information of the target part, and it is judged that image repair is needed when the target part is judged to be small. Please continue to refer to Figure 3 When the size of the target part in the initial conversion image or the image to be processed is small, it is very easy for the target part in the initial conversion image to be distorted, blurred or distorted, resulting in poor image generation effect. Therefore, it is possible to determine whether it is necessary to perform image restoration on the target part in the initial conversion image based on the size information of the target part to improve the image generation effect. The image restoration model can be an image for restoring the target part in the initial conversion image. Optionally, the image restoration model can be a diffusion model, for example, an SD model (SD-inpainting) based on an image completion function. The image restoration model can use the encoder (Transformer Encoder) of the transformer model as the basic structure of the model.
[0087] Among them, an image restoration model is used to restore the target part in the initial conversion image. There are many ways to obtain the target image. For example, a target detection frame where the target part is located can be identified in the image to be processed, and feature information of the target part identified in the target part based on the target detection frame. A target area image is extracted from the initial conversion image based on the target detection frame and input into the image restoration model. The area where the target part is located in the target area image is marked to obtain target area information and input into the image restoration model. Feature extraction of the target part feature information is performed through a restoration control model to obtain control features and input into the image restoration model. The image restoration model performs restoration processing on the target area in the target area image based on the control features, the target area image and the target area information to obtain a restored target area image. The restored target area image and the initial conversion image are subjected to image fusion processing to obtain a target image of the image to be processed in the target style.
[0088] Among them, the target detection frame can be a bounding box (Bbox for short) containing the target part detected in the image to be processed, and the bounding box can be a directed rectangular box used to represent the position and size of the object in the target detection. The target part feature information can be information characterizing the features of the target part in the image to be processed, and the features of the target part can include the distribution of key points in the target part, the image features of the target part, and the attributes of the target part. For example, the target part feature information can include key point information, image features, and attribute information of the target part in the image to be processed. The key point information can be information describing the position distribution of key points of the target part in the image to be processed in the target detection frame, and the image features can be information characterizing the image of the area where the target part is located in the image to be processed. The attribute information can be information describing the properties and relationships of the object in the image to be processed, for example, it can include information such as color, gender, age, newness, season, etc. Optionally, the attribute information can be attribute information of the object identified based on the target part in the image to be processed. For example, the object attribute recognition can be performed on the target part in the image to be processed according to the target detection frame to obtain the age, gender, newness, and other attribute information of the object in the image to be processed.
[0089] In one embodiment, when the target part is a human face, the key point information may be information describing the distribution of key points of the human face in the image to be processed, the key points may include key feature points such as eyes, mouth, nose, etc., the image features may be facial features, and the attribute information may be attribute information based on face detection in the image to be processed, which may describe the attribute information of the person corresponding to the current face in the image to be processed, for example, may include information such as the gender and age of the object.
[0090] The target area image may be an image containing the target part in the initial conversion image, or may be an image containing an area to be repaired (target part) and a part of the area not to be repaired (surrounding area of the target part), which can facilitate image repair. The target area information may be information such as the position of the area where the target part is located in the initial conversion image in the target area image, the area boundary, etc., and the area where the target part is located may be determined in the target area image based on the target area information. The target area information may be used to indicate the area that the image repair model needs to repair in the target area image. The control feature may be a feature extracted by the repair control model for controlling the image repair model to perform image repair on the target area image based on the key point information and image features of the target part. Based on the control feature, the image repair model may obtain the relevant feature information of the target part in the image to be processed, so that the image repair of the target area image may be performed more accurately and more closely to the image to be processed, thereby improving the image repair effect and the image generation quality, and thus improving the image processing efficiency. The repair control model may be a model that guides the image repair process of the image repair model, for example, it may be a control model (controlnet) corresponding to the SD model and other plug-ins. The repaired target region image may be a target region image obtained by performing a repair process on a target part of the target region in the target region image.
[0091] There are many ways to extract the target area image from the initial conversion image based on the target detection frame and input it into the image restoration model. For example, the initial area image corresponding to the target part can be cropped out from the initial conversion image based on the target detection frame, and a preset target image size can be obtained. The initial area image is scaled according to the target image size to obtain the target area image, and the target area image is input into the image restoration model.
[0092] Among them, the initial region image can be an image containing the target part cropped out of the initial conversion image, and the target image size can be the size of the target region image for image restoration. Since the target part in the image to be processed and the initial conversion image occupies a small area, it is necessary to enlarge the cropped initial region image, so as to perform image restoration and generation based on the enlarged initial region image, and obtain a restored image with more detailed details, thereby improving the restoration effect. The target image size can be set according to the design situation, and the embodiment of the present application is not limited here.
[0093] There are many ways to crop the initial region image corresponding to the target part in the initial conversion image based on the target detection frame. For example, a first target region where the target part is located can be determined in the initial conversion image based on the target detection frame, and an expansion parameter corresponding to the first target region can be obtained. The first target region is expanded in the initial conversion image according to the expansion parameter to obtain the initial region, and the initial region in the initial conversion image is cropped to obtain the initial region image.
[0094] The first target area may be an area determined in the initial conversion image according to the target detection frame, and the image sizes of the initial conversion image and the image to be processed may be the same, so that the first target area may be determined in the initial conversion image according to the position of the target detection frame in the image to be processed. The expansion parameter may be a parameter for expanding the first target area in the initial conversion image. Since the target area image for image restoration needs to include a part of the area that does not need to be restored, that is, the outer area of the area where the target part is located, this part of the area does not change during image restoration. Therefore, after the image restoration is performed on the area corresponding to the target part, the restored target area image can be easily fused with the initial conversion image based on the unchanged area to obtain the final restored initial conversion image, thereby improving the efficiency of image restoration. The initial area may be an area determined after the first target area is expanded in the initial conversion image.
[0095] Optionally, the expansion parameter may be an offset distance of each boundary of the first target area offset outward in a corresponding vertical direction. For example, please refer to Figure 4 , Figure 4 This is a schematic diagram of the area expansion of an image processing method provided in an embodiment of the present application. Assuming that the offset distance is d, each boundary of the first target area can be moved outward by a distance d in the vertical direction of the boundary to obtain an initial area. Among them, the offset distance of each boundary can be different or the same, and can be set according to actual needs. Optionally, the first target area can also be expanded in the direction from the center of the first target area to each vertex of the first target area, and other methods can also be used to expand the first target area, which can be set according to actual conditions, and the embodiment of the present application is not limited here.
[0096] After extracting the target area image from the initial conversion image based on the target detection frame and inputting it into the image restoration model, the target area where the target part is located in the target area image can also be marked to obtain the target area information. There are many ways to mark the target area where the target part is located in the target area image. For example, the target area can be the area where the target part is located, that is, it can be the area corresponding to the target detection frame. In this way, the corresponding area of the target detection frame in the target area image can be marked in the target area image to obtain the target area information. For example, an image with the same image size as the target area image can be obtained, and the pixel value of each pixel in the image is set to 0, that is, black, and the pixel value of each pixel in the target area where the target part is located in the image is set to 1, that is, white, so as to achieve the marking of the target area, and the image can be used as the target area information.
[0097] Optionally, the target part feature information may include key point information and image features of the target part in the image to be processed. Therefore, the control feature may be a feature extracted from the key point information and image features, and may include the position distribution of the key points of the target part in the image to be processed and the shape features corresponding to each key point and other information. Therefore, based on the control feature, the image restoration model can obtain the position distribution of the key points of the target part in the target area of the target area image to be restored, and can also obtain the shape features corresponding to each key point, for example, the curvature of the mouth, the line of sight of the eyes and other information. Therefore, based on the relevant feature information of the target part in the image to be processed, the target area image can be restored more accurately and more closely to the image to be processed, thereby improving the image restoration effect.
[0098] Among them, there can be many ways to extract feature information of the target part through the repair control model. For example, the target part can be a face part, and the target part feature information includes facial key point information and facial image. Feature extraction can be performed on the facial image, and the facial image features are input into the repair control model. Feature extraction of facial key point information and facial image features can be performed through the repair control model.
[0099] The facial key point information may be information describing the position distribution of facial key points, the facial image may be an image containing a human face, and the facial image feature may be an image feature of a part of a human face.
[0100] There are many ways to extract facial key point information and facial image features through the repair control model. For example, a preset image of the target image size can be obtained, and key points can be drawn in the preset image based on the facial key point information to obtain a key point image indicating the position distribution of facial key points in the target part. The key point image and facial image features can be extracted through the repair control model.
[0101] Among them, the preset image can be a pre-set image, for example, the preset image can be an image with a pixel value of 0, that is, a black image, or other types of images, which can be set specifically according to actual needs. The key point image can be an image indicating the position distribution of facial key points in the target part. Optionally, in order to correspond between feature information, the image size of the key point image should be the same as the image size of the target area image, and accordingly, the area where the key points in the key point image are distributed should correspond to the target area where the target part is located in the target area image. Therefore, the area where the corresponding target part is located in the preset image can be determined based on the area where the target part is located in the target area image, so that key points can be drawn in the area where the target part is located in the preset image according to the facial key point information to obtain a key point image.
[0102] Optionally, after expanding the first target area to obtain the target area image, when drawing key points in the preset image based on the facial key point information, the key points can be drawn in the preset image based on the facial key point information, the expansion parameters and the target image size.
[0103] There are many ways to draw key points in a preset image based on facial key point information, expansion parameters and target image size. For example, the image size of the initial area image can be obtained to obtain a first image size, and image scaling parameters can be determined according to the first image size and the target image size. The shrinkage parameters are determined according to the expansion parameters, so that key points can be drawn in the preset image according to the shrinkage parameters and the image scaling parameters, as well as the facial key point information.
[0104] Among them, the image scaling parameter can be a parameter for scaling the initial area image to the target area image, for example, it can be a magnification factor for enlarging the initial area image to the target area image, and the shrinkage parameter can be a parameter for shrinking the area in a preset image, wherein the offset direction of the shrinkage parameter is opposite to the offset direction of the expansion parameter, and the offset distance value of the shrinkage parameter is the same as the offset distance value of the expansion parameter.
[0105] Among them, there can be multiple ways to draw key points in a preset image based on the indentation parameters, image scaling parameters, and facial key point information. For example, the offset distance value of the indentation parameters can be weighted according to the image scaling parameters to obtain a target offset distance value, and the facial key point information can be adjusted according to the image scaling parameters to obtain target facial key point information that describes the position distribution of the facial key points in the enlarged target detection frame. Therefore, regional indentation can be performed in the preset image according to the target offset distance value, and the area corresponding to the enlarged target detection frame can be determined in the preset image. Therefore, key points can be drawn in the preset image according to the position distribution of the target facial key point information in the enlarged target detection frame to obtain a key point image.
[0106] There are many ways to perform image fusion processing on the restored target area image and the initial conversion image to obtain the target image of the image to be processed in the target style. For example, a fusion area can be determined in the initial conversion image based on the target area image, and the restored target area image can be pasted to the initial conversion image based on the fusion area to obtain the target image of the image to be processed in the target style.
[0107] The fusion region may be the region where the target region image is located in the initial conversion image.
[0108] There are many ways to paste the repaired target area image to the initial conversion image based on the fusion area. For example, the repaired target area image can be resized according to the size of the fusion area so that the image size of the repaired target area image is the same as the fusion area, so that the repaired target area image after size adjustment can be pasted to the fusion area of the initial conversion image to obtain the target image of the image to be processed in the target style.
[0109] As can be seen from the above, the embodiment of the present application performs target object detection on the image to be processed; when it is detected that there is a target object in the image to be processed, the object posture feature of the target object is extracted from the image to be processed, and the control information corresponding to the image to be processed is determined based on the object posture feature; when it is detected that there is no target object in the image to be processed, the image edge feature is extracted from the image to be processed, and the control information corresponding to the image to be processed is determined based on the image edge feature; the image drawing model is used to perform target style conversion on the image to be processed based on the control information to obtain the target image under the target style corresponding to the image to be processed. In this way, the image type of the image to be processed is determined by detecting whether there is a target object in the image to be processed, and different types of image features are extracted from the image to be processed according to whether there is a target object in the image to be processed, so as to determine the control information matching the current image type, and the image drawing model is guided to perform target style conversion on the image to be processed according to the determined control information, so as to effectively improve the stability of the image generated by the image drawing model, thereby improving the image processing effect.
[0110] In order to better implement the above method, an embodiment of the present invention further provides an image processing apparatus, which can be integrated in a computer device, and the computer device can be a server.
[0111] For example, Figure 5 As shown, it is a schematic diagram of the structure of the image processing device provided in an embodiment of the present application. The image processing device may include an object detection unit 201, a first determination unit 202, a second determination unit 203 and an image generation unit 204, as follows:
[0112] An object detection unit 201 is used to detect a target object on the image to be processed;
[0113] The first determining unit 202 is used to extract the object posture feature of the target object in the image to be processed when detecting that there is a target object in the image to be processed, and determine the control information corresponding to the image to be processed based on the object posture feature;
[0114] The second determining unit 203 is used to extract image edge features from the image to be processed when it is detected that there is no target object in the image to be processed, and determine the control information corresponding to the image to be processed based on the image edge features;
[0115] The image generation unit 204 is used to perform target style conversion on the image to be processed based on the control information by using the image rendering model to obtain a target image in a target style corresponding to the image to be processed.
[0116] In one embodiment, the image processing apparatus further includes a first style conversion description information determining unit, configured to:
[0117] Identifying object attribute information of a target object in the image to be processed;
[0118] Determine first target style conversion description information of the image to be processed based on the object attribute information and the first style conversion description information, where the first style conversion description information is style conversion description information preset for the image carrying the target object;
[0119] The first determining unit 202 is configured to:
[0120] Based on the object posture feature and the first target style conversion description information, control information corresponding to the image to be processed is determined.
[0121] In one embodiment, the object attribute information includes one or more information of the number of objects, the object category, and the object posture of the target object.
[0122] In one embodiment, the second determining unit 203 is configured to:
[0123] Acquire second style transfer description information, where the second style transfer description information is style transfer description information preset for an image that does not carry a target object;
[0124] The image edge features and the second style conversion description information are determined as control information corresponding to the image to be processed.
[0125] In one embodiment, when there is a target object in the image to be processed, the image generating unit 204 includes:
[0126] An image conversion subunit is used to perform a target style conversion on the image to be processed based on the control information using an image rendering model to obtain an initial converted image under the target style corresponding to the image to be processed;
[0127] An object part detection subunit, used for performing object part detection on the initial conversion image;
[0128] A size information acquisition subunit, for acquiring size information of a region where the target part is located in the initial conversion image if a target part is detected in the initial conversion image;
[0129] The image restoration subunit is used to use the image restoration model to restore the target part in the initial conversion image to obtain the target image when the size information meets the size judgment condition corresponding to the image restoration.
[0130] In one embodiment, the image restoration subunit includes:
[0131] A part detection module, used to identify a target detection frame where a target part is located in the image to be processed, and target part feature information identified in the target part based on the target detection frame;
[0132] The first extraction module is used to extract the target area image from the initial conversion image based on the target detection frame and input it into the image restoration model, mark the area where the target part is located in the target area image, and obtain the target area information and input it into the image restoration model;
[0133] The second extraction module is used to extract the feature information of the target part through the repair control model, and obtain the control feature to input into the image repair model;
[0134] An image restoration module is used to perform a restoration process on a target area in the target area image based on the control feature, the target area image and the target area information through an image restoration model to obtain a restored target area image;
[0135] The image fusion module is used to perform image fusion processing on the restored target area image and the initial converted image to obtain a target image of the image to be processed in the target style.
[0136] In one embodiment, the image fusion module is used to:
[0137] Determine a fusion region in the initial transformed image based on the target region image;
[0138] The repaired target area image is pasted to the initial converted image based on the fusion region to obtain the target image of the image to be processed in the target style.
[0139] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0140] As can be seen from the above, the embodiment of the present application performs target object detection on the image to be processed by the object detection unit 201; when the first determination unit 202 detects that there is a target object in the image to be processed, it extracts the object posture feature of the target object in the image to be processed, and determines the control information corresponding to the image to be processed based on the object posture feature; when the second determination unit 203 detects that there is no target object in the image to be processed, it extracts the image edge feature in the image to be processed, and determines the control information corresponding to the image to be processed based on the image edge feature; the image generation unit 204 uses the image drawing model to perform target style conversion on the image to be processed based on the control information, and obtains the target image under the target style corresponding to the image to be processed. In this way, the image type of the image to be processed is determined by detecting whether there is a target object in the image to be processed, so that different types of image features are extracted from the image to be processed according to whether there is a target object in the image to be processed, so as to determine the control information matching the current image type, and guide the image drawing model to perform target style conversion on the image to be processed according to the determined control information, so as to effectively improve the stability of the image generated by the image drawing model, thereby improving the image processing effect.
[0141] The present application also provides a computer device, such as Figure 6 As shown, it shows a schematic diagram of the structure of a computer device involved in an embodiment of the present application, and the computer device may be a server, specifically:
[0142] The computer device may include one or more processing core processors 301, one or more computer readable storage media memories 302, a power supply 303, an input unit 304 and other components. Those skilled in the art will appreciate that Figure 6 The computer device structure shown in the figure does not constitute a limitation on the computer device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently. Among them:
[0143] The processor 301 is the control center of the computer device. It uses various interfaces and lines to connect various parts of the entire computer device. It executes various functions of the computer device and processes data by running or executing software programs and / or modules stored in the memory 302, and calling data stored in the memory 302. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 301.
[0144] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and data processing by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an 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 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0145] The computer device also includes a power supply 303 for supplying power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, so as to manage charging, discharging, and power consumption through the power management system. The power supply 303 can also include any components such as one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, and power status indicators.
[0146] The computer device may further include an input unit 304, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0147] Although not shown, the computer device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 301 in the computer device will load the executable files corresponding to the processes of one or more application programs into the memory 302 according to the following instructions, and the processor 301 will run the application programs stored in the memory 302, thereby realizing various functions, as follows:
[0148] Perform target object detection on the image to be processed; when it is detected that there is a target object in the image to be processed, extract the object posture features of the target object in the image to be processed, and determine the control information corresponding to the image to be processed based on the object posture features; when it is detected that there is no target object in the image to be processed, extract the image edge features in the image to be processed, and determine the control information corresponding to the image to be processed based on the image edge features; use an image drawing model to perform target style conversion on the image to be processed based on the control information, and obtain a target image under the target style corresponding to the image to be processed.
[0149] The specific implementation of each of the above operations can be found in the previous embodiments, which will not be described in detail here. It should be noted that the computer device provided in the embodiment of the present application and the image processing method in the above embodiment belong to the same concept, and its specific implementation process is detailed in the above method embodiment, which will not be described in detail here.
[0150] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0151] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any one of the image processing methods provided in the embodiments of the present application. For example, the instructions can execute the following steps:
[0152] Perform target object detection on the image to be processed; when it is detected that there is a target object in the image to be processed, extract the object posture features of the target object in the image to be processed, and determine the control information corresponding to the image to be processed based on the object posture features; when it is detected that there is no target object in the image to be processed, extract the image edge features in the image to be processed, and determine the control information corresponding to the image to be processed based on the image edge features; use an image drawing model to perform target style conversion on the image to be processed based on the control information, and obtain a target image under the target style corresponding to the image to be processed.
[0153] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0154] Since the instructions stored in the computer-readable storage medium can execute the steps in any image processing method provided in the embodiments of the present application, the beneficial effects that can be achieved by any image processing method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0155] According to one aspect of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the methods provided in the various optional implementations provided in the above embodiments.
[0156] The above is a detailed introduction to an image processing method, device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image processing method, characterized in that: include: Perform target object detection on the image to be processed; When detecting that a target object exists in the image to be processed, extracting an object posture feature of the target object in the image to be processed; Identifying object attribute information of the target object in the image to be processed; Determine first target style conversion description information of the image to be processed based on the object attribute information and the first style conversion description information, where the first style conversion description information is style conversion description information preset for the image carrying the target object; Determining control information corresponding to the image to be processed based on the object posture feature and the first target style conversion description information; When it is detected that the target object does not exist in the image to be processed, image edge features are extracted from the image to be processed, and control information corresponding to the image to be processed is determined based on the image edge features; An image rendering model is used to perform target style conversion on the image to be processed based on the control information to obtain a target image under the target style corresponding to the image to be processed.
2. The image processing method according to claim 1, characterized in that: The object attribute information includes one or more information of the number of objects, the object category, and the object posture of the target object.
3. The image processing method according to claim 1, characterized in that: The determining the control information corresponding to the image to be processed based on the image edge feature includes: Acquire second style transfer description information, where the second style transfer description information is style transfer description information preset for an image that does not carry a target object; The image edge feature and the second style conversion description information are determined as control information corresponding to the image to be processed.
4. The image processing method according to any one of claims 1 to 3, characterized in that: When the target object exists in the image to be processed, the image rendering model is used to perform target style conversion on the image to be processed based on the control information to obtain a target image under the target style corresponding to the image to be processed, including: Using an image rendering model to perform target style conversion on the image to be processed based on the control information to obtain an initial converted image under the target style corresponding to the image to be processed; Performing target part detection on the initial conversion image; If it is detected that a target part exists in the initial conversion image, obtaining size information of a region where the target part is located in the initial conversion image; When the size information satisfies the size determination condition corresponding to the image restoration, the target part in the initial conversion image is restored by using the image restoration model to obtain the target image.
5. The image processing method according to claim 4, characterized in that: The method of using an image restoration model to restore the target part in the initial converted image to obtain a target image includes: Identifying a target detection frame in which the target part is located in the image to be processed, and target part feature information identified in the target part based on the target detection frame; Extracting a target area image from the initial conversion image based on the target detection frame and inputting it into an image restoration model, marking the area where the target part is located in the target area image, and obtaining target area information and inputting it into the image restoration model; Extracting feature information of the target part through a repair control model to obtain control features and input them into the image repair model; Performing a target area repair process on the target area in the target area image based on the control feature, the target area image and the target area information by the image repair model to obtain a repaired target area image; The restored target area image and the initial conversion image are subjected to image fusion processing to obtain a target image of the image to be processed in the target style.
6. The image processing method according to claim 5, characterized in that: The step of performing image fusion processing on the restored target area image and the initial conversion image to obtain a target image of the image to be processed in the target style includes: Determining a fusion region in the initial conversion image based on the target region image; The restored target area image is pasted to the initial conversion image based on the fusion area to obtain a target image of the image to be processed in the target style.
7. An image processing device, characterized in that: include: An object detection unit, used for detecting a target object in an image to be processed; A first determining unit is used to extract an object posture feature of the target object from the image to be processed when detecting that there is a target object in the image to be processed, and determine control information corresponding to the image to be processed based on the object posture feature and first target style conversion description information; A first style conversion description information determining unit is used to identify object attribute information of the target object in the image to be processed, and determine first target style conversion description information of the image to be processed based on the object attribute information and the first style conversion description information, where the first style conversion description information is style conversion description information preset for the image carrying the target object; A second determining unit is configured to extract image edge features from the image to be processed when it is detected that the target object does not exist in the image to be processed, and determine control information corresponding to the image to be processed based on the image edge features; An image generation unit is used to use an image rendering model to perform a target style conversion on the image to be processed based on the control information to obtain a target image under a target style corresponding to the image to be processed.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the image processing method according to any one of claims 1 to 6.
9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the image processing method according to any one of claims 1 to 6 when executing the computer program.
Citation Information
Patent Citations
Image generation method and device, storage medium and terminal equipment
CN107845072A
Image style conversion method and device, equipment and computer storage medium
CN109685749A
Image style conversion method and device, electronic equipment and storage medium
CN112150489A
Image style migration method, program product, storage medium and electronic equipment
CN115222578A
Image processing apparatus, image processing method, and image processing program
WO2017115442A1
