AlphaNet: An Attention Guided Deep Network for Automatic Image Matting

by   Rishab Sharma, et al.

In this paper, we propose an end to end solution for image matting i.e high-precision extraction of foreground objects from natural images. Image matting and background detection can be achieved easily through chroma keying in a studio setting when the background is either pure green or blue. Nonetheless, image matting in natural scenes with complex and uneven depth backgrounds remains a tedious task that requires human intervention. To achieve complete automatic foreground extraction in natural scenes, we propose a method that assimilates semantic segmentation and deep image matting processes into a single network to generate detailed semantic mattes for image composition task. The contribution of our proposed method is two-fold, firstly it can be interpreted as a fully automated semantic image matting method and secondly as a refinement of existing semantic segmentation models. We propose a novel model architecture as a combination of segmentation and matting that unifies the function of upsampling and downsampling operators with the notion of attention. As shown in our work, attention guided downsampling and upsampling can extract high-quality boundary details, unlike other normal downsampling and upsampling techniques. For achieving the same, we utilized an attention guided encoder-decoder framework which does unsupervised learning for generating an attention map adaptively from the data to serve and direct the upsampling and downsampling operators. We also construct a fashion e-commerce focused dataset with high-quality alpha mattes to facilitate the training and evaluation for image matting.


page 1

page 4

page 6

page 7


Instance Segmentation based Semantic Matting for Compositing Applications

Image compositing is a key step in film making and image editing that ai...

SGM-Net: Semantic Guided Matting Net

Human matting refers to extracting human parts from natural images with ...

End-to-end Animal Image Matting

Extracting accurate foreground animals from natural animal images benefi...

Indices Matter: Learning to Index for Deep Image Matting

We show that existing upsampling operators can be unified with the notio...

Semantic Human Matting

Human matting, high quality extraction of humans from natural images, is...

Boosting Semantic Human Matting with Coarse Annotations

Semantic human matting aims to estimate the per-pixel opacity of the for...

A Unified Efficient Pyramid Transformer for Semantic Segmentation

Semantic segmentation is a challenging problem due to difficulties in mo...

I Introduction

Digital image matting, which is defined as high-quality extraction of foreground objects from natural images has a wide assortment of applications in mixed reality, film production, and smart creative composition. In an e-commerce website, image composition is usually used to generate smart and personalized creative assets for customers. Generating such compositions requires the extraction of fashion models and accessories from a large amount of fashion data, followed by their composition with the new creative backgrounds. In pursuit of smoother and faster customer experience, the process of extraction and composition that works on a huge volume of data must be automated and the results must be of high quality. An example of a creative composition in a real-world fashion e-commerce website achieved through automatic image matting can be seen in Fig. 1. For designing such an automated pipeline, one would either choose to go for image matting or semantic segmentation techniques. But this particular task is not as trivial as it seems, and there are many underlying bottlenecks that make it more complicated that one may perceive. Neither semantic segmentation nor image matting itself delivers a satisfactory result. One major drawback of using just semantic segmentation in this use case is that this technique focuses on coarse semantics of the visual input, thus leads to the blurring of fine structural details. On the contrary, simple image matting that is well-known for extracting fine details from images requires user interactions like trimaps or scribbles. Therefore, in such a time-sensitive and data-intensive scenario, only applying image matting cannot serve as a robust solution. In this work, we present a method for automatic foreground object extraction that can work even with complex natural backgrounds. Our method combines semantic segmentation and image matting processes, which allows for multiple foreground objects to be segmented and extracted from the background with high quality. The ability of the semantic segmentation to extract different types of semantic labels enables a way to automatically extract objects of different types.

Fig. 1: AlphaNet being used for an Fashion e-commerce website.

One of the most complex and important tasks in computer vision is object segmentation. Although there have been recent advances in the learning-based methods for segmentation algorithms due to the availability of publicly available datasets, still most of the human drawn segmentation ground truths are unrefined and coarse. This coarse supervision makes the segmentation models generate unrefined and coarse object edges. Therefore, image segmentation techniques not only lack sufficient refinement but also many semantic details required for high-quality image composition. On the contrary, image matting is also an elementary problem in the domain of computer vision that is under continuous research since the 1950s. Identical to image segmentation, which generates a binary mask for the foreground, image matting extracts the foreground by estimating an alpha matte containing the transparency value for each pixel in the static image or a frame stream from a video. The pixel in the foreground typically has an alpha value of 1, whereas the background pixel has an alpha value of 0. Nonetheless, a pixel on the edge of an object can have a contribution from both the foreground and background due to motion blur in videos, thus the alpha is defined as

in such a case. The interpreted relation of alpha and image can be seen in Equation 1, where denotes the alpha value at the pixel location, while FG and BG denote the foreground and background image respectively.


