Code for the paper "Unsupervised Learning from Narrated Instruction Videos", CVPR2016
We address the problem of automatically learning the main steps to complete a certain task, such as changing a car tire, from a set of narrated instruction videos. The contributions of this paper are three-fold. First, we develop a new unsupervised learning approach that takes advantage of the complementary nature of the input video and the associated narration. The method solves two clustering problems, one in text and one in video, applied one after each other and linked by joint constraints to obtain a single coherent sequence of steps in both modalities. Second, we collect and annotate a new challenging dataset of real-world instruction videos from the Internet. The dataset contains about 800,000 frames for five different tasks that include complex interactions between people and objects, and are captured in a variety of indoor and outdoor settings. Third, we experimentally demonstrate that the proposed method can automatically discover, in an unsupervised manner, the main steps to achieve the task and locate the steps in the input videos.READ FULL TEXT VIEW PDF
Human communication takes many forms, including speech, text and
This paper presents a new method for unsupervised segmentation of comple...
Human communication typically has an underlying structure. This is refle...
In this work we address the challenging problem of unsupervised learning...
Recently unsupervised learning of depth from videos has made remarkable
In this paper, we introduce a new problem of manipulating a given video ...
Many important classification problems, such as object classification, s...
Code for the paper "Unsupervised Learning from Narrated Instruction Videos", CVPR2016
Millions of people watch narrated instruction videos222Some instruction videos on YouTube have tens of millions of views, e.g. www.youtube.com/watch?v=J4-GRH2nDvw. to learn new tasks such as assembling IKEA furniture or changing a flat car tire. Many of such tasks have large amounts of videos available on-line. For example, querying for “how to change a tire” results in more than 300,000 hits on YouTube. Most of these videos, however, are made with the intention to teach other people to perform the task and do not provide direct supervisory signal for automatic learning algorithms. Developing unsupervised methods that could learn tasks from myriads of instruction videos on the Internet is therefore a key challenge. Such automatic cognitive ability would enable constructing virtual assistants and smart robots that learn new skills from the Internet to, for example, help people achieve new tasks in unfamiliar situations.
In this work, we consider instruction videos and develop a method that learns a sequence of steps, as well as their textual and visual representations, required to achieve a certain task. For example, given a set of narrated instruction videos demonstrating how to change a car tire, our method automatically discovers consecutive steps for this task such as loosen the nuts of the wheel, jack up the car, remove the spare tire and so on as illustrated in Figure 1. In addition, the method learns the visual and linguistic variability of these steps from natural videos.
Discovering key steps from instruction videos is a highly challenging task. First, linguistic expressions for the same step can have high variability across videos, for example: “…Loosen up the wheel nut just a little before you start jacking the car…” and “…Start to loosen the lug nuts just enough to make them easy to turn by hand…”. Second, the visual appearance of each step varies greatly between videos as the people and objects are different, the action is captured from a different viewpoint, and the way people perform actions also vary. Finally, there is also a variability of the overall structure of the sequence of steps achieving the task. For example, some videos may omit some steps or change slightly their order.
To address these challenges, in this paper we develop an unsupervised learning approach that takes advantage of the complementarity of the visual signal in the video and the corresponding natural language narration to resolve their ambiguities. We assume that the same ordered sequence of steps (also called script in the NLP literature [Regneri10learning]) is common to all input videos of the same task, but the actual sequence and the individual steps are unknown and are learnt directly from data. This is in contrast to other existing methods for modeling instruction videos [Malmaud15what] that assume a script (recipe) is known and fixed in advance. We address the problem by first performing temporal clustering of text followed by clustering in video, where the two clustering tasks are linked by joint constraints. The complementary nature of the two clustering problems helps to resolve ambiguities in the two individual modalities. For example, two video segments with very different appearance but depicting the same step can be grouped together because they are narrated in a similar language. Conversely, two video segments described with very different expressions, for example, “jack up the car” and “raise the vehicle” can be identified as belonging to the same instruction step because they have similar visual appearance. The output of our method is the script listing the discovered steps of the task as well as the temporal location of each step in the input videos. We validate our method on a new dataset of instruction videos composed of five different tasks with a total of 150 videos and about 800,000 frames.
This work relates to unsupervised and weakly-supervised learning methods in computer vision and natural language processing. Particularly related to ours is the work on learning script-like knowledge from natural language descriptions[Chambers08, Frermann14, Regneri10learning]. These methods aim to discover typical events (steps) and their order for particular scenarios (tasks)333We here assign the same meaning to terms “event” and “step” as well as to terms “script” and “task”. such as “cooking scrambled egg”, “taking a bus” or “making coffee”. While [Chambers08] uses large-scale news copora, [Regneri10learning] argues that many events are implicit and are not described in such general-purpose text data. Instead, [Frermann14, Regneri10learning] use event sequence descriptions collected for particular scenarios. Differently to this work, we learn sequences of events from narrated instruction videos on the Internet. Such data contains detailed event descriptions but is not structured and contains more noise compared to the input of [Frermann14, Regneri10learning].
Interpretation of narrated instruction videos has been recently addressed in [Malmaud15what]. While this work analyses cooking videos at a great scale, it relies on readily-available recipes which may not be available for more general scenarios. Differently from [Malmaud15what], we here aim to learn the steps of instruction videos using a discriminative clustering approach. A similar task to ours is addressed in [Naim15discriminative]
using latent variable structured perceptron algorithm to align nouns in instruction sentences with objects touched by hands in instruction videos. However, similarly to[Malmaud15what], [Naim15discriminative] uses laboratory experimental protocols as textual input, whereas here we consider a weaker signal in the form of the real transcribed narration of the video.
In computer vision, unsupervised action recognition has been explored in simple videos [Niebles08]. More recently, weakly supervised learning of actions in video using video scripts or event order has been addressed in [Bojanowski13finding, Bojanowski14weakly, Bojanowski15weakly, Duchenne2009automatic, Laptev08a]. Particularly related to ours is the work [Bojanowski14weakly] which explores the known order of events to localize and learn actions in training data. While [Bojanowski14weakly] uses manually annotated sequences of events, we here discover the sequences of main events by clustering transcribed narrations of the videos. Related is also the work of [Bojanowski15weakly] that aligns natural text descriptions to video but in contrast to our approach does not discover automatically the common sequence of main steps. Methods in [Niebles10a, Raptis13] learn in an unsupervised manner the temporal structure of actions from video but do not discover textual expressions for actions as we do in this work. The recent concurrent work [Sener15unsupervised] is addressing, independently of our work, a similar problem but with a different approach based on a probabilistic generative model and considering a different set of tasks mainly focussed on cooking activities.
Our work is also related to video summarization and in particular to the recent work on category-specific video summarization [Potapov14category, Sun14ranking]. While summarization is a subjective task, we here aim to extract the key steps required to achieve a concrete task that consistently appear in the same sequence in the input set of videos. In addition, unlike video summarization [Potapov14category, Sun14ranking] we jointly exploit visual and linguistic modalities in our approach.
We have collected a dataset of narrated instruction videos for five tasks: Making a coffee, Changing car tire, Performing cardiopulmonary resuscitation (CPR), Jumping a car and Repotting a plant. The videos were obtained by searching YouTube with relevant keywords. The five tasks were chosen so that they have a large number of available videos with English transcripts while trying to cover a wide range of activities that include complex interactions of people with objects and other people. For each task, we took the top 30 videos with English ASR returned by YouTube. We also quickly verified that each video contains a person actually performing the task (as opposed to just talking about it). The result is a total of 150 videos, 30 videos for each task. The average length of our videos is about 4,000 frames (or 2 minutes) and the entire dataset contains about 800,000 frames.
The selected videos have English transcripts obtained from YouTube’s automatic speech recognition (ASR) system. To remove the dependence of results on errors of the particular ASR method, we have manually corrected misspellings and punctuations in the output transcriptions. We believe this step will soon become obsolete given rapid improvements of ASR methods. As we do not modify the content of the spoken language in videos, the transcribed verbal instructions still represent an extremely challenging example of natural language with large variability in the used expressions and terminology. Each word of the transcript is associated with a time interval in the video (usually less than 5 seconds) obtained from the closed caption timings.
For the purpose of evaluation, we have manually annotated the temporal location in each video of the main steps necessary to achieve the given task. For all tasks, we have defined the ordered sequence of ground truth steps before running our algorithm. The choice of steps was made by an agreement of 2-3 annotators who have watched the input videos and verified the steps on instruction video websites such as http://www.howdini.com. While some steps can be occasionally left out in some videos or the ordering slightly modified, overall we have observed a good consistency in the given sequence of instructions among the input videos. We measured that only 6% of the step annotations did not fit the global order, while a step was missing from the video 27% of the time.444We describe these measurements in more details in the supplementary material given in Appendix A.1. We hypothesize that this could be attributed to the fact that all videos are made with the same goal of giving other humans clear, concise and comprehensible verbal and visual instructions on how to achieve the given task. Given the list of steps for each task, we have manually annotated each time interval in each input video to one of the ground truth steps (or no step). The actions of the individual steps are typically separated by hundreds of frames where the narrator transitions between the steps or explains verbally what is going to happen. Furthermore, some steps could be missing in some videos, or could be present but not described in the narration. Finally, the temporal alignment between the narration and the actual actions in video is only coarse as the action is often described before it is performed.
We are given a set of instruction videos all depicting the same task (such as “changing a tire”). The -th input video is composed of a video stream of segments of frames and an audio stream containing a detailed verbal description of the depicted task. We suppose that the audio description was transcribed to raw text and then processed to a sequence of text tokens . Given this data, we want to automatically recover the sequence of main steps that compose the given task and locate each step within each input video and text transcription.
We formulate the problem as two clustering tasks, one in text and one in video, applied one after each other and linked by joint constraints linking the two modalities. This two-stage approach is based on the intuition that the variation in natural language describing each task is easier to capture than the visual variability of the input videos. In the first stage, we cluster the text transcripts into a sequence of main steps to complete the given task. Empirically, we have found (see results in Sec. 5.1) that it is possible to discover the sequence of the main steps for each task with high precision. However, the text itself gives only a poor localization of each step in each video. Therefore, in the second stage we accurately localize each step in each video by clustering the input videos using the sequence of steps extracted from text as constraints on the video clustering. To achieve this, we use two types of constraints between video and text. First, we assume that both the video and the text narration follow the same sequence of steps. This results in a global ordering constraint on the recovered clustering. Second, we assume that people perform the action approximately at the same time that they talk about it. This constraint temporally links the recovered clusters in text and video. The important outcome of the video clustering stage is that the
extracted steps get propagated by visual similarity to videos where the text descriptions are missing or ambiguous.
The goal here is to cluster the transcribed verbal descriptions of each video into a sequence of main steps necessary to achieve the task. This stage is important as the resulting clusters will be used as constraints for jointly learning and localizing the main steps in video. We assume that the important steps are common to many of the transcripts and that the sequence of steps is (roughly) preserved in all transcripts. Hence, following [Regneri10learning], we formulate the problem of clustering the input transcripts as a multiple sequence alignment problem. However, in contrast to [Regneri10learning] who cluster manually provided descriptions of each step, we wish to cluster transcribed verbal instructions. Hence our main challenge is to deal with the variability in spoken natural language. To overcome this challenge, we take advantage of the fact that completing a certain task usually involves interactions with objects or people and hence we can extract a more structured representation from the input text stream.
More specifically, we represent the textual data as a sequence of direct object relations. A direct object relation is a pair composed of a verb and its direct object complement, such as “remove tire”. Such a direct object relation can be extracted from the dependency parser of the input transcribed narration [Marneffe06generating]. We denote the set of all different direct object relations extracted from all narrations as , with cardinality . For the -th video, we thus represent the text signal as a sequence of direct object relation tokens: , where the length of the sequence varies from one video clip to another. This step is key to the success of our method as it allows us to convert the problem of clustering raw transcribed text into an easier problem of clustering sequences of direct object relations. The goal is now to extract from the narrations the most common sequence of main steps to achieve the given task. To achieve this, we first find a globally consistent alignment of the direct object relations that compose all text sequences by solving a multiple sequence alignment problem. Second, we pick from this alignment the most globally consistent clusters across videos.
Multiple sequence alignment model. We formulate the first stage of finding the common alignment between the input sequences of direct object relations as a multiple sequence alignment problem with the sum-of-pairs score [wang1994msaNPhard]. In details, a global alignment can be defined by re-mapping each input sequence of tokens to a global common template of slots, for large enough. We let represent the (increasing) re-mapping for sequence at the new locations indexed by : represents the direct object relation put at location , with if a slot is left empty (denoting the insertion of a gap in the original sequence of tokens). See the middle of Figure 2 for an example of re-mapping. The goal is then to find a global alignment that minimizes the following sum-of-pairs cost function:
where denotes the cost of aligning the direct object relations and at the same common slot in the global template. The above cost thus denotes the sum of all pairwise alignments of the individual sequences (the outer sum), where the quality of each alignment is measured by summing the cost of matches of individual direct object relations mapped into the common template sequence. We use a negative cost when and are similar according to the distance in the WordNet tree [Fellbaum98Wordnet, Miller95Wordnet] of their verb and direct object constituents, and positive if they are dissimilar (details are given in Sec. 5). As the verbal narrations can talk about many other things than the main steps of a task, we set if either or is . An illustration of clustering the transcribed verbal instructions into a sequence of steps is shown in Figure 2.
Optimization using Frank-Wolfe. Optimizing the cost (1) is NP-hard [wang1994msaNPhard]
because of the combinatorial nature of the problem. The standard solution from computational biology is to apply a heuristic algorithm that proceeds by incremental pairwise alignment using dynamic programming[Lee01poa]. In contrast, we show in Appendix B.1 that the multiple sequence alignment problem given by (1) can be reformulated as an integer quadratic program with combinatorial constraints, for which the Frank-Wolfe optimization algorithm has been used recently with increasing success [Bojanowski14weakly, Jaggi2013, Joulin14efficient, Lacoste15GlobalLinearFW]. Interestingly, we have observed empirically (see Appendix B.2) that the Frank-Wolfe algorithm was giving better solutions (in terms of objective (1)) than the state-of-the-art heuristic procedures for this task [Higgins88clustal, Lee01poa]. Our Frank-Wolfe based solvers also offer us greater flexibility in defining the alignment cost and scale better with the length of input sequences and the vocabulary of direct object relations.
Extracting the main steps. After a global alignment is obtained, we sort the global template by the number of direct object relations aligned to each slot. Given as input, the top slots give the main instruction steps for the task, unless there are multiple steps with the same support, which go beyond . In this case, we pick the next smaller number below which excludes these ties, allowing the choice of an adaptive number of main instruction steps when there is not enough saliency for the last steps. This strategy essentially selects salient steps, while refusing to make a choice among steps with equal support that would increase the total number of steps beyond . As we will see in our results in Sec. 5.1, our algorithm sometimes returns a much smaller number than for the main instruction steps, giving more robustness to the exact choice of parameter .
Encoding of the output. We post-process the output of multiple sequence alignment into an assignment matrix for each input video , where means that the direct object token has been assigned to step . If a direct object has not been assigned to any step, the corresponding row of the matrix will be zero.
Given the output of the text clustering that identified the important steps forming a task, we now want to find their temporal location in the video signal. We formalize this problem as looking for an assignment matrix for each input video , where indicates the visual presence of step at time interval in video , and is the length of video . Similarly to , we allow the possibility that a whole row of is zero, indicating that no step is visually present for the corresponding time interval.
We propose to tackle this problem using a discriminative clustering approach with global ordering constraints, as was successfully used in the past for the temporal localization of actions in videos [Bojanowski14weakly], but with additional weak temporal constraints. In contrast to [Bojanowski14weakly] where the order of actions was manually given for each video, our multiple sequence alignment approach automatically discovers the main steps. More importantly, we also use the text caption timing to provide a fine-grained weak temporal supervision for the visual appearance of steps, which is described next.
|Changing a tire||Performing CPR||Repot a plant||Make coffee||Jump car|
|GT (11)||GT (7)||GT (7)||GT (10)||GT (12)|
|get tools out||get tire||open airway||open airway||take plant||remove plant||add coffee||put coffee||connect red A||connect cable|
|start loose||loosen nut||check pulse||put hand||put soil||use soil||fill chamber||charge battery|
|put jack||tilt head||loosen roots||loosen soil||fill water||fill water||connect red B||connect end|
|jack car||jack car||lift chin||place plant||place plant||screw filter||put filter||start car A||start car|
|unscrew wheel||remove nut||give breath||give breath||add top||add soil||see steam||remove cable A||remove cable|
|remove wheel||take wheel||do compressions||do compression||water plant||water plant||put stove||take minutes||remove cable B||disconnect cable|
|put wheel||take tire||open airway||make coffee|
|screw wheel||put nut||start compression||see coffee||see coffee|
|lower car||lower jack||do compression||pour coffee||make cup|
|tight wheel||tighten nut||give breath|
Temporal weak supervision from text. From the output of the multiple sequence alignment (encoded in the matrix ), each direct object token has been assigned to one of the possible steps, or to no step at all. We use the tokens that have been assigned to a step as a constraint on the visual appearance of the same step in the video (using the assumption that people do what they say approximately when they say it). We encode the closed caption timing alignment by a binary matrix for each video, where is if the -th direct object is mentioned in a closed caption that overlaps with the time interval in video. Note that this alignment is only approximate as people usually do not perform the action exactly at the same time that they talk about it, but instead with a varying delay. Second, the alignment is noisy as people typically perform the action only once, but often talk about it multiple times (e.g. in a summary at the beginning of the video). We address these issues by the following two weak supervision constraints. First, we consider a larger set of possible time intervals in the matrix rather than the exact time interval given by the timing of the closed caption. and are global parameters fixed either qualitatively, or by cross-validation if labeled data is provided. Second, we put as a constraint that the action happens at least once in the set of all possible video time intervals where the action is mentioned in the transcript (rather than every time it is mentioned). These constraints can be encoded as the following linear inequality constraint on : (see Appendix C.2 for the detailed derivation).
Ordering constraint. In addition, we also enforce that the temporal order of the steps appearing visually is consistent with the discovered script from the text, encoding our assumption that there is a common ordered script for the task across videos. We encode these sequence constraints on in a similar manner to [Bojanowski15weakly], which was shown to work better than the encoding used in [Bojanowski14weakly]. In particular, we only predict the most salient time interval in the video that describes a given step. This means that a particular step is assigned to exactly one time interval in each video. We denote by this sequence ordering constraint set.
Discriminative clustering. The main motivation behind discriminative clustering is to find a clustering of the data that can be easily recovered by a linear classifier through the minimization of an appropriate cost function over the assignment matrix . The approach introduced in [Bach07diffrac] allows to easily add prior information on the expected clustering. Such priors have been recently introduced in the context of aligning video and text [Bojanowski14weakly, Bojanowski15weakly] in the form of ordering constraints over the latent label variables. Here we use a similar approach to cluster the input video streams into a sequence of steps, as follows. We represent each time interval by a
-dimensional feature vector. The feature vectors for the-th video are stacked in a design matrix denoted by . We denote by the matrix obtained by the concatenation of all matrices (and similarly, by , and the appropriate concatenation of the , and matrices over ). In order to obtain the temporal localization into
steps, we learn a linear classifier represented by amatrix denoted by . This model is shared among all videos.
The target assignment is found by minimizing the clustering cost function under both the consistent script ordering constraints and our weak supervision constraints:
The clustering cost is given as in DIFFRAC [Bach07diffrac] as:
The first term in (3) is the discriminative loss on the data that measures how easy the input data is separable by the linear classifier when the target classes are given by the assignments . For the squared loss considered in eq. (3), the optimal weights minimizing (3) can be found in closed form, which significantly simplifies the computation. However, to solve (2), we need to optimize over assignment matrices that encode sequences of events and incorporate constraints given by clusters obtained from transcribed textual narrations (Sec. 4.1). This is again done by using the Frank-Wolfe algorithm, which allows the use of efficient dynamic programs to handle the combinatorial constraints on . More details are given in Appendix C.
In this section, we first describe the details of the text and video features. Then we present the results divided into two experiments: (i) in Sec. 5.1, we evaluate the quality of steps extracted from video narrations, and (ii) in Sec. 5.2, we evaluate the temporal localization of the recovered steps in video using constraints derived from text. All the data and code are available at our project webpage [Alayrac15UnsupervisedWeb].
Video and text features. We represent the transcribed narrations as sequences of direct object relations. For this purpose, we run a dependency parser [Marneffe06generating] on each transcript. We lemmatize all direct object relations and keep the ones for which the direct object corresponds to nouns. To represent a video, we use motion descriptors in order to capture actions (loosening, jacking-up, giving compressions) and frame appearance descriptors to capture the depicted objects (tire, jack, car). We split each video into 10-frame time intervals and represent each interval by its motion and appearance descriptors aggregated over a longer block of 30 frames. The motion representation is a histogram of local optical flow (HOF) descriptors aggregated into a single bag-of-visual-word vector of 2,000 dimensions [Wang13action]
. The visual vocabulary is generated by k-means on a separate large set of training descriptors. To capture the depicted objects in the video, we apply the VGG-verydeep-16 CNN[Simonyan14c] over each frame in a sliding window manner over multiple scales. This can be done efficiently in a fully convolutional manner. The resulting 512-dimensional feature maps of conv5 responses are then aggregated into a single bag-of-visual-word vector of 1,000 dimensions, which aims to capture the presence/absence of different objects within each video block. A similar representation (aggregated into compact VLAD descriptor) was shown to work well recently for a variety of recognition tasks [Cimpoi15]. The bag-of-visual-word vectors representing the motion and the appearance are normalized using the Hellinger normalization and then concatenated into a single 3,000 dimensional vector representing each time interval.
WordNet distance. For the multiple sequence alignment presented in Sec. 4.1, we set if and have both their verbs and direct objects that match exactly in the Wordnet tree (distance equal to 0). Otherwise we set to be 100. This is to ensure a high precision for the resulting alignment.
Results of discovering the main steps for each task from text narrations are presented in Table 1. We report results of the multiple sequence alignment described in Sec. 4.1 when the maximum number of recoverable steps is . Additional results for different choices of are given in the Appendix E.1. With increasing , we tend to recover more complete sequences at the cost of occasional repetitions, e.g. position jack and jack car
that refer to the same step. To quantify the performance, we measure precision as the proportion of correctly recovered steps appearing in the correct order. We also measure recall as the proportion of the recovered ground truth steps. The values of precision and recall are given at the bottom of Table1.
In the previous section, we have evaluated the quality of the sequences of steps recovered from the transcribed narrations. In this section, we evaluate how well we localize the individual instruction steps in the video by running our two-stage approach from Sec. 4.
Evaluation metric. To evaluate the temporal localization, we need to have a one-to-one mapping between the discovered steps in the videos and the ground truth steps. Following [Liao05Clustering], we look for a one-to-one global matching (shared across all videos of a given task) that maximizes the evaluation score for a given method (using the Hungarian algorithm). Note that this mapping is used only for evaluation, the algorithm does not have access to the ground truth annotations for learning.
The goal is to evaluate whether each ground truth step has been correctly localized in all instruction videos. We thus use the F1 score that combines precision and recall into a single score as our evaluation measure. For a given video and a given recovered step, our video clustering method predicts exactly one video time interval . This detection is considered correct if the time interval falls inside any of the corresponding ground truth intervals, and incorrect otherwise (resulting in a false positive for this video). We compute the recall across all steps and videos, defined as the ratio of the number of correct predictions over the total number of possible ground truth steps across videos. A recall of 1 indicates that every ground truth step has been correctly detected across all videos. The recall decreases towards 0 when we miss some ground truth steps (missed detections). This happens either because this step was not recovered globally, or because it was detected in the video at an incorrect location. This is because the algorithm predicts exactly one occurrence of each step in each video. Similarly, precision measures the proportion of correct predictions among all possible predictions, where is the number of videos and
is the number of main steps used by the method. The F1 score is the harmonic mean of precision and recall, giving a score that ranges between 0 and 1, with the perfect score of 1 when all the steps are predicted at their correct locations in all videos.
Hyperparameters. We set the values of parameters and to 0 and 10 seconds. The setting is the same for all five tasks. This models the fact that typically each step is first described verbally and then performed on the camera. We set for all methods that use (3).
Baselines. We compare results to four baselines. To demonstrate the difficulty of our dataset, we first evaluate a “Uniform” baseline, which simply distributes instructions steps uniformly over the entire instruction video. The second baseline “Video only” [Bojanowski14weakly] does not use the narration and performs only discriminative clustering on visual features with a global order constraint.555We use here the improved model from [Bojanowski15weakly] which does not require a “background class” and yields a stronger baseline equivalent to our model (2) without the weak textual constraints. The third baseline “Video + BOW dobj” basically adds text-based features to the “Video only” baseline (by concatenating the text and video features in the discriminative clustering approach). Here the goal is to evaluate the benefits of our two-stage clustering approach, in contrast to this single-stage clustering baseline. The text features are bag-of-words histograms over a fixed vocabulary of direct object relations.666Alternative features of bag-of-words histograms treating separately nouns and verbs also give similar results. The fourth baseline is our own implementation of the alignment method of [Malmaud15what] (without the supervised vision refinement procedure that requires a set of pre-trained visual classifiers that are not available a-priori in our case). We use [Malmaud15what] to re-align the speech transcripts to the sequence of steps discovered by our method of Sec. 4.1 (as a proxy for the recipe assumed to be known in [Malmaud15what]).777Note that our method finds at the same time the sequence of steps (a recipe in [Malmaud15what]) and the alignment of the transcripts. To assess the difficulty of the task and dataset, we also compare results with a “Supervised” approach. The classifiers for the visual steps are trained by running the discriminative clustering of Sec. 4.2 with only ground truth annotations as constraints on the training set. At test time, these classifiers are used to make predictions under the global ordering constraint on unseen videos. We report results using 5-fold cross validation for the supervised approach, with the variation across folds giving the error bars. For the unsupervised discriminative clustering methods, the error bars represent the variation of performance obtained from different rounded solutions collected during the Frank-Wolfe optimization.
Results. Results for localizing the discovered instruction steps are shown in Figure 3. In order to perform a fair comparison to the baseline methods that require a known number of steps , we report results for a range of values. Note that in our case the actual number of automatically recovered steps can be (and often is) smaller than . For Change tire and Perform CPR, our method consistently outperforms all baselines for all values of demonstrating the benefits of our approach. For Repot, our method is comparable to text-based baselines, underlying the importance of the text signal for this problem. For Jump car, our method delivers the best result (for ) but struggles for lower values of , which we found was due to visually similar repeating steps (e.g. start car A and start car B) which are mixed-up for lower values of . For the Make coffee task, the video only baseline is comparable to our method, which by inspecting the output could be attributed to large variability of narrations for this task. Qualitative results of the recovered steps are illustrated in Figure 4.
We have described a method to automatically discover the main steps of a task from a set of narrated instruction videos in an unsupervised manner. The proposed approach has been tested on a new annotated dataset of challenging real-world instruction videos containing complex person-object interactions in a variety of indoor and outdoor scenes. Our work opens up the possibility for large scale learning from instruction videos on the Internet. Our model currently assumes the existence of a common script with a fixed ordering of the main steps. While this assumption is often true, e.g. one cannot remove the wheel before jacking up the car, or make coffee before filling the water, some tasks can be performed while swapping (or even leaving out) some of the steps. Recovering more complex temporal structures is an interesting direction for future work.
This research was supported in part by a Google Research Award, and the ERC grants VideoWorld (no. 267907), Activia (no. 307574) and LEAP (no. 336845).
This supplementary material provides additional details for our method and presents a more complete set of results. Section A gives detailed statistics and an illustration of the newly collected dataset of instruction videos. Section B gives details about our new formulation of the multiple sequence alignment problem (Section 4.1 of the main paper) as a quadratic program and presents empirical results showing that our Frank-Wolfe optimization approach obtains solutions with lower objective values than the state-of-the-art heuristic algorithms for multiple sequence alignment. Section C provides the details for the discriminative clustering of videos with text constraints that was briefly described in Section 4.2 of the main paper. Section D gives additional details about the experimental protocol used in Section 5.2 in the main paper. Finally, in Section E, we give a more complete set of qualitative results for both the clustering of transcribed verbal instructions (see E.1) and localizing instruction steps in video (see E.2).
In this section, we introduce three different scores which aim to illustrate different properties of our dataset. The scores characterize (i) the step ordering consistency, (ii) the missing steps and (iii) the possible step repetitions.
Let be the number of videos for a given task and the number of steps defined in the ground truth. We assume that the ground truth steps are given in an ordered fashion, meaning the global order is defined as the sequence . For the -th video, we denote by the total number of annotated steps, by the number of unique annotated steps and finally by the length of the longest common subsequence between the annotated sequence of steps and the ground truth sequence .
The order error score is defined as the proportion of non repeated annotated steps that are not consistent with the global ordering. In other words, it is defined as the number of steps that do not fit the global ordering defined in the ground truth divided by the total number of unique annotated steps. More formally, is defined as follows:
We define the missing steps score as the proportion of steps that are visually missing in the videos when compared to the ground truth. Formally,
The repetition score is defined as the proportion of steps that are repeated:
In Table 2, we give the previously defined statistics for the five tasks of the instruction videos dataset. Interestingly, we observed that globally the order is consistent for the five tasks with a total order error of only . Steps are missing in of the cases. This illustrates the difficulty of defining the right granularity of the ground truth for this task. Indeed, some steps might be optional and thus not visually demonstrated in all videos. Finally the global repetition score is . Looking more closely, we observe that the Performing CPR task is the main contributor to this score. This is obviously a good example where one needs to repeat several times the same steps (here alternating between compressions and giving breath). Even if our model is not explicitly handling this case, we observed that our multiple sequence alignment technique for clustering the text inputs discovered these repetitions (see Table 4). Finally, these statistics show that the problem introduced in this paper is very challenging and that designing models which are able to capture more complex structure in the organization of the steps is a promising direction for future work.
|Task||Changing tire||Performing CPR||Repoting plant||Making coffee||Jumping cars||Average|
Figure 6 illustrates all five tasks in our newly collected dataset. For each task, we show a subset of 3 events that compose the task. Each event is represented by several sample frames and extracted verbal narrations. Note the large variability of verbal expressions and the terminology in the transcribed narrations as well as the large variability of visual appearance due to viewpoint, used objects, and actions performed in different manner. At the same time, note the the consistency of the actions between the different videos and the underlying script of each task.
In this section, we review in details the way we model the text clustering. In particular, we give details on how we can reformulate multiple sequence alignment as a quadratic program. Recall that we are given narrated instruction videos. For the -th video, the text signal is represented as a sequence of direct object relation tokens : , where the length of the sequences varies from one video clip to another. The number of possible direct object relations in our dictionary is denoted . The multiple sequence alignment (MSA) problem was formulated as mapping each input sequence of tokens to a global common template of slots, while minimizing the sum-of-pairs score given in (1). For each input sequence , we used the notation to denote the re-mapped sequence of tokens into slots: represents the direct object relation put at location , with denoting that a gap was inserted in the original sequence and the slot is left empty. We also have defined a cost of aligning two direct object relations together, with the possibility that or is , in which case we defined the cost to be by default. In the following, we summarize the cost of aligning non-empty direct object relations by the matrix . is equal to the cost of aligning the -th and the -th direct object relation from the dictionary together.
We now present our formalization of the search problem as a quadratic program. To the best of our knowledge this is a new formulation of the multiple sequence alignment (MSA) problem, which in our setting (results shown later) consistently obtains better values of the multiple sequence alignment objective than the current state-of-the-art MSA heuristic algorithms.
We encode the identity of a direct object relation with a -dimensional indicator vector. The text sequence can then be represented by an indicator matrix . The -th row of indicates which direct object relations is evoked at the -th position. Similarly, the token re-mapping can be represented as a indicator matrix; where each row encodes which token is appearing in slot (and a whole row of zero is used to indicates an empty slot). This re-mapping can be constructed from two pieces of information: first, which token index of the original sequence is re-mapped to which global template slot ; we represent this by the decision matrix , which satisfies very specific constraints (see below). The second piece of information is the composition of the input sequence encoded by . We thus have (as a indicator matrix). Given this encoding, the cost matrix , and the fact that the alignment of empty slots has zero cost, we can then rewrite the MSA problem that minimizes the sum-of-pairs objective (1) as follows:
In the above equation, the trace () is computing the cost of aligning sequence with sequence (the inner sum in (1)). Moreover, is a constraint set that encodes the fact that has to be a valid (increasing) re-mapping.888More formally s.t. and . As before, we can eliminate the video index by simply stacking the assignment matrices in one matrix of size . Similarly, we denote the matrix which is obtained by the concatenation of all the matrices. We can then rewrite the equation (7) as a quadratic program over the (integer) variable :
In this equation, the matrix is deduced from the input sequences and the cost between different direct object relations by computing . It represents the pairwise cost at the token level, i.e. the cost of aligning token in one sequence to token in another sequence.
|Task||Changing tire||Performing CPR||Repotting plant||Making coffee||Jumping cars|
|Ours using Frank-Wolfe||-5.18||-4.51||-3.55||-3.86||-4.67|
The problem (8) is NP-hard [wang1994msaNPhard] in general, as is typical for integer quadratic programs. However, much work has been done in computational biology to develop efficient heuristics to solve the MSA problem, as it is an important problem in their field. We briefly describe below some of the existing heuristics to solve it, and then present our Frank-Wolfe optimization approach, which gave surprisingly good empirical results for our problem.999We stress here that we do not claim that our formulation of the multiple sequence alignment (MSA) problem as a quadratic program outperforms the state-of-the-art computational biology heuristics for their MSA problems arising in biology. We report our observations on application of multiple sequence alignment to our application, which might have a structure for which these heuristics are not as appropriate.
Here, we compare to a standard state-of-the-art method for multiple sequence alignment [Lee01poa]. Similarly to [Higgins88clustal], they first align two sequences and merge them in a common template. Then they align a new sequence to the template and then update the template. They continue like this until no sequence is left. Differently from [Higgins88clustal], they use a better representation of the template by using partial order graph instead of simple linear representations. This gives more accuracy for the final alignment. For the experiments, we use the author’s implementation.101010Code available at http://sourceforge.net/projects/poamsa/.
We first note that problem (8) has a very similar structure to an optimization problem that we solve using Frank-Wolfe optimization for the discriminative clustering of videos; see Equations (12) and (13) below. For this, we first perform a continuous relaxation of the set of constraints by replacing it with its convex hull . The Frank-Wolfe optimization algorithm [Jaggi2013] can solve quadratic program over constraint sets for which we have access to an efficient linear minimization oracle. In the case of , the linear oracle can be solved exactly with a dynamic program very similar to the one described in Section C.2. We note here that even with the continuous relaxation over , the resulting problem is still non-convex because is not positive semidefinite – this is because of the cost function appearing in the MSA problem. However, the standard convergence proof for Frank-Wolfe can easily be extended to show that it converges at a rate of to a stationary point on non-convex objectives lacoste16nonconvexFW. Once the algorithm has converged to a (local) stationary point, we need to round the fractional solution to obtain a valid encoding . We follow here a similar rounding strategy that was originally proposed by Chari15FWtrack and then re-used in [Joulin14efficient]: we pick the last visited corner (which is necessarily integer) which was given as a solution to the linear minimization oracle (this is called Frank-Wolfe rounding).
In Table 3, we give the value of the objective (8) for the rounded solutions obtained by the two different optimization approaches (lower is better), for the MSA problem on our five tasks. Interestingly, we observe that the Frank-Wolfe algorithm consistently outperforms the state-of-the-art method of [Lee01poa] in our setting.
We give more details here on the discriminative clustering framework from [Bojanowski14weakly, Bojanowski15weakly] (and our modifications to include the text constraints) that we use to localize the main actions in the video signal.
We recall that is the cost of clustering all the video streams , into a sequence of steps. The design matrix contains the feature describing the time intervals in our videos. The indicator latent variable encodes the visual presence of a step at a time interval . Recall also that and contains the information about all videos . Finally, represents a linear classifier for our steps, that is shared among all videos. We now derive the explicit form of as in the DIFFRAC approach [Bach07diffrac], though yielding a somewhat simpler expression (as in [Bojanowski15weakly]) due to our use of a (weakly regularized) bias feature in instead of a separate (unregularized) bias . Consider the following joint cost function on and defined as
The cost function simply represents the ridge regression objective with output labels
simply represents the ridge regression objective with output labelsand input design matrix . We note that has the nice property of being jointly convex in both and , implying that its unrestricted minimization with respect to yields a convex function in . This minimization defines our clustering cost ; rewriting the definition of with the joint cost from (9), we have:
As is strongly convex in (for any ), we can obtain its unique minimizer as a function of by zeroing its gradient and solving for . For the case of the square loss in equation (9), the optimal classifier can be computed in closed form:
where is a strictly positive definite matrix (and so is actually strongly convex). The clustering cost is a quadratic function in , encoding how the clustering decisions in one interval interact with the clustering decisions in another interval . In the next section, we explain how we can optimize the clustering cost subject to the constraints from Section 4.2 using the Frank-Wolfe algorithm.
The localization of steps in the video stream is done by solving the following optimization problem (repeated from (2) here for convenience):
where is the latent assignment matrix of video time intervals to clusters and is the matrix of assignments of direct object relations in text to clusters. Note that is obtained from the text clustering using multiple sequence alignment as described in Section 4.1 and B.1, and is fixed before optimizing over . is a matrix obtaining by picking the main columns of the matrix defined in Section B.1. This selection step was described in the “extracting the main steps” paragraph in Section 4.1.
The constraint set encodes several concepts. First, it imposes the temporal consistency between the text stream and the video stream. We recall that this constraint was written as ,111111 When , then this constraint does not do anything. When (i.e. the text token was assigned to the main action ), then the constraint enforces that , where represents which video frames are temporally close to the caption time of the text token . It thus then enforces that at least one temporally close video frame is assigned to the main action . where encodes the temporal alignment constraints between video and text (type I). Second, it includes the event ordering constraints within each video input (type II). Finally, it encodes the fact that each event is assigned to exactly one time interval within each video (type III). The last two constraints are encoded in the set of constraints . To summarize, let denote the resulting (discrete) feasible space for i.e. .
We are then left with a problem in which is still hard to solve because the set is not convex. To approximately optimize over , we follow the strategy of [Bojanowski14weakly, Bojanowski15weakly]. First, we optimize over the relaxed by using the Frank-Wolfe algorithm to get a fractional solution . We then find a feasible candidate by using a rounding procedure. We now give the details of these steps.
First we note that the linear oracle of the Frank-Wolfe algorithm can be solved separately for each video .
Indeed, because we solve a linear program, there is no quadratic term that brings dependence between different videos in the objective, and moreover all the constraints are blockwise in
. Indeed, because we solve a linear program, there is no quadratic term that brings dependence between different videos in the objective, and moreover all the constraints are blockwise in. Thus, in the following, we will give details for one video only by adding an index to , to and to .
The linear oracle of the Frank-Wolfe algorithm can be solved via an efficient dynamic program. Let us suppose that the linear oracle corresponds to the following problem:
where is a cost matrix that arises by computing the gradient of with respect to at the current iterate. The goal of the dynamic program is to find which entries of are equal to 1, recalling that means that the step was assigned to time interval . From the constraint of type III (unique prediction per step), we know that each column of has exactly one (to be found). From the ordering constraint (type II), we know that if , then the only possible locations for a 1 in the -th column is for (i.e. the pattern of 1’s is going downward when traveling from left to right in ). Note that there can be “jumps” in between the time assignment for two subsequent steps and . In order to encode this possibility using a continuous path search in a matrix, we insert dummy columns into the cost matrix .
We first subtract the minimum value from and then insert columns filled with zeros in between every pair of columns of .
In the end, we pad
. In the end, we padwith an additional row filled with zeros at the bottom. The resulting cost matrix is of size and is illustrated (as its transpose) along with the corresponding update rules in Figure 5.
The problem that we are interested in is subject to the additional linear constraints given by the clustering of text transcripts (constraints of type I). These constraint can be added by constraining the path in the dynamic programming algorithm. This can be done for instance by setting an infinite alignment cost outside of the constrained region.
At the end of the Frank-Wolfe optimization algorithm, we obtain a continuous solution for each . By stacking them all together again, we obtain a continuous solution . From the definition of , we can also look at the corresponding model defined by equation (11) which again is shared among all videos. All have to be rounded in order to obtain a feasible point for the initial, non relaxed problem. Several rounding options were suggested in [Bojanowski15weakly]; it turns out that the one which uses gives better results in our case. More precisely, in order to get a good feasible binary matrix , we solve the following problem: . By expanding the norm, we notice that this corresponds to a simple linear program over as in equation (14) that can be solved using again the same dynamic program detailed above. Finally, we stack these rounded matrices to obtain our predicted assignment matrix .
In this section, we give more details about the setting for our experiments on the time localization of events with results given in Figure 3.
Here, we describe in more details how we obtained the scores for the supervised approach depicted in yellow in Figure 3. We first divided the input videos in 5 different folds. One fold is kept for the test set while the 4 other are used as train/validation dataset. With the 4 remaining folds, we perform a 4-fold cross validation in order to choose the hyperparameter . Once the hyper parameter is fixed, we retrain a model on the 4 folds and evaluate it on the test set. By iterating over the five possible test folds, we report variation in performance with error bars in Figure 3.
The goal of this phase is to learn classifiers for the visual steps. To that end, we minimize the cost defined in (2) under the ground truth annotations constraints. This is very close to our setting, and in practice we can use exactly the same framework as in problem (13) by simply replacing the constraints coming from the text by the constraints coming from the ground truth annotations.
At test time, we simply use the classifiers to perform least-square prediction of under ordering constraints. Performance are evaluated with the F1 score.
We explain here how we obtained the error bars of Figure 3 in the main paper for the unsupervised approaches. Let us first recall that the Frank-Wolfe algorithm is used to solve a continuous relaxation of problem (13). To obtain back an integer solution, we round the continuous solution using the rounding method described at the end of Section C.2. This rounding procedure is performed at each iteration of the optimization method. When the stopping criterion of the Frank-Wolfe scheme is reached (fixed number of iterations or target sub-optimality in practice), we have as many rounded solutions as number of iterations. Our output integer solution is then the integer point that achieves the lowest objective. Note that we are only guaranteed to diminish objective in the continuous domain and not for the integer points, therefore there are no guarantees that this solution is the last rounded point. In order to illustrate the variation of the performance with respect to the optimization scheme, we defined our error bars as being the interval with bounds determined by the minimal performance and the maximal performance obtained after visiting the best rounded point (the output solution). This notably explains why the error bars of Figure 3 are not necessarily symmetric. Overall, the observed variation is not very important, thus highlighting the stability of the procedure.
Table 4 shows the automatically recovered sequences of steps for the five tasks considered in this work. The results are shown for setting the maximum number of discovered steps, . Note how our method automatically selects less than steps in some cases. These are the automatically chosen steps that are the most salient in the aligned narrations as described in Section 4.1. This is notably the case for the Repotting a plant task. Even for , the algorithm recovers only 6 steps that match very well the seven ground truth steps for this task. This saliency based task selection is important because it allows for a better precision at high without lowering much the recall.
Please note also how the steps and their ordering recovered by our method correspond well to the ground truth steps for each task. For CPR, our method recovers fine-grained steps e.g. tilt head, lift chin, which are not included in the main ground truth steps, but nevertheless could be helpful in some situations. For Changing tire, we also recover more detailed actions such as remove jack or put jack. In some cases, our method recovers repeated steps. For example, for CPR our method learns that one has to alternate between giving breath and performing compressions even if this alternation was not annotated in the the ground truth. Or for Jumping Cars our method learns that cables need to be connected twice (to both cars).
These results demonstrate that our method is able to automatically discover meaningful scripts describing very different tasks. The results also show that the constraint of a single script providing an ordering of events is a reasonable prior for a variety of different tasks.
Examples of the recovered instruction steps for all five tasks are shown in Figure 7–11. Each row shows one recovered step. For each step, we first show the clustered direct object relations, followed by representative example frames localizing the step in the videos. Correct localizations are shown in green. Some steps are incorrectly localized in some videos (red), but often look visually very similar. Note how our method correctly recovers the main steps of the task and localizes them in the input videos. Those results have been obtained by imposing in our method. The video on the project website illustrates action localization for the five tasks.