# US 2021/0241498 A1 · Method and device for processing image, related electronic device and storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2021/0241498 A1
- Document ID: US20210241498A1
- Status: Published application
- Kind: A1
- Application number: 17/301,070
- Filed: 2021-03-24
- Published: 2021-08-05
- Earliest claimed: 2020-06-12
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science and Technology Co., Ltd.
- Inventors: Hao SUN; Fu LI; Xin LI; Tianwei LIN
- Web page: https://patentgrep.com/patent/US20210241498A1

## CPC

- G06T 11/60: Creating or editing images; Combining images with text
- G06F 16/5854: {using shape and object relationship}
- G06F 18/214: Generating training patterns; Bootstrap methods, e.g. bagging or boosting
- G06T 3/04: Context-preserving transformations, e.g. by using an importance map (panospheric to cylindrical image transformations G06T3/12)
- G06T 7/11: Region-based segmentation
- G06T 11/00: Two-dimensional [2D] image generation
- G06V 10/774: Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
- G06V 10/82: using neural networks
- G06V 40/168: {Feature extraction; Face representation}
- G06V 40/171: {Local features and components; Facial parts (eye characteristics G06V40/18); Occluding parts, e.g. glasses; Geometrical relationships}
- G06T 2207/20081: Training; Learning
- G06T 2207/20132: Image cropping
- G06T 2207/30201: Face
- Y02D 10/00: Energy efficient computing, e.g. low power processors, power management or thermal management
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06V: IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- Y02D: CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE

## Abstract

The disclosure provides a method for processing an image, an electronic device, and a storage medium, belonging to a field of computer vision and deep learning. An image including a face figure is acquired. Facial feature information matching the face figure is extracted. A style of the image is converted to a preset drawing style based on the facial feature information to obtain a style transferred image.

## Claims

### Claim 1

A method for processing an image, including:
acquiring an image, wherein the image comprises a face figure;
extracting facial feature information matching the face figure; and
converting the image into a style transferred image of a preset drawing style based on the facial feature information.

### Claim 2 (depends on 1)

The method according to claim 1, wherein the facial feature information comprises at least one of facial feature positions, facial feature sizes, face contour, and hairstyle contour.

### Claim 3 (depends on 2)

The method according to claim 2, wherein converting the image into the style transferred image comprises:
obtaining the style transferred image by acquiring a style transfer model matching the preset drawing style and inputting the image and the facial feature information into the style transfer model;
wherein the style transfer model is obtained by training a cyclic generative adversarial network in advance using a real portrait image set, facial feature information matching each real portrait image contained in the real portrait image set, a styled portrait image set, and facial feature information matching each styled portrait image in the styled portrait image set, and wherein the styled portrait image set matches the preset drawing style.

### Claim 4 (depends on 3)

The method according to claim 3, further comprising:
acquiring the real portrait image set and acquiring the styled portrait image set matching the preset drawing style;
generating real-styled portrait image pairs from the real portrait image set and the styled portrait image set;
acquiring the facial feature information corresponding to the real portrait image of each real-styled portrait image pair and facial feature information corresponding to the styled portrait image of each real-styled portrait image pair;
training the cyclic generative adversarial network using the real portrait image and the styled portrait image in each real-styled portrait image pair, as well as the facial feature information corresponding to the real portrait image and the facial feature information corresponding to the styled portrait image; wherein the cyclic generative adversarial network comprises: a real-to-styled generator for transferring a real portrait to a styled portrait, a styled-to-real generator for transferring a styled portrait to a real portrait, a real portrait discriminator and a styled portrait discriminator; and
determining the real-to-styled generator in the cyclic generative adversarial network as the style transfer model matching the preset drawing style, in response to detecting that a training ending condition is met.

### Claim 5 (depends on 4)

The method according to claim 4, wherein acquiring the real portrait image set comprises:
generating the real portrait image set from real portrait images acquired from a standard real portrait image database.

### Claim 6 (depends on 5)

The method according to claim 5, further comprising:
performing at least one image preprocessing on real portrait images in the real portrait image set to obtain preprocessed real portrait images, and adding the preprocessed real portrait images to the real portrait image set.

### Claim 7 (depends on 4)

The method according to claim 4, wherein acquiring the styled portrait image set matching the preset drawing style comprises:
acquiring standard styled images matching the preset drawing style from a standard styled image database;
acquiring resultant images comprising the face figure by filtering the standard styled images; and
cropping the resultant images to obtain cropped results having face regions, and generating the styled portrait image set from the cropped results.

### Claim 8

An electronic device, comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor;
wherein the memory is configured to store instructions executable by the at least one processor, when the instructions are executed by the at least one processor, the at least one processor is configured to:
acquire an image, wherein the image comprises a face figure;
extract facial feature information matching the face figure; and
convert the image into a style transferred image of a preset drawing style based on the facial feature information.

### Claim 9 (depends on 8)

The electronic device according to claim 8, wherein the facial feature information comprises at least one of facial feature positions, facial feature sizes, face contour, and hairstyle contour.

