GoogleCloudPlatform/tensorflow-sketch-rnn-example

Name: tensorflow-sketch-rnn-example

Owner: Google Cloud Platform

Description: null

Created: 2017-10-27 22:19:06.0

Updated: 2018-04-10 21:01:12.0

Pushed: 2017-10-27 23:37:51.0

Homepage: null

Size: 232

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

TensorFlow Sketch-RNN pre-trained model demo

Discrlaimer: This is not an official Google product.

This is an example application demonstraing how Sketch-RNN: A Generative Model for Vector Drawings can be used to create a sketch generation application.

Products
Language
Prerequisites
  1. A Google Cloud Platform Account
  2. A new Google Cloud Platform Project for this lab with billing enabled
Do this first

First you launch a GCE instance with the following configuration.

You can leave other settings as default. Once the instance has started, log in to the guest OS using SSH and change the OS user to root.

do -i

All remaining operations should be done from the root user.

Install packages
t-get update
t-get install -y build-essential python-pip unzip python-cairosvg git
p install ipython==5.5.0 rdp==0.8 svgwrite==1.1.6 tensorflow==1.3.0 Flask==0.12.2
p install magenta 
Download the pre-trained model binaries
dir -p /opt/sketch_demo/models
 /opt/sketch_demo/models
rl -OL http://download.magenta.tensorflow.org/models/sketch_rnn.zip
zip sketch_rnn.zip
Install the demo application
 $HOME
t clone https://github.com/GoogleCloudPlatform/tensorflow-sketch-rnn-example.git
 -a tensorflow-sketch-rnn-example/sketch_demo /opt/
 /opt/sketch_demo/sketch_demo.service /etc/systemd/system/

This application provides a simple user authentication mechanism. You can change the username and password by modifying the following part in /opt/sketch_demo/auth_decorator.py.

NAME = 'username'
WORD = 'passw0rd'
Launch the demo application
stemctl daemon-reload
stemctl enable sketch_demo
stemctl start sketch_demo
stemctl status sketch_demo

The last command outputs the application status, as in the following example:

etch_demo.service - Sketch-RNN demo
oaded: loaded (/etc/systemd/system/sketch_demo.service; enabled; vendor preset: enabled)
ctive: active (running) since Sat 2017-10-21 05:59:12 UTC; 10s ago
n PID: 2049 (start_app.sh)
Tasks: 10 (limit: 4915)
Group: /system.slice/sketch_demo.service
       ??2049 /bin/bash /opt/sketch_demo/start_app.sh
       ??2050 /usr/bin/python /opt/sketch_demo/backend.py -p 8081 -d /opt/sketch_demo/models/catbu
       ??2051 /usr/bin/python /opt/sketch_demo/backend.py -p 8082 -d /opt/sketch_demo/models/eleph
       ??2052 /usr/bin/python /opt/sketch_demo/backend.py -p 8083 -d /opt/sketch_demo/models/flami
       ??2053 /usr/bin/python /opt/sketch_demo/backend.py -p 8084 -d /opt/sketch_demo/models/owl/l
       ??2054 /usr/bin/python /opt/sketch_demo/app.py

21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Input dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Output dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Recurrent dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Input dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Output dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Recurrent dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Model using gpu.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Input dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Output dropout mode = 0.
21 05:59:17 sketch-demo start_app.sh[2049]: INFO:tensorflow:Recurrent dropout mode = 0.

You have to wait around 60secs for the application to finish loading the pre-trained model graph. After that, you can access the instance's static IP address using a web browser. You draw a sample picture on the white canvas, and when you submit it, three children (emulated by a machine learning model) try to imitate your sample.

There are four classrooms and the machine learning model in each class is tranied with a different dataset. As a result, the children in each classroom tend to draw some specific objects such as cats and buses. You can choose the classroom from the buttons on the screen.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.