Deep Meditations: Latent storytelling
6.1 Introduction
The over-arching theme of this thesis, is to investigate methods that grants a user Meaningful Human Control over generative systems that leverage the capabilities of Deep Neural Networks. In the previous chapters, we have presented a number of studies that explored this in a Realtime Continuous manner, as this is an important point of focus for our research. In this chapter however, we investigate a non-realtime, non-continuous method.
We recognise that non-realtime, non-continuous modes of interaction have traditionally played an important role in existing, established creative workflows, particularly in narrative time-based media, such as the production of long-form video or film. Using this as a starting point, we develop a system based around a typical Non-Linear Video Editing (NLVE) workflow, and we present a method for long-form story telling within a deep generative model's space of latent representations.
In other words, we develop a system that gives users the ability to discover and design desirable trajectories in the high-dimensional latent space of a generative model, allowing them to construct stories to produce long-form videos, with meaningful control over the narrative.
We demonstrate our system by creating a number of films. These include a 60 minute multi-screen video installation called Deep Meditations: A brief history of almost everything in 60 minutes, which we have shown at venues such as St James Hatcham Church Gallery (London, UK), Foster & Associates' nine storey atrium in ME by Melia Hotel in London (UK), the Zen Buddhist Temple Kennin-ji in Kyoto (JP), the Mori Art Museum (Tokyo, JP), and Sonar+D Festival in Barcelona (ES) (Fig. 6.1).
We have also used our system in a collaboration with the renowned electronic musician Max Cooper for his seminal audio-visual performance and tour Yearning For The Infinite which premiered at The Barbican in London (Cooper & Akten, 2019). The piece we made for the performance, Morphosis, was also released online as a music video in 2020 (Akten & Cooper, 2020). We presented a paper on this research at the Machine Learning for Creativity and Design Workshop at Neural Information Processing Systems (NeurIPS) in 2018 (Akten et al., 2018).