In the above-stated equation, only the RGB values of the images are known and the alpha values are still needed to be estimated.

To simplify the estimation process of the alpha matte, many image matting models rely on user intervention in the form of a manually labeled trimap. A trimap is a densely labeled opacity map of the known and unknown regions in a given image. The known region includes the foreground and the background whose values are 1 and 0 respectively, whereas the unknown region includes the boundary regions whose opacity indices are not determined. The unknown regions are given an alpha value of 0.5. An alternative to trimap is stroke. Strokes are labeled regions of background and foreground that are manually marked using coarsely scribbled markings. As a result, stroke-based algorithms are lower in quality as a trade-off to less user input and faster inference speed. Another method for directly processing the RGB input to generate the matting features is spectral matting. Levin’s spectral matting is a semi-automated approach that also requires user guidance to select the foreground features. The need for user intervention not only causes processing latency and expense in the matting workflow but also acutely limits the application of image matting.

Our proposal is a fully automated network for image segmentation-matting which can accurately segment out the target foreground from general natural images such as the COCO [23]

dataset. Our model takes an RGB image as an input and generates a highly accurate alpha matte for the target foreground, without additional user-labeled input. Our proposed deep learning approach encapsulates two stages in a single network, namely the segmentation phase which is responsible for generating a coarse trimap of the target foreground, followed by a matting phase which is responsible for converting the trimap prediction and the RGB image into a detailed alpha matte of the foreground objects.

In the segmentation phase, an RGB image is fed into a DeepLabV3+ [6] network, which predicts a binary mask of the target foreground. The predicted mask is used to retrieve the bounding box of the object, which is used as an informative input to estimate the trimap from the binary mask using an erosion-dilation (ED) layer at the end of the Deeplab network. Unlike other similar works [17], our ED module is built as a part of the network to make the system homogeneous in nature. A homogeneous network not only makes end-to-end training possible (Section 4.1) but also makes the system less prone to code library errors and faster in terms of inference speed. We chose semantic segmentation (returns the mask) over instance segmentation (returns the bounding box and the mask) because, on a CPU run-time, a semantic segmentation model gives a considerable advantage over an instance segmentation model in terms of inference speed, which is a very important factor that affects a production service. The trimap generation phase is followed by a matting phase, which uses the RGB image and the generated trimap to generate the final alpha matte.

Our matting phase is inspired by the Deep Image Matting Network (DIM) [37]. DIM largely borrows its inspiration from SegNet [5], which uses unpooling for upsampling. One of the major advantages of using SegNet for such a task is the recovery of boundary details, that are mostly missed by other architectures such as DeepLabv3+ and RefineNet [21]

. The major reason behind the fact that SegNet is better in recovering boundary details is that unpooling utilizes max-pooling’s index guidance for upsampling. On the other hand, bi-linearly interpolated feature maps fail to emphasize on the boundary details. In order to record the boundary locations, the responses of the shallow layers of the network are used to project the excitation of various index locations on the feature maps into an attention mask.

In this paper, we not only demonstrate the effectiveness of AlphaNet on natural image matting but also on the quality of learned boundary details by visualizing learned indices, which shows that our network successfully captures the boundaries and textural patterns.

Ii Related Works

Image matting methods for natural scenes has been under continuous research in the past few decades. Many of the developed methods predict the alpha matte through the propagation of color [4, 7, 20, 12], sampling [2, 13, 31, 35] or low-level feature analysis. In the research literature of image matting, there are many non-learning types such as Bayesian-based [2], sampling-based [29] and affinity-based methods like Poisson Matting [10], Closed-form Matting [20]

, and KNN Matting 


. However, in recent years, due to the rise of deep learning for computer vision, many convolutional neural network-based learning methods have been introduced for the task of general image matting in natural scenes. The advantage of learning-based methods is that the model learns the semantic meaning of the objects, thus performing exceptionally in cases where the background and foreground colors are similar. One such well-known network designs include deep image matting by Xu et al. 

[37]. Nonetheless, all these methods require trimap or scribbles from the user as compulsion to estimate the alpha matte. Lately, types of research [33][39] have proposed an automatic matting system. Zhu et al. [39] and Shen et al. [33] use fast filter similar to guided filters [14] and closed-form matting with CNN respectively to automatically estimate the alpha mattes of portrait images. Chen et al. [8] also introduced an automatic method for human matting that takes an RGB image as input and primarily predicts the background, foreground and transition region using the three-class segmentation network. The result of the segmentation phase is then used as a trimap for the alpha matte generation. Hu et el. [17] proposed an integration of instance segmentation and image matting processes to generate alpha mattes. Zhang et el. [38] proposes a convolutional network with two decoder branches for the foreground and background segmentation respectively, followed by a fusion branch that integrates the two classification results into an alpha matte. Aksoy et el. [3] proposes a method for soft segmentation that captures the soft transitions between semantically meaningful regions by fusing high-level and low-level features of the image in a single graph structure. However, all the above-mentioned methods fail to recover detailed alpha mattes in case of high depth images, where the disparity between the foreground and the background is minimum.

