{'fraction_non_alphanumeric': 0.0379607738670041, 'fraction_numerical': 0.013852352569012022, 'mean_word_length': 4.768728390318863, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Unsupervised Learning of Object Landmarks through Conditional Image Generation

We propose a method for learning landmark detectors for visual objects (such as the eyes and the nose in a face) without any manual supervision. We cast this as the problem of generating images that combine the appearance of the object as seen in a first example image with the geometry of the object as seen in a second example image, where the two examples differ by a viewpoint change and/or an object deformation. In order to factorize appearance and geometry, we introduce a tight bottleneck in the geometry-extraction process that selects and distils geometry-related features. Compared to standard image generation problems, which often use generative adversarial networks, our generation task is conditioned on both appearance and geometry and thus is significantly less ambiguous, to the point that adopting a simple perceptual loss formulation is sufficient. We demonstrate that our approach can learn object landmarks from synthetic image deformations or videos, all without manual supervision, while outperforming state-of-the-art unsupervised landmark detectors. We further show that our method is applicable to a large variety of datasets - faces, people, 3D objects, and digits - without any modifications.


Introduction
There is a growing interest in developing machine learning methods that have little or no dependence on manual supervision. In this paper, we consider in particular the problem of learning, without external annotations, detectors for the landmarks of object categories, such as the nose, the eyes, and the mouth of a face, or the hands, shoulders, and head of a human body.
Our approach learns landmarks by looking at images of deformable objects that differ by acquisition time and/or viewpoint. Such pairs may be extracted from video sequences or can be generated by randomly perturbing still images. Videos have been used before for self-supervision, often in the context of future frame prediction, where the goal is to generate future video frames by observing one or more past frames. A key difficulty in such approaches is the high degree of ambiguity that exists in predicting the motion of objects from past observations. In order to eliminate this ambiguity, we propose instead to condition generation on two images, a source (past) image and a target (future) image. The goal of the learned model is to reproduce the target image, given the source and target images as input. Clearly, without further constraints, this task is trivial. Thus, we pass the target through a tight bottleneck meant to distil the geometry of the object ( fig. 1). We do so by constraining the resulting representation to encode spatial locations, as may be obtained by an object landmark detector. The source image and the encoded target image are then passed to a generator network which reconstructs the target. Minimising the reconstruction error encourages the model to learn landmark-like representations because landmarks can be used to encode the geometry of the object, * equal contribution.  Figure 1: Model Architecture. Given a pair of source and target images (x, x ), the pose-regressor Φ extracts K heatmaps from x , which are then marginalized to estimate coordinates of keypoints, to limit the information flow. 2D Gaussians (y ) are rendered from these keypoints and stacked along with the image features extracted from x, to reconstruct the target as Ψ(x, y ) =x . By restricting the information-flow our model learns semantically meaningful keypoints, without any annotations.
which changes between source and target, while the appearance of the object, which is constant, can be obtained from the source image alone.
The key advantage of our method, compared to other works for unsupervised learning of landmarks, is the simplicity and generality of the formulation, which allows it to work well on data far more complex than previously used in unsupervised learning of object landmarks, e.g. landmarks for the highly-articulated human body. In particular, unlike methods such as [45,44,55], we show that our method can learn from synthetically-generated image deformations as well as raw videos as it does not require access to information about correspondences, optical-flow, or transformation between images.
Furthermore, while image generation has been used extensively in unsupervised learning, especially in the context of (variational) auto-encoders [22] and Generative Adversarial Networks (GANs [13]; see section 2), our approach has a key advantage over such methods. Namely, conditioning on both source and target images simplifies the generation task considerably, making it much easier to learn the generator network [18]. The ensuing simplification means that we can adopt the direct approach of minimizing a perceptual loss as in [10], without resorting to more complex techniques like GANs. Empirically, we show that this still results in excellent image generation results and that, more importantly, semantically consistent landmark detectors are learned without manual supervision (section 4). Project code and details are available at: http://www.robots.ox.ac.uk/ vgg/research/unsupervised_landmarks/

Related work
The recent approaches of [45,44] learn to extract landmarks based on the principles of equivariance and distinctiveness. In contrast to our work, these methods are not generative. Further, they rely on known correspondences between images obtained either through optical flow or synthetic transformations, and hence, cannot leverage video data directly. Since the principle of equivariance is orthogonal to our approach, it can be incorporated as an additional cue in our method.
Unsupervised learning of representations has traditionally been achieved using auto-encoders and restricted Boltzmann machines [14,47,15]. InfoGAN [6] uses GANs to disentangle factors in the data by imposing a certain structure in the latent space. Our approach also works by imposing a latent structure, but using a conditional-encoder instead of an auto-encoder.
Learning representations using conditional image generation via a bottleneck was demonstrated by Xue et al. [52] in variational auto-encoders, and by Whitney et al. [50] using a discrete gating mechanism to combine representations of successive video frames. Denton et al. [8] factor the pose and identity in videos through an adversarial loss on the pose embeddings. We instead design our bottleneck to explicitly shape the features to resemble the output of a landmark detector, without any adversarial training. Villegas et al. [46] also generate future frames by extracting a representation of appearance and human pose, but, differently from us, require ground-truth pose annotations. Our method essentially inverts their analogy network [36] to output landmarks given the source and target image pairs. Several other generative methods [42,40,37,48,32] focus on video extrapolation. Srivastava et al. [40] employ Long Short Term Memory (LSTM) [16] networks to encode video sequences into fixed-length representation and decode it to reconstruct the input sequence. Vondrick et al. [48] propose a GAN for videos, also with a spatio-temporal convolutional architecture that disentangles foreground and background to generate realistic frames. Video Pixel Networks [20] estimate the discrete joint distribution of the pixel values in a video by encoding different modalities such as time, space and colour information. In contrast, we learn a structured embedding that explicitly encodes the spatial location of object landmarks.
A series of concurrent works propose similar methods for unsupervised learning of object structure. Shu et al. [38] learn to factor a single object-category-specific image into an appearance template in a canonical coordinate system, and a deformation field which warps the template to reconstruct the input, as in an auto-encoder. They encourage this factorisation by controlling the size of the embeddings. Similarly, Wiles et al. [51] learn a dense deformation field for faces but obtain the template from a second related image, as in our method. Suwajanakorn et al. [43] learn 3D-keypoints for objects from two images which differ by a known 3D transformation, by enforcing equivariance [45]. Finally, the method of Zhang et al. [55] shares several similarities with ours, in that they also use image generation with the goal of learning landmarks. However, their method is based on generating a single image from itself using landmark-transported features. This, we show is insufficient to learn geometry and requires, as they do, to also incorporate the principle of equivariance [45]. This is a key difference with our method, as ours results in a much simpler system that does not require to know the optical-flow/correspondences between images, and can learn from raw videos directly.

Method
Let x, x ∈ X = R H×W ×C be two images of an object, for example extracted as frames in a video sequence, or synthetically generated by randomly deforming x into x . We call x the source image and x the target image and we use Ω to denote the image domain, namely the H×W lattice.
We are interested in learning a function Φ(x) = y ∈ Y that captures the "structure" of the object in the image as a set of K object landmarks. As a first approximation, assume that y = (u 1 , . . . , u K ) ∈ Ω K = Y are K coordinates u k ∈ Ω, one per landmark.
In order to learn the map Φ in an unsupervised manner, we consider the problem of conditional image generation. Namely, we wish to learn a generator function such that the target image x = Ψ(x, Φ(x )) is reconstructed from the source image x and the representation y = Φ(x ) of the target image. In practice, we learn both functions Φ and Ψ jointly to minimise the expected reconstruction loss min Ψ,Φ E x,x [L(x , Ψ(x, Φ(x )))] . Note that, if we do not restrict the form of Y, then a trivial solution to this problem is to learn identity mappings by setting y = Φ(x ) = x and Ψ(x, y ) = y . However, given that y has the "form" of a set of landmark detections, the model is strongly encouraged to learn those. This is explained next.

Heatmaps bottleneck
In order for the model Φ(x) to learn to extract keypoint-like structures from the image, we terminate the network Φ with a layer that forces the output to be akin to a set of K keypoint detections. This is done in three steps. First, K heatmaps S u (x; k), u ∈ Ω are generated, one for each keypoint k = 1, . . . , K. These heatmaps are obtained in parallel as the channels of a R H×W ×K tensor using a standard convolutional neural network architecture. Second, each heatmap is renormalised to a probability distribution via (spatial) Softmax and condensed to a point by computing the (spatial) expected value of the latter: Third, each heatmap is replaced with a Gaussian-like function centred at u * k with a small fixed standard deviation σ: The end result is a new tensor y = Φ(x) ∈ R H×W ×K that encodes as Gaussian heatmaps the location of K maxima. Since it is possible to recover the landmark locations exactly from these heatmaps, this representation is equivalent to the one considered above (2D coordinates); however, it is more useful as an input to a generator network, as discussed later.
One may wonder whether this construction can be simplified by removing steps two and three and simply consider S(x) (possibly after re-normalisation) as the output of the encoder Φ(x). The answer is that these steps, and especially eq. (1), ensure that very little information from x is retained, which, as suggested above, is key to avoid degenerate solutions. Converting back to Gaussian landmarks in eq. (2), instead of just retaining 2D coordinates, ensures that the representation is still utilisable by the generator network.
Separable implementation. In practice, we consider a separable variant of eq. (1) for computational efficiency. Namely, let u = (u 1 , u 2 ) be the two components of each pixel coordinate and write Ω = Ω 1 × Ω 2 . Then we set where i = 1, 2 and j = 2, 1 respectively. Figure 2 visualizes the source x, target x and generated Ψ(x, Φ(x )) images, as well as x overlaid with the locations of the unsupervised landmarks Φ(x ). It also shows the heatmaps S u (x; k) and marginalized separable softmax distributions on the top and left of each heatmap for K = 10 keypoints.

Generator network using a perceptual loss
The goal of the generator networkx = Ψ(x, y ) is to map the source image x and the distilled version y of the target image x to a reconstruction of the latter. Thus the generator network is optimised to minimise a reconstruction error L(x ,x ). The design of the reconstruction error is important for good performance. Nowadays the standard practice is to learn such a loss function using adversarial techniques, as exemplified in numerous variants of GANs. However, since the goal here is not generative modelling, but rather to induce a representation y of the object geometry for reconstructing a specific target image (as in an auto-encoder), a simpler method may suffice.
Inspired by the excellent results for photo-realistic image synthesis of [4], we resort here to use the "content representation" or "perceptual" loss used successfully for various generative networks [12,1,9,19,27,30,31]. The perceptual loss compares a set of the activations extracted from multiple layers of a deep network for both the reference and the generated images, instead of the only raw pixel values. We define the loss as is an off-the-shelf pre-trained neural network, for example VGG-19 [39], Γ l denotes the output of the l-th sub-network (obtained by chopping Γ at layer l). As our goal is to have a purely-unsupervised learning, we pre-train the network by using a self-supervised approach, namely colorising grayscale images [25]. We also test using a VGG-19 model pre-trained for image classification in ImageNet. All other networks are trained from scratch. The parameters α l > 0, l = 1, . . . , n are scalars that balance the terms. We use a linear combination of the reconstruction error for 'input', 'conv1_2', 'conv2_2', 'conv3_2', 'conv4_2' and 'conv5_2' layers of VGG-19; {α l } are updated online during training to normalise the expected contribution from each layer as in [4]. However, we use the 2 norm instead of their 1 , as it worked better for us.

Experiments
In section 4.1 we provide the details of the landmark detection and generator networks; a common architecture is used across all datasets. Next, we evaluate landmark detection accuracy on faces (section 4.2) and human-body (section 4.3). In section 4.4 we analyse the invariance of the learned landmarks to various nuisance factors, and finally in section 4.5 study the factorised representation of object style and geometry in the generator.

Model details
Landmark detection network. The landmark detector ingests the image x to produce K landmark heatmaps y . It is composed of sequential blocks consisting of two convolutional layers each. All the layers use 3×3 filters, except the first one which uses 7×7. Each block doubles the number of feature channels in the previous block, with 32 channels in the first one. The first layer in each block, except the first block, downsamples the input tensor using stride 2 convolution. The spatial size of the final output, outputting the heatmaps, is set to 16×16. Thus, due to downsampling, for a network with n − 3, n ≥ 4 blocks, the resolution of the input image is H×W = 2 n ×2 n , resulting in 16×16×(32 · 2 n−3 ) tensor. A final 1×1 convolutional layer maps this tensor to a 16×16×K tensor, with one layer per landmark. As described in section 3.1, these K feature channels are then used to render 16×16×K 2D-Gaussian maps y (with σ = 0.1).
Image generation network. The image generator takes as input the image x and the landmarks y = Φ(x ) extracted from the second image in order to reconstruct the latter. This is achieved in two steps: first, the image x is encoded as a feature tensor z ∈ R 16×16×C using a convolutional network with exactly the same architecture as the landmark detection network except for the final 1×1 convolutional layer, which is omitted; next, the features z and the landmarks y are stacked together (along the channel dimension) and fed to a regressor that reconstructs the target frame x .
The regressor also comprises of sequential blocks with two convolutional layers each. The input to each successive block, except the first one, is upsampled two times through bilinear interpolation, while the number of feature channels is halved; the first block starts with 256 channels, and a minimum of 32 channels are maintained till a tensor with the same spatial dimensions as x is obtained. A final convolutional layer regresses the three RGB channels with no non-linearity. All  layers use 3×3 filters and each block has two layers similarly to the landmark network. All the weights are initialised with random Gaussian noise (σ = 0.01), and optimised using Adam [21] with a weight decay of 5 · 10 −4 . The learning rate is set to 10 −2 , and lowered by a factor of 10 once the training error stops decreasing; the 2 -norm of the gradients is bounded to 1.0.

Learning facial landmarks
Setup. We explore extracting source-target image pairs (x, x ) using either (1) synthetic transformations, or (2) videos. In the first case, the pairs are obtained as (x, x ) = (g 1 x 0 , g 2 x 0 ) by applying two random thin-plate-spline (TPS) [11,49] warps g 1 , g 2 to a given sample image x 0 . We use the 200k CelebA [24] images after resizing them to 128×128 resolution. The dataset provides annotations for 5 facial landmarks -eyes, nose and mouth corners, which we do not use for training. Following [45] we exclude the images in MAFL [57] test-set from the training split and generate synthetically-deformed pairs as in [45,55], but the transformations themselves are not required for training. We discount the reconstruction loss in the regions of the warped image which lie outside the original image to avoid modelling irrelevant boundary artefacts.
In the second case, (x, x ) are two frames sampled from a video. We consider VoxCeleb [28], a large dataset of face tracks, consisting of 1251 celebrities speaking over 100k English language utterances. We use the standard training split and remove any overlapping identities which appear in the test sets of MAFL and AFLW. Pairs of frames from the same video, but possibly belonging to different utterances are randomly sampled for training. By using video data for training our models we eliminate the need for engineering synthetic data. Qualitative results. Figure 2 shows the learned heatmaps and source-target-reconstructionkeypoints quadruplets x, x , Ψ (x, Φ(x )) , Φ(x ) for synthetic transformations and videos. We note that the method extracts keypoints which consistently track facial features across deformation and identity changes (e.g., the green circle tracks the lower chin, and the light blue square lies between the eyes). The regressed semantic keypoints on the MAFL test set are visualised in fig. 3, where they are localised with high accuracy. Further, the target image x is also reconstructed accurately.  . 3).
Quantitative results. We follow [45,44] and use unsupervised keypoints learnt on CelebA and VoxCeleb to regress manually-annotated keypoints in the MAFL and AFLW [23] test sets. We freeze the parameters of the unsupervised detector network (Φ) and learn a linear regressor (without bias) from our unsupervised keypoints to 5 manually-labelled ones from the respective training sets. Model selection is done using 10% validation split of the training data.
We report results in terms of standard MSE normalised by the inter-ocular distance expressed as a percentage [57], and show a few regressed keypoints in fig. 3. Before evaluating on AFLW, we finetune our networks pre-trained on CelebA or VoxCeleb on the AFLW training set. We do not use any labels during finetuning.
Sample efficiency. Figure 3 reports the performance of detectors trained on CelebA as a function of the number n of supervised examples used to translate from unsupervised to supervised keypoints. We note that n = 10 is already sufficient for results comparable to the previous state-of-the-art (SoA) method of Thewlis et al. [45], and that performance almost saturates at n = 500 (vs. 19,000 available training samples).
Vs. SoA. Table 1 compares our regression results to the SoA. We experiment regressing from K={10, 30, 50} unsupervised landmarks, using the self-supervised and the supervised perceptual loss networks; the number of samples n used for regression is maxed out (= 19000) to be consistent with previous works. On both MAFL and AFLW datasets, at 2.58% and 6.31% error respectively (for K = 30), we significantly outperform all the supervised and unsupervised methods. Notably, we perform better than the concurrent work of Zhang et al. [55] (MAFL: 3.16%; AFLW: 6.58%), while using a simpler method. When synthetic warps are removed from [55], so that the equivariance constraint cannot be employed, our method is significantly better (2.58% vs 8.42% on MAFL). We are also significantly better than many SoA supervised detectors [54,41,57] using only n = 100 supervised training examples, which shows that the approach is very effective at exploiting the unlabelled data. Finally, training with VoxCeleb video frames degrades the performance due to domain gap; including a bias in the linear regressor improves the performance.  : Replacing the content loss with 1 , 2 losses on the images, optionally paired with an adversarial loss (adv.) also degrades the performance. shape-vs-illumination (y-axis-vs-x-axis).
Ablation study. In table 2 we present two ablation studies, first on the keypoint bottleneck, and second where we compare against adversarial and other image-reconstruction losses. For both the settings, we take the best performing model configuration for facial landmark detection on the MAFL dataset.
Keypoint bottleneck. The keypoint bottleneck has two functions: (1) it provides a differentiable and distributed representation of the location of landmarks, and (2) it restricts the information from the target image to spatial locations only. When the bottleneck is replaced with a generic low dimensional fully-connected layer (as in a conventional auto-encoder) the performance degrades significantly This is because the continuous vector embedding is not encouraged to encode geometry explicitly.
Reconstruction loss. We replace our content/perceptual loss with 1 and 2 losses on generated pixels; the losses are also optionally paired with an adversarial term [13] to encourage verisimilitude as in [18]. All of these alternatives lead to worse landmark detection performance (table 2). While GANs are useful for aligning image distributions, in our setting we reconstruct a specific target image (similar to an auto-encoder). For this task, it is enough to use a simple content/perceptual loss.