6.2 Background and motivations
In subsection 2.1.3: Latent manipulations, we discuss a number of methods such as semantic vector manipulations, and latent interpolations, that allow some level of control over the output produced from a generative model. These techniques allow control over a single sample produced by a generative model. In the case of an image based model such as a DCGAN, this translates to allowing control over a single image produced by a generative model. Effectively, these methods allow us to find interesting and desirable points in latent space.
At the time that we developed the work that we present in this chapter, in 2017–2018, we are not aware of any research or tools which granted users any kind of control over long-form videos produced via image-based deep generative models such as DCGANs. All DCGAN based video work at the time, were either random trajectories sampled from the latent space of a model, colloquially referred to as random walks in latent space; or very short semantic vector interpolations between two end points. We discuss these in more detail in the section linked above.
In this chapter, we do not attempt to replace any of the above mentioned methods for discovering interesting points in latent space. These methods can in fact, be incorporated into the methods that we describe below. Instead, we are interested in granting users methods of control, which allow them to discover and design interesting trajectories in latent space. In an image based generative model such as a DCGAN, a single point in latent space produces an image. A trajectory in latent space can be thought of as a sequence of points, and thus produces a sequence of images, a video.
Furthermore, the latent space of such a generative model is usually structured so that points which are close to each other in latent space, produce images which are semantically and aesthetically similar to each other. For this reason, a smooth trajectory in latent space, will produce videos where images appear to be morphing between each other. We discussed this in subsection 2.1.3: Latent interpolation.
An additional outcome of this particular study, is in what we call trajectory planning. As we have discussed multiple times throughout this thesis, the generative models that we use, typically have latent distributions that are high-dimensional (e.g. ) multivariate standard normal . We know that the mass of such a high-dimensional normal distribution is concentrated in the shell of a hypersphere, often likened to a ‘soap bubble', with a radius of , and a shell ‘thickness' following a distribution with a variance of (J. D. Cook, 2011). As a result, any latent points that are outside of this shell, will produce images that are far from the distribution, and as a result, are likely to be visually undesirable. For this reason, we investigate a number of different methods which ensure that any trajectory that we construct, stays within this distribution, i.e. on the surface of the hypersphere. We discuss our methods in subsection 6.4.8: Trajectory planner details.
A further point to note, is that in the previous chapter chapter 5: Learning to see: Digital puppetry through realtime video transformation, we used a conditional generative model as the basis for our study. In this chapter, we investigate unconditional generative models. In particular, we work with ProGAN (Karras et al., 2017), which is a form of an unconditional DCGAN. We use ProGAN, as this was the state-of-the-art architecture at the time of our workFootnote 1. We have later tested our approach with StyleGAN (Karras et al., 2019)Footnote 2, BigGAN (Brock et al., 2019)Footnote 3, and StyleGAN2 (Karras et al., 2020), and we have observed that our method works without any modifications.
We choose unconditional generative models as the subject for this chapter for a number of reasons. It is much easier to acquire unlabelled data to train an unsupervised, unconditional model, than it is to acquire labelled data to train a conditional model. Also for this reason, there are already many high quality, pre-trained, unconditional models available for download made available by other researchers. Furthermore, we have already investigated conditional generative models in the previous chapter, and we wish to explore the affordances granted by unconditional models. For more information regarding DCGANs, please refer to subsection 2.3.18: Deep Convolutional Generative Adversarial Networks (DCGAN), and for unconditional generative models in general, subsection 2.1.1: Unconditional generative models.
6.3 Goal and requirements
6.3.1 Main tasks
With all of this information in mind, let us explicitly define our goal and our requirements.
We have a generative model of images, with a high-dimensional space of latent representations (e.g. ). This could be a model that we have trained ourselves, or a pre-trained model downloaded from the internet such as BigGAN, or a pre-trained ProGAN/StyleGAN.
The main tasks that we need to address are:
Exploration
We desire that a user should be able to explore and leverage the full scope of the latent space. For this reason, encoding or ‘filtering' existing images as an input, as we did in the previous chapter chapter 5: Learning to see: Digital puppetry through realtime video transformation, is not satisfactory in this case.
Keyframe selection/generation
Our end goal is to devise a solution which allows a user to generate or select a temporally sparse sequence of keyframe images from the model, such that image corresponds to time , image corresponds to time , and image corresponds to time , where the subscript denotes a sequential integer index, and is the desired point in time that the th image appears in the video. In other words, we require a solution that allows a user to provide or somehow construct a list of pairs.
z-y correspondence
We would like to work with the generic case of a generative model in which it is not always possible to retrieve a corresponding latent representation for an input image via an encoder or optimisation as we discussed in subsection 2.1.3: Latent representation recovery. For this reason, our solution should work with pairs instead of . These can be thought of as temporally sparse keyframe -vectors which are the latent representations of the keyframe images. However, for us, the user, dealing directly with lists of high-dimensional -vectors is not intuitive or even feasible. We prefer to be dealing with images, not high-dimensional -vectors. Therefore, our solution should operate with an interface using images and pairs, while providing the corresponding pairs to the model in the background.
Trajectory planning
Given that the output will be a video with a fixed framerate (e.g. ), our solution should plot a trajectory through the provided list of temporally sparse keyframes. If is provided in seconds, the trajectory planner should interpolate and generate intermediate points, such that each is reached in exactly steps. In other words, the trajectory planner produces a new, temporally dense and smooth list of interpolated -vectors, one per frame of video, where the -vector at frame is equal to . The task of the trajectory planner is further complicated by the fact that the mass of the latent distribution is concentrated in the shell of a hypersphere as we have already discussed. Our trajectory planner needs to take this into consideration.
6.3.2 Additional issues
On top of the main tasks mentioned above, we have encountered a number of additional issues. We summarise these below.
Biased distribution
The latent space is not distributed ‘evenly’, or as one might expect or desire. For example, in the case of our test model, we trained on an incredibly diverse set of images — millions of images from over dozens of categories. However, upon inspection of the model's output, it seems images of flowers seem to occupy a very large portion of the model's latent space. In other words, if we generate a few thousand random samples from the model, we can observe that a disproportionally large percentage of the images generated are of flowers. This is most probably because flowers are overly present in the training data. The inverse is also possible. For example, in the same model, images of bacteria are very sparse. This is most probably because there are not enough images of bacteria present in the training data. In addition, it's quite common for some areas of the latent space to produce images which are aesthetically and subjectively undesirable, or not suitable for the specific use case we have planned.
In our exploration of the latent space, we wish to find ways of taking this into account. One solution which may come to mind to address this, is to readjust the distribution of the training data by adding or removing images, and then retrain the model. However, this is not always feasible or even possible due to a number of reasons. Some of these models take months to train, so an iterative process of tweaking training data and then retraining is not always feasible. Furthermore, these models often require very large amounts of training data, often tens of thousands, sometimes even millions of images, so removing images can degrade the quality of the model, and adding images is sometimes not possible if more images cannot be found. Finally, many researchers are releasing pre-trained models, without releasing their dataset or even their training code. In our research, we wish to present a solution which can also work with these pre-trained models. Due to these reasons, we look into ways of biasing or debiasing the latent space to produce more desirable results.
Perceptually variable speed
As a result of the uneven distribution mentioned above, an additional problem which arises, is that interpolating from latent vector to at a constant speed might produce images changing with a perceptually variable speed. This can make it difficult to meaningfully control the speed at which the images change when producing a video with narrative. This is especially important when producing videos that accompany music.
Unexpected interpolation outcomes
Finally, it is very difficult to anticipate and imagine the outcomes of trajectories in high dimensions. For example, imagine that the latent representation produces which is an image of a flower, and produces which is an image of a mountain. We may wish to interpolate from to , to produce a video morphing from image to . However, in such high dimensions, this trajectory might unexpectedly pass through point , producing an undesirable output which for example might be an image of a dog.
6.4 System description
Based on the tasks and issues that we mention above, we will now detail our proposed solution.
The first important decision to make when starting a project such as this, is whether we build an entire bespoke tool and User Interface (UI) from scratch, as we have done in the previous four studies, or do we try and leverage existing tools. Both approaches have advantages and disadvantages. Building a bespoke tool from scratch requires considerable investment of time and effort, but eventually provides the most flexibility and power. Trying to leverage existing tools can potentially rapidly accelerate the developent of a prototype, at the cost of limited functionality in the long run.
For this particular study, we chose the latter option of leveraging existing tools. We chose this route because our goal is to be able to create videos with precise control over timing. And in many of our use cases, including our collaboration with Max Cooper, it is essential to be able to synchronize specific points in the video with corresponding points in music. Non-Linear Video Editing (NLVE) software have years, even decades, of research and development in this area, with many of the features that we require. For this reason, we chose to leverage and build upon existing NLVE software with the belief that this would save us considerable development time, and would be the most optimal way of developing a prototype to demonstrate a proof of concept. However, this decision presents us with many new challenges. How can we use a standard NLVE to edit sequences of high-dimensional -vectors?
In order to address the different tasks and issues mentioned in the previous section, we have developed a number of different methods and tools, and we have produced many hours worth of carefully constructed films using this method.
Workflow overview
An overview of the entire workflow can be summarized as follows:
-
Exploration of the model: bias and de-bias the latent space distribution, create short journeys for later editing
-
The narrative edit: edit the short journeys using a NLVE to produce keyframe images, i.e. pairs
-
The narrative conform: produce the final keyframe -vectors, i.e. pairs, from the pairs
-
Trajectory planning: produce the final dense, interpolated trajectory from
-
The final render: select a desired model snapshot and produce the final video by rendering through the model
6.4.1 Concepts and definitions
Before we expand on each of these steps, it is important to introduce some concepts which are key to our process.
Conforming an edit
Our solution is analogous — and in fact inspired by — a common practice in video editing and post-production pipelines known as conforming an edit. Typically in digital video post-production, working with full-quality, full-resolution video clips is not always feasible due to performance reasonsFootnote 4. In this case, one typically performs an edit on a set of proxy clips. These are usually lower resolution, lighter-to-decode, easier-to-manage copies of the original videos. Editing with proxies is also known as an offline edit (this terminology dates back to working with film and automated machines operating on reels of footage). Once the offline edit is completed on the proxy clips, the edit is conformed by applying the same edits to the original, high resolution rushes. To perform this conform process, a file such as an Edit Decision List (EDL) is exported from the offline editor. This is an industry standard file format which contains all of the reel and timecode information for each of the video clips, their in and out points, and their position on the timeline. The EDL is transferred to an online system, i.e. with access to the original, full quality rushes, where the final cut is reproduced.
(z-sequence, video) pairs
Since both we as users, and NLVEs, are more comfortable working with images, not -vectors, we need to associate images with their corresponding -vectors. In order to address this, we define (-sequence, video) pairs.
A -sequence, is simply a list of -vectors. In other words, it is a trajectory in latent space, and we store it on disk as a numpy array. To be more specific, it is a matrix where each row is a -vector, the th row is the vector .
A video is a normal video file — typically an mp4 file with h264 codec — where each frame of the video is the image output from the model decoding the corresponding -vector from the corresponding -sequence. In other words, the th frame of the video, is the image generated by the model decoding .
In our analogue of conforming an edit, these video files act as the easier-to-manage proxy clips which we will later load into a NLVE to perform a desired edit. We will then conform, by applying this edit to the corresponding -sequences, using custom tools that we developed during this research.
Rendering z-sequences
We generate the videos to be edited using a process we call rendering. We appropriate this term from the Computer Graphics literature, where some lower dimensional, custom representation of a scene (for example 3D geometry consisting of vertex, face, material and lighting information) is used to produce a high quality raster image.
In our case, the lower dimensional custom representation is the latent vector sequence. The process of rendering a -sequence, refers to simply loading the corresponding numpy array, and saving a video where the th frame of the video is the image , generated by feeding the row to the model.
Given one or more -sequences, we can render them to produce (-sequence, video) pairsFootnote 5. Once we have these pairs, we can then edit the videos in a NLVE as we would edit any normal videos, and then use the tools we developed in this research, to conform the edit on the corresponding numpy arrays containing the -vectors.
Snapshots across time
During the training of a generative model, the model's latent space changes with each training iteration, to hopefully represent the data more efficiently and accurately. However, a noticeable change across these iterations also includes transformations and shifts in space. To give an oversimplified example, what may be an area in latent space dedicated to mountains at iteration 70K, might become flowers at iteration 80K, while mountains slides over to the area previously used to represent clouds. This is a vast simplification, as the real effects are little bit more subtle. Nevertheless, there have been no studies conducted on this phenomena, and specifically, on how it may impact creative uses and explorations of generative models.
Furthermore, when we download a pre-trained model from the internet, often we only have access to the final model provided by the researchers that trained the model. However, when we are training our own models, we can save intermediate snapshots at desired intervals. This can be particularly useful while training GANs, because there is no objectively quantifiable point at which we can measurably determine that the training has optimally converged. This is due to the fact that while training, the optimiser is trying to satisfy two opposing objectives, improving both the generator, and the discriminator, by finding a Nash equilibrium of a non-convex minimax game. We discuss this in more detail in subsection 2.3.18: Deep Convolutional Generative Adversarial Networks (DCGAN).
Since there is no objectively quantifiable point at which the training is ‘complete', a common workaround is to simply set a fixed number of iterations to let the optimiser run for. This is typically in the range , depending on the size and complexity of the training data. In addition, at a fixed interval (e.g. every iterations) a small selection of random image samples (e.g. samples) are saved to disk. These samples are manually inspected, and if they appear to be subjectively satisfactory and of a desired quality, the training is manually interrupted, and a snapshot is saved and used as the ‘final' model.
When assessing the random selection of samples, there are a number of factors to consider. First, one looks for satisfactory visual quality in the individual images themselves, to ensure that both the coarse structure and fine detail are satisfactory. Second, one looks at the diversity of the images across the selection, to ensure that the model is able to produce images with a satisfactory level of diversity representative of the dataset.
For many typical use cases, where the model will be used only to produce still images, or ‘random walk' videos, this method of snapshot selection may be satisfactory. However, this method does not allow any way of seeing how the latent space of a snapshot model is organised, how compact or sparse key points are distributed, and what it actually looks like to move from one point to another. For example, looking at the random selection of samples, we may see a perfect reproduction of a flower, or a mountain. We may thus conclude that the model is ready. However, later when we plot a trajectory through this model, we may see that the space between the flower and the mountain has many undesirable artefacts, that maybe was not there a few thousand iterations earlier, or maybe will disappear a few thousand iterations later.
For this reason, we believe that this snapshot selection method is not ideal, particularly when the goal is to design narratives and construct trajectories, where we desire a high level of meaningful control.
An ideal solution would allow us, when we are designing our trajectories, to visualize the results of those trajectories, in not just a single snapshot, but in many snapshots simultaneously, covering a wide range of iterations.
To achieve this, we save snapshots at regular intervals, and render -sequences from multiple snapshots. When we render a -sequence, instead of rendering it from just one model, we render it from multiple snapshots. We then tile the results of each of these renders together into a single video. In other words, the rendered video of a (-sequence, video) pair, is no longer a video rendered from a single model, but instead, each frame of the video contains the output from multiple snapshots arranged in a grid. This can be seen clearer in Fig. 6.2.