Our other related work field is upsampling. Upsampling is an important stage in the network decoding phase for the task of dense prediction. The initial operator of upsampling was deconvolution which was initially used for visualizing the convolutional activations and was later extended to semantic segmentation. But deconvolution can easily have uneven overlap, putting more of the metaphorical paint in some places than others which leads to checkerboard artifacts. To avoid this uneven overlap of artifacts, resize + convolution paradigm was suggested. This paradigm presently serves as a standard configuration for most of the state-of-the-art semantic segmentation networks [6][21]. Apart from these, unpooling [5] and perforate [26] operators were also suggested for generating sparse index maps to guide upsampling. However, these operators induce sparsity into the upsampled output but preserve the boundary information. [34]

introduces periodic shuffling which is a memory efficient and fast upsampling operator, generally used for the task of super-resolution. Lu et el. 

[24] introduced a concept of index learning in their research through a novel index-guided encoder-decoder framework which use the data to automatically learn the indices to guide upsampling and pooling operator.

In our work, we propose an attention module for the matting network, which can be considered as a combination of holistic and depthwise index networks [24]. We realize the importance of spatial information, thus we preserve it during the encoding phase of the network. The stored spatial information is utilized by the encoding and decoding phase of the network during downsampling and upsampling respectively. For achieving the same, we use an attention module that self-learns the attention map from the data itself.

Iii Our Method

In this section, we introduce the model architecture of the proposed method (Figure 2) and explain how each phase of the pipeline works individually and together. The model takes an RBG image as an input into the segmentation network and generate a binary segmentation mask for the foreground objects. The binary mask is used to estimate the bounding box, which is used as an input to the Erosion-Dilation (ED) Layer along with the mask to generate a trimap. The trimap generated by this process is coarse and contains many uncertain regions, mostly along the edges of the generated mask. This trimap is then concatenated with the RGB image and serves as an input to the matting network. The matting network is an attention guided model that estimates an alpha matte from the RGB image and the generated coarse trimap. The predicted alpha matte is then compared to the ground truth using different loss functions, and the gradient is calculated for network parameter optimization.

Fig. 2: Overview of AlphaNet Architecture. Given an input image, a Segmentation-Trimap net, which is implemented as DeeplabV3+ with a ED Layer, is used to predict a trimap. The predicted trimap is then concatenated behind the input image as the fourth channel and fed into the matting net to predict the raw alpha matte which is processed with predicted trimap to generate the final alpha matte. The entire network is trained in an end-to-end fashion.

Iii-a Segmentation and Trimap Estimation Phase

The initial phase of AlphaNet is segmentation. The segmentation network comprises DeepLabV3+ [6] encoder-decoder architecture with an additional erosion-dilation layer at the end to convert the binary output into a coarse trimap. The segmentation stage of our model could use any semantic segmentation model that produces a binary mask. We use DeepLabV3+ with a ReseNet18 backbone and pre-trained on the supervisely dataset [1]. The pre-training dataset consists of 5711 images with 6884 high-quality annotated person instances. There are some additional advantages of pre-training on the supervisely dataset as compared to other public datasets. Human segmentation is a critical task in case of natural scenes, therefore a network pre-trained on such high-quality segmentation masks creates a robust initial checkpoint for training.

Trimap estimation takes the output of the segmentation model along with additional derived information of the object bounding box. The trimap estimation phase makes an assumption that only the region near the mask boundary requires further estimation by the image matting model. This assumption is a major reason for the bottlenecks listed in Section 4.2.1 . A certain region eroded and dilated from the object binary mask is marked to be the unknown region in the trimap with

. Other pixels that are inside the mask are classified as foreground with

, while the pixels other than the unknown and foreground pixels are assigned . The extent of erosion and dilation is determined by the calculated object dimensions. Height is approximated by , whereas width is approximated by . The erosion and dilation rates are accordingly fixed as a percentage of the average height and width. However, there is a trade-off in adopting a lower or higher erosion-dilation rate. In our observation, when the true object boundary and the mask boundary are near, a small erosion-dilation rate is sufficient to cover the refinement region. But in some cases, when an object mask has errors along the boundaries, a large erosion-dilation rate tends to recover better and larger uncertainty region in the trimap. In order to estimate a precise alpha matte, a precise trimap is favored to impose a strong constraint on the matting half of the network.

Iii-B Matting Phase

