Method, device, electronic device and readable storage medium for editing human face
Through the attribute conversion, semantic segmentation and fusion technology of face images, the problems of high face editing cost and low flexibility in the existing technology are solved, and free editing of different parts of the face under different needs is achieved, which improves the quality of human face editing. Face editing flexibility.
Patent Information
- Application Number
- CN202010576349.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-22
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2040-06-22
AI Technical Summary
The existing technology has high cost and low editing flexibility in face editing, and cannot realize free editing of different parts of the face under different needs.
By obtaining the face image in the image to be processed, attribute conversion is performed to generate an attribute image, semantic segmentation is performed to generate a mask image, and the mask image is fused with the image to be processed to generate a result image.
It reduces the cost of face editing, increases the flexibility of face editing, and enables free editing of different parts of the face under different needs.
Smart Images

Figure CN111861954B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, device, electronic device and readable storage medium for editing faces in the field of image processing and deep learning technology. Background Art
[0002] Currently, short video and live video applications are widely used by more and more users. Among these applications, there are interactive functions related to the face, such as face beauty, face shaping, face editing, and facial expression triggering animation effects.
[0003] Among them, the existing technology usually adopts the method of fusing pre-set stickers with the face to realize face editing. However, face editing by manually setting stickers is very costly on the one hand, and on the other hand, all users use the same set of stickers, which cannot realize the free editing of different parts of the face according to different needs. Summary of the invention
[0004] The technical solution adopted by the present application to solve the technical problem is to provide a method for editing faces, including: obtaining a face image in an image to be processed; performing attribute conversion on the face image according to editing attributes to generate an attribute image; after semantically segmenting the attribute image, processing the semantic segmentation image according to the editing attributes to generate a mask image; and using the mask image to fuse the attribute image with the image to be processed to generate a result image.
[0005] The technical solution adopted by the present application to solve the technical problem is to provide a device for editing human faces, including: an acquisition unit, used to acquire a human face image in an image to be processed; a conversion unit, used to perform attribute conversion on the human face image according to editing attributes to generate an attribute image; a processing unit, used to perform semantic segmentation on the attribute image, and then process the semantic segmentation image according to the editing attributes to generate a mask image; a fusion unit, used to use the mask image to fuse the attribute image with the image to be processed to generate a result image.
[0006] An electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above method.
[0007] A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the above method.
[0008] A computer program product comprises a computer program, wherein the computer program implements the above method when executed by a processor.
[0009] One embodiment of the above application has the following advantages or beneficial effects: the application can reduce the cost of editing faces, realize free editing of different parts of faces under different requirements, and increase the flexibility of face editing. Because the technical means of processing semantic segmentation images according to editing attributes to generate mask images is adopted, the technical problems of high cost and low editing flexibility caused by face fusion through stickers in the prior art are overcome, and the technical effect of increasing the flexibility of face editing is achieved.
[0010] Other effects of the above optional manner will be described below in conjunction with specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present application.
[0012] Figure 1 is a schematic diagram according to the first embodiment of the present application;
[0013] Figures 2A to 2E is a schematic diagram according to a second embodiment of the present application;
[0014] Figure 3 is a schematic diagram according to a third embodiment of the present application;
[0015] Figure 4 It is a block diagram of an electronic device used to implement the method for editing faces in an embodiment of the present application. DETAILED DESCRIPTION
[0016] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0017] Figure 1 is a schematic diagram according to the first embodiment of the present application. Figure 1 As shown in , the method for editing a face in this embodiment may specifically include the following steps:
[0018] S101, obtaining a face image in an image to be processed;
[0019] S102, performing attribute conversion on the face image according to the editing attributes to generate an attribute image;
[0020] S103, after semantic segmentation of the attribute image, processing the semantic segmentation image according to the editing attribute to generate a mask image;
[0021] S104: Using the mask image, fuse the attribute image with the image to be processed to generate a result image.
[0022] The method for editing a face in this embodiment can realize free editing of different parts of a face under different requirements, thereby increasing the flexibility of face editing.
[0023] The image to be processed in this embodiment may be a single image or may be each frame image split from a video. If the image to be processed in this embodiment is each frame image in a video, after obtaining the result images corresponding to each frame image, each result image is sequentially combined to generate a result video.
[0024] When acquiring a face image in an image to be processed, this embodiment may adopt the following method: performing face key point detection on the image to be processed to acquire face key point information; and extracting a face image from the image to be processed based on the acquired face key point information.
[0025] It is understandable that this embodiment may also use a pre-trained neural network model to obtain a facial image from an image, and this embodiment does not limit the method of obtaining the facial image.
[0026] Since different images to be processed may have different sizes, in order to ensure that face editing can be completed for images to be processed of different sizes, after acquiring the face image, this embodiment may also affine transform the face image to a preset size, where the preset size may be 256*256.
[0027] In order to obtain a better attribute image, this embodiment may further include the following contents before performing attribute conversion on the face image according to the editing attributes: performing preprocessing on the face image corresponding to the editing attributes, wherein different editing attributes correspond to different preprocessing.
[0028] For example, if the editing attribute is "become smaller" and the preprocessing corresponding to the editing attribute is warp, then before the attributes of the facial image are converted according to the editing attribute, the preprocessing performed in this embodiment is to reduce the chin of the face in the facial image; if the editing attribute is "become female" and the preprocessing corresponding to the editing attribute is padding, then before the attributes of the facial image are converted according to the editing attribute, the preprocessing performed in this embodiment is to fill the background in the facial image (i.e., fill the hair).
[0029] After acquiring the face image, this embodiment converts the face image according to the editing attributes to generate an attribute image corresponding to the face image. The editing attributes in this embodiment include at least one of the gender attribute and the age attribute, the gender attribute includes changing to male or female, and the age attribute includes changing to younger or older, that is, this embodiment converts the gender and / or age of the face in the image.
[0030] Therefore, in the attribute image generated by this embodiment, except for the change of the attributes of the face, the identity, expression, posture and other features of the face in the image remain unchanged. Taking the editing attribute as "aging" as an example, after inputting a young face image of user A, the attribute image generated by this embodiment is an old face image of user A, and the expression, posture and other features of user A in the old image are consistent with those in the young image.
[0031] The editing attribute in this embodiment can be determined according to the user's choice. In this embodiment, the editing attribute can also be determined according to the attribute corresponding to the current attribute. If the current attribute is young and the attribute corresponding to the current attribute is old, the editing attribute can be "get older"; if the current attribute is female and the attribute corresponding to the current attribute is male, the editing attribute can be "get male".
[0032] In this embodiment, when performing attribute conversion on a face image according to editing attributes to generate an attribute image, stickers corresponding to the editing attributes may be first obtained, and then the obtained stickers may be merged with the face image to obtain the attribute image.
[0033] When converting the attributes of a face image according to the editing attributes to generate an attribute image, the present embodiment may also adopt the following method: input the editing attributes and the face image into a pre-trained attribute editing model, and use the output result of the attribute editing model as the attribute image. The attribute editing model in the present embodiment belongs to a deep learning neural network, which can automatically edit the attributes of the face in the face image according to the editing attributes, thereby obtaining an attribute image after attribute conversion.
[0034] It can be understood that the attribute editing model in this embodiment is a generative model in a generative adversarial network. By simultaneously modeling the foreground image, fusion mask and background image when training the generative adversarial network, the trained generative model can fill in the missing parts of the background in the generated attribute image, thereby obtaining an attribute image with better conversion effect.
[0035] After obtaining the attribute image corresponding to the face image, this embodiment first performs semantic segmentation on the generated attribute image to obtain a semantic segmentation image, and then processes the obtained semantic segmentation image according to the editing attributes to generate a mask image. The mask image generated in this embodiment is a binary image composed of 0 and 1. The mask image is used to control the area of image fusion. The area with a pixel value of 1 in the mask image selects the content in the attribute image, and the area with a pixel value of 0 selects the content in the image to be processed.
[0036] The semantic segmentation performed in this embodiment is to segment the various parts of the face in the attribute image, for example, to separate the eyes, nose, mouth, eyebrows, hair and other parts of the face, and to use different colors to represent different parts in the semantic segmentation image. This embodiment can use the existing technology to perform semantic segmentation on the attribute image to obtain the semantic segmentation image, which will not be described in detail here.
[0037] When this embodiment processes a semantic segmentation image according to editing attributes to generate a mask image, the following method can be adopted: determining the editing part corresponding to the editing attribute, where different editing attributes correspond to different editing parts; setting the value of the pixels in the semantic segmentation image belonging to the determined editing part to 1, and setting the values of other pixels to 0, to obtain a mask image.
[0038] For example, if the editing attribute is "getting older", if the editing parts corresponding to the editing attribute are eyes, nose, mouth, eyebrows, chin, cheeks, and forehead, then the values of the pixels belonging to the above parts in the semantic segmentation image are set to 1, and the values of other pixels are set to 0; if the editing attribute is "getting female", if the editing parts corresponding to the editing attribute are eyes, mouth, eyebrows, and chin, then the values of the pixels belonging to the above parts in the semantic segmentation image are set to 1, and the values of other pixels are set to 0.
[0039] Therefore, this embodiment processes the semantic segmentation image by combining the editing attributes so that the generated mask image can correspond to different editing attributes, thereby achieving the purpose of freely editing different parts of the face under different requirements.
[0040] After generating the mask image, this embodiment uses the generated mask image to fuse the attribute image with the image to be processed, thereby generating a result image corresponding to the image to be processed.
[0041] In addition, before using the generated mask image to fuse the attribute image with the image to be processed, this embodiment may also include the following: performing super-resolution processing on the attribute image to generate an ultra-clear attribute image; using the mask image to fuse the ultra-clear attribute image with the image to be processed.
[0042] This embodiment obtains an ultra-clear attribute image through super-resolution processing. On the one hand, it can expand the size of the attribute image (for example, expanding a 256*256 image to a 512*512 image) to better match the size of the user's face; on the other hand, it can remove the blur in the attribute image.
[0043] In order to improve the accuracy of the fusion between the attribute image and the image to be processed, this embodiment can adopt the following method when using the mask image to fuse the attribute image and the image to be processed: align the mask image, the attribute image and the image to be processed according to the face position; determine the area in the image to be processed whose pixel value is 0 in the corresponding mask image, and keep the image content of the area unchanged; determine the area in the image to be processed whose pixel value is 1 in the corresponding mask image, and replace the image content of the area with the image content of the corresponding area in the attribute image.
[0044] That is to say, this embodiment fuses the attribute image and the image to be processed according to the generated mask image. Since the mask image corresponds to the editing attribute, only the corresponding image content in the attribute image is used to replace the image content in the image to be processed, thereby achieving the purpose of freely editing different parts of the face under different requirements and improving the flexibility of face editing.
[0045] It is understandable that if this embodiment performs a size transformation after acquiring the face image, then when this embodiment aligns the mask image, the attribute image and the image to be processed according to the face position, it is also necessary to transform the size of the mask image and the attribute image to the size of the face in the image to be processed.
[0046] Through the above method disclosed in this embodiment, the face image is first converted according to the editing attributes to generate an attribute image, and then the attribute image is processed according to the editing attributes to generate a mask image. Finally, the mask image is used to fuse the attribute image and the image to be processed to generate a result image. Free editing of different parts of the face can be achieved under different requirements, thereby increasing the flexibility of face editing.
[0047] Figures 2A to 2E is a schematic diagram according to the second embodiment of the present application, Figure 2A is the image to be processed and the face image in it, Figure 2B is the attribute image of the face image, Figure 2C is the semantic segmentation image and mask image of the attribute image, Figure 2D To create an ultra-high-definition attribute image that doubles the size of the attribute image, Figure 2E is the result image of the image to be processed. Compared with the image to be processed, except that the facial attributes (aging) of the corresponding parts in the mask image have changed, other features of the result image have not changed.
[0048] Figure 3 is a schematic diagram according to the third embodiment of the present application. Figure 3 As shown in , the apparatus for editing a face in this embodiment includes:
[0049] An acquisition unit 301 is used to acquire a face image in an image to be processed;
[0050] The conversion unit 302 is used to perform attribute conversion on the face image according to the editing attribute to generate an attribute image;
[0051] The processing unit 303 is used to process the semantic segmentation image according to the editing attribute after semantic segmentation of the attribute image to generate a mask image;
[0052] The fusion unit 304 is used to fuse the attribute image with the image to be processed by using the mask image to generate a result image.
[0053] When acquiring the face image in the image to be processed, the acquisition unit 301 in this embodiment may adopt the following method: perform face key point detection on the image to be processed to acquire face key point information; and extract the face image from the image to be processed based on the acquired face key point information.
[0054] It is understandable that the acquisition unit 301 may also use a pre-trained neural network model to acquire a facial image from an image. This embodiment does not limit the method for acquiring the facial image.
[0055] Since different images to be processed may have different sizes, in order to ensure that the face editing can be completed for images to be processed of different sizes, after acquiring the face image, the acquisition unit 301 can also affine transform the face image to a preset size, where the preset size can be 256*256.
[0056] In order to obtain a better attribute image, before the conversion unit 302 performs attribute conversion on the face image according to the editing attribute, the conversion unit 302 may further include the following contents: performing preprocessing on the face image corresponding to the editing attribute, wherein different editing attributes correspond to different preprocessing.
[0057] In this embodiment, after the acquisition unit 301 acquires the face image, the conversion unit 302 performs attribute conversion on the face image according to the edit attribute to generate an attribute image corresponding to the face image. The edit attribute in the conversion unit 302 includes at least one of a gender attribute and an age attribute, the gender attribute includes changing to male or female, and the age attribute includes changing to younger or older, that is, the conversion unit 302 converts the gender and / or age of the face in the image.
[0058] Therefore, in the attribute image generated by the conversion unit 302, except for the change in the attributes of the face, the identity, expression, posture and other features of the face in the image remain unchanged.
[0059] The editing attribute in the conversion unit 302 can be determined according to the user's selection. The conversion unit 302 can also determine the editing attribute according to the attribute corresponding to the current attribute.
[0060] When performing attribute conversion on the face image according to the editing attributes to generate the attribute image, the conversion unit 302 may first obtain stickers corresponding to the editing attributes, and then fuse the obtained stickers with the face image to obtain the attribute image.
[0061] When the conversion unit 302 converts the attributes of the face image according to the editing attributes to generate the attribute image, the following method can also be adopted: the editing attributes and the face image are input into the pre-trained attribute editing model, and the output result of the attribute editing model is used as the attribute image. The attribute editing model in the conversion unit 302 can automatically edit the attributes of the face in the face image according to the editing attributes, so as to obtain the attribute image after the attribute conversion.
[0062] In this embodiment, after the conversion unit 302 obtains the attribute image corresponding to the face image, the processing unit 303 first performs semantic segmentation on the generated attribute image to obtain a semantic segmentation image, and then processes the obtained semantic segmentation image according to the editing attribute to generate a mask image. The mask image generated by the processing unit 303 is a binary image composed of 0 and 1. The mask image is used to control the area of image fusion. The area with a pixel value of 1 in the mask image selects the content in the attribute image, and the area with a pixel value of 0 selects the content in the image to be processed.
[0063] The semantic segmentation performed by the processing unit 303 is to segment the various parts of the face in the attribute image, such as dividing the eyes, nose, mouth, eyebrows, hair and other parts of the face, and using different colors to represent different parts in the semantic segmentation image.
[0064] When the processing unit 303 processes the semantic segmentation image according to the editing attributes to generate a mask image, the following method can be adopted: determine the editing part corresponding to the editing attribute, and different editing attributes correspond to different editing parts; set the value of the pixel belonging to the determined editing part in the semantic segmentation image to 1, and set the value of other pixels to 0, to obtain a mask image.
[0065] Therefore, the processing unit 303 processes the semantic segmentation image by combining the editing attributes, so that the generated mask image can correspond to different editing attributes, thereby achieving the purpose of freely editing different parts of the face under different requirements.
[0066] After the processing unit 303 generates the mask image, the fusion unit 304 fuses the attribute image with the image to be processed using the generated mask image, thereby generating a result image corresponding to the image to be processed.
[0067] In addition, before the fusion unit 304 uses the generated mask image to fuse the attribute image with the image to be processed, it can also include the following contents: performing super-resolution processing on the attribute image to generate an ultra-clear attribute image; using the mask image to fuse the ultra-clear attribute image with the image to be processed.
[0068] The fusion unit 304 obtains an ultra-clear attribute image through super-resolution processing. On the one hand, it can expand the size of the attribute image (for example, expanding a 256*256 image to a 512*512 image) to better match the size of the user's face; on the other hand, it can remove the blur in the attribute image.
[0069] In order to improve the accuracy of the fusion between the attribute image and the image to be processed, the fusion unit 304 can adopt the following method when using the mask image to fuse the attribute image with the image to be processed: align the mask image, the attribute image and the image to be processed according to the position of the face; determine the area in the image to be processed whose pixel value is 0 in the corresponding mask image, and keep the image content of the area unchanged; determine the area in the image to be processed whose pixel value is 1 in the corresponding mask image, and replace the image content of the area with the image content of the corresponding area in the attribute image.
[0070] That is to say, the fusion unit 304 fuses the attribute image and the image to be processed according to the generated mask image. Since the mask image corresponds to the editing attribute, only the corresponding image content in the attribute image is used to replace the image content in the image to be processed, thereby achieving the purpose of freely editing different parts of the face under different requirements, thereby improving the flexibility of face editing.
[0071] It is understandable that if the acquisition unit 301 performs a size transformation after acquiring the face image, then when the fusion unit 304 aligns the mask image, the attribute image and the image to be processed according to the face position, it is also necessary to transform the size of the mask image and the attribute image to the size of the face in the image to be processed.
[0072] According to an embodiment of the present application, the present application also provides an electronic device, a computer-readable storage medium, and a computer program product.
[0073] like Figure 4 , is a block diagram of an electronic device for a method of editing a face according to an embodiment of the present application. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0074] like Figure 4 As shown, the electronic device includes: one or more processors 401, a memory 402, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are interconnected using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to an interface). In other embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 4 A processor 401 is taken as an example.
[0075] The memory 402 is a non-transitory computer-readable storage medium provided in the present application. The memory stores instructions executable by at least one processor to enable the at least one processor to perform the method for editing a face provided in the present application. The non-transitory computer-readable storage medium of the present application stores computer instructions, which are used to enable a computer to perform the method for editing a face provided in the present application.
[0076] The memory 402 is a non-transient computer-readable storage medium that can be used to store non-transient software programs, non-transient computer executable programs and modules, such as the program instructions / modules corresponding to the method for editing a face in the embodiment of the present application (for example, the attached Figure 3 The processor 401 executes various functional applications and data processing of the server by running the non-transient software programs, instructions and modules stored in the memory 402, that is, the method for editing faces in the above method embodiment is implemented.
[0077] The memory 402 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and applications required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 402 may optionally include a memory remotely arranged relative to the processor 401, and these remote memories may be connected to the electronic device of the method for editing a face via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0078] The electronic device of the method for editing a face may further include: an input device 403 and an output device 404. The processor 401, the memory 402, the input device 403 and the output device 404 may be connected via a bus or other means. Figure 4 The example of connecting through bus is taken in the following.
[0079] The input device 403 can receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device of the method for editing human faces, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick and other input devices. The output device 404 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display and a plasma display. In some embodiments, the display device may be a touch screen.
[0080] Various implementations of the systems and techniques described herein can be realized in digital electronic circuit systems, integrated circuit systems, dedicated ASICs (application specific integrated circuits), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0081] These computer programs (also referred to as programs, software, software applications, or code) include machine instructions for programmable processors and can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or means (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0082] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0083] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0084] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0085] According to the technical solution of the embodiment of the present application, the facial image is first converted according to the editing attributes to generate an attribute image, and then the attribute image is processed according to the editing attributes to generate a mask image. Finally, the mask image is used to fuse the attribute image and the image to be processed to generate a result image. This allows free editing of different parts of the face under different requirements, thereby increasing the flexibility of face editing.
[0086] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0087] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A method for editing a face, include: Obtaining a face image in an image to be processed; Performing attribute conversion on the face image according to an editing attribute to generate an attribute image, wherein the editing attribute is an attribute corresponding to a current attribute of the face image, and the editing attribute includes at least one of a gender attribute and an age attribute; After semantic segmentation of the attribute image, the semantic segmentation image is processed according to the edit attribute to generate a mask image; Using the mask image to fuse the attribute image with the image to be processed to generate a result image; The step of processing the semantic segmentation image according to the editing attribute to generate a mask image comprises: Determining an editing location corresponding to the editing attribute; The values of pixels belonging to the edited part in the semantic segmentation image are set to 1, and the values of other pixels are set to 0, to obtain a mask image.
2. The method according to claim 1, further comprising: After acquiring the face image in the image to be processed, the face image is transformed into a preset size.
3. The method according to claim 1, further comprising: Before performing attribute conversion on the face image according to the editing attribute, preprocessing corresponding to the editing attribute is performed on the face image.
4. The method according to claim 1, further comprising: Before using the mask image to fuse the attribute image with the image to be processed, performing super-resolution segmentation on the attribute image to generate an ultra-clear attribute image; The ultra-high definition attribute image is fused with the image to be processed by using the mask image.
5. The method according to claim 1, in, The step of fusing the attribute image with the image to be processed by using the mask image to generate a result image comprises: According to the face position, aligning the mask image, the attribute image and the image to be processed; Determine an area in the image to be processed corresponding to a pixel value of 0 in the mask image, and keep the image content of the area unchanged; Determine an area in the image to be processed corresponding to a pixel value of 1 in the mask image, and replace the image content of the area with the image content of the corresponding area in the attribute image.
6. A device for editing human faces, include: An acquisition unit, used for acquiring a face image in an image to be processed; a conversion unit, configured to perform attribute conversion on the face image according to an editing attribute to generate an attribute image, wherein the editing attribute is an attribute corresponding to a current attribute of the face image, and the editing attribute includes at least one of a gender attribute and an age attribute; A processing unit, configured to perform semantic segmentation on the attribute image and then process the semantic segmentation image according to the edit attribute to generate a mask image; A fusion unit, used for fusing the attribute image with the image to be processed using the mask image to generate a result image; When the processing unit processes the semantic segmentation image according to the editing attribute to generate the mask image, the processing unit specifically performs: Determining an editing location corresponding to the editing attribute; The values of pixels belonging to the edited part in the semantic segmentation image are set to 1, and the values of other pixels are set to 0, to obtain a mask image.
7. The device according to claim 6, wherein the acquisition unit further executes: After acquiring the face image in the image to be processed, the face image is transformed into a preset size.
8. The device according to claim 6, wherein the conversion unit further performs: Before performing attribute conversion on the face image according to the editing attribute, preprocessing corresponding to the editing attribute is performed on the face image.
9. The device according to claim 6, wherein the fusion unit further performs: Before using the mask image to fuse the attribute image with the image to be processed, performing super-resolution segmentation on the attribute image to generate an ultra-clear attribute image; The ultra-high definition attribute image is fused with the image to be processed by using the mask image.
10. The device according to claim 6, in, When the fusion unit fuses the attribute image with the image to be processed by using the mask image to generate a result image, the fusion unit specifically performs: According to the face position, aligning the mask image, the attribute image and the image to be processed; Determine an area in the image to be processed corresponding to a pixel value of 0 in the mask image, and keep the image content of the area unchanged; Determine an area in the image to be processed corresponding to a pixel value of 1 in the mask image, and replace the image content of the area with the image content of the corresponding area in the attribute image.
11. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
12. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 5.
13. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 5.
