# US 2021/0082124 A1 · Foreground-aware image inpainting

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

- Number: US 2021/0082124 A1
- Document ID: US20210082124A1
- Status: Published application
- Kind: A1
- Application number: 17/103,119
- Filed: 2020-11-24
- Published: 2021-03-18
- Earliest claimed: 2019-04-15
- Assignees: Adobe Inc.
- Applicants: Adobe Inc.
- Inventors: Zhe Lin; Wei Xiong; Connelly Barnes; Jimei Yang; Xin Lu
- Web page: https://patentgrep.com/patent/US20210082124A1

## CPC

- G06T 7/149: involving deformable models, e.g. active contour models
- G06T 5/60: using machine learning, e.g. neural networks
- G06T 5/77: Retouching; Inpainting; Scratch removal
- G06T 7/13: Edge detection
- G06T 7/194: involving foreground-background segmentation
- G06T 2207/20081: Training; Learning
- G06T 2207/20084: Artificial neural networks [ANN]
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL

## Abstract

In some embodiments, an image manipulation application receives an incomplete image that includes a hole area lacking image content. The image manipulation application applies a contour detection operation to the incomplete image to detect an incomplete contour of a foreground object in the incomplete image. The hole area prevents the contour detection operation from detecting a completed contour of the foreground object. The image manipulation application further applies a contour completion model to the incomplete contour and the incomplete image to generate the completed contour for the foreground object. Based on the completed contour and the incomplete image, the image manipulation application generates image content for the hole area to generate a completed image.

## Claims

### Claim 1

A non-transitory computer-readable medium having program code that is stored thereon, the program code executable by one or more processing devices for performing operations comprising:
applying, to an incomplete image comprising a hole area lacking image content, a contour detection operation that detects an incomplete contour of a foreground object in the incomplete image, wherein the hole area prevents the contour detection operation from detecting a completed contour of the foreground object;
applying, to the incomplete contour and the incomplete image, a contour completion model that is trained to generate the completed contour for the foreground object; and
applying an image completion model to the incomplete image and the completed contour to generate a completed image comprising image content for the hole area.

### Claim 2 (depends on 1)

The non-transitory computer-readable medium of claim 1, wherein the contour completion model comprises a generative adversarial network (GAN) that comprises a coarse contour generative model, a refined contour generative model and a discriminative model.

### Claim 3 (depends on 2)

The non-transitory computer-readable medium of claim 2, the operations further comprising training the contour completion model that comprises applying a loss function that comprises a first loss term associated with content loss of the coarse contour generative model and the refined contour generative model and a second loss term associated with adversarial loss of the discriminative model, wherein one or more weights applied to the first loss term and the second loss term change over time.

### Claim 4 (depends on 3)

The non-transitory computer-readable medium of claim 3, wherein the weights comprise a first weight applied to the first loss term of the loss function and a second weight applied to the second loss term of the loss function, and wherein a first ratio between the first weight and the second weight at a first stage of the training is higher than a second ratio between the first weight and the second weight at a second stage of the training.

### Claim 5 (depends on 1)

The non-transitory computer-readable medium of claim 1, wherein the image completion model comprises a generative adversarial network that comprises a generative model and a discriminative model.

### Claim 6 (depends on 5)

The non-transitory computer-readable medium of claim 5, the operations further comprising training the image completion model that comprises applying a loss function that comprises a first loss term associated with content loss of the generative model and a second loss term associated with adversarial loss of the discriminative model, wherein a first ratio between a first weight applied to the first loss term and a second weight applied to the second loss term at a first stage of the training is higher than a second ratio between the first weight and the second weight at a second stage of the training.

### Claim 7 (depends on 6)

The non-transitory computer-readable medium of claim 6, wherein the generative model comprises a coarse image generative model and a refined image generative model, and wherein the first loss term defines content loss of the coarse image generative model and content loss of the refined image generative model.

### Claim 8 (depends on 1)

The non-transitory computer-readable medium of claim 1, wherein the contour detection operation comprises:
detecting the foreground object to generate a foreground map, wherein detecting the foreground object comprises applying a contour model to the incomplete image; and
generating the incomplete contour of the foreground object, wherein generating the incomplete contour comprises applying an edge detector to the foreground map.

