scieee AI-readable full text Open interactive document viewer

Generation of art works using deep neural networks

Vilalta Arias, Armand

Abstract

The representative power of Deep Neural Networks is used to create, from photographs of reality, artworks. Several methods are proposed in a common framework.

Full text

GENERATION OF ART WORKS USING DEEP NEURAL NETWORKS Armand Vilalta Arias Directors: René Alquezar Mancho, Enrique Romero Merino Department of Computer Science MASTER IN ARTIFICIAL INTELLIGENCE FACULTAT D’INFORMÀTICA DE BARCELONA (FIB) FACULTAT DE MATEMÀTIQUES (UB) ESCOLA TÈCNICA SUPERIOR D’ENGINYERIA (URV) UNIVERSITAT POLITÈCNICA DE CATALUNYA (UPC) – BarcelonaTech UNIVERSITAT DE BARCELONA (UB) UNIVERSITAT ROVIRA I VIRGILI (URV) 5 February 2016 A la Mare i a la Nerea pel recolzament per començar, to MAI friends for their support to do it. 3 4 Abstract Art creation has always been on of the most popular and difficult challenges of Artificial Intelligence. This work uses state of the art Artificial Intelligence techniques to create artistic images. First the concept of what art is is analysed along its history. It is related to its capacity to show a conceptual and subjective representation of reality that is able to stimulate our minds. The representative power of Deep Neural Networks is used to create, from photographs of reality, artworks. Along the Art history, from paleolithic to modern art, Art has been used to communicate to other humans (or gods) ideas in human minds. From ancient times, Art studies the relations that already exist in nature, like the golden ratio, and applies them to its works to provide a pleasant feeling to observers. Art finds the ways to express ideas as they are stored in minds, not like perfect reproductions of reality. These ideas are affected by subjective point of view, preconceptions, emotions or the artist’s whole understanding of the world. The artwork is able to communicate author’s ideas to other humans. In modern times Art moved away from politics, religion and society and started looking for its own reasons. The concept of aesthetic is born as the philosophy of the art. Kant states that beauty is not a property of an artwork or natural phenomenon, but is instead a consciousness of the pleasure that attends the ’free play’ of the imagination and the understanding. From different attitudes, the artists expected to interpret the reality creating feelings of vitality, pleasure, imagination and reflection, giving birth to different styles or artistic movements. Some philosophers and artists call nowadays the Death of Art period, since everything can be considered Art. The process of creating an artwork starts with the perception of reality. In our brain and mind a representation of reality is coded in the form of neural impulses and ideas. These are combined with previous state of mind, ideas and emotions. The imagination employs the same circuits used by perception to create a mental representation of an artwork that produces in the mind the stimulus that the artist wants to communicate. During the creation of the artwork the artist keeps modifying it until it matches the imaginary image, until the artwork produces in the artist the desired effect. The algorithm presented emulates, up to a certain point, this process. Deep Neural Networks have proved its capacity to learn to build a representation of an image useful for complex tasks like image classification. Their training on real world examples provides them capacity of "understanding" real images somehow similar to ours. The process of creating an artwork starts with the encoding of the images presented in the form of features that correspond to the activations of the pre-trained Very Deep Neural Network at different layers. A starting image is provided as a basis for the creation of the artwork. It is also fed to the same Neural Network to build its feature representation. These feature representations are used as they are, combined in more elaborate features, or modified. These combinations and modifications are defined in the form of losses on the features. The gradients of the errors are back-propagated through the Neural Network until the image layer. Optimisation is performed on the image to obtain a new image that matches better the desired representation in the activations of the neurons. This process is repeated until the images matches perfectly the desired representation, it can not evolve to a better solution or the user stops it. The different errors used correspond to different models that pretend to focus on different features of the images and different effects. Here are presented: Content model, represents the same image that is fed and tries to make the generated image to be a reconstruction of 5 it. Texture model: represents the texture of the image presented; is based on combinations of features that use to be present in same place. Maximum Activation: maximises the sum of the activations of the neurons. Minimum activation: minimises the sum of activations. The last two have a version where the features to maximise or minimise need to be present too in an auxiliary image. All of them can be combined working on the same framework having as an input an arbitrary number of images represented at different layers. Relative importance of different models is controlled using sets of weights for each model, each image and each layer. The number of possibilities that this technique offers is unlimited. Several experiments are done showing the effects of each model and the main parameters of them. Also combinations of models are tested. The results are interpreted from the perspective of what do they represent and their analogy to human processes and the practical use of the algorithm for art creation as well. Up to this point the algorithm is able to produce artistic works. Nevertheless the images produced usually have some noise or small artifacts. To provide a painting finish they are processed with a special Convolutional Neural Network. This convolutional neural network was originally designed for super-resolution. It is trained using low-res inputs and high-res outputs. For this work I am using a set of weights trained with Japanese anime images. They encode a plain colours effect while keeping sharp edges, quite similar to the style of painting artworks. This work and some of the artworks produced were presented with Cadi Art Natura and Espai d’Art La Duana to a group of artists. They recognised the artistic quality of the artworks and admitted that never would think that they were made by a computer. They explained interpretations and similarities with other styles. They considered this an interesting tool for their work and suggested uses and possibilities that I did not consider before. There is a world of possibilities to explore in the use of Deep Neural Networks for Art creation. 6 Contents Abstract 6 1 Introduction, Motivation and Objectives 9 1.1 Introduction....................................... 9 1.2 MotivationandObjectives............................... 10 2 Art 11 2.1 Introduction....................................... 11 2.2 Prehistoricart ..................................... 11 2.3 ClassicalAntiquity................................... 13 2.4 MiddleAge ....................................... 15 2.5 Renaissance....................................... 16 2.6 ModernAge....................................... 16 2.7 Contemporaryart ................................... 19 2.8 Creationprocess .................................... 20 2.8.1 Creation process in humans . . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.8.2 Creation process proposed . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3 Methods 25 3.1 Convolutional Neural Network . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.1.1 VGG19Architecture.............................. 25 3.1.2 Modifications on the network . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.1.3 VGG19 Trained features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.1.4 Other Neural Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.2 Imagegeneration.................................... 27 3.3 ModelsandLosses ................................... 29 3.3.1 Contentmodel ................................. 29 3.3.2 Texturemodel ................................. 29 3.3.3 Activation maximisation model . . . . . . . . . . . . . . . . . . . . . . . . 30 3.3.4 Activation maximisation model on image . . . . . . . . . . . . . . . . . . 30 3.3.5 Activation minimisation model . . . . . . . . . . . . . . . . . . . . . . . . 31 3.3.6 Activation minimisation model on image . . . . . . . . . . . . . . . . . . . 32 3.3.7 Othermodels.................................. 32 3.4 ArtisticFinishing.................................... 32 4 Experiments 35 4.1 Hardwareused ..................................... 35 4.2 Imagesused....................................... 35 4.3 Contentmodel ..................................... 36 4.4 Texturemodel ..................................... 38 4.4.1 Weights ..................................... 38 4.4.2 Layers...................................... 38 4.5 Texture and content models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 4.5.1 Weights ..................................... 42 4.5.2 Use content image as initial image . . . . . . . . . . . . . . . . . . . . . . 43 7 4.5.3 Evolve texture on content image . . . . . . . . . . . . . . . . . . . . . . . 45 4.5.4 Texture and content from same image . . . . . . . . . . . . . . . . . . . . 45 4.5.5 Drawings .................................... 46 4.5.6 Using MAX pooling instead of AVE pooling . . . . . . . . . . . . . . . . . 47 4.6 Activation maximisation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 4.7 Activation maximisation on image model . . . . . . . . . . . . . . . . . . . . . . . 50 4.8 Activation minimisation model . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4.9 Activation minimisation on image model . . . . . . . . . . . . . . . . . . . . . . . 51 4.10Iterationprocess .................................... 52 4.10.1Fasteningboundaries.............................. 52 4.10.2 Change waves and the end of a generation . . . . . . . . . . . . . . . . . . 53 4.11Finish .......................................... 53 5 Discussion and conclusions 65 5.1 CadiArtNatura’s presentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.2 Conclusion ....................................... 66 A Selection of artworks produced 71 8 Chapter 1 Introduction, Motivation and Objectives 1.1 Introduction Art creation has always been on of the most popular and difficult challenges of Artificial Intelligence. Creativity has long been regarded as an essential part of intelligence and so it is also a challenge for artificial intelligence. Last year, Prof Riedl proposed a new type of test to see whether artificial intelligence was on a par with that of humans. Rather than requiring a machine to have a human-like conversation, as proposed by the Turing Test, his LoveLace 2.0 test would ask a machine to create a convincing poem, story or painting [28]. The idea that computers cannot create art makes intuitive sense. Art is abstract, expressive, cultural; it depends on mood, nuance and emotion—the very opposite of the rational, logical qualities we ascribe to computers. In recent years Deep Neural Networks (DNN), specially Deep Convolutional Neural Networks (CNN), have been used successfully for difficult perceptual tasks like object recognition. They are the first artificial systems that rival biology. At the same time their hierarchical architecture and computational properties have a fundamental similarity to real neural systems [10]. There are evidences of the similarity between DCNN representations and those in the ventral visual pathway [16]. These properties make them a good candidate for studying visual information processing in the brain. In fact, it was recently suggested that textures generated from the representations of performance-optimised convolutional networks “may therefore prove useful as stimuli in perceptual or physiological investigations” [22] Several approaches have been used to obtain representations of the information encoded in the features [29], [26] [21], [7]. These techniques developed provide the possibility of generating images from the representation of reality encoded in the features of a DNN. Obtaining these images can be an interesting tool to understand the features and how the information is represented in the neural network. Recent works have showed the possibility of creating artistic images using the representational power of deep neural networks."A Neural Algorithm of Artistic Style"[9] introduces an artificial system based on a Deep Neural Network that creates artistic images of high perceptual quality. The system uses neural representations to separate and recombine content and style of arbitrary images, providing a neural algorithm for the creation of artistic images. In "Inceptionism: Going Deeper into Neural Networks" [27], instead of exactly prescribing which feature they want the network to amplify, they let the network make that decision. They simply feed the network an arbitrary image or photo and let the network analyse the picture. They then pick a layer and ask the network to enhance whatever it detected. Each layer of the network deals with features at a different level of abstraction, so the complexity of features we generate depends on which layer they choose to enhance. If they choose higher-level layers, which identify more sophisticated features in images, complex features or even whole objects tend to emerge. In this work I will explore the possibilities that the Deep Neural Networks open for the 9 [36]. The artwork mixed a representation of the physical world with the religious understanding of it, the structure that in that moment the world had in the minds of the people, resulting in a deformation of the reality to match the preconception of it. This representation was used to transmit and spread the religious conception of the reality. 2.5 Renaissance With the irruption of bourgeoisie at the end of Middle Age the liberal arts came back from their stagnation. From the philosophical currents of Renaissance and the confirmation of the rational method afterwards, the arts split from science. Mathematical concepts become important inside any aesthetic work and canons based on equilibrium, measure, sobriety, serenity and harmony between the parts and the whole are established [3]. Again mathematical relations and reality knowledge structures become a scaffolding for artworks. It is world famous the man of Vitruvius from Leonardo Da Vinci (fig.2.7) as a symbol of proportion based on man shape. Figure 2.7: Leonardo Da Vinci’s Man of Vitruvius. Galery of Academy of Venice [32]. 2.6 Modern Age At the end of the XVIII century the establishment of the aesthetic or the philosophy of the art as a new discipline gave philosophical backing to the autonomy of the artistic fact. This was the starting point of what we call modern art. The art moved away from politics, religion and society and started looking for its own reasons [3]. The German idealism, in opposition to the theoretical realism, moved the way of thinking to a knowledge complemented with the metaphysical theory. The beauty unchained from the objective point of view and gets subjective, understanding the subjectivity as something real and not only abstract [12]. The aesthetic is informally a synonym of beauty but its origin is philosophical. It was born as a concept in Ancient Greece but it was not until XVIII century that it became a philosophical science. Its creator was the German philosopher Alexander Gottlieb Baumgarten. The root of 16 the word is the Greek adjective aisthetike that means sensation, perception. In 1750 Aesthetica was the title of his unfinished work, where he institutionalised the word as the knowledge of the sensible, the sentiments and the perception of beauty [12]. The systematisation that Immanuel Kant did on Aesthetics made it a philosophical discipline. In his main work, the Critique of Pure Reason, Kant argued for a Transcendental Aesthetic, an approach to the problems of perception in which space and time are argued not to be objects but ways in which the observing subject’s mind organises and structures the sensory world. This was further developed in the third Critique, Critique of Judgement, whose first part Critique of Aesthetic Judgement, discusses the four possible "reflective judgements": the agreeable, the beautiful, the sublime, and the good. In reflective judgement we seek to find unknown universals for given particulars; whereas in determinative judgement, we just subsume given particulars under universals that are already known [11]. It is easy to observe the perfect matching of the Kant’s judgements’ principles and the basis of machine learning and neural networks algorithms used today. The agreeable is a purely sensory judgement, based on inclination alone, e.g. "The food at FIB bar is good". The good is essentially a judgement that something is ethical. That conforms with moral law, a coherence with a fixed and absolute notion of reason. It is in many ways the absolute opposite of the agreeable, in that it is a purely objective judgement: things are either moral or they are not, according to Kant. The remaining two judgements, the beautiful and the sublime, differ from both the agreeable and the good. They are what Kant refers to as "subjective universal" judgements. This means that, in practice, the judgements are subjective, and are not tied to any absolute and determinate concept. However, the judgement that something is beautiful or sublime is made with the belief that other people ought to agree with this judgement, even though it is known that many will not. Kant states that beauty is not a property of an artwork or natural phenomenon, but is instead a consciousness of the pleasure that attends the ’free play’ of the imagination and the understanding. Even though it appears that we are using reason to decide what is beautiful, the judgement is not a cognitive judgement, "and is consequently not logical, but aesthetical". A pure judgement of taste is in fact subjective insofar as it refers to the emotional response of the subject and is based upon nothing but esteem for an object itself: it is a disinterested pleasure, and we feel that pure judgements of taste, i.e. judgements of beauty, lay claim to universal validity. It is important to note that this universal validity is not derived from a determinate concept of beauty but from common sense [11]. In a quite free and inaccurate reinterpretation, I consider Kant’s “free play” between imagination and understanding an inspiration for this work. During the training of the neural network on natural images, we are trying to build understanding of the images in the neural network when we pursue the correct classification of the images in different classes. When we propagate an image through previously learnt filters, the neural network is understanding that image accordingly to its previously formed structures of knowledge. Since the neural network has been trained according to common knowledge (the ground truth of the classification task), the representation it uses can be understood as a form of basic common sense with universal validity, although we are not talking about beauty itself as Kant states. On the other hand we have the imagination. Imagination is the ability to form new images and sensations in the mind that are not perceived through senses. When the neural network produces a new image using the representation stored inside we can say that is imagining the image. Properly, the neural network imagination process would be the activation of the different neurons in the net, not the back-propagation of it to the image generated itself. The imagination is the representation of the image in the activation of the neurons that we store after the forward propagation from the data layer to the different layers of the net. This process, in the model used, is not a neural memory itself, so the matching of it to the imagination process is not perfect. In this section of the critique Kant also establishes a faculty of mind that is in many ways the inverse of judgement: the faculty of genius. Whereas judgement allows one to determine whether something is beautiful or sublime, genius allows one to produce what is beautiful or sublime [11]. 17 According to that, we could say that our algorithm is a genius. This is the final part of the algorithm, working in the opposite direction, where from the understanding and the imagination it generates the beautiful object. The process is carried by little changes in the random noise starting point to make it match the different imagined features of the work in its understanding, which may be up to certain point not compatible, finding a compromise between them. Kant further distinguishes between free and adherent beauty. Whereas judgements of free beauty are made without having one determinate concept for the object being judged (e.g. an ornament or well-formed line), a judgement of beauty is adherent if we do have such a determined concept in mind (e.g. a well-built horse that is recognised as such). The main difference between these two judgements is that purpose or use of the object plays no role in the case of free beauty. In contrast, adherent judgements of beauty are only possible if the object is not ill-suited for its purpose [11]. In this work both kinds of beauty are present. Some of the pictures produced try to keep information on the original object represented, being it a portrait or a landscape, while other just try to find beauty in abstract shapes and lines. At some point the limits between a representation of a known object and an appealing combination of shapes appear diffuse and I consider that the idea of a fuzzy limit is more suitable than a clear distinction. I consider pictures in this fuzzy limit can boost the free play between imagination and knowledge. The judgement that something is sublime is a judgement that it is beyond the limits of comprehension. The feeling of the sublime describes two subjective moments that concern the relationship of the faculty of the imagination to reason. The mathematical sublime is situated in the failure of the imagination to comprehend natural objects that appear boundless and formless, or appear "absolutely great". In the dynamical sublime there is the sense of annihilation of the sensible self as the imagination tries to comprehend a vast might [11]. I relate this sense “absolutely” to the activation of neurons. They can be overexcited, they can have an absolute response to a very impressive stimulus. In neural networks this phenomenon has a parallelism with the activation of the artificial neurons. Their output can be correlated to the firing rate in human neurons. A maximisation of their output may be a correspondent to an absolute. An image that produces this response may have an impact in us too. The opposite can also be stated: the annihilation can correspond to the negation of impulses, the vanishing of activations. I want to make clear that the correspondence between Kant theories and the models used in this work is not accurate in the way I stated them, so it is not possible to say, according to them, that the machine is creating art, but the ideas behind the theory are close enough to make us think about it. A more accurate interpretation is that, if the work produced with these algorithms is able to produce in the subjective human mind that observes its creations the free play relation between understanding and imagination that can be generalised, then it is Art. Given the loose correspondence between the model for the evaluation just mentioned and the model for creation, I consider plausible that this process effectively results in the production of art works. The autonomy that this philosophical thinking gave to Art, now in capital letters, provides the basis for the artworks as a chance for aesthetic judgement. From different attitudes, the artists expected to interpret the reality creating feelings of vitality, pleasure, imagination and reflection, giving birth to different styles or artistic movements. In the XIX century it starts the period of artistic movements: neoclassicism, romanticism, realism, impressionism, symbolism, art nouveau, modernism,...[3] In the XX century the emancipation of the beauty as perfectly controlled idea gained strength. In the vanguards, the limits of the beauty grow towards the limits of the language [3]. Among the movements which flowered in the first decade of the 20th century were Fauvism, Cubism, Expressionism, and Futurism. Many other movements flourish during the rest of the century including constructivism, suprematism, dadaísm, surrealism, rationalism, pop art, happening, minimalism, hyper-realism,conceptual art, land art,... Some of these currents try to express ideas or feelings that are not in the conscious part of the mind. Sometimes their greatest achievement is to find an artwork that stimulates connections in our brain that we are not aware of. The kind of these connections can be completely different, from surrealism or impressionism to abstract art, they target to hidden connections in our brain producing this way a stimulus to our mind. 18 One of the results of this work uses existing art pictures and tries to mix their style with the content from a real photography. As we will see later, this approach uses the textures representation in a neural network to represent the style of the painting. Although many information is lost, and probably no expert would recognise the work produced this way as a part of the original style, the impression in the general public is that the work produced really matches the style of the original. I let the interpretation of that phenomenon on art experts. 2.7 Contemporary art Today the contemporary art uses the beauty or the ugly equally with the objective of producing aesthetical emotion, going further of the sensible, getting in the field of the aesthetic experience, the emotivity, the play and the surprise. With the raise of the conceptual and popular, the art today evaporates in any human action, the ugly can be aesthetic and the artistic can be anything. The aura that always tried to have the art exists no more. Everything has become invaluable, illogical and indeterminate. During the 80’s the US philosopher Arthur C. Danto called this moment the death of the art [1]. The "end of art" refers to the beginning of our modern era of art in which art no longer adheres to the constraints of imitation theory but serves a new purpose. Art began with an "era of imitation, followed by an era of ideology, followed by our post-historical era in which, with qualification, anything goes... In our narrative, at first only mimesis (imitation) was art, then several things were art but each tried to extinguish its competitors, and then, finally, it became apparent that there were no stylistic or philosophical constraints. There is no special way works of art have to be. And that is the present and, I should say, the final moment in the master narrative. It is the end of the story."[1]. According to this point of view, anything produced in this work would be art, but this is not my personal point of view. Getting deeper in Danto’s point of view, his definition of art has been glossed as follows according to the Stanford Encyclopedia of Philosophy [1]: “Something is a work of art if and only if: 1. it has a subject 2. about which it projects some attitude or point of view (has a style) 3. by means of rhetorical ellipsis (usually metaphorical) which ellipsis engages audience participation in filling in what is missing, and 4. where the work in question and the interpretations thereof require an art historical context.” I like to think about the first condition as what is it about?, what are we talking about? Similarly, the second would be what do we say about it?, how do we feel about it? What are the important features of it that we do want to highlight? I consider that these interpretations are included in the definition itself. But, expressing them this way we may realise that we are talking, that we are communicating something, so, the art needs a subject to talk about and a style to say something about it. As we will see later, these two parts of an art work are clearly differentiated in the approach described in the work. The third condition is the most fascinating. It reminds me about the free play between understanding and imagination of Kant. I think that both are talking about the same idea, difficult to express with words but present in every modern artwork, not to say just any artwork. I don’t know better ways to express it, but the way I understand it is related to the way information is represented in our mind. Our mind has a natural ability to fill the gaps, to provide the missing information according to the context, that relies on our neural structure and the representation of the information in it. Filling this ellipsis, these gaps, can be engaging and I consider this a key to love the art. Oppositely, I strongly disagree with the fourth condition. It is a condition about cultural background, but is written in the form of restricted art historical context. It is closing the existence of art, so the appreciation of it, to the subset of well formed minds aware of art historical context. I also consider that the cultural background is a key factor of the art. but I would extend it to the more general possible cultural background. Even more, art appreciation 19 can extend over different cultures and times, and our appreciation of ancient and foreign art is a proof on that. Then, the art background must be something, at least, available for the entire human race. Maybe, it could even be open to other sensible beings. After opening the range of the fourth condition, I would add another loose condition for the art: originality. I consider that one of the main characteristics of the art, that distinguishes it from craft-work and industrial production, is that is a way to explore new horizons. Art is usually on the edge, exploring new ways of expression, new subjects. Art is not about repeating once and again the same things, it is about doing them in a different way or doing new things, it is a kind of research for expression. 2.8 Creation process 2.8.1 Creation process in humans It is difficult to define the creative process followed when creating an artwork. According to what I explained before about art I developed my own. The main elements involved in the process of creating an artwork can be roughly modelled according to the diagram in figure 2.8. Figure 2.8: Creative process in humans In blue we can see the mental processes. These processes involve the nervous system for transmitting and manipulating the information. The processes involving manipulation of information are separated in 3 boxes according to their different roles: •Perception: It bridges the gap between the real world and the representation of it in our mind. It involves not only the senses but also the preprocess of the information collected to build a good representation of it. It receives the inputs from the real world in general, but more specifically for art creation from the tools used and the support that will become the artwork itself when finished. 20 •Mind: Is the center of the system. It works with high level representations of reality. It generates high level concepts and abstract concepts that do not need correlate directly to perceptions of the real world. It has the ability to imagine a reality that is not perceived. To create this reality it makes use of part of the perception system, to give a sense of real to the concepts generated at high level. Mind is also the responsible of controlling the body, and through it actuate in the real world. The mind, to perfection this control, has the feedback via proprioception. •Emotions, will: Are the driving force of the mind. Freud called them the Superego and the It. They are affected by the ideas in the mind and the perceptions directly. They are who decide what to do. They many times play a key role in the creative process, being the art itself a manifestation of these forces. The style in the art, the point of view is a way to express them. They are many times the reason that stimulates the creation of art. The working of the whole system start in the real world. To create an artwork the first thing is to gather the inputs from the real world. These inputs need to be mentally represented, so are encoded in the form of higher ideas. These ideas can be then processed by the mind and combined with the subjectives point of view coming from the will and the emotions. The ideas are altered and are no more a realistic representation of the world to become a subjective vision. The mind manipulate the real world to create a representation of the subjective ideas via the hands, or feet or any other way it has to act on the world. These actuators are part of the body but their capabilities can be extended using tools that are part of the world. The actuation is focused on a part of the world itself, the support for the artwork. The support is going to change during the creation of the artwork to become the artwork itself. The perception that arrives to the mind of the support can modify the artwork to be created. In the same way the perception of the artwork itself during the process of creation can change the idea of it and then modify the final result. When the perception received from the artwork fulfils the requirements of the mind and will, or when the mind recognises that can not find a way to improve it, the artwork is finished. 2.8.2 Creation process proposed In this work a modular structure based on deep neural networks (DNN) to create artworks is proposed. In figure 2.9 it is shown roughly the general schema used in the generation of artworks as it is coded. In the lowest part of the schema there are the input images. The left block with 3 images, representing a generic array of N images, are the auxiliary images used for the composition. On top of each image a pre-trained CNN takes this images as inputs to build a representation of them in the activations of their neurons. The architecture, given the adjustments for different sizes of the images, and the weights are the same for all networks in the schema, so they are represented as a unique neural network.The activations on top of the networks are gathered at several levels of depth in the neural networks, not only in the final layer. In the right part we have the image that is being generated at two different stages. The same CNN is used to extract the set of features at the same layers used by any of the other networks for auxiliary images. On top of the activations we have the error measures. These errors are computed according to the different models available. The models used can be all different or several instances of the same error. The errors are fed by the activations of each auxiliary image and the activations of the image in process of creation. Some proposed models’ error measures do not require an auxiliary image, so they are fed only by the generative CNN. The errors output a loss measure and a gradient according to its definition. Each of the errors is weighted using specific weights for each layer, each image and each kind of model. The weighted gradients are combined and fed to the generative neural network. Since the errors depend on the depth of the layer they are really combined inside the generative neural network. The gradients of same layer are vectorially added, then they are propagated to shallower layers and there their propagated value combined with other errors of that layer. 21 Figure 2.9: General schema of the algorithm proposed. This point is not showed in this general schema for the sake of simplicity. The gradient is finally propagated until the image layer is reached. The arriving gradient is used as input for L-BFGS numerical optimization of the image in process of generation. Figure 2.10: General schema of the algorithm proposed with finish CNN. To complete the schema I have to add the finishing process as is shown in figure 2.10. The final image resulting from the previous schema is fed in a special neural network that encodes knowledge about paintings appearance. This Finish CNN removes the noise generated during the image generation process and gives a painting appearance to the final artwork. This process shares a similar structure with the human process of artwork creation. We can fit the main components in the previous schema with little changes, like deleting some of the information flows, now in white, as we can see in figure 2.11. The point that is out of the system here defined are the emotions, the will. The subjective part of the artwork creation is not included in the schema working in the computer. This part is provided by the human operator. The user defines which images are to be used, which error measures and their relative importance. The user is also the final judge of the artwork created. From this point of view it is clear that an important part of the creation process is done by the 22 Figure 2.11: Adaptation of the human creative process to the presented algorithm. algorithm. Another, more simple, point of view is to restrict the algorithm in the Tools box. Then all the creation process is done by the human user and the algorithm is just a tool. I consider more appropriate the first possibility since I consider that the role of the AI is capable of getting its own representation of the world. It is obtained through the images presented thanks to its previous training which gave it this ability. It can go beyond the capabilities of the user’s imagination producing completely unexpected results. I understand this can be a very controversial point subject to different interpretations. 23 24 Chapter 3 Methods 3.1 Convolutional Neural Network The neural network used to represent the features of the original images is the same network that is used for the image generation. In this work it is called composition network. The architecture of convolutions and pooling layers and the weights must be the same. The size is the same in the case of the content model, since all the features are used to compute the error. In the case of the texture model the size is not required to be the same since the information in the Gram matrix is stationary, not dependent of the positions in the image. 3.1.1 VGG19 Architecture I use the VGG-19 network, a convolutional neural network trained on object recognition that was introduced and extensively described previously [30]. I use the feature space provided by the 16 convolutional and 5 pooling layers of the VGG-19 network and do not use any of the fully connected layers. The network’s architecture is based on two fundamental computations: 1. Linearly rectified convolution with filters of size 3×3×kwhere k is the number of input feature maps. Stride and padding of the convolution is equal to one such that the output feature map has the same spatial dimensions as the input feature maps. 2. Maximum pooling in non-overlapping 2×2regions, which down-samples the feature maps by a factor of two. These two computations are applied in an alternating manner. A number of convolutional layers is followed by a max-pooling layer. After each of the first three pooling layers the number of feature maps is doubled. Together with the spatial down-sampling, this transformation results in a reduction of the total number of feature responses by a factor of two. Next table provides a schematic overview over the network architecture and the number of feature maps in each layer. Since only the convolutional layers are used, the input images can be arbitrarily large. The first convolutional layer has the same size as the image and for the following layers the ratio between the feature map sizes (rows and columns) remains fixed. Generally each layer in the network defines a non-linear filter bank, whose complexity increases with the position of the layer in the network. In figure 3.1 we can see the architecture for a typical image used in the tests. Although other neural networks can be used with the same code I consider that for the purpose of this thesis is better to use only one neural network not to increase the number of parameters to consider in the tests. 3.1.2 Modifications on the network According to Gatys, [10] replacing the max-pooling operation by average pooling improves the gradient flow and obtains slightly cleaner results. Also, for practical reasons, in [10] the weights in the network are rescaled such that the mean activation of each filter over images and positions 25 This loss and gradient are fed to the generation network. Note again that in the case the activation of a specific neuron is 0 the gradient will not be propagated for that neuron. 3.3.6 Activation minimisation model on image Combining the previous models we can apply the minimisation model on auxiliary image. This time we have two versions of the model that make some sense. The initial approach is the same, minimising the activations that produce a high response in both, generated and auxiliary image. The second one is to minimise the activations that already produce a low correlation. While the first should tend to make the image more different, minimising what they have in common, the second should make them more similar reducing what is not similar. In the same way of content model in section 3.3.1, from an input image ~x and auxiliary model image ˆ ~x the activations are computed for each layer Fland ˆ Flwith dimensions Nl×Wl×Hl and Nl׈ Wl׈ Hl. To compute the error first we compute the similarity or dissimilarity of the features of both images using the inner product. Then we select the features that give a maximum or minimum similarity independently of their positions in the images. For maximum similarity we have: FAmax =argmax((Fl)T·ˆ Fl)i and for minimum FAmin =argmin((Fl)T·ˆ Fl)i The error used to maximise the activation of the features in the framework of a minimisation problem, compatible with other models, is minus the squared value of the activations of the features that maximised or minimised the inner product: El=−1 2X j,k (FAl jk)2 Note that this error is independent of the position of the features in the auxiliary image but not in the generated image. The total loss, as usual is weighted in every layer: Loss(~x, ˆ ~x) = L X l=0 ωlEl where ωlare weighting factors of the contribution of each layer to the total loss. The derivative of Elwith respect to the activations in layer lcan be computed analytically: Dl=∂El ∂F l ij =−(FAl)ij This loss and gradient are fed to the generation network. Note again that in the case the activation of a specific neuron is 0 the gradient will not be propagated for that neuron. 3.3.7 Other models Given the modular structure of the approach presented it is clear that other models can be developed. The models can rely or not on auxiliary images. New models can find other kinds of relations between features that have not been explored yet. Also it is possible to think on combinations of presented models. 3.4 Artistic Finishing One of the problems of the system used for generation of images from a DNN representation is that during the generation of the image some noisy artifacts may be included. 32 Some authors [19] suggest using an error soft constraint on the image pixels during the generation of the image. This is usually called image prior Γ(x). The most common value for it is the TV norm: Γ(x) = X ij (xi,j+1 −xi,j)2+ (xi+1,j −xi,j)2 which encourages nearby pixels to have similar values and five smoother reconstructions. Although this approach would be easy to introduce in the general schema used in this work I decided not to use it. I considered that sometimes this normalisation may make the picture generated appear blurred, lose strength, making the images obtained more dull. I did not make any tests on that, just checked the pictures presented by other authors. It is also a personal point of view. From my point of view it is worth to try something different. CNN had been used for image super-resolution achieving good performance on the details [6]. They are also a good denoiser, another work used this property to build a compression denoiser [5]. I considered to use a similar approach using a neural network trained not on real images but on paintings to denoise the final images, giving a painting style finishing at the same time. Figure 3.3: Schema of the CNN architecture used for super-resolution [6] As we can see in figure 3.3, given a low resolution image ~y, the first convolutional layer of the Super-Resolution CNN (SRCNN) extracts a set of feature maps. The second layer maps these feature maps nonlinearly to high-resolution patch representations. The last layer combines the predictions within a spatial neighbourhood to produce the final high-resolution image ~ F(~y). The hardware restrictions made that idea not practical since the training time will be too long for this thesis. Fortunately I found a shortcut. A Japanese software engineer had been training a CNN on Japanese anime and made it publicly available [24]. It can be found as a ready to use app in the web under the name Waifu2X [25]. Finally I used the pretrained neural network on anime with different degrees of denoising according to the finishing I wanted to give to the final pictures. In some images I used it several times to obtain smooth images, in others I used the real images filter to obtain less noise filtering. This process worked very well, keeping sharp edges and giving continuity to the colour at the same time. 33 34 Chapter 4 Experiments 4.1 Hardware used For all the computations done in this thesis, a laptop with a CPU Intel Core i5-4200 and a GPU Nvidia Geforce 820M has been used. The use of a generic laptop demonstrates that the use of Deep Neural Networks is not constrained to research labs equipped with powerful processors but, on the other hand, set restrictions on the computations carried on. From the first tests it was clear that the use of GPU for the processing of forward and backward propagations in the neural network was the fastest option, but even in this case the time required to compute one model with 2000 iterations is around one hour. The memory available in the GPU, 2Gb, is partially used for error correcting and visualization, leaving only around 1,2Gb of free memory for nets. This restricted the size of the images to use to 2202 pixels. This value was obtained after several tentatives with bigger images and different models. Obviously the number of constraints and models used made the maximum size variable, but to ensure that experiments could be finished this size was chosen. The low resolution is not a big problem for the experiments since the networks used are usually trained with 2562 pixels, so the features trained are mainly contained in the image size used. The flexibility of caffe to adapt to different input sizes is also key for the success of this work. From the artistic point of view it is obvious that bigger images would be preferable but, since the cost of obtaining them in time would result in less experiments, I consider it is better to keep them small and do more tests. To overcome these constraints a schedule of the experiments was required. I made a version of the code able to run several experiments sequentially. After first trials I used a slightly faster version performing around 15 experiments in each run, spending a total time of about 10-12 hours. 4.2 Images used The choice of what images are more suitable for preliminary experiments and art generation is not trivial. In order to make easier the evaluation of the results obtained and achievement of appealing art works the images used are carefully selected. One of the most studied problems in computer vision is face recognition. It has been studied for long time and includes all kind of classification problems ranging from gender recognition to age estimation and properly face recognition for identification purposes. It has also been demonstrated that the ability that humans have for face recognition is learnt in early stages of development and that is higher than any other visual task. Evolution favoured individuals with higher ability recognising the small differences from one face to another and the differences that show particular emotions. This natural training makes us experts understanding faces and, at the same time, finding strange elements in a face or detecting faces in images where there is no face actually. This is the reason why I use face images in many of the experiments. I used Geoffrey Hinton’s photo as a homage for his work in developing neural networks, which are the basis of this work. 35 I also use some landscapes to see the impression produced for images generated in the case of a image of reality that is natural too but we are not so much used to it. For textures I use different kind of images that have a texture appearance. I specially focus on images with straight lines. Similarly to the case of the faces explained before we also have a special ability to recognise straight lines and regular geometric patterns. I think it is interesting to use them to have a better understanding of the behaviour of the texture algorithms used. I also use images of gradients of colours, like the colour palettes, to give the neural networks a representation that includes all kind of colours for the images reconstruction. 4.3 Content model One of the first experiments to do is to test the content model. In the following figures 4.1 and 4.2 we can see the images obtained from the representation encoded in the features of only one layer. In all these tests the initial image used is random noise. From this initial image the algorithm tries to find an image that minimises the error in feature representation at specified layer. original ’pool5’ ’pool4’ ’pool3’ ’pool2’ ’pool1’ ’conv1_1’ Figure 4.1: Image reconstruction from content features. For all images: contentweight = 104, maximum number of iterations = 2000 In figure 4.1 we can see that the reconstruction of the original image is decreasing its quality as deeper layers are used. The images are very similar to the original image for lower layers, up to ’pool3’. In ’pool3’ the smallest features appear blurred but the shapes very similar, with some noise. In the reconstruction built only with features from ’pool4’ the quality is not that good. The details in the borders of the coins and in the figures of the coins are not restored properly. Nevertheless, the general appearance of the image is quite good and the objects can be easily identified as coins. In ’pool5’ reconstruction lots of artifacts appear, the shapes are very distorted and it is hard to recognise the coins if that image is presented independently. However, in the context of the figure we can find it similar to the original and the general texture is kept. In figure 4.2 we do the same experiment using a face as the image to be reconstructed. The behaviour is similar to the previous experiment. Up to ’pool3’ layer the reconstructed images are very similar to the original one. In ’pool4’ some artifacts and noise start to appear. It is not specially noticeable but in the eyes. In ’pool5’ the image obtained is completely weird. It does not keep any trait of the original image. Unlike the previous test, now it is completely unrecognisable the original figure. 36 original ’pool5’ ’pool4’ ’pool3’ ’pool2’ ’pool1’ ’conv1_1’ Figure 4.2: Image reconstruction from content features. For all images: contentweight = 103, maximum number of iterations = 2000 In the paper [26] the authors explain this phenomenon of multiple possible inputs that minimise the error in the feature representation of a CNN but have no apparent similitude with the original. This experiment shows that in low to high layers (’pool4’ is layer 16th) it is possible to obtain a high precise Reconstruction of the original image from random noise. Using only very high layers (’pool5’ is layer 21st) it is not possible unless additional constraints are provided. The data compression in these levels is so high that many images can produce the same feature representation. Most of these images are not natural at all, so are unrecognisable for us. This result can give some clues about the way the information is encoded in CNN trained for image recognition and their difference with the way we do in our brains. From the art creation perspective, it is interesting the different level of abstraction that each level provides on the content represented. When we want to combine different "ideas" from different images, it is important that the representation of the content allows different solutions that still are representative of the content. In this case the results obtained for layers ’pool5’ and ’pool4’ are specially interesting. The non perfect, or "wild", reconstruction obtained show that there is space for more that one solution that still matches the main features represented in those layers. This fact may allow a better combination of the content with other features, and so give more space for the "fair play" mentioned in section 2.6. Another interesting result of this experiment was found in the early stages of evolution by an artist consulted. When he saw the images said that the first images were showing the most important structure of the content image. Besides the interest he found from an artistic point of view, latest studies reveal that the same kind of images can be used to make Saliency Maps for classification tasks that can be used for automatic segmentation [29]. 37 4.4 Texture model 4.4.1 Weights The implementation includes a general factor for the weights of gradients for all layers and sources. In the algorithm the gradient is not normalised but each loss is multiplied by a different weight before the back-propagation. It has been observed that for small weights for the features the minimisation problem can be solved with only one iteration. This produces images that are almost random noise. I consider that this is a problem of numerical stability, since with small values for the gradients they can be so close to zero that after propagation no optimisation can be practically done. In the images of figure 4.3 it can be seen that a very large weight can make the gradient drive optimisation to extreme values in pixels. However after a few iterations the results are practically the same. As a rule of thumb, minimum weights of the order of 103are required. Higher weights do not improve final image and do not speed up optimisation process. 4.4.2 Layers The selection of layer used for the texture reconstruction has an important effect on the results. Their representation is based on the features encoded by different layers and it was shown in previous section that this representation is different according to the layer. Figures 4.4 and 4.5 show the images obtained for different combinations of layers for a particular texture. The images used in the experiments in figures 4.4 and 4.5 where chosen because they have geometric shapes that can be easily identified visually. The first interesting thing we can see in these images is the size of the features that they are able to encode. As we increase the depth of the layers used, the size of the features increase according to the area covered by those features. As we have seen in section 3.1.1 the size of the area influencing one feature increases with the depth of the layer. A feature of layer ’conv1_1’ gathers information from a 3x3 pixels area, while a feature from ’pool5’ is based on a 46x46 pixels square. Nevertheless, we can see that the area of the visual features of the experiments is bigger than this size. According to its formulation in section 3.3.2, the Gram matrix encodes the spatial correlation between the different features. That is which features tend to have a similar activation in all places across the image. If in all the places feature ihas a strong activation and feature jhas also a strong activation and vice-verse, then the Gram matrix value Gij will be close to 1. If they are not related they will be close to 0. But the features share some overlapping area, in our case up to 2/3of their total area of influence. So their activations are not completely independent. This interdependence in layers features increases the size of the features that Gram matrices apparently encode. In the images of coins in figures 4.4 and 4.5 we can see that the complete ellipsoid/rounded shape of the coins is only achieved in ’pool4’ and ’pool5’ experiments. For lower layers the features are too small. In the case of the mosaic at ’pool3’ the sizes and square form are kept. In pool2 we can see that the vertical and horizontal lines are coded, forming clear rectangles, but not the proportion. In previous layers the lines are more blurred, although they keep the direction. In the gravel images we see again that the hexagonal line orientation is present from the most simple representations. In ’pool2’ it starts to appear the idea that different colours should group together and a cell wall should be placed between. In successive images this grouping feature is more evident. The cell size also tends to be similar to the original. Nevertheless any of the generated images has been able to evolve to a point where the two colours are separated in only two groups or where the hexagonal structure is coherent in all the image. This can have two explanations: the random starting point made the network evolve to a local minimum and is not able to find a better solution, or the size of the features is not big enough to penalise these errors as happens in the lower lever models. In the last of the examples, the colours images, we can see again the size of the scope of the features in the first two images. It is interesting to notice that in general the bright colours are 38 iteration 1 iteration 25 iteration 2000 1 original 102 103 1010 1030 Figure 4.3: Effect of order of magnitude of weights in image generation. A certain minimum weight is required. Very high weights do not affect results after a few iterations. Only texture model is used. Layers used: ’pool4’, ’pool3’, ’pool2’, ’pool1’, ’conv1_1’ 39 coins mosaic gravel colors ’conv1_1’’pool1’’pool2’original Figure 4.4: Effect of the layers used in image generation starting from lowest layers. Each row includes the layer stated and also the previous ones. i.e for last row are used layers: ’pool5’,’pool4’, ’pool3’, ’pool2’, ’pool1’ and ’conv1_1’. We can see that the complexity and size of the features increase when using deeper layers. not touching each other but placed in a grey background. If we look close to the original image we realise that there are shadows between colours. The small scope of the network may be using this feature as a general border between colour blobs of different random sizes, more related to initialisation than to their representation area. In the third image the idea of vertical lines gains 40 coins mosaic gravel colors ’pool3’’pool4’’pool5’original Figure 4.5: Effect of the layers used in image generation starting from lowest layers. Each row includes the layer stated and also the previous ones. i.e for last row the used layers are: ’pool5’,’pool4’, ’pool3’, ’pool2’, ’pool1’ and ’conv1_1’. We can see that the complexity and size of the features increase when using deeper layers. importance but is not until the ’pool2’ that is associated with colour changes. The horizontal relations between colours are also kept at this level disappearing the grey background. From this point the change in successive deeper models is the increasing vertical size of the colours, that I consider related to the size of the scope of the features in deeper layers. 41 content generated texture A B C D Figure 4.12: Generation of images from a manga content and real textures. Image A,B,C: tex/cont = 104; content layers = ’conv5_1’; texture layers = ’pool3’, ’pool2’, ’pool1’, ’conv1_1’. Image D: tex/cont = 104; content layers = ’pool5’; texture layers = ’pool4’, ’pool3’, ’pool2’, ’pool1’, ’conv1_1’. 48 content generated texture Figure 4.13: Generation of an image from a real content and manga textures. tex/cont = 104; content layers = ’conv5_1’; texture layers = ’pool3’, ’pool2’, ’pool1’, ’conv1_1’. Figure 4.14: Image reconstruction from content and texture features using MAX pooling. For all images tex/cont = 1011/102. Maximum number of iterations = 1000. the algorithm. Others are done to obtain a different result. This algorithm does not intend to create dreams from the images that end up in a representation of the neural network knowledge, not related to the image used. The intention is to emphasise the features present in the image that are significant for the neural network. One of the changes that showed to have a significant impact in the results is the neural network used. Like in all the rest of the experiments the neural network used is the VGG19 modified with average pooling. The information this network encodes in each layer is different from the GoogLenet used by Google. This ha a major impact in the features generated. Besides the impact of the neural network architecture and training, the use of average pooling have also a big impact in the results. In figure 4.18 we can see the results when we use MAX pooling instead of AVE pooling. The result is more different when we use the model in pooling layers. From an artistic point of view it is clear that this images achieve the goal of maximising the activations of our neurons as well as artificial ones. The images are impacting but the interesting thing is that the shapes they emphasise have been always there. Even in the last images of the sequences we can see, in some cases, similarities with the original one. They are still a representation of the same subject. The images at first iterations show a subtle increase of certain features already present in the image. This effect remembers me the Greek sculptors that made the muscles of the bodies more sharp that they were in reality, actually, more sharp that they can never be. This way they emphasised that feature. This experiments show that this model can be used in the same 49 Figure 4.15: Image reconstruction from content and texture features from same image using MAX pooling. tex/cont = 107/104. Maximum number of iterations = 1000. way. 4.7 Activation maximisation on image model This group of experiments perform, like the previous one, a maximisation of the sum of activations at a certain layer of the network. In this case an auxiliary image is provided and the features to maximise must be strong in that image as well. The results of the experiments are divided in two figures, 4.19 and 4.20, for convenience of presentation. In this set of experiments we test different weights for the loss and the gradient. We can see that the range of weights that work well in this experiments depend on the layer used. It actually depend on the strength of the features to maximise. And this strength depend on the correlation of features between principal and auxiliary images. In any case we see that for large weights we obtain stronger results. In the case that there is almost no relation between the two images in that layer, as happens in layer ’pool5’, no image is computed or if obtained is almost the original one. This algorithm use to stop after a few iterations since at some point the features stop being similar because the comparison is always done on the generated image at each iteration. For understanding of neural networks it is interesting this algorithm because it produces a clear strong output when the features of both images at a certain level are related and almost no output otherwise. It visually answer the question "what do have in common this pair of images at this lever of representation". It is also possible to locate the features in the original image and visualise their target. In the final image we see also the shape of their preferred output, so it is very clear what do they represent. From the artistic point of view this maximisation of activation can emphasise features present in both images. This deformation of reality can be visually attractive, and in some cases even shocking. Personally, I consider some of the images created with this technique and the previous one, very artistic and visually attractive. This tool can also be useful for previous drafts of the artwork to be created, avoiding the colourful explosion it usually generates. The fact of restricting the features used to be present 50 in another image give an incredible analysis power. It can also be used to emphasise features that unconsciously we find in other images in the same way the CNN does. 4.8 Activation minimisation model As we have seen previously maximisation of the activation can produce interesting images that are at the same time informative of the process inside the neural network. In this set of experiments the method tested is the opposite. The goal is to minimise the sum of the activations of the neurons at a certain layer. The results for different layers and iterations are showed in figures 4.21 and 4.22. Some of the images are very similar at same iterations, so different iterations have been chosen for representation. It is interesting to see in figures 4.21 and 4.22 that lower layers tend to make a completely grey image, while highest layers can be in a minimum with a recognisable image. In all layers above ’conv1_1’ the final image is not completely grey, it has some patterns although they are almost unrecognisable. In layers ’conv4_4’ and ’pool4’ we can almost see the face in the image. Another feature of this images is that each layer draws a special pattern in the image. This should be the visually opposite of the pattern that this layer recognises. The visually opposite is not the negative of the pattern but an independent one, so it produces no activation. The images in the sequence of iterations look phantasmagorical modifications of the original. Contrary to the opposite algorithm that draws bright colours, this tend vanish the images. The deformations that occur to the face while vanishing also have a phantasmagorical distortion. The effect is the best seen on video of the sequence of images in both directions. There we can also appreciate better that the dissolution of the original shape generates waves around it. I consider that this waves are generated when gradient in the image vanish generating smaller gradients around which in the next iteration also vanish repeating the cycle. This process makes the original face look smaller every time, being the process faster in the areas where there are less features. It is very interesting to realise that the images that we associate with live are the ones that maximise the activations of the CNN while the ones we associate with death are the ones that minimise the activations. Also the process of vanishing produces shapes with small mouths and big empty eyes that are the one we usually use to represent phantoms. 4.9 Activation minimisation on image model The same process used in section 4.8 can be used in the case of a minimisation filter. As we will see, now makes sense to try two different approaches. The initial approach is the same, minimising the activations that produce a high response in both, generated and auxiliary image. The second one is to minimise the activations that already produce a low correlation. While the first should tend to make the image more different, minimising what they have in common, the second should make them more similar reducing what is not similar. A problem with this solutions is the initial similarity of both images. As we confirmed in the previous experiment in section 4.7 the process tend to make little changes in the images when they are not so similar. Here we are trying to reduce the activations that are used in that comparison so a little change in the images may happen. When I did the experiments I confirmed that for high specialised layer there is no effect or very small. In lower layer, more generic there are more similarities so the algorithm can produce something. In figure 4.23 we can see the comparison of the outputs of both algorithms for minimisation of activations of ’pool3’ using both approaches. We can see in the images of figure 4.23 that the features minimised in both cases are very different. Any of them is similar to the features minimised in previous experiment with same layer and image in figure 4.22. 51 4.10 Iteration process 4.10.1 Fastening boundaries If we look at the films of the evolution of the texture pictures we can realise that the boundaries of the picture start to get the appropriate shape before the middle parts of the picture. It is a phenomenon that had been usually observed in the experiments conducted. The interpretation of that phenomenon is based on the constraints during the optimisation process. We know that the features used for the optimisation have a spatial area of influence. The higher level the feature is, the bigger area of influence it has. The texture features are actually the spatial correlation of the activation of layer features. A pixel placed close to the edge of the image is connected to less feature influence areas, because there are less areas overlapping on that pixel, than in the case of a pixel in the centre. When optimisation is conducted the general optimisation gradient sum the influence of all the features that overlap their influence areas on that pixel. These gradients are based on all the area of each feature, so each of them, according to its influence area, may be pushing the pixel value in a different direction. In the sides of the images there are less features pushing, so it is easier to find a coordinated direction for all of them, a common agreement, and the values of all affected pixels move to that common minimum faster. This phenomenon has a strong effect in the final image. When boundaries are fastened to their local minima, it is more difficult to find a common minimum for the centre of the image. The fact of having a poor matching in the middle has an impact on the general loss computed but this is, in many cases, smaller than the impact that would have to change the value of all neighbouring pixels, increasing for each of them their contribution to the total loss. The usual result of this is that the image get stuck in a local minimum with some “unmatched” areas instead of evolving to a global minimum where all the parts find a global organisation that matches the patterns represented in the full extent of the image. The experiments with highly structured images in textures using high level layers make clear to our vision this phenomenon, while in less structured images it is not so easy to see. This ability to realise the disorganisation in some kind of images while not in others could be discussed from a neuroscience point of view. To overcome this limitation the optimisation process should be carried gradually, starting from the centre of the image and gradually increasing to the boundaries. This approach could be implemented: 1. Starting image smaller that target image. 2. Generate image 3. Extend image with randomly generated boundaries 4. Use extended image as a seed for next generation step. 5. Repeat from 2 to 4 until the desired size is achieved. In the code used in this thesis this could be done defining progressively decreasing nonoptimisation masks in the boundaries. Another possibility is to assign bigger weights to the optimisation losses according to their position in the image. This would have two effects: 1. Increase the magnitude of the gradients in the central area, speeding up the optimisation in this areas. 2. Make possible for central areas with bad matching to surpass low losses of well matching surrounding areas. To introduce this solution in the code used in this thesis is not as much straightforward as the previous one. If we want to apply it to the final loss in the final layer we have the problem that the Gram matrix computed is spatial independent. An indirect approach would be to act directly on the gradients applied to the image. This, actually, would be quite similar to the first solution applying a weighted mask instead of a none/all mask. 52 4.10.2 Change waves and the end of a generation We can see in some parts of the images a wave texture. We can see it clearly in the sequences of images of figure 4.24. The images in the first row show the generation of an image of only texture. While the images in the second row combine the same texture with a content. In this case the ratio of weight is tex_w/cont_w= 1010/102. In the first row, in the first image, we can see a strong wave effect over all image, while in the second it almost disappeared over all the image. In the third we can not see any of these features. It is possible to observe that between the first and second images there are important differences in the images. Mainly some small features disappeared and the image is more consistent according to high level features. The second and third images are very similar. It is important to notice the larger number of iterations between the second and third images than between the first and second. In the second sequence we can see that, in the first image, forms are still being generated and there are no visible waves. In the second one there are a lot in the central area that is changing at this moment. In the third one they are reduced but we can still see some in the boundaries of the shapes. After many experiments I realised that these waves appear in areas that are changing in that moment and their absence over all the image is a sign of stabilisation of the optimisation process. Nevertheless, sometimes they don’t disappear even when the image is clearly stable and almost no noticeable changes occur for 1000 iterations. This phenomenon happens more often and is more pronounced in images that combine different features. In figure 4.25 we can see that the size of the waves is similar to the size of the features coded in the first layer of the network. They are not just random changes pixel by pixel, noise like, but of the size of the features of the lowest level layer, ’conv1_1’. This fact points in the direction that there is relation with this layer activations. Actually, we don’t see the size of the gradients in this layer but the size of the plain areas. In other experiments we see that waves of this size are stable when the texture used has many abrupt changes in the colour. My explanation is that the neural networks knows that it should be a plain area but there is contradictory information on its colour. I consider that these waves are caused by a low level texture layer whose minimum loss correspond to them and that gets stuck in a local minimum. When the higher layer gradient propagation makes the image displace from this minimum point and change the features activated in lower layers for others corresponding to a consistent solution they disappear. Usually they still remain close to some edges probably because the higher level gradients in these areas are not strong enough to jump over the local minimum for lower layers. The main importance of this fact is that it becomes, with the lack of important changes in last iterations, a visual indicator that the result is stable and more iterations would make no significant difference in the image produced. 4.11 Finish In this section wee show the effect of applying the finish network to upscale the images to double size while at the same time reducing noise and giving a painting appearance. In the examples in figures 4.26 4.27 we can see that the effect sometimes is too strong and some interesting features of the image are lost. In other cases is preferable a more smooth result. We can see in the Maximisation of activation images that the process use to keep the sharp edges even in high frequency images. 53 A B C D 2000 ’conv1_1’’pool1’’pool2’’pool3’’pool4’’pool5’ Figure 4.16: Generation of images maximising the activation of neurons at certain layer. The different columns show different number of iterations. For first 4 columns the number of iteration is different since interesting features appear at different times depending on the layer used. The lists of iterations are [layer: A,B,C,D]: [’conv1_1’: 50,100,200,300], [’pool1’: 100,250,333,450], [’pool2’: 100,300,500,800], [’pool3’: 10,20,30,50], [’pool4’: 15,25,45,80], [’pool5’: 19,33,75,170]. The unnormalized and AVE pooling version is used. The general weight applied in all cases is 1 54 iteration 20 iteration 20 normalized iteration 2000 iteration 2000 normalized ’conv3_4’’conv4_1’’conv4_2’’conv4_3’’conv4_4’ Figure 4.17: Effect of gradient normalisation in generation of images maximising the activation of neurons at certain layer. We can see that different layers represent different kind of features. The difference between the normalised and unnormalised gradient versions of the algorithm is presented. The AVE pooling network is used. The general weight applied in all cases is 1 55 A B C D 1000 ’pool4’’conv4_1’’conv4_2’’conv4_3’’conv4_4’’pool5’ Figure 4.18: Effect of MAX pooling in CNN architecture in generation of images maximising the activation of neurons at certain layer. We can see that different layers represent different kind of features. For first 4 columns the number of iteration is different since interesting features appear at different times depending on the layer used. The lists of iterations are [layer: A,B,C,D]: [’pool4’: 5, 10, 15, 50], [’conv4_1’: 3, 5, 8, 12], [’conv4_2’: 3, 6, 10, 100], [’conv4_3’: 3, 6, 11, 22], [’conv4_4’: 3, 15, 44, 100], [’pool5’: 3, 10, 66, 120]. Use normalise. General weight = 1 56 original maximisation image original auxiliary image w= 10−1w= 1 w= 101w= 102 ’pool3’’pool4’ Figure 4.19: Maximisation of activations that are present in an auxiliary image (part 1). In all the experiments the network stopped before reaching the maximum number of iterations. The number of iterations achieved are [layer: w= 10−1, w = 1, w = 101, w = 102]: [’pool3’: 6, 6, 22, 20], [’pool4’: 2, 12, 15, 15], [’pool5’: 0, 0, 0, 0]. Notice that for layer ’pool5’ the CNN did not produce a single image for w≤103 57 level 0 level 1 level 2 level 3 Figure 4.27: Effect of the finish neural network filter. All images are upscaled 2X. The level of noise reduction is different in each column. 64 Chapter 5 Discussion and conclusions 5.1 CadiArtNatura’s presentation In order to have an independent evaluation of this work from an artistic point of view I contacted a group of artists called CadiArtNatura [17]. This group share a studio in Berga, organise different artistic events and keep a permanent exposition in Espai d’Art La Duana. Most of the members of the group are painters. Some of them work professionally in art creation and teaching and the majority sell regularly their works. The responsible of organizing the expositions gave me the chance of making a presentation of this work in Espai d’Art La Duana on 15th of january. The presentation was open to everybody although it was not announced outside the artists group. I presented this work, with a brief introduction on Artificial Intelligence and Neural Networks. Some of the works produced were printed and distributed among the audience. After the presentation we had an interesting debate. The general opinion was that the works presented are art. Most people recognised that if I did not tell before the would never think that they were done by a computer. A professional painter stated that in the actual art period, that he called the Death of Art, everything is art; furthermore, the works presented can be considered even classical. Most of the assistants found very interesting the capacity of mix the shapes and textures from two images. The ones that had been working on it were amazed how easy was for the computer to do it, and the results obtained. An artist said he once tried to make a picture similar to one of the presented and remembers how difficult was to get the draft combining the ideas. Another said it could help him with one project involving a woman and a tree for which he could not find a fully satisfactory solution yet. Other artists were amazed by the process of evolving of the images. They were more focused on simplification in their work. They considered that the images formed in the early iterations were very interesting because they were just the essence of the forms. I have to recognise that I did not consider this point of view before. Some pointed to the idea of combining other painters textures to their compositions. I explained the work of A. Gatys et. al. [9]. and they found it amazing and suggested other variations. They did not find especially interesting the images formed by the excitation or suppression of neural activations. Which I consider extremely interesting because of the relation of the impressions they produce and their origin. They considered that this can be a very useful tool for making drafts for posterior paintings. This tool can allow them to try different things before starting to paint, saving a lot of time. A painting teacher said that with this tool you can do 90% of the preparation work automatically. Talking about the reactions and evaluations on specific pictures: •Most of the assistants recognised an impressionist style in “Girasols”. It liked in general to everybody. The version where it is not finished did not like so much but was also thought to be impressionist. 65 •One of the presents suggested that “Hinton by VGG” remembers Francis Bacon’s portraits. In general nobody liked it. •Some cubist influence was found in “Blue Hinton”. Artist liked it more that general public. •Approximately half of the presents recognised the shape of a nude woman in the abstract picture “Nu” (did not know the title). •Most of the public liked the game of colors in the serie “Colors” although nobody thought that the image used was the same for the three pictures. •Among the presented printed works the Public Award was undoubtedly for “Violí” (fig.5.1. Figure 5.1: Violí. The Public Award in the presentation in Espai d’Art La Duana. With this feedback I have to consider that this work raise interest in the art world beyond the academic or philosophical research. 5.2 Conclusion In the review of history and philosophy of art I remarked the importance of the representative function of art. It can be the most powerful tool in man history to encode and transmit the knowledge about the world and ourselves. It has been proven useful to represent objective and subjectives visions of reality. It can express the mathematical relations found in nature and our exaggerated ideals driven by unconscious impressions. It combines reality and well structured 66 ideas, the input of the senses and preconception of the mind. And, successfully, transmits all that to other people, being able to introduce simple concepts or to evoke feelings. Kant states that beauty is not a property of an artwork or natural phenomenon, but is instead a consciousness of the pleasure that attends the ’free play’ of the imagination and the understanding. This idea is connected to the representation the deep neural networks provide. The process of the process of creation of an artwork have been studied and a parallelism with the process of image generation described here established. The framework proposed for art creation is modular. Its elements are well defined and can be combined in multiple forms to produce different results. New elements and combinations can be created in the future to expand its possibilities. The different models can be combined in parallel or sequentially. The content model is able to produce a good reconstruction of the original image but, when deepest layers are used, it is also possible to produce free representations that stimulate the ’free play’ in our mind. The texture model provides a good representation of the textures in the original image, keeping their most important elements. It also have flexibility enough to establish a compromise with the content model mixing the information of both representations intricately. The maximisation of activations model generates striking images. The images that produce high activations of artificial neurons seem to be capable to stun human minds as well. In the other hand, they prove to be an effective visualisation of the features encoded in the neural networks and the inputs they are connected to. Even more, they can be used to compare images according to each feature level. The minimisation of activations model was already expected to show a behaviour opposite to the maximisation, but the phantasmagorical figures that appeared are amazing. All the characteristics of these images: lack of colour, edges, blurred shapes are associated with death, but the change of the shapes of the face ended in a mask of phantom. This results denote that phantoms really exist in computers’ minds, their characteristics are the ones that their neurons perceive when their activation in front of a real image is reduced. Is that true for humans as well? Do we see phantoms when our neurons slow down? And another philosophical thought: the final minimum activation is not for any colour, nor for black, nor for white, is for grey. All this results have been produced without any special training of the neural network on art. The neural network used have only been trained on natural images from ImageNet, so it does not have any specific knowledge beyond the reality. This proved to be a handicap when drawings were presented. This may be a sign that the ability to draw is not directly related to the ability to understand the images in the same way that object recognition is. To overcome this handicap a specially trained neural network have been used. This last module completes the schema that is able to generate art in a form that is similar to paintings. Here the neural networks show their capacity to encode implicit knowledge acquired during their training. After the feedback from the artists of Cadí Art Natura I feel that the algorithm and models presented are a first step in the use of the representative power of Deep Neural Networks in the creation of Artworks, and envision that it provides an exciting new tool for artists. The evaluation of the quality of the artworks presented is subjective, and all opinions are welcome. I can only say that I am satisfied. 67 68 References [1] Thomas Adajian. “The Definition of Art”. In: The Stanford Encyclopedia of Philosophy. Ed. by Edward N. Zalta. Winter 2012. 2012. [2] Francis Bacon. Three Studies for the Portrait of Henrietta Moraes. 1963. [3] Guillem Collell Mundet. Lo bello, lo estético, lo artístico. Online; accessed 27-January- 2016. May 2013. url:http://www.dobooku.com/2013/05/lo-bello-lo-estetico- lo-artistico-y-la-muerte-del-arte/. [4] Jia Deng et al. “ImageNet: A large-scale hierarchical image database”. In: Computer Vision and Pattern Recognition, 2009. CVPR 2009. IEEE Conference on. 2009, pp. 248–255. doi: 10.1109/CVPR.2009.5206848. [5] C. Dong et al. “Compression Artifacts Reduction by a Deep Convolutional Network”. In: ArXiv e-prints (Apr. 2015). arXiv: 1504.06993 [cs.CV]. [6] C. Dong et al. “Image Super-Resolution Using Deep Convolutional Networks”. In: ArXiv e-prints (Dec. 2015). arXiv: 1501.00092 [cs.CV]. [7] A. Dosovitskiy and T. Brox. “Inverting Visual Representations with Convolutional Networks”. In: ArXiv e-prints (June 2015). arXiv: 1506.02753. [8] George Dvorsky. 15 Uncanny Examples of the Golden Ratio in Nature. Online; accessed 27-January-2016. Feb. 2013. url:http : / / 2eyeswatching . com / tag / 15 - uncanny - examples-of-the-golden-ratio-in-nature/. [9] L. A. Gatys, A. S. Ecker, and M. Bethge. “A Neural Algorithm of Artistic Style”. In: ArXiv e-prints (Aug. 2015). arXiv: 1508.06576 [cs.CV]. [10] L. A. Gatys, A. S. Ecker, and M. Bethge. “Texture Synthesis Using Convolutional Neural Networks”. In: ArXiv e-prints (May 2015). arXiv: 1505.07376 [cs.CV]. [11] Hannah Ginsborg. “Kant’s Aesthetics and Teleology”. In: The Stanford Encyclopedia of Philosophy. Ed. by Edward N. Zalta. Fall 2014. 2014. [12] Paul Guyer. “18th Century German Aesthetics”. In: The Stanford Encyclopedia of Philosophy. Ed. by Edward N. Zalta. Spring 2014. 2014. [13] Priya Hemenway. “Divine Proportion: Phi In Art, Nature, and Science”. In: Sterling, 2005, pp. 20–21. isbn: 1-4027-3522-7. [14] Jana. Fibonacci: Capturing a Mathematical Enigma in Jewelry. Online; accessed 27- January-2016. Sept. 2015. url:http : / / www . enarmour . com / blog / 2015 / 8 / 18 / fibonacci-capturing-a-mathematical-enigma-in-jewelry. [15] Yangqing Jia et al. “Caffe: Convolutional Architecture for Fast Feature Embedding”. In: Proceedings of the 22Nd ACM International Conference on Multimedia. MM ’14. Orlando, Florida, USA: ACM, 2014, pp. 675–678. isbn: 978-1-4503-3063-3. doi:10.1145/2647868. 2654889.url:http://doi.acm.org/10.1145/2647868.2654889. [16] Kriegeskorte N Khaligh-Razavi S-M. “Deep Supervised, but Not Unsupervised, Models May Explain IT Cortical Representation.” In: PLoS Comput Biol (2014). url:http: //journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003915. [17] Cadi Art Natura. Espai d’Art La Duana. [18] Y. LeCun et al. “Efficient BackProp”. In: Neural Networks: Tricks of the trade. Ed. by G. Orr and Muller K. Springer, 1998. 69 [19] T.-Y. Lin and S. Maji. “Visualizing and Understanding Deep Texture Representations”. In: ArXiv e-prints (Nov. 2015). arXiv: 1511.05197 [cs.CV]. [20] T.-Y. Lin, A. RoyChowdhury, and S. Maji. “Bilinear CNN Models for Fine-grained Visual Recognition”. In: ArXiv e-prints (Apr. 2015). arXiv: 1504.07889 [cs.CV]. [21] A. Mahendran and A. Vedaldi. “Understanding Deep Image Representations by Inverting Them”. In: ArXiv e-prints (Nov. 2014). arXiv: 1412.0035 [cs.CV]. [22] A. J. Movshon and 2015. E. P. Simoncelli. Representation of naturalistic image structure in the primate visual cortex. Cold Spring Harbor Symposia on Quantitative Biology: Cognition. [23] Rafael Mujeriego. El arte clássico, Guía de estudio. Online; accessed 27-January-2016. Jan. 2010. url:http : / / www . uclm . es / ab / humanidades / profesores / descarga / mujeriego/arteclasico.pdf. [24] Nagadomi. Image Super-Resolution for anime-style Art. Online; accessed 27-January- 2016. url:https://github.com/nagadomi/waifu2x/blob/master/README.md. [25] Nagadomi. Image Super-Resolution for anime-style Art. Online; accessed 27-January- 2016. url:http://waifu2x.udp.jp/. [26] A. Nguyen, J. Yosinski, and J. Clune. “Deep Neural Networks are Easily Fooled: High Confidence Predictions for Unrecognizable Images”. In: ArXiv e-prints (Dec. 2014). arXiv: 1412.1897 [cs.CV]. [27] A. Nguyen, J. Yosinski, and J. Clune. Inceptionism, Going Deeper into Neural Networks. June 2015. url:http://googleresearch.blogspot.com.es/2015/06/inceptionismgoing-deeper-into-neural.html. [28] M. O. Riedl. “The Lovelace 2.0 Test of Artificial Creativity and Intelligence”. In: ArXiv e-prints (Oct. 2014). arXiv: 1410.6142 [cs.AI]. [29] K. Simonyan, A. Vedaldi, and A. Zisserman. “Deep Inside Convolutional Networks: Visualising Image Classification Models and Saliency Maps”. In: ArXiv e-prints (Dec. 2013). arXiv: 1312.6034 [cs.CV]. [30] K. Simonyan and A. Zisserman. “Very Deep Convolutional Networks for Large-Scale Image Recognition”. In: CoRR abs/1409.1556 (2014). [31] Mike Smith. The Golden Ratio. Online; accessed 27-January-2016. Apr. 2015. url:http: //www.kmcreate.co.uk/the-golden-ratio.html. [32] Luc Viatour. Da Vinci Vitruve. Online; accessed 27-January-2016. url:www.Lucnix.be. [33] Pollio Vitruvius. The Ten Books on Architecture. Trans. by Morris Hicky Morgan. Courier Dover Publications, 1960. isbn: 0-486-20645-9. [34] David S. Whitley. “Cave Paintings and the Human Spirit: The Origin of Creativity and Belief”. In: Prometheus, 2009, p. 35. isbn: 978-1-59102-636-5. [35] Wikipedia. Cave painting Wikipedia, The Free Encyclopedia. Online; accessed 27-January- 2016. url:https://en.wikipedia.org/w/index.php?title=Cave_painting&oldid= 701838938. [36] Laboratorio Cadius en Zaragoza. Diseño esquemático del mundo en la Edad Media. Online; accessed 27-January-2016. Jan. 2007. url:http://pasapues.blogia.com/2007/ 011901-laboratorio-cadius-en-zaragoza-sobre-cartografia-medieval.-i.php. [37] Ciyou Zhu et al. “Algorithm 778: L-BFGS-B: Fortran Subroutines for Large-scale Boundconstrained Optimization”. In: ACM Trans. Math. Softw. 23.4 (Dec. 1997), pp. 550–560. issn: 0098-3500. doi:10.1145/279232.279236.url:http://doi.acm.org/10.1145/ 279232.279236. 70 Appendix A Selection of artworks produced 71 Figure A.1: Hinton by VGG. 72 Figure A.2: Blue Hinton. 73 Figure A.9: Daisy Hinton. 80 Figure A.10: MAX3. 81 Figure A.11: Fantasma. 82 Figure A.12: Hinton color. 83 Figure A.13: Violí. The Public Award in the presentation in Espai d’Art La Duana. 84 Figure A.14: Feelings1. 85 Figure A.15: Feelings2. 86 Figure A.16: Feelings3. 87 Figure A.17: Girasols. 88