Rendering multiple snapshots in a grid on a single frame in this way gives us an overview of how the latent space has evolved across training iterations.
Furthermore, we do not do this simply to observe how the model's latent space evolves over time. This method also allows us to easily see and select the most aesthetically desirable snapshot(s) for the particular trajectory that we have designed.
In other words, instead of first picking a snapshot as the final model, as is the current typical workflow, and then creating a trajectory, we explore trajectories in all of the snapshots simultaneously. Throughout the entire process that we outline below, we work with these tiled videos. This allows us at every step, to visualise how the trajectory looks like from each of these different snapshots. At the very end, once we have produced our final draft tiled video, we can select the particular snapshot which provides us the most aesthetically desirable results, and render the same trajectory in high resolution with only that snapshot.
The selection of snapshots to include is based on a simple subjective assessment of the visual quality of the snapshots. In our specific test cases, we train a number of ProGAN models for a fixed number of iterations, namely , as suggested by the authors of the paper. Looking at the random image samples generated during training, we noticed that the quality of the outputs started to become satisfactory at around iterations. Based on this observation, we decide to save snapshots every iterations, and include the final snapshots in the render. This covers iterations through to , and gives us ample options to choose from. In addition, the images can be tiled into a x grid. This makes viewing the results on a typical 16:9 monitor very practical.
6.4.2 Exploration of the model
Exploration is the first step that we outline in subsection 6.4: Workflow overview, where we bias and de-bias the latent space distribution, and create short journeys for later editing.
If we already have a strong idea of the narrative that we would like to construct, and we are already familiar with the particular model that we are working with, we can keep this exploration phase very brief and jump straight to the narrative edit. However, if we are dealing with a new model, and we do not yet know what the model is capable of, this phase can provide very valuable insights.
The exploration phase can be expanded as follows:
-
We take many — e.g. one thousand — unbiased and independent samples from the model's latent distribution . We render and save this as a (-sequence, video) pair, where each frame is an entirely different random image. Stepping through this video frame by frame gives us an idea of what the model has learnt, and how the latent space is distributed. It also gives us an idea of how the distribution changes across subsequent training iterations, and which snapshots provide more aesthetically desirable images.
-
We edit this video in a NLVE to remove any undesirable images, and to bias or de-bias the distribution. For example, to address the issue with flowers being overly present in our model, we simply remove a small random selection of flowers from the video. To address the issue with there not being enough images of bacteria, we edit the video to duplicate frames containing bacteria. We continue performing simple edits such as this until we are content with the overall distribution of the different types of images in the video. At this stage we are not performing edits to construct a narrative or to tell a story. We are simply removing or duplicating frames to bias the distribution of different types of images.
-
Once we are happy with the distribution of images in the edit, we run our script to conform the edit on the original -sequence. This produces a new -sequence — which we refer to as a -sequence — where each frame is still an entirely different random image, but which has a more desired distribution, i.e. that contains no undesirable images, and a satisfactory balance between different images types.
-
We render the conformed -sequence to a new video, and we inspect this video in the NLVE. If necessary, we can repeat steps 2–3 to further fine-tune the distribution until we are entirely satisfied with it. However, we have not found this to be necessary.
-
Optionally, before rendering the conformed -sequence, we can add a small amount of Gaussian noise to it, for example . This allows us to explore the neighbourhoods of the currently selected frames — for example, to include and investigate more images of bacteria, with more variation.
The steps above produce a final (-sequence, video) pair, where each frame is a random image, with desired distribution of images and no undesired images.
Short journeys
Once we are satisfied with the distribution of the random samples, we generate and render hundreds of random short journeys. We do this by loading the final -sequence in python, and simply select random pairs or triplets of -vectors, and we render interpolations between them. This can be seen in Alg. 3.
This produces hundreds of short (-sequence, video) pairs that contain smooth, slow interpolations between two or three keyframes, where the keyframes are chosen from our preferred distribution . Viewing these videos gives us an idea on how the model transitions between selected desired images. For example, using such a method, we can quickly see that the shortest path between an image of a mountain and an image of a flower might travel through the latent space region of buildings, and this may not be desirable. We can use this as a cue to insert an additional keyframe in-between.
We repeat the previous step, honing in on the short journeys which seem promising. Optionally, we can again add varying amounts of Gaussian noise to the -vectors to explore the neighbourhoods of selected frames and journeys.
6.4.3 The narrative edit
The previous steps produce an arsenal of short snippets of (-sequence, video) pairs, as well as a single long (-sequence, video) pair with many desirable images.
To perform the narrative edit, we simply load the videos that we like, or that contain images or sections that we like, into the NLVE, and we edit them together. In other words, we select frames or short sequences from these videos, and we sequence them and lay them out on the NLVE timeline with the desired timing, synchronizing to audio if necessary.
During this edit, we essentially lay down the keyframe images , i.e. temporally sparse destination points. When we place video frames onto the timeline, we have two options. The first option is to leave gaps between the keyframes, placing only images and video frames at specific points in time that we deem significant. The gaps will later be filled in by our trajectory planner, which interpolates between neighbouring keyframe images. Due to the smooth nature of the model's latent space, this interpolation manifests itself visually as a kind of morph between the keyframes, as we discussed in subsection 2.1.3: Latent interpolation. The second option, is to leave no gaps between keyframes. In this case however, upon loading the -sequence in the trajectory planner, we can specify a fixed time interval, for example 5 seconds, and the keyframes will be treated as if they are 5 seconds apart.
As a result of this edit, the NLVE project contains information regarding keyframe images, i.e. pairs.
As a side note, for our NLVE software, we chose the open-source Kdenlive for the GNU/Linux platform. One of the reasons for this, is because we are working solely on GNU/Linux. However, our solution does not involve any modifications or plugins to the software itself, but rather it is a workflow involving a number of stand-alone tools, which could be adapted to other NLVEs. This means that the same workflow that we describe in this section, could be applied to other NLVEs which support any kind of easy-to-parse project file.

