<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/exploring-the-quick-draw-dataset-with-r-the-mona-lisa/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://fronkonstin.com/2018/07/01/exploring-the-quick-draw-dataset-with-r-the-mona-lisa/"> R – Fronkonstin</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div class="twitter-share"><a rel="nofollow" href="https://twitter.com/intent/tweet?url=https%3A%2F%2Ffronkonstin.com%2F2018%2F07%2F01%2Fexploring-the-quick-draw-dataset-with-r-the-mona-lisa%2F&via=aschinchon" class="twitter-share-button" target="_blank">Tweet</a></div>
<blockquote>
<p>All that noise, and all that sound, all those places I have found (Speed of Sound, Coldplay)</p>
</blockquote>
<p>Some days ago, my friend <a rel="nofollow" href="https://twitter.com/jayusor" target="_blank">Jorge</a> showed me one of the coolest datasets I’ve ever seen: <a rel="nofollow" href="https://github.com/googlecreativelab/quickdraw-dataset" target="_blank">the Google quick draw dataset</a>. In its Github website you can see a detailed description of the data. Briefly, it contains  around 50 million of drawings of people around the world in <code>.ndjson</code> format. In this experiment, I used the <a rel="nofollow" href="https://console.cloud.google.com/storage/browser/quickdraw_dataset/full/simplified" target="_blank">simplified version</a> of drawings where strokes are simplified and resampled with a 1 pixel spacing. Drawings are also aligned to top-left corner and scaled to have a maximum value of 255. All these things make data easier to manage and to represent into a plot.</p>
<p>Since <code>.ndjson</code> files may be very large, I used <code>LaF</code> package to access randon lines of the file rather than reading it completely. I wrote a script to explore <code>The Mona Lisa.ndjson</code> file, which contains more than 120.000 drawings that the TensorFlow engine from Google recognized as being <em>The Mona Lisa</em>. It is quite funny to see them. Whit this script you can:</p>
<ul>
<li>Reproduce a random single drawing</li>
<li>Create a 9×9 mosaic of random drawings</li>
<li>Create an animation simulating the way the drawing was created</li>
</ul>
<p>I use ggplot2 package to render drawings and <a rel="nofollow" href="https://github.com/dgrtwo/gganimate" target="_blank"><code>gganimate</code></a> package of David Robinson to create animations.</p>
<p>This is an example of a single drawing:</p>
<p><img data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_single.png?fit=3000%2C3000&amp;ssl=1" data-orig-size="3000,3000" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_single.png?fit=300%2C300&amp;ssl=1" data-attachment-id="4579" data-image-meta="{" data-image-description="" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_single.png?resize=604%2C604&ssl=1" data-permalink="https://fronkonstin.com/2018/07/01/exploring-the-quick-draw-dataset-with-r-the-mona-lisa/mona_single/" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_single.png?fit=604%2C604&amp;ssl=1" alt="" data-image-title="mona_single" sizes="(max-width: 604px) 100vw, 604px" width="450" data-comments-opened="1" class="wp-image-4579" data-recalc-dims="1"></p>
<p>This is an example of a 3×3 mosaic:</p>
<p><img data-orig-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_mosaic2.png?fit=3000%2C3000&amp;ssl=1" data-orig-size="3000,3000" data-medium-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_mosaic2.png?fit=300%2C300&amp;ssl=1" data-attachment-id="4580" data-image-meta="{" data-image-description="" src="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_mosaic2.png?resize=604%2C604&ssl=1" data-permalink="https://fronkonstin.com/2018/07/01/exploring-the-quick-draw-dataset-with-r-the-mona-lisa/mona_mosaic2/" data-large-file="https://i1.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_mosaic2.png?fit=604%2C604&amp;ssl=1" alt="" data-image-title="mona_mosaic2" sizes="(max-width: 604px) 100vw, 604px" width="450" data-comments-opened="1" class="wp-image-4580" data-recalc-dims="1"></p>
<p>This is an example of animation:</p>
<p><img data-orig-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_animation2.gif?fit=480%2C480&amp;ssl=1" data-orig-size="480,480" data-medium-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_animation2.gif?fit=300%2C300&amp;ssl=1" data-attachment-id="4581" data-image-meta="{" data-image-description="" src="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_animation2.gif?resize=480%2C480&ssl=1" data-permalink="https://fronkonstin.com/2018/07/01/exploring-the-quick-draw-dataset-with-r-the-mona-lisa/mona_animation2/" data-large-file="https://i2.wp.com/fronkonstin.com/wp-content/uploads/2018/06/mona_animation2.gif?fit=480%2C480&amp;ssl=1" alt="" data-image-title="mona_animation2" width="450" data-comments-opened="1" class="wp-image-4581" data-recalc-dims="1"></p>
<p>If you want to try by yourself, you can find the code <a rel="nofollow" href="https://github.com/aschinchon/quickdraw-R-mona-lisa" target="_blank">here</a>.</p>
<p>Note: to work with <code>gganimate</code>, I downloaded the portable version and pointed to it with <code>Sys.setenv</code> command as explained <a rel="nofollow" href="https://github.com/dgrtwo/gganimate/issues/22" target="_blank">here</a>.</p>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://fronkonstin.com/2018/07/01/exploring-the-quick-draw-dataset-with-r-the-mona-lisa/"> R – Fronkonstin</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/9DAr_g0-iVM" height="1"></a></div>