Our matting phase is inspired by the learning-based method, proposed by Lin et al. [37], named as Deep Image Matting (DIM). DIM is a VGG16 based encoder-decoder network with an additional fully-connected refinement block. DIM shows exceptional results on images with a natural background where the color similarity between the foreground and background is very high. Unlike many non-learning methods, the quality of the trimap doesn’t carry much dependency on the performance of this data-driven model. DIM was originally trained on 431 unique alpha mattes but the variety of the included objects is still narrow as compared to other known object classification datasets.

Iii-B1 Encoder-Decoder

Unlike Deep Image Matting, in our work, we built a MobileNetV2 [30]

based encoder-decoder with an additional attention module to guide the upsampling and downsampling operators, which compensates the utility of the refinement block in DIM. Using mobilenetv2 gives us an inference-time speedup on a CPU as compared to other heavy backbones. Figure 2 shows a basic overview of our network architecture. AlphaNet’s matting phase follows a simple encoder-decoder paradigm with an attention module attached to all the pooling and unpooling layers. The pooling and unpooling layers follow a common configuration of 2 x 2 kernel size and 2 stride. At the core of our network is the attention module, that ingests the feature maps from the encoder branch and generates an attention map to guide the downsampling and upsampling operators. In this research, we also investigate alternate ways for context encoding and low-level feature fusion, but due to lack of any substantial-conclusion, we skip sharing the metrics for the same.

Iii-B2 Attention Module

Our attention module models the attention map as a function of the encoder feature map . The module generates two attention maps for the upsampling and downsampling operators respectively. The attention map has the same spatial dimension as the input feature map but with just one channel containing a specific attention weightage for every index i in F, . The chosen range for provides smooth optimization and helps in better convergence. The attention mechanics consists of a predefined attention block followed by two normalization layers. The core of the attention block consists of a fully convolutional neural network that interprets an input feature map into an attention map. The attention block learns an attention function .

As shown in the attention function, all channels of the feature map get projected into a single attention map. The attention block is followed by two normalization layers that are responsible for normalizing the attention map for encoder and decoder differently. The attention map for the encoder is first normalized by a sigmoid function, which is followed by another normalization by a softmax function. The two normalization of the encoder attention map ensure the magnitude consistency of the feature map post downsampling. However, the decoder attention map only gets normalized by a sigmoid function. Once the attention maps are normalized, they are fed to the encoder and decoder pooling and unpooling operators respectively. In the case of an encoder, given a local region

and its computed attention map , we compute a sum pooling operation of the element-wise multiplication . However, in the case of decoder, given a local region and its computed attention map , we upsample the element-wise multiplication

. The major difference between normal pooling-unpooling and our method is that normal operation applies a fixed learned kernel to all the regions, whereas our module applies different kernels to different regions, based on the calculated attention maps. Concrete design of the attention module can be seen in Figure 3. The attention module assumes a non-linear relationship between the attention map and the feature map. The assumption is natural because a linear function cannot even fit the max function, so assuming a non-linear relationship makes the network more flexible in terms of learning abstract relationships inside the feature maps. The module is implemented as a fully convolutional network. It first uses four parallel 4 x 4 group convolution with 2-stride, 1 padding, and 2 groups on a feature map of dimensions H x W x C, generating an attention map of size H/2 x W/2 x 2C. This operation is followed by a group normalization 


layer and a ReLU activation for nonlinear mappings. The generated tensor is then processed with two point-wise convolution layer to achieve feature map pooling, generating an attention map of dimension H/2 x W/2 x 1. The final attention map is composed of the four downsampled attention maps by shuffling and rearrangement (Pixel Shuffle upsampling). Note that we experimented a lot with different network configurations for the attention module, and most of them achieved similar results with slight improvements. It’s also important to note that the parameters of four convolutional layers in the attention module are not shared.

Fig. 3: Attention Module

Iii-C Relation to Other Networks

In this subsection, we discuss our relationship with some of the published researches that have a similar spirit.

Indices Matter (IndexNet) [24]

. IndexNet suggests a plug-in indexing module applying to any off-the-shelf CNN, using two major types of index networks, DIN and HIN. Both HIN and DIN have their pros and cons. One of the major pros of IndexNet is its flexible network module which learns indices adaptively from the data to guide the downsampling and upsampling operators. However, its cons include the overfitting tendency of DIN and the lower capacity of HIN. Also, due to the use of batch normalization in the index module, the parameter tuning on small batch sizes becomes difficult. On the other hand, the attention module of AlphaNet uses group normalization and different network architecture, that make use of the better half of HIN and DIN, while ruling out the negative sides.

Attention Networks [25]. AlphaNet shares a very close resemblance with the present existing family of attention networks, that works on a simple mechanism of multiplicative operation between a generated attention map and the feature map. Unlike other attention networks that work on refining the feature map, our attention mechanism just emphasize on guiding the upsampling and downsampling operators.