Learning human body landmarks
Setup. Articulated limbs make landmark localisation on human body significantly more challenging than faces. We consider two video datasets, BBC-Pose [3], and Human3.6M [17]. BBC-Pose comprises of 20 one-hour long videos of sign-language signers with varied appearance, and dynamic background; the test set includes 1000 frames. The frames are annotated with 7 keypoints corresponding to head, wrists, elbows, and shoulders which, as for faces, we use only for quantitative evaluation, not for training. Human3.6M dataset contains videos of 11 actors in various poses, shot from multiple viewpoints. Image pairs are extracted by randomly sampling frames from the same video sequence, with the additional constraint of maintaining the time difference within the range 3-30 frames for Human3.6M. Loose crops around the subjects are extracted using the provided annotations and resized to 128×128 pixels. Detectors for K = 20 and K = 50 keypoints are trained on Human3.6M and BBC-Pose respectively.
Qualitative results. Figure 4 shows raw unsupervised keypoints and the regressed semantic ones on the BBC-Pose dataset. For each annotated keypoint, a maximally matching unsupervised keypoint is identified by solving bipartite linear assignment using mean distance as the cost. Regressed keypoints consistently track the annotated points. Figure 5 shows x, x , Ψ (x, Φ(x )) , Φ(x ) quadruplets, as for faces, as well as the discovered keypoints. All the keypoints lie on top of the human actors, and consistently track the body across identities and poses. However, the model cannot discern frontal and dorsal sides of the human body apart, possibly due to weak cues in the images, and no explicit constraints enforcing such consistency.
Quantitative results. Figure 4 compares the accuracy of localising the 7 keypoints on BBC-Pose against supervised methods, for both self-supervised and supervised perceptual loss networks. The accuracy is computed as the the %-age of points within a specified pixel distance d. In this case, the top two supervised methods are better than our unsupervised approach, but we outperform [33,53] using 1k training samples (vs. 10k); furthermore, methods such as [35] are specialised for videos and leverage temporal smoothness. Training using the supervised perceptual loss is understandably better than using the self-supervised one. Performance is particularly good on parts such as the elbow.

