Sunday, February 12, 2017

RailsConf 2016 - Postcards from GorbyPuff by Aja Hammerly




##########################################
(upbeat music).
(train whistle).
- So, welcome to my talk. This is Postcards from Gorby Puff. Y'all who are in here have decided that you'd rather laugh and learn some things than go to the other talks right now and I approve of that choice. I'm Aja, I'm thagomizer on GitHub, and all the code for this talk is in my examples repo already, under RailsConf16..
I tweet @thagomizer_rb. I really like it when people tweet at me during my talks. My phone is somewhere over there, so it won't interfere with the mic or interrupt me when I'm talking, and it definitely won't pop up, I'm offline..
My blog is thagomizer.com, the slides for this talk are also up there if you want to follow along on your own laptop. And I really like dinosaurs. So I work for Google Cloud Platform. We're going to have a workshop tomorrow afternoon in the Workshops track, if you want to check out our stuff, want some time to just work through stuff with some folks who know the platform better sitting around, that's a great way to do it, we'll help you out. We're also going to have a booth, you should totally come by, ask us our questions, get free stuff, because that's why people have booths is to give out free stuff. If you're one of those people who doesn't like actually talking to people face to face, I know there's some of you, check out our Slack, we have a Ruby room. Several of the folks are going to be working the booth and some folks who weren't able to make it to the conference, hang out in that room, we can answer questions, get you hooked up..
Because I work for a big company, I have to have this slide. Lawyer Cat says: Any code in this talk is copyright Google.
And licensed Apache V2. Oh, and by the way, if you didn't notice, this is the cat pictures talk. There's probably an equal amount of cat pictures and code. OK, so who knows who this is? So that's Gorby..
He belongs to this character who also lives in Seattle, and is lovely and is giving the keynote on Friday morning, I believe, and you should totally go to it, because it currently contains less pictures of Gorbachev than this talk..
I stole them all for this conference. Gorby was mad that he couldn't come with Tenderlove to RailsConf, so he decided to set off on a world tour of his very own. So in the spirit of 1980's educational software, where in the world is Gorby Puff? He's going to be leaving us some clues in the form of postcards. I had an argument with someone. Who gets the joke that I'm making here and the computer program that I'm alluding to, raise your hands..
OK, enough of you,.
That's all I cared about. So, first clue..
This kind of statue thing. And this postcard, so here's the back of it. Gorby Puff's hanging out with his new stone friend. Tells me that cars are high in iron. It's made to figure out where Gorby is. Where is Gorby?.
Much like in that quintessential '80s computer game,.
We have access to a super problem solving computer, only ours is called Google, and we're going to be using Google Cloud Vision for this. Google Cloud Vision is a web API that can label landmarks, faces, does face detection, doesn't tell you who they are, just tells you it's a face. Text, they can also label a large variety of things. I'm going to go while the going's good. It can label a large.
Variety of things in images. It can also find adult content of various sorts, if that is a thing that is relevant to you,.
Either not having or having for whatever your website might be. I'm also going to be.
Using the G Cloud gem. If you've tried using Google APIs before with our programmatically generated gem and you had a bad time, I recommend you come back and try G Cloud. This is by Rubyists for Rubyists, it's hand coded..
If you know Mike Moore or Chris Smith, who are in Utah, Mike ran the Mountain West X Conferences. They are the ones who are working on this, and they've done a fantastic job. It really feels natural. Here's the code that you need to look at that postcard from Gorby. I'm going to walk through it, so we're going to require the gem. We're going to be using Vision, so I'm going to require Cloud Vision. Create a new G Cloud object. I'm specifying two arguments here. One is the project,.
Which is just a way of organizing your resources inside Google Cloud..
And the other is a private key that lets me authenticate into that project..
Partly this is for billing. Sadly, Vision is not free. Cloud Vision is not free. Going to create a Vision object, and then I'm going to pull an image. I'm pulling this image off the local disk, but you could also pull it from a web store.
Of some sort or another. Then this is the line that does all the magic. I'm calling annotate on the Vision API, passing it the image, and I'm telling it that I want to find one landmark. Because really seemed like there was only one in that picture. To find something,.
I'm going to print out the description using puts, then I'm also going to print out the location, which is going to give me the lat long. Because yes, from the picture, it can tell you what it is and where it is. Because it's been a while, that's what the image looked like. And this is what comes out. It actually knows that that's the Fremont Troll. The Fremont Troll happens to be about three blocks from the Google Seattle offices. If you've seen the movie, "10 Things I Hate About You," you have seen this troll. It plays a fairly large part in that movie..
So where in the world is Gorbachev? Gorbachev is right here. So we get in our little virtual eight bit plane, and we fly, and we get there. And there's a guy sitting around, he says, "A grumpy cat gave me something for you." I'm like, "Well, this grumpy cat?" "Yeah, yeah, that grumpy cat." And he gave us this postcard. And the guy mentioned to me that he wanted to hang out with this creature. He was very jealous of how not flat its face was. So here's the back of this one. Is it a dog? Is it a rat? It has such a pointy face. Got to figure out what kind of animal this is to come find me..
So we're going to use the label detection in Google Cloud Vision this time. This can label all sorts of things, like animals, including breeds on dogs and cats, especially if they're pretty distinctive breeds, modes of transportation, types of structures,.
And all sorts of other really cool stuff. To give you some examples, those are my cats..
This was taken about a week ago, we were hanging out on the deck. I wanted to run this through Cloud Vision to see what it would label it. These are the labels it gave me. It said, those are cats, they're probably pets. One of them is kind of black, actually the big thing that's black in that.
Is the plastic cover on my planters. There are mammals in that picture, which is interesting, it meant that there are animals in that picture, they're probably playing. They're small to medium sized cats. There's a tabby cat,.
My cat Nick is a tabby, and so on, cat like mammal. It was a little less certain on that. One of the things that it does that I'm not showing you is that whenever it.
Does any of these labels it gives you a percentage certainty how confident it is that a given label applies. It was a little less.
Confident on cat like mammal. But here's another one, entirely different..
This is a picture I took while skiing. And these are the labels it came up with, snow, mountain, weather, piste, winter, geological phenomenon, season, and adventure. Since that's at Double Black Diamond, I was pretty happy with the label of adventure. One of the things I wanted to point out is if you look at this picture, we think of snow, and we think of snow as being white. There's actually very, very little white in this picture because of the way the lighting worked out..
But Cloud Vision,.
Because it uses machine learning techniques,.
Was able to figure out that this was snow. You mean, you think of snow, you think of snowmen. It's really cool that it's that powerful. In the third example, some buses. It says, yeah, there's a transport, they're buses. Not only are they buses, they're double decker buses. Probably a tour bus service, maybe commercial vehicles. Engine, yes, there's probably an engine involved in a bus. But I was able to do all this, and I was able to do it with really, really small amounts of code, specifically, this amount of code. That right there is seven lines, including the require. So it's basically the same setup as before, and the only line that changes is this magic line. Instead of asking it.
To look for landmarks, I'm going to ask it to look for labels. I want to be clear that I'm using a not fully released.
Version of the library yet. You can grab it off GitHub, it's in the public repo. When they finally integrate it fully into the gem, they're going to make it so all you have to do is say annotate,.
And it will find all the interesting stuff for you. Then because I don't have just a single landmark, I'm going to iterate over the labels that it found, I'm just going to print them out. Back to that postcard we had. What the heck is it?.
Some of you probably.
Have a pretty good guess. I'm guessing some of you have no idea what the heck this is. Turns out, it's a wombat. Cloud Vision was successfully able to identify wombat. I tried it with a pangolin, if you know what a pangolin is, it thought it was a.
Turtle or an armadillo, which is actually a fair amount what a pangolin looks like, so I'm not actually all that sad about that..
Figured out a wombat pretty confidently, I believe it was 93 percent confident that this was a wombat. So get in our eight bit plane again, we're going to fly to Australia. We meet someone who says this. "I saw a cat matching that description. "He told me to give you this." Here's another postcard from Gorby Puff. This is some sort of sign in some language that I don't currently speak. On the back of it is, Tenderlove left me a list of countries he likes to visit that was laying around the apartment. Do you have any idea what this sign says? Let's see if we can..
So I mentioned the fact that we can do text detection. The technical term for this is optical character recognition. What this does is it will find things that are characters in the images, and it'll figure out.
What character they are. The really cool thing is it will also figure out what language they are likely to be in. So, same setup as before. Only line that changes, instead of looking for labels or landmarks,.
We look for text..
Then we print out the text, and I also want to print out what locale. The idea of a locale is a combination of a language and a place. So countries that have multiple official languages will have multiple official locales. Countries that only have one official language only have one locale. We'll see what that is, we'll get that information so we can figure out where Gorby has gone off to this time. So here's the picture again. Here's the text that comes back. It's not great, it's not particularly accurate. OCR is actually really hard, especially off of images. If you have an image.
That is neatly lined up, and you're using Roman characters, there's been a lot more training on those kinds of data sets, and so it tends to work better. But I'm using a non-Western character set here..
You'll notice the locale came back as JA, which is for Japan, not surprising. Tenderlove likes to go to Japan, he speaks Japanese, not surprising that Gorby would try to figure out where his owner has been going off to all these times. But I don't actually speak Japanese, so let's figure out.
What I can do with this. So who's used Google Translate? Yeah, who's done the trick where you take a thing and you put it through Google Translate from one language to another to another to another and play like the crazy game of Telephone? Yeah, me too..
That's awesome..
I'm going to show you how to do that programmatically now. There's support for.
Translate in the G Cloud gem. This is all you have.
To do to run something through Translate..
Make a new G Cloud object, creating a Translate object from that, and then running some Translate text through. I'm going to point out that the from argument is completely and utterly optional. It can usually guess pretty well just based on the characters. But since I have the locale, I'm going to throw it in, because it will increase the likelihood that my translation is correct. If you've used Translate, you know that it's doing its best. Human language is a really, really, really hard problem. While it gets really close and you can generally get the gist, sometimes it needs a little bit of help. So this is what comes back from Translate, just the straight out text. There was a bunch of text in that image. This isn't just that sign, there was actually text on some of the buildings and stuff in the background as well that it got pulled in. But I know that Gorby's at a flower garden,.
And he's playing in a beach. You know, he's a cat, giant sandbox, this seems to make sense. So let's go catch up with Gorby, see what he's doing. Eight bit plane..
Someone says, "The cat you were looking for was here. "He's been hitting the books." Yes..
The best part of this talk was going through Gorby's Tumblr, because he has a Tumblr and a Twitter. He has more Twitter followers than I do. It's actually in my goals for this year, social company goals is get more Twitter followers than Gorbachev..
He's decided that he's going to give us some trivia this time. What place on Earth had the hottest temperature on it's actually May 4th, 2000. The slide didn't come out. This is because Gorby found out that he's not particularly good at Ruby karaoke. So he's going to go for Ruby pub trivia instead. So there's a cool tool that Google has called BigQuery. I did a talk about this at Mountain West two years ago. It's a tool that we designed internally for processing large quantities of logs. The really cool thing I like about it is it lets you query large data sets with SQL as opposed to all those other databases or tools that use large data sets and you have to learn a special query language for them. Also, it doesn't have any indices. It's like this awesome magic trick. You don't have to spend time indexing your data, it just works, it's so cool. So if you want to play with it, we've got a bunch of public data sets. The one I like using is GSOD, which stands for Global Surface Conditions of the Day. It's just a database.
Worth of weather data. It's a couple gigabytes, you can do much bigger data sets. I like this one because it's interesting, everyone deals with weather. It's got a huge schema, including things like buoy, and was there thunder on a given day. But since we're trying to figure out what place in the entire world was hottest on May 4th, 2000,.
We're going to just.
Use the station number, which identifies a location, the year, month, and day, and the mean temperature for that day. Makes sense, right?.
Here's the query..
So I don't know how.
Many of y'all know SQL. My guess is you all know enough of it. When I was doing a lot of interviewing, right, a SQL query that looked approximately like this was pretty common..
One of my questions, I'm like, "Here, here's a table. "Find me the max by blah blah blah." Like, this was a totally acceptable answer,.
I'm not doing any aggregation, although BigQuery can totally do that, it does it very quickly. Just finding the mean temp and ordering by descending, so the top, the first one's going to be the warmest. So if I run this query and I'm happy to do this as a demo afterwards, but I'm not going to touch my laptop, because the slides are working right now, is query runs in less than 20 seconds. It goes over, I think, 7GB, 6GB, something like that, to do it, and it's cached, so if I run it again, it's instantaneous after that. Remember, no indexes, nothing like that. It just works..
This is the first four rows that I get back, and so there's this place that was 102 degrees on May 4th, 2000. The station number is this. I've used this data set a lot at this point,.
And so I happen to know that a leading six means it's in Africa. There's a table that you can look up on the World Meteorological Association website.
To figure out what these numbers are. It happens to be that this particular weather station was in Mali..
So let's go find ourselves a cat. Meet someone, some shady character has given us a clue. "The cat had a ball here." Yeah, I made that pun. I stole that one from Tenderlove. Gorby says we're almost done. Here's the next clue. So here's our final postcard. Looks like a landmark again. Someone get's the joke, congratulations. The rest of you will get it shortly. I've been enjoying my world tour. Lots of people to meet and head butt. Gorby's Internet fame is he gets lots of head butts, belly rubs, all the things. He really likes belly rubs. So let's figure out where he is. So landmark again, same code as for the first postcard. Turns out, it's Kauffman Stadium, right here in Kansas City. Congratulations, we've found Gorby Puff. Also, so this is the sponsored track, and I'm supposed to make fun of myself, because I got all of my actual proposals for RailsConf rejected, so I had to speak in the sponsor track. This talk was inspired by children's television from the '80s. I work for a company called Alphabet, so this talk today is brought to you by the letters G, C, and P. Stands for Google Cloud Platform. So this is the part where I do the sponsored pitch. If you have applications, I promise you that we can most likely run them. It's a lovely promise right there. I haven't run into.
Anything that we can't run. It may not make sense for us to run it, but that's up for you to decide. I'm happy to talk to you guys. We've got a lovely team of folks over there.
Sitting in the second row mocking me. They're also happy to help you out. We have VMs, we have storage, we have great tools for big data, we have great tools for machine learning now that are coming out. All this stuff is available to Ruby. If you are like one of the five people who actually use containers in production, let's talk, because.
We've got awesome stuff for container people. I get to make a special announcement, because I got to give the sponsored talk. We are announcing the App Engine for Ruby is in beta as of today..
We're actually officially announcing it tomorrow because today is May the 4th and the Internet is full of Star Wars. (audience laughs).
Let's just be practical about this. App Engine is our platform as a service product. Some of you may have tried it a couple years ago. We're like, we support App Engine for Ruby,.
But only if you use JRuby. That's not this product. You can actually use MRI, like the Ruby that you use on your laptop, we will happily run it, we will happily autoscale it, we will happily take care of loading your logs in if you put the right gems in so you can query them with tools like BigQuery. All that stuff, we're happy to do for you on this product, it's really super cool, and it launches well, and it runs all the stuff that you guys care about. It's got a lot of people who've worked with Ruby for dozens of years at this point working on it. I'm really happy to be able to get up here and say this. You can run Sinatra if you don't want to run Rails, because some of you.
Don't want to run rails even though you're at RailsConf and I understand. The other thing is, if you want to train up our APIs, gem install G Cloud,.
Mike and Chris have done a fantastic job on this. It's really a much better experience than it was, than using some of the other products have been in the past. It just feels more like Ruby. The other stuff worked great, but I've been like,.
"This wasn't actually written by a Rubyist, was it?" This feels like Ruby, like they alias the heck out of things. That annotate method has five names. Because it's Ruby, we need to be able to do everything at least three different ways and have that all be right. We're not Python..
So I want to say some thank yous. Aaron Patterson,.
Because I came up for the idea of this talk at work, and then I'm like, OK, now I have to get Aaron's permission to use all of his pictures of his cat. He's like, "That's the best idea ever." You'll note that he is not in this talk. He's actually seen the slides already. Mike Moore and Chris.
Smith for the G Cloud gem, and my lovely co-workers and the other folks.
Who couldn't make it here who worked on G Cloud Ruby with me, or Google Cloud Ruby support. I've been working at.
Google for about 18 months, and I'm finally glad that I get to talk about something that y'all can use that isn't Docker. It makes me happy..
Photo credits, all.
Creative Commons BY 2.0. This is the part where I take questions, and I am repeating something I started earlier this year. If you ask a question, I'll show you a cat picture. Why should you use Google Cloud Platform over Docker? Why not both?.
You can use both..
If you don't want to do the ops work yourself, try out App Engine..
If you want to, if you're like, I know how to set up a VM, try Compute Engine. If you're like, "Hey, this Docker thing seems awesome," you can try out Container Engine. We have stuff to support all three levels of,.
We call it the Compute Continuum, because we like big words like that. But we pretty much have something for everyone. The only place where it gets to be an interesting conversation is if a particular competitor or running stuff on premises is more cost effective for you, go nuts. The cloud prices keep dropping, so check us out in another couple months, it may be cheaper then. Sorry, cat picture..
This one is named Inchworm. Random useless fact, one of your well known Rubyists fosters baby kittens, and I get to take pictures of them. Yes, in the back..
I did not do it through G Cloud, but you could. If you're going to be doing something from code, so the question was did I do the BigQuery query through G Cloud or did I do it some other way. So there's a web interface, I actually really like the web interface, because I can save things, and I can export them to various formats, and it just... How many of you guys have built an ad hoc reporting tool for a company you've worked at? Yes, OK, BigQuery can be that ad hoc reporting tool for you. That's one of the lovely things about it. It's got the web interface so you can change your mind about your queries and explore and do things like that. I know folks who are using it from the G Cloud gem, from code, because they're doing queries over and over again and they want them to show up on a dashboard. They'll be doing it from G Cloud, because they know what the query they want is. Most of the time, I'm just doing exploratory stuff, so I use the web UI..
It works, it's just as fast, it's kind of pretty, had a lot of blue. So, yeah..
More kittens..
This one was, that's Outrageous Orange. The kittens have awesome names. Any other questions?.
OK, so what algorithms are behind the Vision software? I don't actually know in tons of detail. I know that a good hunk of the idea is neural nets. I know that some of the folks who worked on it also worked on TensorFlow, which is our open source machine learning library that you can download and try out and use for all of your various machine learning problems. But I don't actually have a ton of the details. There are some details available online, and I know that people are working on white papers and deeper talks on the actual machine learning part behind it. One of the things I've found is that I'm like, I have this giant pile of data, or I have a lot of this really cool stuff. What do I do?.
And like, I've read a bunch of machine learning books and I took the Coursera machine learning class. But I'm like, I could spend my time re-implementing this, or I could just grab something that someone else has done and do the cost benefit analysis on it, which is why I think.
Things like Cloud Vision, and we've actually got, what's the talky one? It's been announced..
No, Speech API..
Yeah, there's going to be one for speech as well soon. Which, I've come up.
With a lot of very weird cool things to do with that. The idea that you could just send an audio file and get the text back is kind of awesome, for an arbitrary corpus of words. Giant pelicans, yes..
It is not, but the one thing I was supposed to say when I announced G cloud is that more APIs are coming soon. There are at least two people working on it full time, it's completely open.
Sourced, it's up on GitHub, you can totally look at it. You can enter issues, and that's how I got them to add Vision. So, I'm like, "Hey, I want to give a talk on Vision. "Can you guys please add Vision?" Then Mike's like, "Yes, we'll add Vision. "But it's not going to be fully integrated "by the time you need it." I'm like, "OK, that's OK." So I'm working on, I'm actually working out of a branch. But if you look at my code on GitHub under my repo, you'll see the actual, in the gem file, you'll see where I'm pulling from. Awesome, so we're going to be hanging out, if you want to talk to us. I also have the cardboard, if you want to see a 3D tour of one of our data centers, you can totally come over and shove your face up against a pile of cardboard and see a 3D tour of.
One of our data centers. I know, I'm like, it's a data center, it has blinky lights. But it turns out, really big data centers are actually really cool, even if you think that blinky lights are boring. So thank y'all..
(applause).


##########################################

No comments:

Post a Comment