Deformable Convolution Networks (DCNs) [9]. DCN proposes deformable convolution and RoI pooling by predicting the offsets of convolutional and pooling kernels respectively. DCN also seeks to enhance the transformation modeling capability of convolutional networks by giving a dynamic nature to CNN. AlphaNet also shares the same spirit of making a dynamic learning module that learns an attention map from the data itself.

Fig. 4: Qualitative results on the testing set. From left to right, the original image, LFM(pre-trained on DIM), closed-form matting, KNN matting, DIM with Refinement block, AlphaNet and ground-truth alpha matte.

Iv Results and Discussion

We implement our proposed network with PyTorch 

[27], a framework for coding deep networks. The segmentation and matting stages are first pre-trained and then fine-tuned end to end as explained in this section.

Methods MSE () SAD () Gradient () Connectivity ()
DeeplabV3+ + CF 5.132 8.761 21.528 43.152
DeeplabV3+ + IFM 4.271 7.566 19.712 52.414
DeeplabV3+ + KNN 4.315 7.609 20.416 56.319
DeeplabV3+ + DIM 3.743 6.002 19.397 41.748
LMF (pre-trained on DIM dataset) 5.725 8.641 22.172 42.021
AlphaNet w/o Attention 3.941 6.820 20.143 42.672
AlphaNet 3.794 6.159 19.442 42.001
TABLE I: Quantitative Results on the test Split. Top results are emphasized in bold.

Dataset: We trained our model on a self-curated large scale high-quality image matting dataset, emphasized majorly on human portraits, fashion accessories and some strongly, medium and little transparent objects (the classification of transparent objects can be seen in the test set of [28] — highly Transparent, strongly transparent, medium transparent and little transparent). Our dataset has 25,236 training image and 1,500 testing images. It is important to note that only a fraction of the mentioned number of images is unique foregrounds, composed of different backgrounds from MS COCO [23] to reach the mentioned number. We evaluate our method on a test set made from our own curated dataset and the Adobe Image Matting test set [37]

. It is also important to note that, our dataset has samples from sensitive commercial sources, because of which it cannot be open-sourced.

Measurement: We evaluated the quality of the output matte using four metrics: Mean Squared Error (MSE), Sum of Absolute Differences (SAD), and perceptually motivated Connectivity (Conn) and Gradient (Grad) errors. Mean squared error and sum of absolute differences are directly correlated to the training objective, whereas the connectivity and gradient error evaluate the perceptual visual quality as assessed by a human observer. To calculate these metrics, we normalized the ground truth and predicted alpha to a range between 0 and 1. Also, unlike other similar works, all our metrics were calculated over the entire image instead of the unknown regions, followed by a basic average by the number of pixels. The evaluation code implemented similar to [37] is used. We also perform extensive ablation studies to justify choices of model design.

Baselines and Comparative Models

We evaluated the capability and effectiveness of AlphaNet by comparing it with some of the following state-of-the-art matting methods: KNN matting [7], Late Fusion Matting (pre-trained on the DIM dataset) [38], Deep Image Matting (DIM) [37], Close Form matting (CF) [20] and Information Flow Matting (IFM) [4]. Some of these matting methods are interactive in nature and require trimap as a fourth channel input alongside the RGB. Therefore, to achieve a fair evaluation and comparison, we connect them with the predicted trimaps of our segmentation and trimap generation phase (Section 3.1) and also evaluated them separately by providing the trimap ground truths.

Methods MSE () SAD () Gradient () Connectivity ()
TrimapGT + CF 4.942 8.592 21.149 42.861
TrimapGT + IFM 4.155 7.238 19.860 52.217
TrimapGT + KNN 3.952 6.984 19.539 53.628
TrimapGT + DIM 3.612 5.931 19.179 40.927
AlphaNet 3.794 6.159 19.442 42.001
TABLE II: Quantitative Results on the test Split with trimap GT for interactive models. Top results are emphasized in bold.
Fig. 5: Qualitative results on the testing set with Trimaps. From left to right, the original image, Trimaps, Closed-form matting, KNN matting, DIM with Refinement block, AlphaNet and ground-truth alpha matte.

Iv-a Implementation Details

In this section, we describe some essential training details and other adopted strategies. We used the pre-train technique [16] [32], a very effective and widely adopted technique in the deep learning domain. Following this practice, we first pre-train the segmentation and matting net separately and then the two nets are combined to make AlphaNet and finetuned in an end-to-end manner. One major advantage of adopting this technique is that we can use extra data specific to the sub-tasks for training the networks. Also, it was carefully noted that the pre-training set does not overlap with the testing set.