### Claim 9

A computer-implemented method in which one or more processing devices perform operations comprising:
a step for generating image content for a hole area contained in an incomplete image based on a contour of a foreground object in the incomplete image to generate a completed image, the step for generating the image content comprising applying an image completion model to the incomplete image and a completed contour of the contour of the foreground object to generate the completed image; and
providing the completed image for display.

### Claim 10 (depends on 9)

The computer-implemented method of claim 9, the operations further comprising training a contour completion model that comprises a generative adversarial network (GAN), the GAN comprising a coarse contour generative model, a refined contour generative model and a discriminative model, wherein the step for generating image content for the hole area comprises generating the contour of the foreground object based on the trained contour completion model.

### Claim 11 (depends on 10)

The computer-implemented method of claim 10, wherein training the GAN comprises applying a loss function that comprises a first loss term associated with content loss of the coarse contour generative model and the refined contour generative model and a second loss term associated with adversarial loss of the discriminative model, wherein one or more weights applied to the first loss term and the second loss term change over time.

### Claim 12 (depends on 11)

The computer-implemented method of claim 11, wherein the weights comprise a first weight applied to the first loss term of the loss function and a second weight applied to the second loss term of the loss function, and wherein a first ratio between the first weight and the second weight at a first stage of the training is higher than a second ratio between the first weight and the second weight at a second stage of the training.

### Claim 13 (depends on 9)

The computer-implemented method of claim 9, the operations further comprising training the image completion model, wherein the image completion model comprises a generative model and a discriminative model.

### Claim 14 (depends on 13)

The computer-implemented method of claim 13, wherein the training comprises applying a loss function that comprises a first loss term associated with content loss of the generative model and a second loss term associated with adversarial loss of the discriminative model, wherein a first ratio between a first weight applied to the first loss term and a second weight applied to the second loss term at a first stage of the training is higher than a second ratio between the first weight and the second weight at a second stage of the training.

### Claim 15 (depends on 14)

The computer-implemented method of claim 14, wherein the generative model comprises a coarse image generative model and a refined image generative model, and wherein the first loss term defines content loss of the coarse image generative model and content loss of the refined image generative model.

### Claim 16

A system comprising:
a processing device; and
a non-transitory computer-readable medium communicatively coupled to the processing device, wherein the processing device is configured to execute program code stored in the non-transitory computer-readable medium and thereby perform operations comprising:
detecting a foreground object in an incomplete image that comprises a hole area lacking image content;
detecting an incomplete segmentation map of the foreground object based on a location of the hole area, wherein the location of the hole area prevents a completed segmentation map of the foreground object from being detected;
generating a completed segmentation map for the foreground object based on the incomplete segmentation map and the incomplete image; and
generating a completed image comprising generating image content for the hole area based on the completed segmentation map and the incomplete image.

### Claim 17 (depends on 16)

The system of claim 16, wherein generating the completed segmentation map comprises applying a segmentation map completion model to the incomplete segmentation map and the incomplete image, the segmentation map completion model comprising a generative adversarial network (GAN) that comprises a coarse segmentation map generative model, a refined segmentation map generative model and a discriminative model.

### Claim 18 (depends on 17)

The system of claim 17, wherein generating the image content for the hole area comprises applying an image completion model to the incomplete image and the completed segmentation map, the image completion model comprising a generative adversarial network that comprises a generative model and a discriminative model.

### Claim 19 (depends on 18)

The system of claim 18, wherein the image completion model and the segmentation map completion model are jointly training to minimize a joint loss function defined based on a first loss function for the image completion model and a second loss function for the segmentation map completion model.

### Claim 20 (depends on 18)

The system of claim 18, wherein the operations further comprise training the image completion model that comprises applying a loss function that comprises a first loss term associated with content loss of the generative model and a second loss term associated with adversarial loss of the discriminative model, wherein a first ratio between a first weight applied to the first loss term and a second weight applied to the second loss term at a first stage of the training is higher than a second ratio between the first weight and the second weight at a second stage of the training.
