{'fraction_non_alphanumeric': 0.031212429483029686, 'fraction_numerical': 0.009941736798298344, 'mean_word_length': 5.0242339832869085, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, '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}}
Confidence-aware Adversarial Learning for Self-supervised Semantic Matching

In this paper, we aim to address the challenging task of semantic matching where matching ambiguity is difficult to resolve even with learned deep features. We tackle this problem by taking into account the confidence in predictions and develop a novel refinement strategy to correct partial matching errors. Specifically, we introduce a Confidence-Aware Semantic Matching Network (CAMNet) which instantiates two key ideas of our approach. First, we propose to estimate a dense confidence map for a matching prediction through self-supervised learning. Second, based on the estimated confidence, we refine initial predictions by propagating reliable matching to the rest of locations on the image plane. In addition, we develop a new hybrid loss in which we integrate a semantic alignment loss with a confidence loss, and an adversarial loss that measures the quality of semantic correspondence. We are the first that exploit confidence during refinement to improve semantic matching accuracy and develop an end-to-end self-supervised adversarial learning procedure for the entire matching network. We evaluate our method on two public benchmarks, on which we achieve top performance over the prior state of the art. We will release our source code at https://github.com/ShuaiyiHuang/CAMNet.


Introduction
Dense correspondence estimation has been a core building block for a variety of computer vision tasks [26,9]. Recently, traditional instance-level correspondence has been extended to the problem setting of semantic-level matching, which aims to align different object instances of the same category [20]. Semantic matching has attracted growing attention [6,24,19] and demonstrated practical value in real-world applications [27]. However, an effective strategy remains elusive largely due to the presence of background clutters, severe intra-class variation and viewpoint change, as well as difficulty in data annotation. To tackle those challenges, recent research efforts have adopted the learningbased representation, which have significantly improved semantic matching quality compared with traditional methods [21,15,6,23,19]. Early learning methods in semantic matching require strong supervision in the form of ground truth correspondences, which is difficult to obtain for a large set of real images [5]. As a result, recent trend has focused on weakly-supervised methods [24,10] that only employ matching image pair, but they are mostly limited to small-scale datasets. A more promising strategy is to leverage self-supervised learning where image pairs and ground-truth correspondences are generated synthetically using random transformations [23,8,19]. This can significantly reduce annotation cost and makes it possible to utilize large-scale single image datasets along with their existing labels (e.g. masks) for additional constraints [19].
Despite the increasingly large training datasets, existing deep network based semantic matching typically rely on a deterministic neural networks which do not incorporate uncertainty in their correspondence estimation. Due to the implicit ambiguity in feature matching, such simplistic approaches lack the capacity to measure the quality of prediction results and to properly refine their initial predictions. While some prior work attempt to improve initial estimation through an iterative refinement process [23,8], they often suffer from error propagation when initial predictions are of low quality.
In this paper, we propose to incorporate uncertainty reasoning into selfsupervised semantic matching in order to estimate and correct low-quality correspondence results. Toward this goal, we first introduce a pixel-wise confidence estimation mechanism to determine whether the initial prediction for each location on image plane is reliable or not. We then develop a confidence-aware refinement procedure to update initial predictions. We exploit the self-supervision setting to generate dense ground truth labels for confidence estimation and introduce an additional adversarial loss to improve overall prediction consistency.
A key advantage of our approach is the tight integration of the model design and self-supervised learning strategy, which allows us to effectively train this confidence-aware semantic matching network.
Specifically, we present a novel Confidence-Aware Semantic Matching Network (CAMNet) that estimates matching confidences and base on which refines the correspondence prediction. Our network consists of four parts. First, a Base Correspondence Network produces initial correspondence predictions. Then, a Confidence Estimation Network is developed to measure pixel-wise confidence of initial predictions. Moreover, taking as input initial predictions and estimated confidence maps, we design a Confidence-aware Refinement Network to produce refined correspondences by propagating reliable predictions. We train our model with an alignment loss, a confidence loss and an adversarial loss in an end-to-end fashion. As we develop all the training signals for correspondence, confidence, and adversarial learning from synthetically warped image pairs, we refer to this novel learning scheme as confidence-aware adversarial learning for self-supervised semantic matching.
We extensively evaluate our method on two standard benchmarks, including PF-Willow [5] and PF-PASCAL [5]. Our experimental results demonstrate the strong performance of our model over the prior state-of-the-art approaches. Our main contribution are threefold: -We propose a confidence-aware refinement strategy for semantic matching and are the first to consider generating confidence ground truth with the self-supervised setting. -We introduce adversarial training to mitigate the distortion problem in selfsupervised semantic matching task. -Our self-supervised learning strategy achieves top performance in two standard benchmarks.

Semantic Correspondence
Early semantic matching approaches usually leverage ground truth correspondences for strong supervision [15,5]. Collecting such annotations under large intra-class appearance and shape variations is label-intensive and may be objective. Consequently, recent work has focused on weakly-supervised [24,10] or self-supervised setting. Self supervision has attracted growing attention as it further saves human effort and enables to leverage large-scale single image datasets along with their existing labels for additional constraints. Rocco et al. [23] first propose to synthetically generate the image pair and ground truth correspondences from an image itself. Seo et al. [8] extend this idea with an offset-aware correlation kernel to filter out distractions. Junghyup et al. [19] further utilize images annotated with binary foreground masks and subject to synthetic geometric deformations for this task. However, few methods consider the uncertainty in model prediction or incorporate an estimated prediction quality in a refinement process in order to correct partial errors, especially in challenging cases.

Confidence Estimation
Confidence estimation has been widely explored and showing promissing improvement in stereo matching and depth completion [4,18]. Recently, Sangryul et al. first introduce confidence in weakly-supervised semantic matching [13]. However, confidence is learned without any available supervision and is used for regularization in loss function instead of reasoning during prediction. In contrast, we are the first to consider generating confidence ground truth as supervision, and directly utilize confidence in model design to guide refined correspondence prediction in self-supervised semantic matching.

Generative Adversarial Networks
Generative adversarial networks (GANs) have gained increasing attention [1,11,22]. Inspired from the success of GANs, we introduce adversarial learning to enforce the global consistency of warped images, which has never been explored before in semantic matching. We utilize a discriminator to distinguish real data from fake data, and simultaneously to guide the generator to produce higher quality correspondences. As the real data for training GANs are from synthetically warped image pairs, we call our learning scheme as self-supervised adversarial training.
3 Model Architecture

Overview
Semantic alignment aims to establish dense correspondences between a source image I s and a target image I t . A typical CNN-based method computes a correlation map between the convolution features of two images, from which a dense flow field is predicted as final output.
Our objective is to augment the correspondence prediction with a confidence estimation mechanism so that the model is capable of propagating reliable information during inference and producing a consistent flow prediction from the correlation map. To achieve this, we adopt a refinement strategy: given an initial dense correspondence between two feature maps, we first estimate the probability of being correctly predicted for each feature location. The estimated confidence map is then fed into a refinement process to guide information propagation and prediction of final correspondence.
In this section, we introduce a novel network dubbed Confidence-aware Semantic Matching Network (CAMNet) to implement our strategy. Our network comprises three main submodules, including a Base Correspondence Network (Sec. 3.2), a Confidence Estimation Network (Sec. 3.3), and a Confidence-aware Refinement Network (Sec. 3.4). The entire network is learned in a jointly manner. Below we will describe these submodules of CAMNet in details, and defer the discussion of model learning to Sec. 4. An overview of our model architecture is shown in Figure 2.

Base Correspondence Network
The first module of our CAMNet is the Base Correspondence Network, aiming to produce an initial semantic flow given the input image pair. To this end, we adopt a differentiable semantic correspondence network as our module design, which consists of a feature extractor, a correlation computation operator and a base flow prediction module 1 .
Concretely, the input image pair I s and I t are first passed through a CNNbased feature extractor, which extract features maps f s ∈ R d×hs×ws and f t ∈ R d×ht×wt respectively. We adopt ResNet-101 [7] with additional adaptation layers to parameterize feature extractors as in [19]. Subsequently, we compute a 3D correlation map S s←t ∈ R (hs×ws)×ht×wt from L2 normalized feature map f s and f t , which describes pairwise similarity for any two locations between I s and I t . Given 3D correlation map S s←t , we then apply a flow prediction module to obtain initial semantic flow predictionsF s←t b ∈ R 2×ht×wt . While any differentiable flow prediction networks can be adopted here, we choose the kernel soft argmax layer proposed in [19] due to its superior performance. The initial semantic flow F s←t b will be refined in the later process.

Confidence Estimation Network
To correct partial errors in the initial prediction, we introduce a confidence estimation mechanism to determine what information is trustworthy for guiding the refinement. To this end, we design a confidence estimation network to generate a prediction confidence map from the input image features and predicted flows. By taking the input and output into consideration, the network aims to detect inconsistent flow configurations, which may not be easily discovered by checking output predictions alone.
Concretely, given the target feature map f t and the initial flowF s←t b , the confidence estimation network C estimates a base confidence mapC s←t b ∈ R 1×ht×wt as follows:C where θ C is learnable parameter. C(·) is implemented by fully convolutional layers followed by a softmax operator to normalize score at each location to between 0 to 1, where higher score indicates higher confidence of being correct. The estimated confidence mapC s←t b will serve as an informative guidance in the later refinement process.

Confidence-aware Refinement Network
Our third module, Confidence-aware Refinement Network, aims at refining the initial flow under the guidance of estimated confidence map. It consists of a confidence-aware flow update and a flow fusion operator described as follows.
Confidence-aware Flow Update Different from the initial flow prediction network (cf. Sec. 3.2), our confidence-aware flow update network takes both the confidence map and the correlation map as input, and aims to propagate reliable matching information for flow update.
Specifically, we feed the confidence mapC s←t b for the initial flow and the correlation map S s←t into the confidence-aware flow update network U(·) and compute an updated flowF s←t u ∈ R 2×ht×wt as follows: where θ U is learned parameter.
Flow Fusion Finally, we feed the base flow, updated flow and the base confidence map into a flow fusion operator to obtain the final refined flowF s←t r ∈ R 2×ht×wt , which enable us to explicitly suppress initial predictions with lowconfidence. The confidence maps act as gates that control which pixel position initial predictionsF s←t b will be replaced by the updated flowF s←t u . We choose the following flow fusion operator to generate high quality refined flows: where denotes the point-wise product of confidence maps and flows.

Confidence-aware Adversarial learning
We utilize a self-supervised learning strategy for network training by exploiting an image dataset with foreground segmentation masks. Our method first transforms each image and its corresponding foreground mask with random transformations to generate training image pairs as in [19]. During training, we make predictions from target to source and source to target in two directions for each input image pair. Based on this setup, we develop a multi-task loss that includes three components: an alignment loss that enforces the bidirectional matching consistency, a confidence loss that supervises the confidence network, and an adversarial loss on the transformed images within foreground region. We will describe these loss terms in detail below and omit multiply every loss with foreground masks for notation brevity.

Alignment Loss
We first adopt the self-supervised training loss proposed in SFNet [19] to encourage correspondences to be established within foreground masks and measure consistency between flow estimations in two directions, which has the following form: where λ is the weight parameter for balancing mask and flow consistency loss, M t and M s are the binary ground truth foreground masks for the target and the source image respectively. Our alignment loss is defined on the initial flow and the refined flow jointly: where γ is used to balance loss for base flow and refined flow.

Confidence Loss
As we have ground truth flow in self-supervised learning, the ground truth base confidence map C s←t b can be obtained by thresholding the error between the predicted base flowF s←t b and the ground truth flow F s←t . This enables us to directly supervise confidence estimation. The confidence loss measures the quality between estimated confidence map and the ground truth confidence map as follows: L c (C s←t ,C t←s , C s←t , C t←s ) = CE(C s←t , C s←t ) + CE(C t←s , C t←s ) (6) where CE is the cross entropy loss. In addition to the confidence mapsC t←s b andC t←s b , we also estimate refined confidence mapsC t←s r andC s←t r for the refined flow in order to further regularize confidence estimation network. Hence our final confidence loss is defined as where β is the weight parameter balancing the two loss terms.

Adversarial Loss
We introduce an adversarial loss for enforcing global consistency in flow prediction. To this end, we first build an image generator G by integrating our model (described in Sec. 3) with a warping operator W. Considering matching from target to source, G generates synthetically warped source imagesĨ t given an image pair (I s , I t ) as follows: We define a Discriminator D to distinguish warped images from the groundtruth flows and the generated flows. The input of the discriminator contains either source images warped by the ground truth flow (denoted as I * t ) or by the predicted flow, i.e.Ĩ t , and both of them are concatenated with the corresponding target image. From the input pair, the discriminator should learn whether the flow is correct s.t. the warped source image align with target image. D outputs a one channel prediction map with values between 0 to 1 where higher value indicates the more D believes that the input pair is real data.
In self-supervision, we apply random transformation in the form of ground truth flow F s←t to the single source image I s to form a training image pair (I s , I t ). Thus, the source image warped by ground truth flow I * t is essentially the target image I t itself in the self-supervised setting: Consequently, we call our framework as self-supervised adversarial learning as real input pair for training GANs is developed from self-supervision (i.e., no real annotations are needed).
Adversarial loss is used for mitigating distortion problem in semantic matching. The discriminator and the generator is trained alternatively as shown in Fig. 3. After training is done, the generator (without warping operator) is used as a correspondence estimator and the discriminator can be removed.
Training the Generator The generator G tries to generate realistic images to fool the discriminator, and our loss term aims to minimize the following Least Square GAN loss bidirectionally which enforces the generator to produce reasonable warped images. Our overall loss for the generator consists of the alignment loss, the confidence loss and the adversarial loss terms with µ 1 , µ 2 as weight parameters as follows, Training the Discriminator The discriminator is used to distinguish predicted flow-image pair from real flow-image pair. Considering both matching directions, the discriminator loss for the real data pair L real and predicted data pair L f ake is as follows where I * t is the same as I t in self-supervision as shown in Eq. 9. Similarly, I * s equals to I s . Consequently, the overall loss for the discriminator is defined as:

Experiments
We conduct experiments on standard datasets PF-PASCAL [5] and PF-WILLOW [5] to evaluate our method for semantic matching. We first present the implementation details in Sec.5.1. Then, we show quantitative and qualitative results of the two datasets in Sec.5.3 and Sec.5.2. Ablation study is given in Sec.5.4.

Implementation details
Images are resized into the size of 320×320. Following SFNet [19], our model is trained on the PASCAL VOC 2012 segmentation dataset [3] which includes a foreground mask for each image and PF-PASCAL [5] validation split is used for model selection. The confidence estimation network is implemented with 3×3 convolutional filters sequentially followed by BN and ReLU. We multiply correlation map by estimated confidence map as the input of the confidence-aware refinement network. The confidence-aware refinement network is implemented with architecture similar to Dense-Net and the last layer of which is of two channels. We adopt PatchGAN [12] as our discriminator. To validate generalization ability of our method, we test our trained model on PF-WILLOW dataset [5] test split without finetuning. We set λ = 0.188, γ = β = 0.4, µ 1 = 288.0, µ 2 = 18.0.

PF-WILLOW Benchmark
Dataset and evaluation metric The PF-WILLOW dataset [5] contains 900 image pairs selected from 100 images with four categories. We report the PCK scores [28] (α = 0.05, 0.10, 0.15) w.r.t bounding box size. Table 1 Fig. 4 shows that our method can effectively handle background clutters and viewpoint changes.

PF-PASCAL Benchmark
Dataset and evaluation metric There are 1351 image pairs on PF-PASCAL [5] benchmark. The key point annotations are only used for evaluation. In line with previous works, we report PCK [28] (α = 0.05, 0.10, 0.15) w.r.t image size. Table 2 shows the detailed comparison. Our method achieves the best results on α = 0.05, 0.1, 0.15 in self-supervised setting, which outperforms the previous best self-supervised method SFNet [19] by 1.3%, 1.6% and 0.4% respectively, demonstrating our method's effectiveness. Fig. 4 shows qualitative comparision between our model and SFNet [19].

Ablation Study
We select SFNet [19] as our baseline and report PCK(α = 0.1) on PF-PASCAL [5] and PF-WILLOW [5] test split to analyse the effectiveness of our proposed individual modules. As shown in Table 3, PCK results increase steadily when sequentially adding our proposed modules, leading to 1.1% and 1.6% improvement on the PF-WILLOW and PF-Pascal respectively in the end. Although adding GANs does not show significant improvements in numbers, it indeed mitigates distortion problems and provides better visual quality, and does not add any additional computational complexity during inference.  Table 3. Ablation study on PF-PASCAL [5] and PF-WILLOW [5].

Conclusion
In this paper, we proposed an effective deep network CAMNet for semantic matching. First, we developed a confidence-aware refinement procedure by directly utilizing confidence in model design to guide refined correspondence prediction. In addition, we introduce adversarial training to mitigate distortion in semantic alignment. Finally, we design a novel end-to-end framework with selfsupervision to enable effective confidence and adversarial learning. Experimental results on two standard benchmarks confirmed the effectiveness of our method.