Robot Art 2017 - Top Technical Contributor
CloudPainter used deep learning, various open source AI, and some of our own custom algorithms to create 12 paintings for the 2017 Robot Art Contest. The robot and its software was awarded the Top Technical Contribution Award while the artwork it produced recieved 3rd place in the aesthetic competition. You can see the other winners and competitors at www.robotart.org.
Below are some of the portraits we submitted.
We chose to go an abstract route in this year's competition by concentrating on computational abstraction. But not random abstraction. Each image began with a photoshoot, where CloudPainter's algorithms would then pick a favorite photo, create a balanced composition from it, and use Deep Learning to apply purposeful abstraction. The abstraction was not random but based on an attempt to learn from the abstraction of existing pieces of art whether it was from a famous piece, or from a painting by one of my children.
Full description of all the individual steps can be seen in the following video.
NVIDIA GTC 2017 Features CloudPainter's Deep Learning Portrait Algorithms
CloudPainter was recently featured in NVIDIA's GTC 2017 Keynote. As deep learning finds it way into more and more applications, this video highlight some of the more interesting applications. Our ten seconds comes around 100 seconds in, but I suggest watching the whole thing to see where the current state of the art in artificial intelligence stands.
Hello7Bot - A Tutorial to get 7Bot Moving
Couple of people have asked for how I got my 7Bots running. Writing this tutorial to demonstrate how I got their example code working. Will also be giving all the code I used to run my 7Bots in the Robot Art 2017 Contest. Hopefully this tutorial is helpful, but if it isn't, email me with any issues and I will try and respond as quickly as possible, maybe even immediately.
So here is quick list of steps in this tutorial:
1: Get your favorite PC or Mac.
2: Plug 7Bot into your computer.
3: Make sure Arduino Due is installed on 7Bot
4: Install Processing3 to run code.
5: Download 7Bot example code.
6: Open 7Bot example code in Processing3.
7: Make minor configuration adjustments.
8: Run the example code in Processing3.
9: Watch 7Bot come to life.
10: Experiment with my 7Bot code.
In more detail:
Step 1: Go on your favorite PC (Windows or Mac, maybe Linux?)
Simple Enough. Pretty sure it will also work on Linux, but I haven't tried it.
Step 2: Plug 7Bot into Computer and Electrical Socket
Use USB cable to plug 7Bot into your computer.
Also make sure 7Bot is plugged into external power source.
To see if it has power, hit the far left of the three buttons on the back of the robot. It should go to the default ready position as seen below.
Step 3: (OPTIONAL) If 7Bot is acting weird Make sure Drivers for the Arduino Due Are Installed
This step may or may not be needed and I am currently working to get to bottom of why this tutorial works for some 7Bots and not others. My 7Bots came with drivers for the Arduino Due pre-installed, though I have heard of of 7Bots where it sounds like they are not. If you think your 7Bot has already been set up you can proceed. If not try one of the two following strategies to figure out if 7Bot is ready to go..
1: Download the GUI at http://www.7bot.cc/download and try using it to get your 7Bot moving.
2: Download Getting_Started_with_Bot_v1.0.pdf and make sure Arduino Due drivers are installed from its instructions.
Step 4: Download Processing3
Processing3 is a java based development environment that is pretty straight forward if you are familiar with any of the major languages.
Download it here and install it.
Step 5: Download 7Bot Example Code
Go to github and clone their example code from the following repo.
If you are unfamiliar with github or just want the zip file, here take this.
Step 6: Open Example Code in Processing3
Go to the Arm7Bot_Com_test.pde example file you got earlier and open it.
It will ask you how to open the code, so specify the location of wherever you put the processing.exe file.
When it opens up in Processing3 it will look something like this.
Step 7: Make Minor Configuration Adjustments.
Early in the code you will find the following lines
// Open Serial Port: Your should change PORT_ID accoading to
// your own situation.
// Please refer to: https://www.processing.org/reference/libraries/serial/Serial.html
int PORT_ID = 3;
Change the PORT_ID to match the one you plugged 7Bot into. You can refer to the documentation shown, use trial and error, or find yours by adding the following line of code and running the program...
// List all the available serial ports:
printArray(Serial.list());
When I ran this, I saw the following...
[0] "/dev/cu.Bluetooth-Incoming-Port"
[1] "/dev/cu.Bluetooth-Modem"
[2] "/dev/cu.usbmodem1411"
[3] "/dev/tty.Bluetooth-Incoming-Port"
[4] "/dev/tty.Bluetooth-Modem"
[5] "/dev/tty.usbmodem1411"
And set the Port_ID to the first usb port, 2.
int PORT_ID = 2; //PINDAR - CHANGED FROM int PORT_ID = 3;
Step 8: Run the Code in Processing
Hit the Play Button in the top left hand corner of Processing3, and a small window should open and the robot should start moving.
Step 9: Watch 7Bot come to life.
Or not. Well it should start moving, but if it doesn't, first thing to try changing is the Port in Step 7. If that doesn't work contact me and I will try and work with you to get it running. Then I will update this blog so that next person doesn't have same problem you had.
Step 10: Have fun with my Robot Art 2017 Code
The example code from 7Bot is well documented and shows you how to do all sorts of cool things like recording the robots movements and then playing it back. I learned most of the code I used in the Robot Art 2017 contest by reverse engineering this example.
If you want to see my code, here is a version that has some of the extra functionality like easier to use inverse kinematics. But if you clone this repo, no judging my coding style. I like comments and leaving lots of them in as a history of what I was doing earlier in the process. Never know when I might need to reference them or revert. I know that is what version control is for, but I leave comments everywhere anyways. Hey. You promised you wouldn't judge!
Hope this tutorial works out for you. As mentioned earlier, write with any issues and I will try to clarify within 24 hours, maybe even immediately. 7Bot is awesome and I hope this tutorial helps you get it running.
Pindar
Elastic{ON} 17
Just finished with a busy week at Elastic{ON} 17 where we had a great demo of our latest painting robot. One of the best things to come of these exhibitions is the interaction with the audience. We can get better sense of what works as part of the exhibit as well as what doesn't.
Our whole exhibition had two parts. The first was a live interactive demo where one of our robots was tracking a live elastic index of conference attendee's wireless connections and painting them in real time. The second was an exhibition of the cloudpainter project where Hunter and I are trying to teach robots to be creative.
A wall was set up at the conference where we hung 30 canvases. Each 20-30 minutes, a 7Bot robotic arm painted dots on a black canvas. The location of the dots were taken from the geolocation of 37 wireless access points within the building.
There are lots of ways to measure the success of an exhibit like this. The main reason we think that it got across to people, though, was the shear amount of pictures and posts to social media that was occurring. There was a constant stream of interested attendees and questions.
Also, the exhibition's sponsors and conference organizers appeared to be pleased with the final results as well as all the attention the project was getting. At the end of two days, approximately 6,000 dots had been painted on the 30 canvases..
Personal highlight for me was fact that Hunter was able to join me in San Francisco. We had lots of fun at conference and were super excited to be brought on stage during the conference's closing Q&A with the Elastic Founders.
Will leave you with a pic of Hunter signing canvases for some of our elastic colleagues.
cloudpainter AI described in a Single Graphic
I always struggle to describe all the AI behind cloudpainter. It is all over the place. The following graphic that I put together for my Elastic{ON} 17 Demo sums it up pretty well. While it doesn't include all the algorithms, it features many of my favorite ones.
cloudpainter at Elastic{ON} 17
Less than half an hour ago I wrote about how I am on my way the first annual TensorFlow Dev Summit at Google HQ. There is more. While in Mountain View I will also be stopping by elastic HQ to discuss an upcoming booth that cloudpainter has been invited to have at Elastic{ON} 2017.
For the booth I have prepped 5 recreations of masterpieces as well as a new portrait of Hunter based on many of my traditional AI applications. Cool thing about this data set is that I have systematically recorded every brush stroke that have gone into the masterpieces and stored them in an elasticsearch database.
Why? I don't know. Everything is data - even art. And I am trying to reverse engineer the genius of artists such as da Vinci, Van Gogh, Monet, Munch, and Picasso. I have no idea what it will tell us about their art work, or how it will help us decipher the artistry. I am just putting the data out there for the data science community to help me figure it out. The datasets of each an every stroke will be revealed during Elastic{ON} on March 7th. Until then here is a sneak peak at the paintings my robots made.
TensorFlow Dev Summit 2017
About two months ago I applied to go to Google's first annual TensorFlow Dev Summit. I sent in the application and forgot about it. After a month I figured that I did not get an invite. Then about a week ago, the invite came in. Turns out only one in ten applicants were invited to the conference. I have no idea what criteria they used to select me, but I am currently on plane to Mountain View excited to talk with the TensorFlow team and see what other developers are doing with it.
The summit will be broadcast live around the world. Here is a link. Look for me in the crowd. I will have a grey pullover on.
Our First Truly Abstract Painting
Have had lots of success with Style Transfer recently. With the addition of Style Transfer to some of our other artificially creative algorithms, I am wondering if cloudpainter has finally produced something that I feel comfortable calling a true abstract painting. It is a portrait of Hunter.
In one sense, abstract art if easy for a computer. A program can just generate random marks and call the finished product abstract. But that's not really an abstraction of an actual image, its the random generation of shapes and colors. I am after true abstraction and with Style Transfer, this might just be possible.
More details to come as we refine the process, but in short the image above was created from three source images, seen in the top row below, and image of Hunter, his painting, and Picasso's Les Demoiselles d Avignon.
Style Transfer was applied to the photo of Hunter to produce the first image in the second row. The algorithm tried to paint the photo in the style of Hunter's painting. The second image in the second row is a reproduction of Picasso's painting made and recorded by one of my robots using many of its traditional algorithms and brush strokes by me.
The final painting in the final row was created by cloudpainter's attempt to paint the Style Transfer Image with the brush strokes and colors of the Picasso reproduction.
While this appears like just another pre-determined algorithm that lacks true creativity, the creation of paintings by human artists follow a remarkably similar process. They draw upon multiple sources of inspiration to create new imagery.
The further along we get with our painting robot, I am not sure if we are less creative than we think, or computers are much more so than we imagined.
Hunter's Portrait
Inspired by our trip to the National Portrait Gallery, we started thinking to ourselves, what's so impressive about making our robot's paint like a famous artist. Sure they are inspirational and a lot can be learned from them, but when you think about it, people are more interested in the art of their loved ones.
So this morning, Hunter and I decided to do quick portraits of each other and then run the portraits through deep neural nets to see how well they applied to a photo we took of each other. As soon as we started, Corinne joined in so here is obligatory photo of her helping out.
Also in the above photo you can see my abstract portrait in progress.
Below you can see the finished paintings and how they were applied to the photos we took. If you have been following this blog recently, you will know that the images along the top are the source images from which style is taken and applied to the photos on the left. This is all being done via Style Transfer and TensorFlow. Also I should note that the painting on left is mine, while Hunter's is on right.
Most interesting thing about all this is that the creative agent remains Hunter and I, but still something is going on here. For example even though we were the creative agents, we drew some of our stylistic inspiration from other artist's paintings that we saw at the National Portrait Gallery yesterday. Couldn't a robot do something similar?
More work to be done.
Inspiration from the National Portrait Gallery
One of the best things about Washington D.C. is its public art museums. There are about a dozen or so world class galleries where you are allowed to take photos and use the work in your own art, because after all, we the people own the paintings. Excited by the possibilities of deep learning and how well style transfer was working, the kids and I went to the National Portrait Gallery. for some inspiration.
One of the first things that occurred to us was a little inception like. What would happen if we applied style transfer to a portrait using itself as the source image. It didn't turn out that well, but here are a couple of those anyways.
While this was idea of a dead end, the next idea that came to us was a little more promising. Looking at the successes and failures of the style transfers we had already performed, we started noticing that when the context and composition of the paintings matched, the algorithm was a lot more successful artistically. This is of course obvious in hindsight, but we are still working to understand what is happening in the deep neural networks, and anything that can reveal anythign about that is interesting to us.
So the idea we had, which was fun to test out, was to try and apply the style of a painting to a photo that matched the painting's composition. We selected two famous paintings from the National Portrait Gallery to attempt this, de Kooning's JFK and Degas's Portrait of Miss Cassatt. We used JFK on a photo of Dante with a tie on. We also had my mother pose best she can to resemble how Cassatt was seated in her portrait. We then let the deep neaural net do its work. The following are the results. Photo's courtesy of the National Portrait Gallery.
Farideh likes how her portrait came out, as do we, but its interesting that this only goes to further demonstrate that there is so much more to a painting than just its style, texture, and color. So what did we learn. Well we knew it already but we need to figure out how to deal with texture and context better.
Applying Style Transfer to Portraits
Hunter and I have been focusing on reverse engineering the three most famous paintings according to Google as well as a hand selected piece from the National Gallery. These art works are The Mona Lisa, The Starry Night, The Scream, and Woman With A Parasol.
We also just recently got Style Transfer working on our own Tensor Flow system. So naturally we decided to take a moment to see how a neural net would paint using the four paintings we selected plus a second work by Van Gogh, his Self-Portrait (1889).
Below is a grid of the results. Across the top are the images from which style was transferred, and down the side are the images the styles were applied to. (Once again a special thanks to deepdreamgenerator.com for letting us borrow some of their processing power to get all these done.)
It is interesting to see where the algorithm did well and where it did little more than transfer the color and texture. A good example of where it did well can be seen in the last column. Notice how the composition of the source style and the portrait it is being applied to line up almost perfectly. Well as could be expected, this resulted in a good transfer of style.
As far as failure. it is easy to notice lots of limitations. Foremost, I noticed that the photo being transferred needs to be high quality for the transfer to work well. Another problem is that the algorithm has no idea what it is doing with regards to composition. For example, in The Scream style transfers, it paints a sunset across just about everyone's forehead.
We are still in processing of creating a step by step animation that will show one of the portraits having the style applied to it. It will be a little while thought cause I am running it on a computer that can only generate one frame every 30 minutes. This is super processor intensive stuff.
While processor is working on that we are going to go and see if we can't find a way to improve upon this algorithm.
Channeling Picasso with Style Transfer and Google's TensorFlow
We are always jumping back and forth between hardware and software upgrades to our painting robot. This week it's the software. Pleased to report that we now have our own implemention of Dumoulin, Shlens, and Kudlar's Style Transfer. This of course is the Deep Learning algorithm that allows you to recreate content in the style of a source painting.
The first image that we successfully created was made by transferring the style of Picasso's Guernica into a portrait of me in my studio.
So here are the two images we started with.
And the following is the image that the neural networks came up with.
I was able to get this neural net working thanks in large part to the step-by-step tutorial in this amazing blog post by LO at http://www.chioka.in/tensorflow-implementation-neural-algorithm-of-artistic-style. Cool thing about the Deep Learning community, is that I found half a dozen good tutorials. So if this one doesn't work out for you, just search out another.
Even cooler though, is that you don't even need to set up your own implementation. If you want to do your own Style Transfers, all you have to do is head on over to the Deep Dream Generator at deepdreamgenerator.com. On this site you can upload pictures and have their implementation generate your own custom Style Transfers. There is even a way to upload your own source images and play with the settings.
Below is a grid of images I created on the Deep Dream Generator site using the same content and source image that I used in my own implementation. In them, I played around with the Style Scale and Style Weight settings. Top row has Scale set to 1.6, while second row is 1, and third is 0.4. First column has the Weight set to 1, while second is at 5 and third is at 10.
So while I suggest you go through the pains of setting up your own implementation of Style Transfer, you don't even have to. Deep Dream Generator lets you perform 10 style transfers an hour.
For us on the other hand, we need our own generator as this technology will be closely tied into all robot paintings going forward.
Capturing Monet's Style with a Robot
As we gather data in an attempt to recreate the style and brushstroke of old masters with Deep Learning, we thought we would show you one of the ways we are collecting data. And it is pretty simple actually. We are hand painting brushstrokes with a 7BOT robotic arm and recording the kinematics behind the strokes. It is a simple trace and record operation where the robotic arms position is recorded 30 times a second and saved to a file.
As can be seen in the picture above, all Hunter had to do was trace the brush strokes he saw in the painting. He did this for a number of colors and when he was done, we were able to play the strokes back to see how well the robot understood our instructions. As can be seen in the following video, the playback was a disaster. But that doesn't matter to us that much. We are not interested in the particular strokes as much as we are in analyzing them for use in the Deep Learning algorithm we are working on.
Woman With A Parasol is the fourth Masterpiece we have begun collecting data for. As this is an open source project, we will be making all the data we collect public. For example, if you have a 7Bot, or similar robotic arm with 7 actuators, here are the files that we used to record the strokes and make the horrible reproduction.
Selecting Masterpieces to Recreate with Our Robot
Spent afternoon with Hunter exploring the National Gallery of Art to decide on the next masterpiece we are going to recreate and analyze with our robot. Saw the da Vinci, many Van Gogh's, and lots of other paintings before being drawn to Monet. And as we looked around at several Monets, it became obvious that he had a special artistic style that would lend itself well to replication by our robot and Deep Learning algorithms. In the end Hunter and I decided on the painting the artwork on the left below - Monet's "Woman with a Parasol."
Now if we could somehow program our robots to capture and paint the wind across her face like Monet did. Wow, that would be amazing.
Brushstroke Maps for Three Famous Paintings
When you Google "Famous Artwork" a list of paintings is revealed, and at the top of that list is da Vinci, Van Gogh, and Munch. Here is a picture of the top ten actually...
Now that we have a stroke map of the Mona Lisa and The Scream, we decided to round up the top three by creating a mapping of The Starry Night. Interestingly, The Starry Night is probably one of the best examples of the importance of brushstrokes in a painting. There is nothing but flow in it. And a major part of the composition is the movement made by the direction of the strokes.
If we could somehow capture how Van Gogh used his strokes, well thats impossible, but if we could at least learn something from them. Well we will never know until we try.
As of 7:00 PM January 8, 2017, cloudpainter has just barely begun to explore the strokes of Van Gogh's The Starry Night. We realize these first strokes are rudimentary, but its just laying down a background. Over the next several days we will attempt to copy as many of the strokes with as much detail as possible. These will be stored in an Elasticsearch database and shared for anyone to use in attempts to deconstruct Van Gogh's brushstroke.
Stroke Maps, TensorFlow, and Deep Learning
Just completed recreations of The Scream and The Mona Lisa. These are not meant to be accurate reproductions of the paintings, but an attempt at recreating how the artists painted each stroke. The Idea being that once these strokes are mapped, TensorFlow and Deep Learning can use the data to make better pastiches.
Work Continues Mapping the Brushstrokes of Famous Masterpieces
Once I created a brushstroke map of Edvard Munch's The Scream, I thought it would be cool to have brush stroke mappings for more iconic artworks. So I googled "famous paintings" and was presented with a rather long list. Interestingly The Scream was in the top three along with da Vinci's Mona Lisa and Van Gogh's Starry Night. Well, why not do the top three. So work has begun an creating a stroke map for The Mona Lisa. In the following image, the AI has taken care of laying down an underpainting, or what would have been called a cartoon in da Vinci's time.
I am now going into it by hand and finger-swiping my best guess as to how da Vinci would have applied his brushstrokes. Will post the final results as well as provide access to the Elasticsearch database with all the strokes as soon as it is finished. My hope is that the creation of the brushstroke mappings can be used to better understand these artists, and how artists create art in general.
A Deeper Learning Analysis of The Scream
Am a big fan of what The Google Brain Team, specifically scientists Vincent Dumoulin, Jonathon Shlens, and Majunath Kudlar, have accomplished with Style Transfer. In short they have developed a way to take any photo and paint it in the style of a famous painting. The results are remarkable as can be seen in the following grid of original photos painted in the style of historical masterpieces.
However, as can be seen in the following pastiches of Munch's The Scream, there are a couple of systematic failures with the approach. The Deep Learning algorithm struggles to capture the flow of the brushstrokes or "match a human level understanding of painting abstraction." Notice how the only thing truly transferred is color and texture.
Seeing this limitation, I am currently attempting to improve upon Google's work by modeling both the brushstrokes and abstraction. In the same way that the color and texture is being successfully transferred, I want the actual brushstrokes and abstractions to resemble the original artwork.
So how would this be possible? While I am not sure how to achieve artistic abstraction, modeling the brushstrokes is definitely doable. So lets start there.
To model brushstrokes, Deep Learning would need brushstroke data, lots of brushstroke data. Simply put, Deep Learning needs accurate data to work. In the case of the Google's successful pastiches (an image made in style of an artwork), the data was found in the image of the masterpieces themselves. Deep Neural Nets would examine and re-examine the famous paintings on a micro and macro level to build a model that can be used to convert a provided photo into the painting's style. As mentioned previously, this works great for color and texture, but fails with the brushstrokes because it doesn't really have any data on how the artist applied the paint. While strokes can be seen on the canvas, there isn't a mapping of brushstrokes that could be studied and understood by the Deep Learning algorithms.
As I pondered this limitation, I realized that I had this exact data, and lots of it. I have been recording detailed brushstroke data for almost a decade. For many of my paintings each and every brushstroke has been recorded in a variety of formats including time-lapse videos, stroke maps, and most importantly, a massive database of the actual geometric paths. And even better, many of the brushstrokes were crowd sourced from internet users around the world - where thousands of people took control of my robots to apply millions of brushstrokes to hundreds of paintings. In short, I have all the data behind each of these strokes, all just waiting to be analyzed and modeled with Deep Learning.
This was when I looked at the systematic failures of pastiches made from Edvard Munch's The Scream's, and realized that I could capture Munch's brushstrokes and as a result make a better pastiche. The approach to achieve this is pretty straight forward, though labor intensive.
This process all begins with the image and a palette. I have no idea what Munch's original palette was, but the following is an approximate representation made by running his painting through k-means clustering and some of my own deduction.
With the painting and palette in hand, I then set cloudpainter up to paint in manual mode. To paint a replica, all I did was trace brushstrokes over the image on a touch screen display. The challenging part is painting the brushstrokes in the manner and order that I think Edvard Munch may have done them. It is sort of an historical reenactment.
As I paint with my finger, these strokes are executed by the robot.
More importantly, each brushstroke is saved in an Elasticsearch database with detailed information on its exact geometry and color.
At the conclusion of this replica, detailed data exists for each and every brushstroke to the thousandth of an inch. This data can then be used as the basis for an even deeper Deep Learning analysis of Edvard Munch's The Scream. An analysis beyond color and texture, where his actual brushstrokes are modeled and understood.
So this brings us to whether or not abstraction can be captured. And while I am not sure that it can, I think I have an approach that will work at least some of the time. To this end, I will be adding a second set of data that labels the context of The Scream. This will include geometric bounds around the various areas of the painting and be used to consider the subject matter in the image. So while The Google Brain Team used only an image of the painting for its pastiches, the process that I am trying to perfect will consider the the original artwork, the brushstrokes, and how brushstroke was applied to different parts of painting.
Ultimately it is believed that by considering all three of these data points, a pastiche made from The Scream will more accurately replicate the style of Edvard Munch.
So yes, these are lofty goals and I am getting ahead of myself. First I need to collect as much brushstroke data as possible and I leave you now to return to that pursuit.
Full Visibility's Machine Learning Sponsorship
Wanted to take a moment to publicly thank cloudpainter's most recent sponsor, Full Visibility.
Full Visibility is a Washington D.C. based software consulting boutique that I have been lucky enough to become closely associated with. Their sponsorship arose from a conversation I had with one of their partners. Was telling him how I finally thought that Machine Learning, which has long been an annoying buzzword, was finally showing evidence of being mature. Next thing I knew Full Visibility bought a pair of mini-supercomputers for the partner and I to experiment with. One of the two boxes can be seen in the picture of my home based lab below. It's the box with the cool white skull on it. While nothing too fancy, it has about 2,500 more cores than any other machine I have ever been fortunate enough to work with. The fact that private individuals such as myself can now run ML labs in their own homes, might be the biggest indicator that a massive change is on the horizon.
Full Visibility joins the growing list of cloudpainter sponsors which now includes Google, 7Bot, RobotArt.org, 50+ Kickstarter Backers, and hundreds of painting patrons. I am always grateful for any help with this project that I can get from industry and individuals. All these fancy machines are expensive, and I couldn't do it without your help.
Pindar Van Arman
cloudpainter Hardware Complete - 2 Robotic Arms and 5 Airbrushes
cloudpainter, as we currently imagine it, will have two 7bot robotic arms and five airbrushes on our Neural Jet painthead. The canvas will be on a track and move up and down between the painting tools.
We are thinking that when a painting begins, the Neural Jet will use its airbrushes to paint a quick background.
Then the canvas will be moved up to an area where the robotic arms can use artist brushes to touch up the painting. If it needs more airbrushing, it will move back to that area, back and forth as needed.
There is still a lot of fine tuning we need to make to the hardware to make all of this possible. But at least we now know the direction we are heading in and we can begin to write the software.