6.4.4 The narrative conform
Having constructed a list of keyframe images during the narrative edit, the narrative conform is simply a process of running our conform script on the narrative edit NLVE project file. This produces a list of temporally sparse keyframe -vectors, i.e. a numpy matrix of pairs.
Unfortunately, Kdenlive does not support EDL Footnote 6. However, the project file format used by Kdenlive is itself a text based XML with open specifications. This allows us to easily parse the project file in our own python based tools. One of the open-source toolsFootnote 7 that we developed during this research, is a parser which conforms the edit as shown in Alg. 4. With relatively minor modifications to this tool, EDL support could be implemented, which would permit the use of other NLVEs such as Adobe Premiere, Apple Final Cut, and Avid Media Composer.
As mentioned, the output of this conform process is a list of temporally sparse keyframe -vectors. This is a numpy matrix of pairs, which is saved to disk, and can then be sent to the trajectory planner for interpolation.
6.4.5 Trajectory planner
The trajectory planner takes the temporally sparse keyframe -vectors produced by the conform, and produces the final dense trajectory which will eventually be rendered by the model.
As we have mentioned before, the latent distribution of our models are concentrated in the shell of a hypersphere. For this reason, we need to ensure that the trajector planner takes this into account. This is a rather complex issue that we have invested considerable time into. Instead of detailing all of our findings here, we have devoted a separate section to it below in subsection 6.4.8: Trajectory planner details.
6.4.6 The final render
Rendering the final dense -sequence produced by the trajectory planner, produces a final tiled video. In this video, we can see the same trajectory rendered from each of the available snapshots, just as we saw in Fig. 6.2. Viewing this video, we can see which of the snapshot(s) provides the most aesthetically pleasing results, and we can then re-render the video in full resolution with only one snapshot, or a smaller selection of snapshots.
6.4.7 Model architecture and data
We applied the approach mentioned in this paper on a number of different models and architectures, however the primary test case we refer to (and from which we also show the results) is a ProGAN trained on over 100,000 images scraped from the photo sharing website Flickr. The dataset is very diverse and includes images tagged on Flickr with: art, cosmos, everything, faith, flower, god, landscape, life, love, micro, macro, bacteria, mountains, nature, nebula, galaxy, ritual, sky, underwater, marinelife, waves, ocean, worship and more. We include three thousand images from each category and train the network with no classification labels. Given such a diverse dataset without any labels, the network is forced to try and organize its distribution based purely on aesthetics, without any semantic information. Thus in this high-dimensional latent space we find directions allowing us to seamlessly morph from swarms of bacteria to clouds of nebula, oceanic waves to mountains, flowers to sunsets, blood cells to technical illustrations etc. Most interestingly, we can perform these transformations across categories while maintaining overall composition and form.
6.4.8 Trajectory planner details
In this section, we detail some of our investigations into trajectory planning. As we have mentioned, the trajectory planner takes the temporally sparse keyframe -vectors produced by the conform, and produces the final dense trajectory which will eventually be rendered by the model. In order to do this, the aim is to produce the final dense trajectory , such that at time , the trajectory goes through the point , and for every frame in between, -vectors are smoothly interpolated.
One of the challenges that we face, is that our latent distribution is a high-dimensional standard normal As a result, the mass of the distribution is concentrated in the shell of a hypersphere with a radius , and a shell ‘thickness' following a distribution with a variance of (J. D. Cook, 2011). For this reason, the trajectory planner needs to ensure that any that it generates, needs to be on, or very close to, the surface of this hypersphere. If this criteria is not met, the images produced will be far from the distribution, and potentially very undesirable. We investigate a number of different methods to address this.
Spherical spatial interpolation, linear temporal interpolation
Given just two points, and , if we linearly interpolate between them, this will diverge from the distribution. This can be visualized as a straight line between two points on the surface of a sphere, diverging from the surface of the sphere. As recommended by (J. D. Cook, 2011; White, 2016a) and many others, spherical interpolation provides the most desirable results in this case. However, when we have more than two points, using spherical interpolation becomes problematic.
The first approach that might come to mind, is to use spherical interpolation between each successive two points, and . An overview of this can be seen in Alg. 5. However, using this method, we observe that this produces visibly noticeable discontinuities in the movement of the output video, due to sudden changes in speed and direction in the latent space. Even though we are using spherical and not linear interpolation, this simply refers to the interpolation in space. However, temporally, the interpolation remains linear. Any experienced animator will know that linear interpolation across time often causes temporal discontinuities at the keyframes due to sudden changes in speed.
These artefacts can be seen in Fig. 6.4. For this test, we generate random samples from a 512 dimensional standard normal distribution , which can be thought of as points that lie on or very near the surface of a hypersphere with radius . We interpret these random samples as keyframes, placed one second apart, and we use spherical interpolation between each successive two points as outlined in Alg. 5, to produce a dense trajectory . In this case we consider a video frame rate of frames-per-second, which means we interpolate between each successive keyframe in equal steps.