Learning 3D object landmarks: pose, shape, and illumination invariance
We train our unsupervised keypoint detectors on the SmallNORB [26] dataset, comprising 5 object categories with 10 object instances each, imaged from regularly spaced viewpoints and under different illumination conditions. We train category-specific detectors for K = 20 keypoints using image-pairs from neighbouring viewpoints and show results in fig. 6 for car and airplane (see supplementary material for visualisation of other object categories). Keypoints most invariant to various factors are visualised. These landmarks are especially robust to changes in illumination and elevation angle. They are also invariant to smaller changes in azimuth (±80 • ), but fail to generalise beyond that. Most interesting, they localise structurally similar regions, even when there is a large change in object shape (e.g. fig. 6-(d)); such landmarks could thus be leveraged for viewpoint-invariant semantic matching.

Disentangling appearance and geometry
In fig. 7 we show that our method can be interpreted as disentangling appearance from geometry. Generator/ keypoint networks are trained on SVHN digits [29], AFLW faces, and Human3.6M people. The generator network is capable of retaining the geometry of an image, and substituting the style with any other image in the dataset, including unrelated image pairs never seen during training. For example, in the third column we re-render the number 3 by mixing its geometry with the appearance of the number 5. This generalises significantly from the training examples, which only consist of pairs of digits sampled from the same house number instance, sharing a common style.

