Image matting is one of the important tasks in computer vision. The main purpose is to distinguish background and foreground to obtain foreground object as accurately as possible. Therefore, the task is to generate an alpha matte that contains alpha values, namely opacity values, betweenfor each pixel to represent the effect of the background and foreground over the final image. In addition to this, portrait matting, which is a subtopic of image matting, focuses on generating alpha matte to obtain the subject itself, instead of the generic objects, from an input image or a video frame. There are numerous different application areas of portrait matting, such as image/video editing, changing background which is quite common in video conference applications, and video/movie post-production. Although portrait matting seems an easier task than generic image matting since it focuses on only the person, there are various challenges in the portrait matting problem due to the complicated structure of the person’s body. For example, the borders around the body, especially around the face, are significantly difficult to perform nearly perfect matting. Moreover, it is also too hard to get alpha matte for the hair or clothes, especially if the hair flutters and the clothes have some opacity.
The matting problem can be formulated as follows:
where represents each pixel in an image I, alpha represents alpha value for the corresponding pixel in the alpha matte, and F and B are foreground and the new background images, respectively. Figure 1a is the representation of the alpha matte generation task. The goal is to take an input image and produce an alpha matte for the portrait matting problem. Figure 1b shows how someone can use the alpha matte to get the person from an image. The multiplication of the alpha matte and the input image gives the foreground person, while the multiplication of the inverse alpha matte and the input image produces the background. Likewise, an arbitrary image can be generated by following the same pipeline as described in Equation 1
In the traditional approach, the alpha matte is generated using both the original image and trimap which represents foreground, background, and unknown areas on the image. The basic idea is to enhance the unknown areas in the trimap, which are generally problematic parts of the subject, e.g., the area around the subject’s body, to get a more accurate alpha matte. On the contrary, several latest works [liu2020boosting, ke2020green, sengupta2020background] propose not to use trimap, since creating trimap is a time-consuming procedure and needs expert annotators. Instead, one work employs original image and coarse annotated segmentation mask to generate a fine-grained alpha matte [sengupta2020background]. Moreover, recent work focuses on using original image and background image of the same image to produce alpha matte without using any other information such as coarse alpha matte and trimap [lin2020real], while another works utilizes only the input image to achieve fine-grained alpha matte [liu2020boosting, ke2020green].
One of the crucial challenges is posed by the distribution of the background and foreground of an image. It is an extremely difficult case when the background distribution is quite similar to the foreground distribution. Besides, if the background distribution has a huge variance, it is another compelling case to handle the discrimination of background and foreground of an image. Yet another challenge arises from the illumination conditions of the input image. In particular, the alpha matte prediction models are prone to generate coarse, even worse, outputs under the cases of underexposure and overexposure.
In this work, we aim to enhance the quality of the generated alpha matte to extract the foreground object, which is the person itself, since fine-grained details of the subject are the main difficulties in the portrait matting task. To alleviate the problem, we divided the main task into two sub-tasks which are person segmentation and alpha matte generation. We employed a generative adversarial network-based (GAN-based) approach on both tasks and we do not use any additional input such as trimap or background image. While the first network takes an input image and produces the segmentation map for the subject and background, the second network —alpha generation network— takes the output of the segmentation network, which is a segmentation map, as well as the same input image of the first network to predict the alpha matte. Our contributions can be summarized as follows:
We provide a GAN-based system to produce alpha matte from an arbitrary input image without additional input, e.g., trimap, background image, etc, for portrait matting problem.
We divide the problem into two subtasks, which are person segmentation and fine-grained alpha matte generation, to make the main task easier. While we present segmentation network for person segmentation, we introduce alpha generation network for alpha matte generation task. Addressing the sub-tasks separately leads to an improvement in the accuracy of the generated alpha matte.
We present segmentation encoding block to encode the segmentation map predicted by segmentation model. The idea is to obtain the feature representation of the segmentation map and inject it into the residual block as well as decoder layers. We found that using an independent encoder instead of concatenating the input image and segmentation map as single input with a single encoder provides better representation.
We propose border loss
to penalize the errors around the borders of the subject more since the segmentation network and alpha generation network are more likely to make errors in the prediction due to difficulties such as hair. In addition to the pixel-level loss functions, we employ perceptual loss to compare the prediction and ground truth in the feature space.
We combined two different training datasets to improve the number of images as well as diversity in order to achieve better generalization. We evaluate our model on three different benchmark test sets and compared it with the existing works. Besides, we performed a user study to measure the quality of the segmented subjects and finally we performed an ablation study to analyze the effects of the proposed components.
The rest of the paper is organized as follows: In Section 2, we give a brief overview of the related literature. In Section 3, we explain the proposed method and the training procedure. In Section 4, we discuss the performance of the proposed approach and compare it with the existing works. Besides, we present an ablation study and discuss the outcomes. Finally, we conclude the paper in Section 5.
2 Related Work
Although person segmentation can be employed to extract the subject from an image as well as replace the background, it is not adequately accurate to eliminate the background and its effects on the subject completely. Therefore, alpha matte generation is a more accurate approach for background replacement or portrait matting. Since we designed our system inspired by the conditional image-to-image translation approach, we first review the existing methods in this context. Later, we review the image matting problem which focuses on all objects. Finally, we review the portrait matting literature and summarize the contributions of our proposed method.
Conditional image-to-image translation
After the Convolutional Neural Network (CNN) was introduced[waibel1989phoneme, lecun1990handwritten]
, great progress has been made in deep learning. Besides, many different generative models have been proposed[hinton2006fast, salakhutdinov2009deep, kingma2013auto, rezende2014stochastic, goodfellow2014generative]. Conditional image generation or conditional image-to-image translation [pix2pix, pix2pixhd, spade], is one of the main research fields that generative adversarial nets are employed effectively. The basic intuition of conditional image-to-image translation is to learn the mapping between two different domains by GANs to translate an image from one domain to another domain using paired image. This translation can be done between almost any different domains such as semantic label map to natural image, gray scale image to colored image, edges to photo, etc. In Pix2pix [pix2pix], the authors proposed a generative adversarial network to translate the input image to the output image or generate an image based on conditional input data. While the input image can be a semantic segmentation map, it is also possible to be as an RGB image belonging to another domain. In Pix2PixHD [pix2pixhd], the Pix2Pix [pix2pix] approach is improved and more effective method with novel modules as well as loss functions is proposed to learn mapping between two different domains. In [spade], the authors proposed a network that is similar with the [pix2pixhd] yet more effective for semantic image synthesis using spatially-adaptive normalization since the normalization layers tend to lose semantic information. With the help of the SPADE generator, the semantic segmentation map is used to encode parameters and these parameters are sent to the different layers of the network instead of feeding the first layer of the generator with semantic segmentation map.
Image matting We can divide image matting literature into three main groups which are sampling-based methods [chuang2001bayesian, feng2016cluster, gastal2010shared, he2011global, johnson2016sparse, karacan2015image, karacan2017alpha, ke2020guided], propagation-based methods [aksoy2017designing, aksoy2018semantic, bai2007geodesic, chen2013knn, grady2005random, levin2007closed, levin2008spectral, sun2004poisson], and deep learning-based methods [cho2016natural, shen2016deep, zhu2017fast, xu2017deep, chen2018semantic, lutz2018alphagan, zhang2019late, lu2019indices, li2020natural, Qiao_2020_CVPR, yu2020high, liu2020boosting, javidnia2020background, sengupta2020background, wu2020jmnet, forte2020f, ke2020green, liu2021towards]
. In deep learning-based methods, Convolutional Neural Networks (CNNs) and Generative Adversarial Networks (GANs) are proposed to use alpha matte generation for image matting[cho2016natural, xu2017deep, lutz2018alphagan, lu2019indices, javidnia2020background, yu2020high, liu2021towards]. Besides, the attention mechanism is also presented to improve image matting performance [li2020natural, Qiao_2020_CVPR]. In recent years, trimap free approaches gain importance since obtaining trimap is a significantly expensive process in terms of time and the necessity of expert annotators [zhang2019late, forte2020f].
Portrait Matting In [shen2016deep], a CNN-based end-to-end system is presented to produce an alpha matte for the portrait matting task. In [chen2018semantic], Semantic Human Matting (SHM) algorithm is presented to perform portrait matting. The key point is to learn implicit semantic constraints from the data and use them in the proposed method. SHM is the first method to learn and apply semantic info and high-quality details together. Moreover, the authors provide a new dataset and a novel fusion strategy for the alpha matte. In [wu2020jmnet], end-to-end deep learning framework, namely Joint Matting Network (JMNet), is proposed for portrait matting. The proposed method benefits from the pose of the human body to produce alpha matte. Moreover, the model includes a trimap refiner network to improve the sharpness of the alpha matte. In [liu2020boosting], the authors proposed a system to improve the human matting performance by translating coarse annotated data to fine-grained annotated data. The proposed system contains three submodules that are mask prediction network, quality unification network, and matting refinement network. While the mask prediction network produces low resolution coarse semantic mask, the quality unification network tries to improve the quality of the output of the mask prediction network. Finally, the matting refinement network generates the final alpha matte output. In [sengupta2020background], another trimap-free method is proposed to perform human matting. The system takes an input image and the background of the same image without subject to capture the subject and generate alpha matte. A deep network is trained using the adversarial loss to perform this task. Besides, to perform generalization for other domains, another matting network is trained in relating with the first network. In [dai2020towards], the authors proposed a light-weight portrait matting method. Two decoders and a single encoder are employed in the system. While the encoder is responsible to extract semantic information, the task-specific decoders use low-resolution feature maps and high-resolution feature maps. In [ke2020green], the authors provide a matting objective decomposition network (MODNet) to perform portrait matting using an input image. The proposed system achieves real-time performance (63 fps). Since the existing methods that do not use trimap are not effective against the domain shift problem, a self-supervision-based strategy is proposed to adjust MODNet to the real-world scenario. Besides, a one-frame delay trick is presented when the input data is a video sequence. In [lin2020real], a portrait matting system is designed to produce alpha matte and foreground images. The proposed method works in real-time with a high-resolution image. Besides, two large-scale datasets for video matting and image matting are presented as well. The network contains two subnetworks. While the first network takes an image and its background image as input and generates four different outputs, which are alpha matte, foreground residual, error map, and hidden, the second network performs refinement for these outputs.
All of these works are effective for the portrait matting problem. However, domain shift is still a significant problem that degrades the performance. Besides, providing additional information to the network is not cost-efficient. In contrast to the existing approaches, we try to address the problem in a different way and benefit from the natural statistics of the background and foreground without using any additional input. That is, our proposed method takes only the input image and does not require an additional input. Except MODNet, other state-of-the-art approaches require additional inputs, such as the same background without subject or trimap that describes foreground, background, and unknown areas on the image. Although all these additional inputs provide useful information to the network, it is not an efficient way. For this reason, we propose an end-to-end system that only takes an input image and generates an alpha matte. Besides, we divided the task into two sub-tasks —person segmentation and alpha matte generation— to alleviate the main task. The experimental results indicate that this approach improves the performance of the proposed model. Moreover, we present the segmentation encoding block to downsample the segmentation map in order to provide useful features to the network. In addition, we propose border loss to measure the model performance on the challenging area of the subject separately. Finally, to provide a more diverse training set as well as to increase the amount of data, we combine two different training datasets.
3 Proposed Method
In this work, we proposed Portrait Mattting GAN (POMAGAN) to learn alpha matte generation for the purpose of portrait matting. The proposed method contains two sub-networks that separately perform two different tasks to produce the final alpha matte. The first model, segmentation network
, is responsible to generate a coarse segmentation map in which the pixels that belong to the person are estimated asand the remaining pixels that belong to the background are estimated as . The second network, alpha generation network, is employed to generate alpha matte with respect to the input image and the coarse segmentation map that is predicted by the segmentation network. In Figure 2, we show the proposed POMAGAN and overall pipeline of our method. The first network, segmentation network, takes an image, , as an input and tries to segment the person. In the segmentation network, convolutional layers downsample the input image first. After that, the encoded image is passed through the consecutive residual layers [he2016deep] and ASPP (Atrous Spatial Pyramid Pooling) module [chen2017deeplab]. The ASPP module contains dilated convolution filters with separate dilation rates. Then, the decoder network, which contains multiple consecutive deconvolutional layers, processes the output of the ASPP module to generate the output image —segmentation map . The second network, the alpha generation network, takes two inputs simultaneously but separately —an image and the predicted coarse segmentation map
. It has two different encoders to encode input image and the coarse segmentation map. After the encoders, the encoded image and the coarse segmentation map are concatenated along the depth dimension. Later, it is passed through the consecutive residual layers and the decoder block to predict alpha matte. Besides, the residual connections encourage the network to avoid from vanishing the features, especially features of the coarse segmentation map.
3.1 Segmentation Network
Generator network In the segmentation network, the generator consists of encoder and decoder blocks as well as residual block and ASPP module. There are several convolutional layers in the encoder block, residual layers and ASPP module after the encoder block, and deconvolutional layers in the decoder block. The generator is created based on U-Net generator [unet] and it is responsible to downsample the input image, process the features, and upsample to achieve the segmentation map. The input image travels across the network in order to obtain the corresponding segmentation map. Besides, there are residual connections between reciprocal layers of the encoder and decoder blocks of the generator. To perform this, the output of the convolutional layer in the encoder and the output of the conjugate layer in the decoder are concatenated along with the depth. Moreover, there is a multi-scale discriminator network [pix2pixhd] to distinguish between real and fake data. The segmentation network is illustrated in Figure 2.
Multi-scale discriminator network For the multi-scale discriminator [pix2pixhd], we provide an image pyramid using the original image and downsampled versions by a factor of two and a factor of four to obtain the same image on different scales. Therefore, this approach provides us to learn from a general perspective to finer details, since each discriminator has a different receptive field. Please note that all three discriminators are identical, though each discriminator works on a different scale.
Loss functions We utilized adversarial loss [goodfellow2014generative], perceptual loss [johnson2016perceptual] —for segmentation map and foreground image —, segmentation loss, compositional loss (foreground loss) [xu2017deep], and border loss for both segmentation map and foreground object.
We used the standard adversarial loss to train our GAN model. In addition to adversarial loss, we also benefit from the perceptual loss. In the perceptual loss [johnson2016perceptual], we utilized the VGG model [simonyan2014very] to extract features. For this, we employed five different layers of the VGG model to obtain features for the generated image and the real image. We followed a similar pipeline as in [johnson2016perceptual] to decide the layers to extract features. After that, we calculated a weighted sum of the L1 distances between features of the predicted segmentation map and the real segmentation map for all extracted features. In addition to this, we also calculated the same loss for the segmented foreground subject instead of a segmentation map. For this, we extracted the subject from the input image by multiplying the image with the predicted segmentation map and ground truth segmentation map separately. Afterwards, we calculated the loss between extracted two subjects. The foreground image creating procedure is explained in Equation 2.
where and are original image, ground truth segmentation map, and predicted segmentation map, respectively, and represents element-wise production. Besides, is the extracted foreground subject based on ground truth data and represents the extracted subject based on predicted segmentation map. The corresponding perceptual loss formula is presented in Equation 3.
where represents feature maps that we extract from the th layer of the VGG-19 network. is the coefficient to alter the effect of the distance between features, which are extracted from the th layer of the VGG model, over total loss. This coefficient stays in the range of .
In the segmentation loss, we calculate the absolute distance between the predicted segmentation map and the ground truth segmentation map. We also employed compositional loss —foreground loss— under the segmentation loss that is responsible for calculating the absolute distance between foreground images. The generation process of the foreground images is the same as explained in perceptual loss. These images are generated based on the multiplication of the ground truth image and ground truth segmentation map for real foreground image, and the multiplication of the ground truth image and predicted segmentation map for generated foreground image. Besides, we calculated the L1 distance between them. The combination of segmentation loss and compositional loss is shown in Equation 4.
Finally, we employed border loss for the segmentation map and foreground object as in the segmentation loss. First of all, we manually created the border images. For this, we first performed an erosion operation to get the eroded segmentation map. After that, we applied a dilation operation to obtain the dilated segmentation map. In the end, the border map is produced by subtracting the eroded segmentation map image from the dilated one. The sample images are shown in Figure 3 and the operation is presented in Equation 5. Afterwards, we used these border maps to calculate border losses for the segmentation map and foreground object as in Equation 6.
The corresponding coefficients , , and are coefficients to determine the effect of each loss over total loss and they are empirically chosen as 10 based on the experiments on the validation set.
3.2 Alpha Generation Network
The alpha generation network uses the original input image as well as the output of the segmentation network as input and it produces the corresponding alpha matte.
Generator network In the alpha generation network, the first encoder is responsible to encode the input image to obtain a feature map to represent the original input image. It is based on the U-Net generator [unet] and it contains consecutive convolutional blocks to downsample the input image. On the other hand, the segmentation encoding block encodes the coarse segmentation map produced by the segmentation network to obtain the feature map. This representation is concatenated with the output of the first encoder. The concatenated features are passed through the residual block. After the residual block, the generator has a decoder module to produce an output alpha map by upsampling the residual output. The generated image is expected to be the fine-grained alpha matte of the input image for portrait matting problem. Besides, the residual connections encourage the network to keep information from the both encoders.
Multi-scale discriminator network We followed the same pipeline that is explained in the segmentation network part. We created a multi-scale discriminator to learn from a general perspective to finer details by using different discriminators on a different scale. We employed three different discriminators as we did before and all are identical except the data size.
Loss functions For the training of the alpha generation network, we used the similar loss functions as in the segmentation network. Besides, we apply L1 loss for image, which is the combination of foreground subject and background in addition to the foreground subject and alpha map, since the background and foreground have different effects for the pixels of the combined image where the alpha coefficient is neither one nor zero. As a result, we employed adversarial loss [goodfellow2014generative], perceptual loss [johnson2016perceptual] –for alpha map and foreground—, alpha loss [xu2017deep] which includes compositional loss (foreground loss) and image loss as well, border loss which contains alpha border loss, foreground border loss, and image border loss.
For the adversarial loss [goodfellow2014generative] and perceptual loss [johnson2016perceptual], we followed the same strategy as in the segmentation network. The only difference is that we employed ground truth alpha matte, , and predicted alpha matte, , instead of ground truth and predicted segmentation maps, and . In addition to this, we compared alpha matte, foreground subjects, and combination of foreground and background. The combination procedure is defined in Equation 8.
where is original input image, is ground truth alpha matte, represents predicted alpha matte, indicates an arbitrary background image, states the created image based on input, background, and ground truth alpha matte, and specify the created image based on input, background, and predicted alpha matte. The corresponding alpha loss is expressed in Equation 9.
Finally, we utilized border loss to measure the difference in the border area of the subjects of two images. With the guidance of this loss, we made the training more sensitive to the regions that are more likely to be challenging for the network. Equation 10 indicates the proposed loss function.
where is the mask image that represents the border area around the subject. We obtain the mask image by subtracting eroded version from dilated version of the binary version of alpha matte, . The and indicate the border area of the foreground subject and they are obtained using the application of the formulas in Equation 5 for alpha mattes instead of segmentation maps. In addition, and state the border area of the created image in Equation 8 and they are achieved by the following formulas; , . Please note that, since we used the border images for only calculating the loss during the training of the network, it is not necessary to have it in the inference time.
Overall objective The overall objective function is obtained by combining all loss functions that have been explained. Consequently, the full objective of the alpha generation GAN can be formulated in Equation 11:
where , , , and are conditional adversarial loss, perceptual loss, alpha loss, and border loss, respectively. , and coefficients alter the effects of corresponding functions over total objective function. We performed experiments on the validation set and empirically decided these values as 10, 100, 100, respectively.
3.3 Training procedure
We trained the segmentation model and alpha generation model separately to prevent negatively affecting each other’s performance. During the inference time, they work end-to-end which means we provide an input image to the complete network and get an alpha matte for the corresponding input image. The input images are resized to resolution before feeding the network. We used learning rate for the generator and ten times smaller () for the discriminator to slow down the convergence of the discriminator. We trained the segmentation model with batch size two and alpha generation network with batch size one since using one image in each batch causes better convergence [forte2020f]. Besides, we utilized Adam optimizer for the training of both models.
4 Experimental Results
Datasets For training our model, we used the combination of Adobe Image Matting dataset (AIM) [xu2017deep] and Distinctions (D646) [Qiao_2020_CVPR] dataset in order to employ more data as well as increase the diversity. Since we focused on the portrait matting problem, we selected appropriate images containing only people to use in the training and test states. In the end, there are 201 subjects in the AIM dataset and 363 subjects in the D646 dataset, making in total 564 subjects for the training set. We created the training set by following the standard strategy in the image matting literature for these datasets. For this, we combined each person in the training set with 100 different images of the MSCOCO dataset [mscoco2014]. In the end, we have 56400 training images. For the test, we have three different test sets which are AIM [xu2017deep], PhotoMatte85 (PM85) [lin2020real], and D646 [Qiao_2020_CVPR]
. We followed the same strategy and combined each person in the test set with 20 different images of the PASCAL VOC dataset[everingham2015pascal]. In the end, AIM contains 220 images (11 different subjects), PM85 includes 1700 images (85 different subjects), and D646 has 220 images (11 different subjects), respectively. We evaluated our model on these three benchmark test sets and compared our results with the previous works. Please note that the training and test sets do not contain any common subjects —subject independent—, and the training and test subjects have been listed in the corresponding datasets.
Evaluation We trained the proposed model on the combination of AIM and D646 datasets and evaluated it on the AIM test set, PM85 dataset, and D646 test set. We used Mean Squared Error (MSE), Mean Absolute Error (MAE), Sum of Absolute Difference (SAM), Gradient, and Connectivity metrics to evaluate our model as in the literature and we compared them with the previous works. For this, we chose available state-of-the-art methods, namely MODNet [ke2020green], BGM-V2 [lin2020real], FBA [forte2020f], in the literature and we tested them on the test sets in order to perform a fair comparison since different backgrounds may change the models’ performances. Please note that we calculated these metrics over the whole image and MSE and MAE scores are scaled by to improve the readability. Besides, we performed a user study to compare our results with other studies. To perform this study, we combined the extracted subjects with a green background and used these images for the user study.
In this section, we present the experimental results and compare our results with the recent works, MODNet [ke2020green], FBA [forte2020f], BGM-V2 [lin2020real]. The FBA is trained on AIM dataset whilst BGM-V2 and MODNet are trained on their own datasets and the datasets are not published. Please note that, while our method and MODNet take an input image to generate alpha matte for portrait matting, BGM-V2 requires the original background image without subject as an additional input and FBA expects trimap to identify background, foreground, and unknown areas in addition to the original input image.
|BGM-V2 [lin2020real]||Image, background||AIM [xu2017deep]||2.12||8.62||9.04||8329||11216|
|FBA [forte2020f]||Image, trimap||AIM [xu2017deep]||0.40||3.79||3.98||4192||5984|
|MODNet [ke2020green]||Image||AIM [xu2017deep]||21.65||32.36||33.93||14246||15452|
|BMG-V2 [lin2020real]||Image, background||PM85 [lin2020real]||0.37||1.38||1.45||4464||2381|
|FBA [forte2020f]||Image, trimap||PM85 [lin2020real]||1.01||2.43||2.55||7524||5916|
|MODNet [ke2020green]||Image||PM85 [lin2020real]||2.32||6.90||7.23||11663||8663|
|BMG-V2 [lin2020real]||Image, background||D646 [Qiao_2020_CVPR]||0.98||4.60||4.83||6132||7816|
|FBA [forte2020f]||Image, trimap||D646 [Qiao_2020_CVPR]||0.44||3.10||3.25||3861||4592|
|MODNet [ke2020green]||Image||D646 [Qiao_2020_CVPR]||3.51||9.80||10.27||13019||15826|
Quantitative evaluation Experimental results are shown in Table 1. We presented MSE, MAE, SAD, Gradient, and Connectivity, respectively, and we evaluated all models under the same conditions, e.g., used background image, resolution. According to the experimental results presented in Table 1, our model surpassed the performance of MODNet, which does not use any additional input, on three different benchmarks. Other methods in the table —BGM-V2 and FBA— benefit from additional input such as the same background image without subject and trimap. These additional inputs make the task easier and more accurate results are likely to happen, since the background image is exactly the same one as the original input image, and trimap identifies most of the area on the image as foreground and background. On the AIM dataset, our model is found superior to the BGM-V2 in all metrics. However, the FBA method achieves the best performance on this test set. On the PM85 dataset, our proposed POMAGAN outperforms all methods on the MSE metric. However, BGM-V2 is slightly better in other metrics. On the D646 benchmark, we again outperform the MODNet and BGM-V2. The FBA reaches the best performance. However, it is slightly better than our method and our results are quite acceptable when we compare with the FBA. Please note that while our approach does not take any input in addition to the original image, the FBA method takes trimap and the BGM-V2 method takes the same background image with the original image without the subject itself. However, they are too sensitive against these additional inputs. For instance, if there are any dissimilarities on the background image such as translation, BGM-V2 cannot produce a proper output, generates a completely corrupted prediction instead. Similarly, since the FBA method is quite sensitive to the input trimap, different trimaps cause considerably different outputs. In addition to all these states, our model and all other models are sensitive to the background of the input image according to our detailed experiments. It indicates that the alpha map prediction performance of the models for the same subject can considerably change according to the background of the input image.
Qualitative evaluation In Figure 4, we present our results, input image, ground truth, and the outputs of the other models for all three benchmark datasets; AIM, D646, PM85. We generated outputs with our model and MODNet without additional inputs. However, BGM-V2 method needs exactly the same background of the input image and FBA requires trimap for the corresponding input data. For BGM-V2, we provided the background image that we used during the preparation of the test data. For the experiments with FBA, although AIM dataset contains trimaps, D646 and PM85 datasets do not include them. For this reason, we created trimaps for D646 and PM85 datasets by using erosion and dilation operation. According to the figure, our results are almost the same with the ground truth data. Besides, although all models perform quite well, the differences between them are in the details of the subjects, e.g., hair.
We also performed a user study to ask 30 different participants to compare and evaluate all results. We present the results in Table 2. We used randomly selected sample images from all three benchmark test sets in the user study and present the overall results in the table. We have five different levels of score which are much better, better, same, worse, and much worse to compare our results with three different methods. The scores indicate how much the output images of our method is better or worse than the outputs of other methods. For the comparison, we extracted subjects from the image using predicted alpha matte and combined with a green background to make the details of the subject more visible for the users. During the survey, we showed the original input image and the combination of green background and outputs of the models. We utilized 8 subjects for each test benchmark for the user study. We chose one random image for each selected subject and we made pairs with our results and other results to show them to the participants. In total, we have 24 images for each model and 72 questions created based on the combination of our results and other results. According to the table, our model overperforms the MODNet and it is slightly better than BGM-V2. On the other hand, participants could not easily distinguish our results and FBA results and majority, 52.44%, said they are the same.
|Much worse||1.94%||0.69%||3.58 %|
4.2 Ablation study
Loss functions We performed an ablation study to evaluate the effects of different cases on the performance. We first investigated the loss functions and then we examined the datasets. In the first part of Table 3, we show used loss functions for the training as well as corresponding MSE values on the AIM test set. According to the results, it is observed that alpha loss and alpha border loss contribute significantly to the accuracy improvement of the generated alpha matte. Please note that we did not modify the training procedure of the segmentation step, since it directly affects the performance of the alpha matte generation network.
In the bottom part of Table 3, we present the effect of using matte, foreground object, and the combination of an arbitrary background and subject. While means that we only utilized predicted alpha matte and ground truth alpha matte for all loss functions, and represent that we extracted the subject from the input image with predicted alpha map and ground truth alpha map to obtain real and predicted foreground objects and we additionally employed these outputs in the calculation of all losses. Moreover, in case, we combined extracted subjects with an arbitrary background image and used the final images with all loss functions. While using helps to penalize the difference between predicted and ground truth alpha maps, using foreground subject and the combination of foreground subject and an arbitrary background image provide more information to the network, since they contain more detailed and semantic information than the alpha map. MSE scores indicate that using foreground subject and the combination of the subject with a background in addition to alpha map encourages the network to produce a more accurate alpha map.
Datasets We further investigated the effect of the training dataset. In the proposed method, we trained our network with the combination of training sets of AIM and D646 datasets. In this section, we present the ablation study for the training dataset. We repeated the training procedure with AIM, D646, and the combination of them by following the same pipeline as we explained in the methodology section. The experimental results are given in Table 4. The evaluation scores state that the combination of AIM and D646 provides the best performance, since the combined data contains more images and more unique subjects that provide diversity.
|AIM + D646||1.93|
In this work, we proposed a GAN-based novel additional input-free approach to perform the portrait matting task. For this, we addressed the problem as two different sub-problems. In the first step, we proposed a segmentation model and it takes an input image to predict a coarse segmentation map. In the second step, this output and the original image are sent to the alpha generation network to generate the alpha matte. Our method is cost-efficient since it does not require any additional input. Besides, we proposed border loss to penalize challenging parts around the subject and we also adapted the perceptual loss for the portrait matting task. In order to handle the domain shift problem, we combined two important training datasets to increase the amount of data as well as the diversity. Moreover, we proposed the segmentation encoding block to encode the coarse segmentation map and we injected the feature representation of the coarse segmentation map to both residual block and decoder layers. Experimental results indicate that using border loss and perceptual loss improved the accuracy of the model and combining two datasets improved the generalization capacity. It is also observed that encoding the segmentation map by the segmentation encoding block provided more useful features than concatenating input image and segmentation map along with the depth and then encoding it with one encoder.