Segmentation Net Pre-training: Segmentation net comprise a DeeplabV3+ model with an additional erosion-dilation layer at the end. Since the ED layer is non-differentiable, the segmentation net was pre-trained as a normal semantic segmentation model. For training, images were uniformly resized to 496 x 496 spatial resolution, followed by the augmentation of the samples to avoid overfitting. It is worth noting that the model was pre-trained on supervisely dataset

Matting Net Pre-training: To pre-train the matting net, we follow a similar training configuration as used in deep image matting [37]

. For data augmentation, we used 320 x 320 random cropping, followed by random flipping and random scaling. We used ImageNet 

[18] pre-trained parameters for the encoder as the initial checkpoint. For initializing all the other parameters, we utilized a better form of [11], which was proposed in [15][15]

shows that "Xavier" has a very direct conclusion for the derived variance being adopted for Gaussian distributions only. We used Adam 


for optimization and trained the net for about 50 epochs. The batch size is set to 16 along with fixing the BN layers of the backbone.

AlphaNet Training

: In order to perform end-to-end training of AlphaNet, we first initialize AlphaNet with the pre-trained segmentation and matting net. During training, the input samples are augmented on-the-fly using random horizontal flipping (0.5 probability). We also rescale the longer dimension of the input if it exceeds 1500 pixels to cap it to 1500 for the GPU memory limitation. The predicted alpha matte is then rescaled back to its original size for the evaluation. This technique enables AlphaNet to perform testing on CPU for high-resolution images, without any significant loss of resolution. One major catch in the end-to-end training is that the gradient is unable to flow from the matting net to the segmentation net, due to the non-parametric nature of the erosion-dilation layer. Thus, only the loss value of the matting net flows back as a feedback to the segmentation net (end-to-end non-differentiable).

Loss: For pre-training the segmentation net, we mainly used a combination focal [22] and dice loss. For pre-training the matting net, we adopted compositional and alpha prediction loss. The compositional loss ( ) can be defined as the absolute difference between the predicted alpha compositional image and the ground truth compositional image. Whereas, the alpha prediction loss ( ) can be defined as the absolute difference between the predicted alpha and the ground truth alpha. The overall loss is then calculated according to the following equation.

Where , and in our case. Unlike similar works that only compute loss over the unknown regions, our prediction loss is summed over the complete image.

Iv-B Performance Comparison

In this sub-section, we study the comparison of AlphaNet vs the state-of-the-art image matting models. To get a fair comparison, we feed the interactive models with our segmentation net generated trimaps. Table 1 summarizes the quantitative result of our evaluation.

Considering the complex structural details to be learned by the models, the resulting metric shows that the automatic models outperform most of the interactive matting models. DIM connected with DeeplabV3+ outperforms all the other models, mainly due to its efficiency to learn complex context and the add-on advantage of the extra refinement block. But we can see from the results that AlphaNet not only performs better than most of the baselines but also better than LFM (a completely automatic method). The major reason is the attention learning capability of our model that enables it to learn fine details and coarse semantics. Fig. 4 summarizes several visual evaluations and respective comparisons with all the baselines. It can be clearly seen from the results that our model was able to recover subtle details and generate much clearer mattes with good local contrast.

Iv-B1 Dataset Bottleneck

There are majorly four categories of data in the image matting datasets. The categories include highly transparent, strongly transparent, medium transparent and little transparent entities [28]. One major drawback of our work is that we emphasized our dataset on only strongly, medium and little transparent objects. We dropped the category of highly transparent objects because of the low availability of such data in context with our fashion e-commerce industry. Therefore, as our network was not exposed to highly transparent objects, it fails to model the transparency of pixels deep within the boundaries of the object. We plan to remove this data bottleneck in our next version and come up with a more generic model that covers the matting of highly transparent objects and also extends our dataset domain wider than just fashion e-commerce.

Iv-C Ablative Study of Different Components

Effectiveness of End-to-end Training

The end-to-end training strategy’s effectiveness is calculated by comparing end-to-end trained AlphaNet with the one consisting of only pre-trained parameters. Table 1 shows the results for the same. It can be easily observed from the result metric that end-to-end trained AlphaNet outperforms individually pre-trained nets, thus proving the effectiveness of end-to-end training.

The Evaluation of Attention Module

The effectiveness and importance of our proposed attention module is validated by simply comparing the version of AlphaNet with an attention module to another baseline version with no attention module. The attention-less module is also trained for the same objective as the attention version. On comparing the evaluation metrics of the two versions, it can be seen that AlphaNet with an attention module performs better than the baseline version. It is also worth noting that although most of the metrics are quantitatively small, connectivity and gradient error of the non-attention baseline is relatively large. The major reason for the large error is the blurring of structural details, induced by the encoder-decoder without external guidance of an attention network. Therefore, our proposed attention module not only leverages the coarse estimation of the generated trimap, but also plays a key role in enhancing the overall performance of AlphaNet.