Conclusions
In this paper we have shown that a simple network trained for conditional image generation can be utilised to induce, without manual supervision, a object landmark detectors. On faces, our method outperforms previous unsupervised as well as supervised methods for landmark detection. The method can also extend to much more challenging data, such as detecting landmarks of people, and diverse data, such as 3D objects and digits.  Table 3: Results on MAFL face-landmarks test-set. Varying number (K) of unsupervised landmarks are learnt on two training-sets -random-TPS warps on CelebA [24], and face-videos from the VoxCeleb [28]. These landmarks are regressed onto 5 manually-annotated landmarks in the MAFL [57] test set, using either CelebA or MAFL training sets. Mean squared-error (MSE) normalised by the inter-ocular distance is reported.

B Boundary Discounting
When TPS warping is used during training some pixels in the resulting image may lie outside the original image. Since reconstructing these empty pixels is irrelevant we ignore them in the reconstruction loss. We additonaly ignore 10 pixels on the edges of the original image and use a smooth step over the next 20 pixels. This is to further discourage reconstruction of the empty pixels as they can influence the perceptual loss when a convolutional neural network with a large receptive field is used. keypoints are provided, corresponding to -head, wrists, elbows and shoulders. Solid circles represent the predicted positions; Top rows show raw discovered keypoints which correspond maximally to each annotation; bottom rows show linearly regressed points from the discovered keypoints.
G smallNORB 3D Objects: pose, shape, and illumination invariance Object-category specific keypoint detectors are trained on the 5 categories in the smallNORB dataset human, car, animal, airplane, and truck. Training is performed on pairs of images, which differ only in their viewpoints, but have the same object instance (or shape), and illumination.
Keypoints invaraint to viewpoint, illumniation, and object shape are visualised for object instances in the test set. The training set consists of only 5 object instances per category, yet the detectors generalise to novel object instances in the test set, and correspond to structurally similar regions across instances.

H Disentangling appearance and geometry
The generator substitutes the appearance of the target image (x ) with that of the source image (x). Instead of sampling image pairs (x, x ) with consistent style, as done during training, we sample pairs with different styles at inference, resulting in compelling transfer across different object categories -SVHN digits, Human3.6M humans, and AFLW faces.