Code for our CVPR 2016 paper "Unsupervised Learning of Edges"
Data-driven approaches for edge detection have proven effective and achieve top results on modern benchmarks. However, all current data-driven edge detectors require manual supervision for training in the form of hand-labeled region segments or object boundaries. Specifically, human annotators mark semantically meaningful edges which are subsequently used for training. Is this form of strong, high-level supervision actually necessary to learn to accurately detect edges? In this work we present a simple yet effective approach for training edge detectors without human supervision. To this end we utilize motion, and more specifically, the only input to our method is noisy semi-dense matches between frames. We begin with only a rudimentary knowledge of edges (in the form of image gradients), and alternate between improving motion estimation and edge detection in turn. Using a large corpus of video data, we show that edge detectors trained using our unsupervised scheme approach the performance of the same methods trained with full supervision (within 3-5 detector, our approach provides a novel pre-training scheme for object detection.READ FULL TEXT VIEW PDF
Since edge detection is in the forefront of image processing for object
Semantic edge detection has recently gained a lot of attention as an ima...
Edge detection has made significant progress with the help of deep
It is unknown whether or not every polycube has an edge-unfolding. A pol...
This paper presents a context-aware tracing strategy (CATS) for crisp ed...
In robotic applications, we often face the challenge of discovering new
The goal of this work is to recognise and localise short temporal signal...
Code for our CVPR 2016 paper "Unsupervised Learning of Edges"
Video restoration for medical retinal imaging
The human visual system can easily identify perceptually salient edges in an image. Endowing machine vision systems with similar capabilities is of interest as edges are useful for diverse tasks such as optical flow [revaud2015epic], object detection [UllmanPAMI91, Ferrari2008PAMI], and object proposals [Uijlings13IJCV, Zitnick2014ECCV, Arbelaez2014CVPR]. However, edge detection has proven challenging. Early approaches [Fram1975IEEE, Canny1986PAMI, Freeman91PAMI] relied on low-level cues such as brightness and color gradients. Reasoning about texture [Martin2004PAMI] markedly improved results, nevertheless, accuracy still substantially lagged human performance.
The introduction of the BSDS dataset [Arbelaez2011PAMI], composed of human annotated region boundaries, laid the foundations for a fundamental shift in edge detection. Rather than rely on complex hand-designed features, Dollár et al. [Dollar2006CVPR] proposed a data-driven, supervised approach for learning to detect edges. Modern edge detectors have built on this idea and substantially pushed the state-of-the-art forward using more sophisticated learning paradigms [Ren2012NIPS, Lim2013CVPR, Dollar2015fast, Xie2015hed].
However, existing data-driven methods require strong supervision for training. Specifically, in datasets such as BSDS [Arbelaez2011PAMI], human annotators use their knowledge of scene structure and object presence to mark semantically meaningful edges.111Human annotation of edge structure in local patches (without context) is quite noisy and is matched by machine vision approaches. Humans excel when given context and the ability to reason about object presence [Zitnick2012CVPR].
Moreover, recent edge detectors use ImageNet pre-training[bertasuis2015high, Xie2015hed]. In this paper, we explore whether this is necessary: Is object-level supervision indispensable for edge detection? Moreover, can edge detectors be trained entirely without human supervision?
We propose to train edge detectors using motion in place of human supervision. Motion edges are a subset of image edges, see Figure 1. Therefore motion edges can be used to harvest positive training samples. On the other hand, locations away from motion edges may also contain image edges. Fortunately, as edges are sparse, simply sampling such locations at random can provide good negative training data with few false negatives. Thus, assuming accurate motion estimates, we can potentially harvest unlimited training data for edge detection.
While it would be tempting to assume access to accurate motion estimates, this is arguably an unreasonably strong requirement. Indeed, optical flow and edge detection are tightly coupled. Recently, Revaud et al. proposed EpicFlow [revaud2015epic]: given an accurate edge map [Dollar2015fast] and semi-dense matches between frames [weinzaepfel2013dm]
, EpicFlow generates a dense edge-respecting interpolation of the matches. The result is a state-of-the-art optical flow estimate.
This motivates our approach. We begin with only semi-dense matches between frames [weinzaepfel2013dm] and a rudimentary knowledge of edges (simple image gradients). We then repeatedly alternate between computing flow based on the matches and most recent edge maps and retraining an edge detector based on signal obtained from the flow fields. Specifically, at each iteration, we first estimate dense flow fields by interpolating the matching results using the edge maps obtained from the previous iteration. Given a large corpus of videos, we next harvest highly confident motion edges as positives and randomly sample negatives, and use this data to train an improved edge detector. The process is iterated leading to increasingly accurate flow and edges. An overview of our method is shown in Figure 2.
We perform experiments with the Structured Edge (SE) [Dollar2015fast] and Holistic Edge (HE) [Xie2015hed] detectors. SE is based on structured forests, HE on deep networks; SE is faster, HE more accurate. Both detectors achieve state-of-the-art results. The main result of our paper is that both methods, trained using our unsupervised scheme, approach the level of performance of fully supervised training.
Finally, we demonstrate that our approach can serve as a novel unsupervised pre-training scheme for deep networks [wang2015unsupervised, doersch2015unsupervised]. Specifically, we show that when fine-tuning a network for object detection [everingham2014pascal], starting with the weights learned for edge detection improves performance over starting with a network with randomly initialized weights. While the gains are modest, we believe this is a promising direction for future exploration.
Edge Detection: Early edge detectors were manually designed to use image gradients [Fram1975IEEE, Canny1986PAMI, Freeman91PAMI] and later texture gradients [Arbelaez2011PAMI]. Of more relevance to this work are edge detectors trained in a data-driven manner. Since the work of [Dollar2006CVPR], which formulated edge detection as a binary classification problem, progressively more powerful learning paradigms have been employed, including multi-class classification [Lim2013CVPR], feature learning [Ren2012NIPS], regression [sironi2014multiscale], structured prediction [Dollar2015fast]
, and deep learning[Kivinen2014AISTATS, bertasuis2015high, Xie2015hed]. Recently, Weinzaepfel et al. [weinzaepfel2015learning] extended [Dollar2015fast] to motion edge estimation. These methods all require strong supervision for training. In this work we explore whether unsupervised learning can be used instead (and as discussed select [Dollar2015fast, Xie2015hed] for our experiments).
The estimation of optical flow is a classic problem in computer vision[horn1981determining, Lucas1981iterative]. A full overview is outside of our scope, instead, our work is most closely related to methods that leverage sparse matches or image edges for flow estimation [brox2011large, weinzaepfel2013dm, revaud2015epic]. In particular, as in [revaud2015epic], we use edge-respecting sparse-to-dense interpolation of matches to obtain dense motion estimates. Our focus, however, is not on optical flow estimation, instead, we exploit the tight coupling between edge and flow estimation to train edge detectors without human supervision.
Perceptual Grouping using Motion: Motion plays a key role for grouping and object recognition in the human visual system [koffka2013principles]. In particular, Ostrovsky et al. [ostrovsky2009visual] studied the visual skills of individuals recovering from congenital blindness and showed that motion cues were essential to help facilitate the development of object grouping and representation. Our work is inspired by these findings: we aim to learn an edge detector using motion cues.
Learning from Video: There is an emerging interest for learning visual representations using video as a supervisory signal, for example by enforcing that neighboring frames have a similar representation [mobahi2009deep], learning latent representations for successive frames [taylor2010convolutional], or learning to predict missing or future frames [ranzato2014video, srivastava2015unsupervised]. Instead of simply enforcing various constraints on successive video frames, Wang and Gupta [wang2015unsupervised] utilized object tracking and enforce that tracked patches in a video should have a similar visual representation. The resulting network generalizes well to surface normal estimation and object detection. As we will demonstrate, our approach can also serve as a novel unsupervised pre-training scheme. However, while in previous approaches the training objective was used as a surrogate to encourage the network to learn a useful representation, our primary goal is to train an edge detector and the learned representation is simply a useful byproduct.
We start with a set of low level cues using standard tools in computer vision, including point correspondences and image gradients. We use DeepMatching [weinzaepfel2013dm] to obtain semi-dense matches between two consecutive frames . DeepMatching computes correlations at different locations and scales to generate the matches. Note that contrary to its name, the method involves no deep learning. For the rest of the paper, we fix the matching results .
Our proposed iterative process is described in Figure 2 and Algorithm 1. We denote the edge detector at iteration by . For each image , we use and to denote its image edges and motion edges at iteration . We initialize to the raw image gradient magnitude of , defined as the maximum gradient magnitude over color channels. The gradient magnitude is a simple approximation of image edges, and thus serves as a reasonable starting point.
At each iteration , we use EpicFlow [revaud2015epic] to generate edge-preserving flow maps given matches and previous edges . We next apply on a colored version of to get an estimate of motion edges . is further refined by aligning to superpixel edges. Next, for training our new edge detector , we harvest positives instances using a high threshold on and sample random negatives away from any motion edges.
The above process is iterated until convergence (typically 3 to 4 iterations suffice). At each iteration the flow and edge maps and improve. In the following sections we describe the process in additional detail.
EpicFlow: EpicFlow [revaud2015epic] takes as input an image pair , semi-dense matches between the images, and an edge map for the first frame. It efficiently computes approximate geodesic distance defined by between all pixels and matched points in . For every pixel, the geodesic distance is used to find its
nearest matches, and the weighted combination of their motion vectors determines the source pixel’s motion. A final optimization is performed by a variational energy minimization to produce an edge-preserving flow map with high accuracy. We refer readers to[revaud2015epic] for additional details.
Motion Edge Detection: Detecting motion edges given optical flow estimates can be challenging, see Figure 3. Weinzaepfel et al. [weinzaepfel2015learning] showed that simply computing gradients over a flow map produces unsatisfactory results and instead proposed a data-driven approach for motion edge detection (for a full review of earlier approaches see [weinzaepfel2015learning]). In this work we employ a simpler yet surprisingly effective approach. We use an edge detector trained on image edges for motion edge estimation by applying the (image) edge detector to a color-coded flow map. The standard color-coding scheme for optical flow maps 2D flow vectors into a 3D color space by encoding flow orientation via hue and magnitude via saturation [baker2011database]. Motion edges become clearly visible in this encoding (3b) (we tried other color spaces but HSV worked best). Running an edge detector on the colored flow map gives us a simple mechanism for motion edge detection (3c). Moreover, in our iterative scheme, as both our edge detector and flow estimate improve with each iteration , so do our resulting estimates of motion edges .
Motion Edge Alignment:
Motion edges computed from flow exhibit slight misalignment with their corresponding image edges. We found that this can adversely affect training, especially for HE which produces thick edges. To align the motion edges we apply a simple heuristic: after applying non-maximum suppression and thresholding, we align the motion edges to superpixels detected in the color image. Specifically, we utilize SLIC super-pixels[achanta2012slic], which cover over 90% of all image edges, and match motion and superpixel edge pixels using bipartite matching (also used in BSDS evaluation) with a tolerance of 3 pixels. Matched motion edge pixels are shifted to the superpixel edge locations and unmatched motion edges are discarded. This refinement, illustrated in Figure 3d, helps to filter out edges with weak image gradients and improves localization.
We emphasize that our goal is not to detect all motion edges. A subset with high precision is sufficient for training. Given a large video corpus, high-precision motion edges should provide a dense coverage of image edges. However, due to our alignment procedure our sampling is slightly biased. In particular, motion edges with weak corresponding image edges are often missing. This limitation and its impact on performance is discussed in Section 4.
Training : The aligned motion edge maps serve as a supervisory signal for training an edge detector . Positives are sampled at locations with high scoring motion edges in . Negatives are uniformly sampled from location with motion edges below a small threshold. Note that locations with ambiguous motion edge presence ( with intermediate scores) are not considered in training. As we will demonstrate, samples harvested in this manner provide a strong supervisory signal for training .
Video Dataset: For training, we combine videos from two different datasets: the Video Segmentation Benchmark (VSB) [galasso2013unified] and the YouTube Object dataset [Prest2012CVPR]. We use all HD videos () in both datasets. We drop all the annotations for YouTube object dataset. This collection of videos () contains more than frames and has sufficient diversity for training an edge detector.
Frame Filtering: Given the vast amount of available data, we apply a simple heuristic to select the most promising frames for motion estimation. We first fit a homography matrix between consecutive frames using ORB descriptor matches [rublee2011orb] (which are fast to compute). We then remove frames with insufficient matches, very slow motion (max displacement 2 pixels), very large motion (average displacement 15 pixels), or a global translational motion. These heuristics remove frames where optical flow may be either unreliable or contain few motion edges. For all experiments we used this pruned set of frames.
We experiment with the Structured Edge (SE) [Dollar2015fast] and Holistic Edge (HE) [Xie2015hed] detectors, based on structured forests and deep networks, respectively. SE has been used extensively due to its accuracy and speed, e.g. for flow estimation [revaud2015epic] and object proposals [Zitnick2014ECCV, Arbelaez2014CVPR]. HE is more recent but achieves the best reported results to date. When trained using our unsupervised scheme, both methods approach similar performance as when trained with full supervision.
Structured Edges (SE):
SE extracts low-level image features, such as color and gradient channels, to predict edges. The method learns decision trees by using structured labels (patch edge maps) to determine the split function at each node. During testing, each decision tree maps an input patch to a local edge map. The final image edge map is the average of multiple overlapped masks predicted by each tree at each location, leading to a robust and smooth result. We use the same parameters as in[Dollar2015fast] for training. The forest has 8 trees with maximum depth of 64. Each tree is trained using a random subset (25%) of patches, with equal number of positives and negatives. During training, we convert a local edge map to a segmentation mask as required by SE by computing connected components in the edge patch. We discard patches that contain edge fragments that do not span the whole patch (which result in a single connected component). During each iteration of training, the forest is learned from scratch. During testing, we run SE over multiple scales with sharpening for best results.
Holistic Edges (HE): HE uses a modified VGG-16 network [Simonyan14vgg] with skip-layer connections and deep supervision [lee2014deeply]. Our implementation generally follows [Xie2015hed]
convolutions) to the last conv layer of each stage, their outputs are averaged to generate the final edge map. In our implementation, we remove the deep supervision (multiple loss functions attached to different layers) as we found that a single loss function has little performance penalty (vs in ODS score) but is easier to train.
We experimented with both fine-tuning a network pre-trained on ImageNet [ILSVRC15] and training a network from scratch (random initialization). For fine-tuning, we use the same hyper-parameter as in [Xie2015hed] with learning rate , weight decay , momentum , and batch size
. When training from scratch, we add batch normalization[ioffe2009batch] layers to the end of every conv block. This accelerates training and also improves convergence. We also increase learning rate and weight decay when training from scratch. We train the network for epochs in each iteration, then reduce learning rate by half. Unlike for SE, we can reuse the network from previous iterations as the starting point for each subsequent iteration.
The somewhat noisy labels, in particular missing positive labels, prove to be challenging for training HE. The issue is partially alleviated by discarding ambiguous samples during back propagation. Furthermore, unlike in [Xie2015hed], we randomly select negative samples ( as many negatives as positives) and discard negatives with highest loss (following the same motivation as in [szegedy2014scalable]). Without these steps for dealing with noisy labels convergence is poor.
Our method produces motion edges , image edges , and optical flow at each iteration . We provide an extensive benchmark for each task tested with two different edge detectors (se and he). Our main result is that the image edge detectors, trained using videos only, achieve comparable results as when trained with full supervision. As a byproduct of our approach, we also generate competitive optical flow and motion edge results. Finally, we show that pre-training networks using video improves their performance on object detection over training from scratch.
While our focus is not on motion edge detection, identifying motion edges reliably is important as motion edges serve as our only source of supervision. Thus our first experiment is to benchmark motion edges.
We use the Video Segmentation Benchmark (VSB) [galasso2013unified] which has annotated ground truth motion edges every frames. We report results on the annotated frames in the test set (we remove frames without motion edges and the final frame of each video as [weinzaepfel2015learning] requires frames). We evaluate using three standard metrics [Arbelaez2011PAMI]: fixed contour threshold (ODS), per-image best threshold (OIS), and average precision (AP). As we are concerned about the high precision regime, we introduce an additional measure: precision at recall (P20). Non-maximum suppression is applied to all motion edges prior to evaluation.
In Table 1 we report results of four baselines and the motion edges obtained from the final iteration of our approach (se/he-video). The baselines include: image edges (se/he-image), gradient magnitude of optical flow (epicflow), a method which combines superpixel segmentation with motion cues (Galasso [galasso2013unified]), and a recent data-driven supervised approach (Weinzaepfel [weinzaepfel2015learning]).
Our method, albeit simple, has a precision at recall, only slightly worse than [weinzaepfel2015learning], even though it was not trained for motion edge detection. It substantially outperforms all other baselines in the high precision regime. While our goal is not motion edge detection per-se, this result is important as it enables us to obtain high quality positive samples for training an image edge detector.
We next investigate edge detection performance. Results are reported on the Berkeley Segmentation Dataset and Benchmark (BSDS) [Martin2004PAMI, Arbelaez2011PAMI], composed of 200 train, 100 validation, and 200 test images. Each image is annotated with ground truth edges. We again evaluate accuracy using the same three standard metrics: ODS, OIS and AP.
Can an image edge detector be trained using motion edges? Our first experiment tests this question. We use all ground truth motion edges available in VSB ( images) to train both se and he. The results are reported in Table 2 (se-vsb, he-vsb). For both methods, results are within 2-4 points ODS compared to training with image edge supervision (se-bsds, he-bsds). Our results suggest that using motion edges to learn an image edge detector is feasible.
We next present results using videos as the supervisory signal (se-video, he-video). se-video achieves an ODS of compared to for the supervised case (se-bsds). Results for he are similar ( versus ). As these results show, using video supervision achieves competitive results (within 3-5%). Interestingly, learning from video slightly outperforms training using the ground truth motion edges. We attribute this to the small size of VSB.
For he, we experiment with starting with an ImageNet pre-trained model (he) and training from scratch (he). Pre-training on ImageNet benefits he across all training scenarios. This is encouraging as it implies that object level knowledge is useful for edge detection. On the other hand, our video supervision scheme also benefits from ImageNet pre-training, thus implying that in our current setup we are not training the model to its full potential.
To probe how performance evolves, we plot the ODS scores at each iteration for both methods in Figure 4. Raw image gradient at iteration has ODS of (not shown). Our iterative process provides a significant improvement from the image gradient, with most of the gains coming in the first iteration. Performance saturates after about 4 iterations (for the last iteration, we use 4 million samples for se and epochs for he, which slightly increases accuracy).
We provide visualizations of edge results (before NMS) in Figure 5. se misses some weak edges but edges are well aligned to the image content. he generally produces thicker edges due to use of downsampled conv feature maps which makes it difficult to produce sharp image edges. he-video/he-video results have thinner edges than he-bsds/he-bsds, potentially due to the sampling strategy used for training with motion edges. When training using video, we also observe that the edge detection output is less well localized and more likely to miss weak edges, which likely accounts for much of the performance differences.
We benchmark optical flow results on the Middlebury [baker2011database] and MPI Sintel [butler2012sintel] datasets. Middlebury is widely used and consists of complex motions with small displacements. Sintel is obtained from animated sequences and features large displacements and challenging lighting conditions. We use the ‘final’ version of Sintel and test on the train set with public ground truth. As our goal is to test the quality of generated edge maps, we focus only on variants of EpicFlow [revaud2015epic], the highest performing method on Sintel as of CVPR 2015.
Table 3 shows the average endpoint error (AEE) of EpicFlow using different edge maps for Sintel and Middleburry. Most edge maps give rise to relatively similar results (AEE around ) on Sintel. In particular, originally EpicFlow used se-bsds edges; the results with se-video edges are nearly identical. Top results are obtained with he-bsds, while he-video and he-video are slightly worse. On Middleburry the method rankings are similar.
As an upper bound, we also include EpicFlow given ground truth (GT) motion edges (derived from the ground truth flow). Accuracy is only slightly better than with the best learned edge maps. This suggests that the performance of EpicFlow is saturated given the current matches.
Finally, in Figure 4 we plot AEE on Sintel for each iteration. All methods improve over the initial flow (AEE , not shown) and results again saturate after a few iterations.
|gt motion edges||3.588||-|
Finally, we test whether our unsupervised training scheme for edge detection can be used to pre-train a network for object detection. The question of whether strong supervision is necessary for learning a good visual representation for object detection is of much recent interest [wang2015unsupervised, doersch2015unsupervised]. While not the focus of our work, we demonstrate that our scheme can likewise be used for network initialization.
For these experiments, we use the he edge detector (without ImageNet pre-training). We perform experiments using PASCAL VOC 2007 [everingham2014pascal] and the Fast R-CNN [ross2015frcnn] object detector with proposals from [Uijlings13IJCV]. Results are evaluated by mean Average Precision (mAP). We compare results using two networks, VGG [Simonyan14vgg] and ZF [zeiler2014visualizing], and four pre-training schemes: ImageNet pre-training; no pre-training; pre-trained on BSDS (he-bsds), and pre-trained using video (he-video). All networks are fine-tuned using the train-val set for iterations ( iterations when training from scratch). Results are summarized in Table 4.
VGG Results: We attempted to train VGG [Simonyan14vgg] from scratch on VOC (with various learning rates plus batch normalization and dropout) but failed to obtain meaningful results. Even after iterations detection performance remains poor ( mAP). When the network is pre-trained on BSDS for edge detection, we were able to achieve mAP on PASCAL. Interestingly, when training using video, we observe a further point improvement in mAP (even though the same network is inferior for edge detection).
ZF Results: We also experimented with training a smaller ZF network [zeiler2014visualizing] which has only convolutional layers. We modify the network slightly for edge detection to facilitate the alignment between outputs from different layers222We change kernel size of all pooling layers to and modify padding to
and modify padding toand in conv1 and conv2, respectively. We also attach classifiers ( convs) on all conv layers and up-sample and merge the results into a single edge map as in [Xie2015hed]. Finally, when training from scratch, we add batch normalization after every conv layer. The ZF network has an ODS of when trained using BSDS and when trained using videos.. With ImageNet pre-training, Fast R-CNN with our modified ZF network achieves mAP on PASCAL, which is close to the ZF result originally reported in [ross2015frcnn]. With no pre-training, mAP drops to . Pre-trained for edge detection, either with or without supervision, improves results by 3 mAP over training from scratch.
Overall we conclude that pre-training for edge detection (with or without supervision) improves the performance of training an object detector from scratch. However, ImageNet pre-training still achieves substantially better results.
Why doesn’t unsupervised training outperform supervised training for edge detection? In theory, a sufficiently large corpus of video should provide an unlimited training set and an edge detector trained on this massive corpus should outperform the much smaller supervised training set. However, there are a number of issues that currently limit performance. (1) Existing flow methods are less accurate at weak image edges, in addition, our alignment scheme also removes weak edges. Thus weak image edges are missing from our training set. (2) Further improving image edges does not improve optical flow, see Table 1. We conjecture that the matches between frames are the limiting factor for EpicFlow and until these are improved neither optical flow nor edges will improve in the current scheme. (3) Training is harmed by noisy labels, and in particular, the missing positive labels. The false negatives, if not handled properly, tend to dominate the gradients in the late stages of training.
Is the unsupervised learning scheme capturing object-level information? The extent of an object is defined by its edges and conversely many edges can only be identified with knowledge of objects. Our results on both edge and object detection support this connection: on one hand, ImageNet pre-training is useful for edge detection, possibly because it injects object-level information into the network. On the other hand, pre-training a network for edge detection also improves object detection. In principle, an edge detection network has to learn high-level shape information, which might explain the effectiveness of pre-training. However, we observe that pre-training on ImageNet still benefits edge detection under all scenarios; moreover, ImageNet pre-training is still substantially better than video pre-training for object detection. Hence, perhaps unsurprisingly, the current unsupervised scheme is not as effective as ImageNet pre-training at capturing object level information.
In this work, we proposed to harvest motion edges to learn an edge detector from video without explicit supervision. We developed an iterative process that alternated between updating optical flow using edge results, and learning an edge detector based on the flow fields, leading to increasingly accurate edges and flows.
The main result of our paper is that edge detectors, trained using our unsupervised scheme, approach the same level of performance as fully supervised training.
We additionally demonstrated our approach can serve a novel unsupervised pre-training scheme for deep networks. While the gains from pre-training were modest, we believe this is a promising direction for future exploration.
In the long run we believe that unsupervised learning of edge detectors has the potential to outperform supervised training as the unsupervised approach has access to unlimited data. Our work is the first serious step in this direction.
Acknowledgements We thank Saining Xie for help with the he detector and Ahmad Humayun, Yan Zhu, and Yuandong Tian and many others for valuable discussions and feedback. The work was conducted when Yin Li was an intern at FAIR. Yin Li gratefully acknowledges the support of the Intel ISTC-PC while completing the writing of the paper at Georgia Tech.