TranslateProject/sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md
DarkSun f2d1d0491e 选题[tech]: 20201116 Day 5: drawing lots of faces with sketch-rnn
sources/tech/20201116 Day 5- drawing lots of faces with sketch-rnn.md
2020-11-18 05:04:25 +08:00

4.6 KiB
Raw Blame History

Day 5: drawing lots of faces with sketch-rnn

Hello! This week its generative art week at RC, and I thought it would be fun to generate drawings of faces.

Someone suggested the Google Quickdraw dataset, which has a lot of pictures of faces. And even though I think most of the faces in there are not really that interesting, I really quite like some of them, like these two:

So that seems like somewhere to start!

step 1: get the sketch-rnn model

sketch-rnn is an RNN trained on the quickdraw dataset that generates line drawings. You can see it in action in Monica Dinculescus very fun magic sketchpad demo here you start making a drawing, and itll complete you drawing as a cat / bridge / whatever you want.

I figured that would be a fun place to start, and ml5js has a tutorial showing how to write Javascript code to draw things with sketch-rnn, which I followed.

step 2: make the tutorial code use async/await

The ml5js example had a bunch of global variables and callbacks and I found it difficult to work with, so I spent a while refactoring it to use async/await so that I could play around with it more easily. This took a while but I got it to work.

I started out with making a more interactive website, but decided to instead do something really simple to start: just get the model to draw a lot of faces and see how I felt about them.

Heres the resulting (very janky, not responsive) website I made, which draws faces and then puts them into a little “gallery” on the right: lots of sketch-rnn faces. You can see it “live” drawing the faces which is fun.

The set of images that comes out looks something like this:

I dont really like any of these faces, but its a start! Its also very slow on my 2015 laptop, but faster on the iPad. I didnt spend a lot of time profiling it, but it seems to spend a lot of time in some function with lstm in its name I dont know what an LSTM is exactly but I know its a component of an RNN, so I guess (as youd expect) it just has a lot of math to do in Javascript to calculate the next line to draw and thats slow.

next step: maybe find out if sketch-rnn can tell the difference between “interesting” and “boring” faces

I think that this face:

is a lot more interesting than this face:

Can I convince the neural network to distinguish between faces that I think are interesting and boring and maybe only generate more “interesting” faces? Well see! Right now I am stuck on trying to get a pre-trained model loaded into Python, so theres a long way to go.

I did find someone whod done something kind of similar, on bad flamingos vs good flamingos in the quickdraw dataset.

I still dont really know anything about RNNs, but maybe if I can answer this question I will learn something about them.

also theres a refrigerator poetry forum

Heres that refrigerator poetry forum I was talking about last week: https://refrigerator-poetry-forum.herokuapp.com/. You can write magnet poetry-style poems on a refrigerator. People wrote some charming poems and Im happy with it. I think I might use Rails for another project in the future.

Hopefully people wont abuse it, if theres abuse Ill just take it off the internet probably.


via: https://jvns.ca/blog/2020/11/16/day-5--lots-of-faces-with-sketch-rnn/

作者:Julia Evans 选题:lujun9972 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出