V Conclusion

In this work, we propose AlphaNet, a fully automated image matting method. Our method does not require any human interaction to predict smooth alpha mattes. The proposed method can be seen both as a fully automated semantic image matting method and a refinement of existing semantic segmentation models that work on common datasets. We compared and presented our results with the related works and proved how AlphaNet not only outperforms many but also shows comparable performance with the remaining. We also proposed a novel attention module that along with the encoder-decoder net, captures local details and global semantic context to generate high-quality alpha mattes automatically. Furthermore, we also created a high-quality fashion e-commerce oriented dataset. Benefiting from our own curated dataset and model architecture, our method registers comparable results with state-of-the-art matting methods.


We would like to thank our organization for the constant support, resources and valuable suggestions for conducting this research.


  • [1] External Links: Link Cited by: §III-A.
  • [2] (2001-12) A Bayesian Approach to Digital Matting. In Proceedings of IEEE CVPR 2001, Vol. 2, pp. 264–271. Cited by: §II.
  • [3] Y. Aksoy, T. Oh, S. Paris, M. Pollefeys, and W. Matusik (2018) Semantic Soft Segmentation. ACM Transactions on Graphics (Proc. SIGGRAPH) 37 (4). Cited by: §II.
  • [4] Y. Aksoy, T. O. Aydin, and M. Pollefeys (2017) Designing Effective Inter-Pixel Information Flow for Natural Image Matting. CoRR abs/1707.05055. Cited by: §II, §IV.
  • [5] V. Badrinarayanan, A. Kendall, and R. Cipolla (2017) SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation. IEEE Transactions on Pattern Analysis and Machine Intelligence 39, pp. 2481–2495. Cited by: §I, §II.
  • [6] L. Chen, Y. Zhu, G. Papandreou, F. Schroff, and H. Adam (2018) Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation. CoRR abs/1802.02611. Cited by: §I, §II, §III-A.
  • [7] Q. Chen, D. Li, and C. Tang (2012) KNN Matting. IEEE Transactions on Pattern Analysis and Machine Intelligence 35, pp. 2175–2188. Cited by: §II, §IV.
  • [8] Q. Chen, T. Ge, Y. Xu, Z. Zhang, X. Yang, and K. Gai (2018) Semantic Human Matting. CoRR abs/1809.01354. Cited by: §II.
  • [9] J. Dai, H. Qi, Y. Xiong, Y. Li, G. Zhang, H. Hu, and Y. Wei (2017) Deformable Convolutional Networks. CoRR abs/1703.06211. Cited by: §III-C.
  • [10] E. S. L. Gastal and M. M. de Oliveira Neto (2010) Shared Sampling for Real-Time Alpha Matting. Comput. Graph. Forum 29, pp. 575–584. Cited by: §II.
  • [11] X. Glorot and Y. Bengio (2010-01) Understanding the difficulty of training deep feedforward neural networks.

    Journal of Machine Learning Research - Proceedings Track

    9, pp. 249–256.
    Cited by: §IV-A.
  • [12] L. Grady and R. Westermann (2005) RANDOM WALKS FOR INTERACTIVE ALPHA-MATTING. Cited by: §II.
  • [13] K. He, C. Rhemann, C. Rother, X. Tang, and J. Sun (2011) A global sampling method for alpha matting. CVPR 2011, pp. 2049–2056. Cited by: §II.
  • [14] K. He, J. Sun, and X. Tang (2013-06) Guided Image Filtering. IEEE transactions on pattern analysis and machine intelligence 35, pp. 1397–1409. External Links: Link Cited by: §II.
  • [15] K. He, X. Zhang, S. Ren, and J. Sun (2015) Delving Deep into Rectifiers: Surpassing Human-Level Performance on ImageNet Classification. CoRR abs/1502.01852. Cited by: §IV-A.
  • [16] G. Hinton, S. Osindero, and Y. Teh (2006-08) A Fast Learning Algorithm for Deep Belief Nets. Neural computation 18, pp. 1527–54. External Links: Link Cited by: §IV-A.
  • [17] G. Hu and J. J. Clark (2019) Instance Segmentation based Semantic Matting for Compositing Applications. CoRR abs/1904.05457. Cited by: §I, §II.
  • [18] (2009) ImageNet: A Large-Scale Hierarchical Image Database. In CVPR09, Cited by: §IV-A.
  • [19] D. P. Kingma and J. Ba (2014) Adam: A Method for Stochastic Optimization. CoRR abs/1412.6980. Cited by: §IV-A.
  • [20] A. Levin, D. Lischinski, and Y. Weiss (2006) A Closed-Form Solution to Natural Image Matting. IEEE Transactions on Pattern Analysis and Machine Intelligence 30, pp. 228–242. Cited by: §II, §IV.
  • [21] G. Lin, A. Milan, C. Shen, and I. D. Reid (2016) RefineNet: Multi-Path Refinement Networks for High-Resolution Semantic Segmentation. CoRR abs/1611.06612. Cited by: §I, §II.
  • [22] T. Lin, P. Goyal, R. B. Girshick, K. He, and P. Dollár (2017) Focal Loss for Dense Object Detection. CoRR abs/1708.02002. Cited by: §IV-A.
  • [23] T. Lin, M. Maire, S. J. Belongie, L. D. Bourdev, R. B. Girshick, J. Hays, P. Perona, D. Ramanan, P. Dollár, and C. L. Zitnick (2014) Microsoft COCO: Common Objects in Context. CoRR abs/1405.0312. Cited by: §I, §IV.
  • [24] H. Lu, Y. Dai, C. Shen, and S. Xu (2019) Indices Matter: Learning to Index for Deep Image Matting. In Proc. IEEE/CVF International Conference on Computer Vision (ICCV), Cited by: §II, §II, §III-C.
  • [25] V. Mnih, N. Heess, A. Graves, and K. Kavukcuoglu (2014) Recurrent Models of Visual Attention. CoRR abs/1406.6247. Cited by: §III-C.
  • [26] C. Osendorfer, H. Soyer, and P. van der Smagt (2014) Image Super-Resolution with Fast Approximate Convolutional Sparse Coding. In ICONIP, Cited by: §II.
  • [27] A. Paszke, S. Gross, S. Chintala, G. Chanan, E. Yang, Z. DeVito, Z. Lin, A. Desmaison, L. Antiga, and A. Lerer (2017) Automatic differentiation in PyTorch. Cited by: §IV.
  • [28] C. Rhemann, C. Rother, J. Wang, M. Gelautz, P. Kohli, and P. Rott (2009) A Perceptually Motivated Online Benchmark for Image Matting. In

    Proceddings of the IEEE Conference on Computer Vision and Pattern Recognition

    Cited by: §IV-B1, §IV.
  • [29] M. A. Ruzon and C. Tomasi (2000) Alpha estimation in natural images. Proceedings IEEE Conference on Computer Vision and Pattern Recognition. CVPR 2000 (Cat. No.PR00662) 1. Cited by: §II.
  • [30] M. Sandler, A. G. Howard, M. Zhu, A. Zhmoginov, and L. Chen (2018) Inverted Residuals and Linear Bottlenecks: Mobile Networks for Classification, Detection and Segmentation. CoRR abs/1801.04381. Cited by: §III-B1.
  • [31] E. Shahrian, D. Rajan, B. L. Price, and S. Cohen (2013) Improving Image Matting Using Comprehensive Sampling Sets. 2013 IEEE Conference on Computer Vision and Pattern Recognition, pp. 636–643. Cited by: §II.
  • [32] R. Sharma and A. Vishvakarma (2019) Retrieving Similar E-Commerce Images Using Deep Learning. CoRR abs/1901.03546. Cited by: §IV-A.
  • [33] X. Shen, X. Tao, H. Gao, C. Zhou, and J. Jia (2016) Deep Automatic Portrait Matting. In ECCV, Cited by: §II.
  • [34] W. Shi, J. Caballero, F. Huszár, J. Totz, A. P. Aitken, R. Bishop, D. Rueckert, and Z. Wang (2016) Real-Time Single Image and Video Super-Resolution Using an Efficient Sub-Pixel Convolutional Neural Network. CoRR abs/1609.05158. Cited by: §II.
  • [35] J. Wang and M. F. Cohen (2007) Optimized Color Sampling for Robust Matting. 2007 IEEE Conference on Computer Vision and Pattern Recognition, pp. 1–8. Cited by: §II.
  • [36] Y. Wu and K. He (2018) Group Normalization. CoRR abs/1803.08494. Cited by: §III-B2.
  • [37] N. Xu, B. L. Price, S. Cohen, and T. S. Huang (2017) Deep Image Matting. CoRR abs/1703.03872. Cited by: §I, §II, §III-B, §IV-A, §IV, §IV, §IV.
  • [38] Y. Zhang, L. Gong, L. Fan, P. Ren, Q. Huang, H. Bao, and W. Xu (2019-06) A Late Fusion CNN for Digital Matting. In The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Cited by: §II, §IV.
  • [39] B. Zhu, Y. Chen, J. Wang, S. Liu, B. Zhang, and M. Tang (2017) Fast Deep Matting for Portrait Animation on Mobile Phone. CoRR abs/1707.08289. Cited by: §II.