### Claim 10 (depends on 9)

The electronic device according to claim 9, wherein the at least one processor is further configured to:
obtain the style transferred image by acquiring a style transfer model matching the preset drawing style and inputting the image and the facial feature information into the style transfer model;
wherein the style transfer model is obtained by training a cyclic generative adversarial network in advance using a real portrait image set, facial feature information matching each real portrait image contained in the real portrait image set, a styled portrait image set, and facial feature information matching each styled portrait image in the styled portrait image set, and wherein the styled portrait image set matches the preset drawing style.

### Claim 11 (depends on 10)

The electronic device according to claim 10, wherein the at least one processor is further configured to:
acquire the real portrait image set and acquire the styled portrait image set matching the preset drawing style;
generate real-styled portrait image pairs from the real portrait image set and the styled portrait image set;
acquire the facial feature information corresponding to the real portrait image of each real-styled portrait image pair and facial feature information corresponding to the styled portrait image of each real-styled portrait image pair;
train the cyclic generative adversarial network using the real portrait image and the styled portrait image in each real-styled portrait image pair, as well as the facial feature information corresponding to the real portrait image and the facial feature information corresponding to the styled portrait image; wherein the cyclic generative adversarial network comprises: a real-to-styled generator for transferring a real portrait to a styled portrait, a styled-to-real generator for transferring a styled portrait to a real portrait, a real portrait discriminator and a styled portrait discriminator; and
determine the real-to-styled generator in the cyclic generative adversarial network as the style transfer model matching the preset drawing style, in response to detecting that a training ending condition is met.

### Claim 12 (depends on 11)

The electronic device according to claim 11, wherein the at least one processor is further configured to:
generate the real portrait image set from real portrait images acquired from a standard real portrait image database.

### Claim 13 (depends on 12)

The electronic device according to claim 12, wherein the at least one processor is further configured to:
perform at least one image preprocessing on real portrait images in the real portrait image set to obtain preprocessed real portrait images, and add the preprocessed real portrait images to the real portrait image set.

### Claim 14 (depends on 11)

The electronic device according to claim 11, wherein the at least one processor is further configured to:
acquire standard styled images matching the preset drawing style from a standard styled image database;
acquire resultant images comprising the face figure by filtering the standard styled images; and
crop the resultant images to obtain cropped results having face regions, and generate the styled portrait image set from the cropped results.

### Claim 15

A non-transitory computer-readable storage medium, having computer instructions stored thereon, wherein the computer instructions are configured to cause a computer to execute a method for processing an image, the method comprising:
acquiring an image, wherein the image comprises a face figure;
extracting facial feature information matching the face figure; and
converting the image into a style transferred image of a preset drawing style based on the facial feature information.

### Claim 16 (depends on 15)

The non-transitory computer-readable storage medium according to claim 15, wherein the facial feature information comprises at least one of facial feature positions, facial feature sizes, face contour, and hairstyle contour.

### Claim 17 (depends on 16)

The non-transitory computer-readable storage medium according to claim 16, wherein converting the image into the style transferred image comprises:
obtaining the style transferred image by acquiring a style transfer model matching the preset drawing style and inputting the image and the facial feature information into the style transfer model;
wherein the style transfer model is obtained by training a cyclic generative adversarial network in advance using a real portrait image set, facial feature information matching each real portrait image contained in the real portrait image set, a styled portrait image set, and facial feature information matching each styled portrait image in the styled portrait image set, and wherein the styled portrait image set matches the preset drawing style.

### Claim 18 (depends on 17)

The non-transitory computer-readable storage medium according to claim 17, wherein the method further comprises:
acquiring the real portrait image set and acquiring the styled portrait image set matching the preset drawing style;
generating real-styled portrait image pairs from the real portrait image set and the styled portrait image set;
acquiring the facial feature information corresponding to the real portrait image of each real-styled portrait image pair and facial feature information corresponding to the styled portrait image of each real-styled portrait image pair;
training the cyclic generative adversarial network using the real portrait image and the styled portrait image in each real-styled portrait image pair, as well as the facial feature information corresponding to the real portrait image and the facial feature information corresponding to the styled portrait image; wherein the cyclic generative adversarial network comprises: a real-to-styled generator for transferring a real portrait to a styled portrait, a styled-to-real generator for transferring a styled portrait to a real portrait, a real portrait discriminator and a styled portrait discriminator; and
determining the real-to-styled generator in the cyclic generative adversarial network as the style transfer model matching the preset drawing style, in response to detecting that a training ending condition is met.

### Claim 19 (depends on 18)

The non-transitory computer-readable storage medium according to claim 18, wherein acquiring the real portrait image set comprises:
generating the real portrait image set from real portrait images acquired from a standard real portrait image database.

### Claim 20 (depends on 20)

The non-transitory computer-readable storage medium according to claim 20, wherein the method further comprises:
performing at least one image preprocessing on real portrait images in the real portrait image set to obtain preprocessed real portrait images, and adding the preprocessed real portrait images to the real portrait image set.