In Fig. 6.4, a single pixel wide vertical slice represents a single -vector, and time flows left to right. Because we placed the keyframes one second apart, with a framerate of , in this image, the keyframes occur 15 pixels apart. Upon close inspection of the image, we can see notch-like vertical artifacts every 15 pixels. This happens when the spherical interpolation reaches its destination -keyframe, and a new target -keyframe is set. In other words, the inner loop on line 10 in Alg. 5 is reached. This creates a sudden change in speed and direction.
Spherical spatial interpolation, easing temporal interpolation
A simple remedy that may come to mind, is to smooth the movement over time, using what are known in the field of animation as easing functions, and more formally known as sigmoid functions. These are functions that create a linear S shaped mapping, and for this reason they are also known as S-curves.
A very common easing function is the cubic , where t is limited to the range . We can see that and . Furthermore, if we take the derivate of we find that , and both and . In other words, this cubic S-curve goes through the points and while having a zero first derivative at both end points. Using an easing function such as this, while interpolating between adjacent keyframes, ensures that there are no first order discontinuities, by ensuring that velocity is zero at the keyframes. In some sensitive cases however, using even cubic easing is not sufficient, as this can produce second order discontinuity. For this reason a quintic easing function of can be used where the second derivative — i.e. acceleration — is also zero at both and (Perlin, 2002).
We can use these, or other similar functions on the parameter in Alg. 5 while performing the spherical inteprolation in line . While this does remove the sudden changes in speed and direction, it does so in an undesirable manner. We see that the whole video momentarily grinds to a halt at every keyframe. This should not come as a surprise, as that is exactly what we are doing by using an easing function only on time with zero derivatives at the end points. It becomes clear, that in order to address the issue in a desirable manner, we have to smooth the transitions at keyframes across space as well as time, ideally without dropping speed down to zero.
Gaussian filter with reprojection
The first method we investigate to smooth transitions across space and time, involves applying a Gaussian filter to the trajectory produced in subsection 6.4.8: Spherical spatial interpolation, linear temporal interpolation. can be thought of as matrix of columns, where is the dimensionality of the model's latent distribution. Each row is an interpolated -vector, and the number of rows is equal to the number of frames in the final video to be rendered.
We apply a one dimensional Gaussian convolution vertically across this matrix, in other words, only across the time dimension. This filters each dimension of the motion trajectory individually, without filtering across the components of the positions. This does nicely eliminate any sudden changes in speed and direction. However, it also pulls the positions towards the center of the latent space, away from the surface of the hypersphere. Since the trajectory diverges from the distribution, this has the potential to produce undesirable images. To alleviate this, we normalize the filtered matrix and reproject all of the points back onto the surface of the hypersphere. This can be seen in eqn. (6.1)
where is the Gaussian filter function with standard deviation , and is the radius of the hypersphere.
The standard deviation of the kernel depends entirely on subjective aesthetic preferences, and certain characteristics of the video such as the general pace of the video and spacing of keyframes. Unsurprisingly, a larger kernel provides slower and smoother movement, while a smaller kernel provides less smoothing.
Projecting the filtered trajectory back onto the hypersphere in this manner does bring the points back into the distribution, and produces more aesthetic and desirable images. However, depending on the nature of the trajectory, the final smoothed and reprojected trajectory might not travel exactly through the desired keyframes , but instead might pass nearby. This is particularly likely to happen if the kernel size is quite large. This is not always a major problem. Due to the nature of how the model's latent space is organized, points which are close in latent space, produce images which are semantically and aesthetically similar. So missing a keyframe by a small amount, will produce an image which is very similar to the desired keyframe image. Thus, selecting an optimal kernel size becomes a balancing act between selecting a large enough size such that the movement is adequately smoothed, but not too large so as to minimize the divergence between the trajectory and desired keyframes. We find that an optimal kernel size to be in the order of half of the spacing of the keyframes. With a kernel size in this range, the movement is smoothed enough so that keyframes are not noticable when viewing the video, while simultaneously the trajectory goes close enough to the keyframes so that the images produced are very similar to the desired keyframes.
To summarize, this method creates a perfectly smoothed trajectory, however it fails to hit the desired keyframe positions perfectly. For most of the works that we created for this chapter, we used this method of interpolation, as precise position turned out to be not very significant as long as the trajectory passed close enough to the keyframes to be semantically and aesthetically similar.
Physical Interpolation
Another method we investigate, is a physics based dynamical system. In the high-dimensional latent space, we create a dynamical particle connected to the next keyframe position with a heavily damped spring, with zero length. This ensures that the particle always moves towards the next keyframe, without any discontinuities in speed or direction. We also connect the particle to the origin, i.e. all components of the vector equal to zero, with a damped spring with length . This ensures that the particle always stays close to the surface of the hypersphere, i.e. the distribution. Finally, we add a maximum speed cap to the particle, to prevent excessive speeds. An overview of the method can be seen in Alg. 6.

