{'fraction_non_alphanumeric': 0.036031314487864, 'fraction_numerical': 0.007566576042451439, 'mean_word_length': 4.932763311309755, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
GlassNet: Label Decoupling-based Three-stream Neural Network for Robust Image Glass Detection

Most of the existing object detection methods generate poor glass detection results, due to the fact that the transparent glass shares the same appearance with arbitrary objects behind it in an image. Different from traditional deep learning-based wisdoms that simply use the object boundary as auxiliary supervision, we exploit label decoupling to decompose the original labeled ground-truth (GT) map into an interior-diffusion map and a boundary-diffusion map. The GT map in collaboration with the two newly generated maps breaks the imbalanced distribution of the object boundary, leading to improved glass detection quality. We have three key contributions to solve the transparent glass detection problem: (1) We propose a three-stream neural network (call GlassNet for short) to fully absorb beneficial features in the three maps. (2) We design a multi-scale interactive dilation module to explore a wider range of contextual information. (3) We develop an attention-based boundary-aware feature Mosaic module to integrate multi-modal information. Extensive experiments on the benchmark dataset exhibit clear improvements of our method over SOTAs, in terms of both the overall glass detection accuracy and boundary clearness.


Introduction
Transparent glass is widely used in our daily life, such as glass windows/doors and many other glass products. However, it commonly hinders many vision-related tasks like depth prediction, instance segmentation, refection removal, and object detection, etc. For example, when an intelligent robot or an unmanned plane operates automatically, they should avoid crashing into the glass. It is, therefore, essential to accurately detect the overall glass with its boundary clearly from single images. Unfortunately, most of the existing object detection methods generate inaccurate or even wrong regions of the glass with fuzzy boundaries, due to the fact that the glass is transparent. That means, a glass region nearly has no fixed patterns; the pattern is determined by the arbitrarily appeared object behind the glass. Therefore, unlike many other objects which have relatively fixed patterns to detect more easily, the same appearance between the glass region and the objects behind it makes existing object detection methods work ineffectively. We list three representative detection approaches in Figure 1, i.e., DANet [FLT*19] for semantic segmentation, EGNet [ZLF*19] for edge-guided salient object detection, GDNet [MYW*20] for glass detection, as well as our proposed GlassNet. As shown, DANet wrongly considers the background as the glass; EGNet also yields wrong detection regions; although GDNet [MYW*20] pioneers to automatically detect glass from single images, it leads to inaccurate glass boundaries; while the proposed network operates smoothly on these two challenging images: the glass is exactly detected with its clearer boundaries by GlassNet.
Intuitively, like other vision tasks, a straightforward solution to enhance the glass detection ability, is to use boundaries of the glass as auxiliary supervision. However, in an image with glass in it, the glass-boundary pixels are much rarer than other pixels. Such a very unbalanced distribution of the glass-boundary pixels will introduce large prediction errors around the glass boundary. To this end, we arise an intriguing question that if the glass boundary diffuses itself into the glass's interior and the interior diffuses itself from its center to boundary, a deep network can better focus on regions around the glass boundary and concentrate on center areas of the glass object? To answer it, 1) we first use label decoupling (LD) [WWW*20] to explicitly decompose the original glass map into an interior-diffusion map and a boundary-diffusion map, where the first map is concentrated in the center of glass objects and the second map focuses on regions around glass boundaries; 2) based on the three different types of label information, we propose a threestream neural network for robust glass detection (GlassNet). For the interior-diffusion stream, we only use the highest two-level image features with rich semantic information to locate the glass region; for the boundary-diffusion stream, all levels of information are aggregated to make the detection result more accurate; for the original glass stream, we utilize the lowest two-level image features with more detailed information and highest-level image features to predict the final glass maps.
Meanwhile, we design a multi-scale interactive dilation module with a large receiving field to integrate the features from adjacent levels. And we propose an attention-based boundary fusion module to merge the boundary and glass features. We have tested all the approaches on the benchmark dataset GDD [MYW*20] and our GlassNet achieves a very competitive performance. In summary, our contributions are mainly four-fold: • We observe that in an image with glass in it, the glass-boundary pixels are much rarer than other pixels. Such a very imbalanced distribution of the glass-boundary pixels introduces large prediction errors around the glass boundary when performing object detection. To break such an imbalanced distribution between glass-boundary pixels and non-glass-boundary pixels, we utilize the label decoupling procedure to decompose a glass label into an interior-diffusion map and a boundary-diffusion map to supervise the network training.
• We propose a three-stream network, called GlassNet, which is enhanced by label decoupling features to produce more precise glass maps. • We design a multi-scale interactive dilation module to explore a wider range of contextual information and an attention-based boundary-aware feature Mosaic module to integrate multi-modal information.
• Extensive experiments on the benchmark dataset exhibit clear improvements of our method over SOTAs, in terms of both the overall glass detection accuracy and boundary clearness.

Related Work
In the past two years, glass detection had begun to attract mucch attention, but little work has been done on this topic. In this section, we briefly introduce the methods used in glass detection and the methods that can assist in solving this problem from relevant fields, including semantic segmentation, salient object detection, and mirror detection.
Semantic segmentation. Semantic segmentation is a key problem in the computer vision community, which aims at assigning semantic class labels to each pixel in the given image. With the development of deep neural networks, an end-to-end training architecture method called fully convolutional networks (FCNs) [LSD15] has been proposed to solve this problem, which uses multi-scale context fusion to achieve high segmentation performance. However, the fixed geometric structures of convolution operations in those deep neural networks make the pixels capture local information and short-range contextual information inherently. Thus, Chen et al. [CPK*18] introduce an atrous spatial pyramid pooling module (ASPP) with multi-scale dilation convolutions for contextual information aggregation. Zhao et al. [ZSQ*17] further propose PSPNet to capture a wider range of contextual information by using a pooling operation and the pyramid structure. In addition, the encoder-decoder structures, like U-Net [RFB15], are widely used to fuse middle-level and high-level semantic features.
However, the dilated convolution-based methods [DJS*18;CPSA17] fail to capture global contextual information and cause sparse local information due to their structures. The pool-based methods [ZDS*18;ZTZ*17] aggregate context information in a non-adaptive way to make image pixels use the homogeneous contextual information. Therefore, Wang et al. [WGGH18] introduce non-local networks utilizing a self-attention mechanism [VSP*17; CDL16], which calculate the relationship between each pixel and all other pixels in an image, thus harvesting global contextual information. To solve the problem that self-attention based methods have high computation complexity and occupy a huge amount of GPU memory, Huang et al. [HWH*19] and Fu et al. [FLT*19] respectively propose CCNet and DANet to reduce the parameters.
After that, Carion et al. [CMS*20] adopt Transformer that is widely used in the NLP field, which replaces the convolution layer with the self-attention layer, for semantic segmentation.
Salient object detection (SOD). SOD aims at identifying the most visually distinctive objects or regions in an image, which is widely applied as a pre-processing procedure for downstream tasks [XWL*18; WLF*21]. Early salient object detection methods are mainly based on hand-crafted features (e.g., color, texture, and contrast) to segment salient objects in the scene [YZL*13; ZLWS14; SB15; ZSL*15]. Recent convolutional neural networks (CNNs) [KSH12;SZ14;HZRS16] are extensively used and achieve very remarkable performance.
Ronneberger et al. [RFB15] propose U-Net, a representative network widely used in a variety of graphics processing tasks, which effectively generates more accurate detection results by using a skip connection operation and an encoder-decoder structure. Based on U-Net, many other methods adopt different decoders, combined with multi-level CNN features, and have achieved remarkable performance. Zhang et al. [ZWL*17] introduce an AmuletNet for salient object detection that aggregates an another-level convolutional feature at each different level. Zhang et al. [ZWQ*18] add an attention module to the decoder, which can guide the network to selectively integrate multi-level features. Zhao et al. [ZW19] propose a pyramid feature attention network (PFAN) to enhance the highlevel context features and the low-level spatial structural features. Pang et al. [PZZL20] propose aggregate interaction modules to integrate the features from adjacent levels by using a more complex decoder structure. Besides, more efforts utilize boundary information to improve the accuracy of saliency maps. Zhao et al. [ZLF*19] focus on the complementarity between salient edge information and salient object information and present an edge guidance network (EGNet) for salient object detection. Zhou et al. [ZXL*20] analyze the correlation between saliency and boundary and introduce an interactive two-stream decoder to explore multiple cues, including saliency, boundary, and their correlation. Furthermore, Wei et al. [WWW*20] propose a label decoupling framework (LDF) that exploits more boundary information to enhance salient object detection performance.
Mirror detection. Similar to other image detection tasks, mirror detection aims at segmenting mirror regions in single images. Yang et al. [YMX*19] make the first attempt to automatically detect mirrors and propose MirrorNet by utilizing inconsistencies between the inside and outside of the mirror region, called contextual contrasted features, to segment mirrors from the real scene. The reason is the performance difference between the mirror region and other non-mirror regions. The mirror region reflects the scene in front of the mirror, which makes the semantic and low-level discontinuities often occur at the boundary of the mirror. But not all mirrors have a great distinction between inside and outside. Some of them have little contextual contrasted information. Thus, Lin et al. [LWL20] introduce a model to progressively learn the content similarity between the inside and outside of the mirror while explicitly detecting the mirror boundaries. The scenes reflected by a mirror often exhibit similarities to scenes outside the mirror, which can aid to detect mirror regions by enlarging the receptive fields of the convo-lution operation. Glass detection is very similar to mirror detection that also has the problem of similar foreground and background.
Transparent object detection (TOD). Similar to glass detection, transparent object detection (TOD) aims to segment transparent object regions in single images. Xie et al. [XWW*20] propose a large-scale dataset for TOD named Trans10K and a novel boundary-aware segmentation method termed TransLab to address the transparent object detection problem. However, there exists a difference between TOD and GD: TOD is a multi-label segmentation problem, while GD is a binary segmentation problem. This fact indicates that TOD does not operate smoothly on the GD task and vice versa. This is why we do not compare our method with those TOD methods.
Glass detection. Glass regions in an image do not have a fixed pattern since they depend on what appears behind the glass, and the content of the glass region is the content of the background region. This situation makes it difficult to distinguish between the glass and the background region, even using state-of-the-art segmentation methods. Meanwhile, other object detection methods are also not suitable for glass detection tasks on account of the difference between glass and other objects. Mei et al. [MYW*20] pioneer to propose a novel glass detection network (GDNet) by exploring abundant contextual features from a large receptive field. They utilize multiple well-designed large-field contextual feature integration modules for the precise positioning of the glass region, but this method has poor performance in some cases where the glass boundary region or scene is very complex or the background inside and outside the glass is insufficient. Lin et al. [LHL21] observe that humans often rely on identifying reflections to sense the existence of glass and also rely on locating the boundary in order to determine the extent of the glass. They propose a rich context aggregation module (RCAM) to extract multi-scale boundary features and a reflection-based refinement module (RRM) to detect reflection. Then, they utilize two modules for glass surface detection to solve the problem of insufficient contexts in part of the scene.

Label Decoupling
Many object detection methods pay attention to boundary information for the enhancement of detection accuracy, but the prediction difficulty of boundary pixels is closely related to their locations. Therefore, it is difficult to classify the pixels near the boundary correctly, which is called "hard examples" [CZXL19]. In contrast, the consistency of interior regions makes the central region easier to detect. Therefore, a strategy of dealing with boundary pixels and interior pixels differently will make the detection results more reasonable. However, it is difficult to claim which pixels are hard examples or not, as illustrated in Figure 2. We adopt the label decoupling (LD) strategy proposed by Wang et al. [ZLF*19] to decouple the original glass map into an interior-diffusion map and a boundary-diffusion map, as shown in Figure 3. In more detail, LD uses the simple Distance Transformation (DT) to convert the ground-truth glass map into a new image, where the value of the foreground pixel is the minimum distance from the background obtained by the distance function. Please note that the foreground herein refers to the glass region, and the background means the remaining non-glass region.
Distance Transformation (DT) calculates the distance from the nearest zero points to itself for each non-zero point in an image. Its input is a binary graph such as the ground truth of the image detection task, which can be divided into two groups (i.e., the foreground I f g and the background I bg ). The original metric function is defined as f (p, q) = (px − qx) 2 + (py − qy) 2 to calculate the distance between two pixels, and here we modify f (p, q) to fit our approach. The new distance function is formulated as: For the foreground pixel p, DT calculates the original distance function f (p, q) by looking for its nearest pixel q in the background pixel, and directly sets the value to 0 for the background pixel. We use a linear normalization function I = I −min (I ) max (I )−min (I ) , which normalizes the image generated from the new distance function. Compared with the original image, the new image obtained by defining the distance function depends not only on its foreground or the background but also on its relative position. Therefore, the new image corresponds to the inner part of the original image, and the closer to the center is, the larger the pixel value will be. The boundary images obtained by subtracting the new image from the original image can help deal with the hard examples. To remove the background interference, we process the new image and the original ground truth to generate the interior-diffusion label and boundarydiffusion label as: where BL means the interior-diffusion label and DL represents the boundary-diffusion label. Thus, we decouple the original label into two different kinds of labels, to work in learning both interior and boundary features with different characteristics.  (c) it is challenging to determine the pixels near the boundary to be hard examples or not.

Network Overview
The overview of the proposed model is illustrated in Figure  4, which consists of three parallel streams: an interior-diffusion stream, a boundary-diffusion stream, and a glass stream. We first feed an image to the backbone network to extract multi-scale backbone features. Then, the features of each level are fed into the three streams supervised by the decoupled labels to generate different features. In each stream, we use the Multi-scale Interactive Dilation Module (MID) to extract large-field contextual features, then obtain the glass features, interior-diffusion features, and boundarydiffusion features for each stream. Finally, we use the attentionbased Boundary-aware Feature Mosaic Module (BFM) to integrate the boundary features and interior-diffusion features into the glass prediction maps to generate the final glass map of the whole network. Details of the proposed approach are described as follows.
Feature encoder. We use ResNet-50 [HZRS16] as the backbone network to extract common multi-level image features for the three , EF i+1 = f i (EF i ). Then, we input the different levels of features into the three streams for processing. The features EF 5 and EF 4 are fed into the interior-diffusion stream decoder to roughly locate the glass region. In order to obtain a finer glass boundary, the features {EF i |i = 1, 2, 3, 4, 5} are fed into the boundary-diffusion stream decoder. In addition, we utilize the features {EF i |i = 1, 2, 5} for the glass map generation in the glass stream.
Three-stream decoder. As shown in Figure 4, we built a threestream network to use the label decoupling information. We utilize a label decoupling procedure to decompose a glass label into an interior-diffusion map and a boundary-diffusion map to supervise the model separately. Through the supervision of these three different labels, better detection results can be obtained.
In each stream, we use a Multi-scale Interactive Dilation Module (MID) to extract large-field contextual features. Figure 4 illustrates the detailed structure of the decoder. For the glass stream and the boundary-diffusion stream, we employ the short connections [HCH*17] to merge feature maps EF i at different CNN layers, resulting in new feature maps (denoted as DF i ). Specifically, the merged feature map DF i at the k-th CNN layer (i = 1, ..., 5) is computed by Then, we use MID to generate large-field contextual features MF i , which can be formulated as: where MID(·) is the Multi-scale Interactive Dilation Module. Then, we integrate the different levels of MF through a decoder structure. In particular, we concatenate the output of each level in the boundary-diffusion stream to get the final boundary map. For the interior-diffusion stream, we add EF 4 and EF 5 by using the element-wise addition operation and entering them into MID to generate MF. In this way, different-level feature maps are jointly fused, which is beneficial for semantic segmentation.

Multi-scale Interactive Dilation Module
For glass detection, the key to accurately locate glass regions is to aggregate a wide range of contextual features at different scales. GDNet [MYW*20] exploits the Large-field Contextual Feature Integration (LCFI) module to efficiently extract abundant contextual information from a large field. It utilizes convolutions with large kernels and dilated convolutions to enlarge the receiving field, and spatially separable convolution to reduce the parameters of convolution with large kernels. Inspired by them, we propose a multiscale interactive dilation module (named as MID, as shown in Figure 5) to efficiently aggregate different-scale contextual information for enhancing the glass detection performance.
Specifically, we propose to utilize dilated convolution with different dilation rates to expand the receiving field of each pixel so that it can obtain a wider range of contextual information. After passing the feature map into this module, the maps first pass through a convolution layer for feature extraction at each of the branches. Then, we use dilated convolution to extract a wide range of context features. Different from LCFI [MYW*20], we use the dilation convolution with larger dilation rates, which are set to 2, 4, 8, and 16, respectively. And an additional branch is added which uses a 3 × 3 convolution to obtain more dense local information. Besides, in order to reduce the parameters of the module in the whole network, we remove the large kernel convolution of LCEI. Meanwhile, we adopt Short Connections [HCH*17] to transfer the output of the smaller receiving field branch into the other larger branch for getting dense contextual information. Finally, we integrate the context feature maps of each branch through convolution layers and obtain the feature map MF by utilizing an element-wise addition operation.

Attention-based Boundary-aware Feature Mosaic Module
After obtaining a high-quality boundary prediction map using the boundary-diffusion stream, we utilize a Boundary-aware Feature Mosaic Module (BFM) to integrate the boundary maps into the predicted glass maps generated by the glass stream, as shown in Figure 6. BFM first takes the predicted boundary map, interiordiffusion map, and glass feature map as inputs. Through using the predicted boundary map and the interior-diffusion map as attention maps, we integrate them into the feature maps of the glass stream by using an element-wise product operation ⊗. We concatenate the interior-diffusion map and the boundary-diffusion map and input them into the SE module, respectively to enhance the corresponding boundary-and interior-diffusion features. Here, the SE module is an architectural unit proposed by Hu et al. [HSS18], which is termed as the "Squeeze-and-Excitation" (SE) block, that adaptively re-calibrates channel-wise feature responses by explicitly modelling inter-dependencies between channels. Finally, we add the enhanced features to the input glass feature map to generate the final output.

Loss Function
We use two different loss functions, i.e., the binary cross-entropy (BCE) loss l bce , and the intersection over union (IoU) loss l iou [QZH*19], to supervise the network. The BCE loss is a widelyused loss function in computer vision because of its robustness: [g(x, y)log(p(x, y)) + (1 − g(x, y))log(1 − p(x, y))] (5) IoU is an important metric to evaluate object detection quality by calculating the ratio of the intersection and union of the "predicted box" and "GT box". Recently, it is widely used as the training loss: Therefore, the three different streams are supervised separately by combining different losses. In the interior-diffusion stream, the glass stream, and the final output prediction maps, we adopt the BCE loss and the IoU loss, which can be formulated as: [l bce (p k , g glass ) + l iou (p k , g glass )] (7) L inner = l bce (p k , g inner ) + l iou (p k , g inner ) L f inal = l bce (p k , g glass ) + l iou (p k , g glass ) where L glass is the sum of the different levels of losses in the glass stream, and L f inal is the supervision loss of the final output of the whole network. p k is the prediction map of the different branches in the three streams. g glass is the ground-truth label, and g inner is Output Figure 5: The structure of the Multi-scale Interactive Dilation (MID) module. Conv represents a convolutional layer with a kernel size of 3 × 3, a normalized layer, and a ReLU layer. 3 × 3 means the convolutional kernel size, and rate represents the dilation rate in a dilated convolution. the interior-diffusion label decoupled by the original label. N i and Ng are the numbers of branches in the interior-diffusion stream and the glass stream, respectively. Moreover, we only use the BCE loss in the boundary-diffusion stream: where g boundary is the boundary-diffusion label decoupled by the Therefore, the final loss function is formulated as: 4. Experiments

Datasets and Evaluation Metrics
Currently, there is only a dataset available, i.e., GDD [MYW*20], which is the first large-scale benchmark for glass detection and has 4,018 mirror images with their corresponding masks. We use five metrics widely used by other computer vision tasks to evaluate the performance of our model and existing state-of-the-art methods. First, we use two popular metrics, i.e., the pixel accuracy (acc) and the intersection of union (IoU). Besides, we apply the F-measure [AHES09] and mean absolute error (MAE) metrics from the salient object detection field, which are widely adopted in [CTWH18;LYC*18;LHY18;HCH*17]. The F-measure is the weighted harmonic mean of precision and recall. We use the maxi-mum F-measure (F β ) version as:  where β 2 is set to 0.3 as suggested in [AHES09]. MAE is the mean absolute error, i.e., the mean value of the absolute error between the prediction and the ground truth, which is defined as: where g(x, y) ∈ [0, 1] is the ground-truth label of the pixel (x, y) and p(x, y) ∈ [0, 1] is the predicted probability of being glass. In addition, we select the balance error rate (BER) [VHS15] from the shadow detection field as our last metric, which can be obtained as: where T P, T N, Nn and Np is the numbers of true positives, true negatives, glass pixels and non-glass pixels, respectively.

Implementation Details
We implement the proposed network GlassNet based on the Py-Torch framework [PGM*19] and train it on the benchmark dataset GDD. The pre-trained ResNet-50 network [HZRS16] on ImageNet [DDS*09] is used to initialize the parameters of the backbone, and the other parameters are initialized randomly. We train the whole network by using the stochastic gradient descent (SGD) with a momentum of 0.9 and the weight decay of 5 × 10 −4 . The initial learning rate is set to 0.0001 and is adjusted by poly decay strategies [YWP*18] with a power of 0.9. The network with a batch setting of 4 is trained on an NVIDIA GTX 1080 Ti graphics card. During testing, images are adjusted to the resolution of 512 × 512 for inference without any post-processing. Quantitative Comparison. We compare the proposed network with state-of-the-art methods from the relevant fields mentioned above, which are shown in Table 1. The first, second, and third best results are marked in bold, red, and blue, respectively. Obviously, compared with other methods in related fields, our method is better than the SOTA methods.

Comparison with the
Qualitative Evaluation. Some prediction examples of the proposed method and state-of-the-art approaches have been shown in Figure 7. We observe that the proposed method not only highlights the glass regions clearly but also well suppresses the background noise. It can be seen that our method can accurately detect small glass (e.g., the first four rows), large glass (e.g., the fifth to seventh rows), and others (e.g., the eighth and ninth rows). Although GDNet can locate these regions well, it has low detection accuracy for the boundary regions and cannot even detect the boundary regions correctly. In contrast, our method has higher detection accuracy in the boundary region because we use boundary information to force the network to pay more attention to the boundary region.  boundary-and interior-diffusion branches can effectively improve the performance. Moreover, the effect of the network without the boundary-diffusion stream is worse than that without the interiordiffusion stream, which is consistent with our observation: Boundaries significantly improve the detection ability, which should be specially considered. In addition, the final detection accuracy can also be improved by the proposed multiple mixing losses, as shown in the 4th and 5th lines, where each row omits a loss, i.e., BCE and IOU, respectively. Finally, w/o MID and w/o BFM, respectively, indicate that we do not use any one of the two modules each time in our network, which shows their contributions on improving the glass detection quality. Figure 8 shows a visual example, proving that our method successfully addresses the glass detection problem with the help of boundaries.

Failure cases
GlassNet has two limitations, as shown in Figure 9: 1) in the case of very large-scale glass, e.g., the area of the glass occupies more than 95% or even 100% of the whole image, it may operate poorly on such extreme cases, due to the lack of sufficient contextual information; and 2) it is nearly impossible to detect the glass in the very weak light, since under the very weak-light condition, the boundary area of the glass and the background will share very similar properties, i.e., they are all black regions with pixel values approximating to (0,0,0).

Conclusion
In this paper, we propose a three-stream network for glass detection from single images, called GlassNet. GlassNet consists of a label decoupling procedure that decouples the ground truth into an interior-diffusion label and a boundary-diffusion label, a multiscale interactive dilation module for extracting and capturing contextual features, and a three-stream network integrating multi-scale and multi-modal information to generate the final prediction map. Besides, GlassNet utilizes an attention-based boundary-aware feature Mosaic module to integrate multi-modal information for further improving the glass detection quality. Experiments on the benchmark datasets demonstrate that our GlassNet outperforms the state-of-the-art methods under different evaluation metrics.