A visualization of a dense trajectory produced using this method can be seen in Fig. 6.5. Note that the vertical notches have disappeared. This is indicative of the transitions between keyframes being much smoother. In other words, upon reaching a particular keyframe, there are no sudden changes in speed or direction. Instead, the interpolated vector, gradually changes speed and direction before heading over to the next -keyframe, while simultaneously trying to stay within the shell of the hypersphere. This is also noticeable while watching the rendered video, it is almost impossible to notice when the keyframes are occuring, and the overall movement is incredibly smooth.
It is difficult to distinguish which method produces smoother and more aesthetically pleasing results between this method, and the previously mentioned subsection 6.4.8: Gaussian filter with reprojection method. However one advantage that this method has over the Gaussian reprojection method, is that the trajectory is guaranteed to travel through all of the -keyframes with the physical interpolation.
However, this comes at the cost of a lack of precise timing. The behaviour of this method is highly sensitive to the dynamics parameters, particularly the spring stiffness and damping. While it is relatively trivial to adjust these parameters to achieve aesthetically pleasing results, it is less trivial to adjust these parameters to achieve aesthetically pleasing results while simultaneously hitting the desired keyframes at exactly the desired times . For this reason, we use this method when very precise timing — such as synchronizing to music — is not necessary.
In the following section we discuss a couple of other potential approaches such as a modification to de Casteljau's algorithm and using differential geometry.
6.5 Conclusion
We present this research as a first step in many, towards enabling users to meaningfully explore and control journeys in high-dimensional latent spaces to construct stories, using and building upon industry standard tools and methods with which they may already be comfortable. Our ultimate goal is to enable users to creatively express themselves, and meaningfully control the way in which they produce time-based media using deep generative models as a medium.
At the time of our research, there were no methods or tools available allowing a user any form of control — let alone what we consider Meaningful Human Control — over the narrative of a video generated with an image based Deep Neural Network. As a first step in this direction, the method that we present here works. Using this method, we have produced many videos of varying lengths, ranging from very short (one minute), to almost feature length (one hour). We have exhibited these works in different contexts including a music video and live concert visuals for the electronic musician Max Cooper, and an immersive, architectural audio-video installation in a hotel lobby designed by Foster & associates.
However, many aspects of our process can be improved; especially from a user experience point of view. We chose to leverage the functionality of existing tools. Specifically, we chose to build our workflow around an existing NLVE, and this allowed us to prototype the desired functionality relatively quickly, since the NLVE's user interface has been designed and developed over decades and optimised for editing videos in a non-linear fashion, and synchronizing to audio if need be. However, the rest of our workflow consists of a number of python scripts, and executing various different cells of an iPython notebook. For this reason, it is not very user friendly. As a next step, we would highly recommend incorporating the functionalities that we mention above, into a stand-alone application where these functionalities can be triggered and controlled via a single GUI.
In addition, the exploration of the model's latent space is currently a bit cumbersome, as it requires switching back and forth between the NLVE — where the viewing and editing takes place, and the python scripts — where the conform and rendering takes place. Collating all of this functionality into a single custom GUI would again allow for a more streamlined, realtime experience for the user.
Finally, we have discovered that trajectory planning is a very important issue if quality of both movement and image is to be preserved when creating videos using deep generative models. We already know that using linear interpolation between successive keyframes causes the trajectory to diverge from the distribution, resulting in undesirable images. In addition, we have tested and observed that using spherical interpolation, results in noticeable discontinuities in movement, which we find very undesirable.
We have implemented and tested two new methods, and both physical interpolation and Gaussian reprojection interpolation provides very nice smooth trajectories with no noticeable discontinuities at all. Physical interpolation is able to produce trajectories that travel precisely through all desired -keyframe positions, but not at precisely the desired times. Gaussian reprojection interpolation is able to produce trajectories that travel close to all desired -keyframe positions, at precisely the desired times. We call this the Heisenberg Uncertainty Principle of latent space navigation.
It's worth adding, that if one were determined to have a smooth trajectory that both travels through all desired -keyframe positions at precisely the desired times, a dual pass approach we have used is to use the physical interpolation method and render a final video, and then time remap the video in a software such as Adobe AfterEffects or Adobe Premiere. However, we have rarely found this to be necessary, as the position precision of Gaussian reprojection has generally been sufficient for our needs.
A more mathematically rigorous approach one could try is based on de Casteljau's algorithm. De Casteljau's algorithm is a recursive method typically used to construct polynomial algebraic curves (known as de Casteljau Bezier curves) from a small number of sparse data points (known as control points) which define the overall shape. The method involves iteratively calculating affine linear combinations of successive sparse points to create the final smooth curve. In our case, instead of using linear interpolations between successive points at each iteration, one could try using a similar recursive approach with spherical interpolation between successive points where the initial control points are the keyframes. This should create a spatially and temporally smooth polynomial curve on (or near) the surface of the hypersphere. However, since the points of a de Casteljau Bezier curve does not go through all of the control points, this is also likely to not travel exactly through all of the desired keyframes. For this reason, a Hermite/Catmull-Rom based approach projected onto the hypersphere might yield more desirable results.
Another method that we believe could work — particularly in conjunction with Hermite/ Catmull-Rom splines as discussed above — is using differential geometry and Riemannian manifolds (Miolane et al., 2018). With this approach we can project an offset vector — such as velocity — onto the tangent space of a manifold, which in our case is a hypersphere. From there, we can ensure that all transformations take place on the surface of the hypersphere directly. Our early investigations in this direction look promising, however, we do not yet have conclusive results, and we recommend this as a direction to study. One of the advantages of this approach is that it could potentially be easily adapted to run in realtime.
Footnotes
-
subsection 2.2.7: Progressive Growing of GANs, ProGAN (2017) ↩
-
It is worth noting that BigGAN is technically a conditional model, as it is conditioned on class labels. However, within each class label, the latent space is still incredibly vast and open for unconditioned exploration. For this reason, we include BigGAN as an example model that we use for this research. We briefly discuss BigGAN in subsection 2.2.7: BigGAN (2018). ↩
-
In the days of analogue film editing, where this terminology originates, trying out edits directly on original rushes by cutting them was highly undesirable! ↩
-
The association between the numpy array file and video file can be stored in a database, or we choose the much quicker method of simply giving them both the same filename. ↩
-
EDL is Edit Decision List, we discuss this in subsection 6.4.1: Conforming an edit ↩