SketchRnn
Description
SketchRNN is a recurrent neural network model trained on millions of doodles collected from the Quick, Draw! game. The SketchRNN model can create new drawings (from a list of categories) based on an initial path.
This original paper and implementation of SketchRNN was made in TensorFlow and ported to Magenta.js by David Ha. The ml5.js implementation was ported by Reiichiro Nakano.
The ml5 library includes a list of supported SketchRNN models.
Quickstart
// Create a new SketchRNN Instance
const model = ml5.sketchRNN('cat', modelReady);
// When the model is loaded
function modelReady() {
console.log('SketchRNN Model Loaded!');
}
// Reset the model's current stat
model.reset();
// Generate a new stroke
model.generate(gotSketch);
function gotSketch(err, result) {
// Do something with the result
}
Usage
Initialize
const sketchrnn = ml5.sketchRNN(model, ?callback);
Parameters
- model: The name of the model to use.
- callback: Optional. A function to be called once the model is loaded. If no callback is provided, it will return a promise that will be resolved once the model has loaded.
Properties
.ready
Boolean. Boolean value that specifies if the model has loaded.
Methods
.reset()
Reset the model’s current state
sketchrnn.reset();
📥 Inputs
- n/a
📤 Outputs
- n/a
.generate()
Generates a new sample with the current state.
sketchrnn.generate(?seed, ?options, ?callback);
📥 Inputs
- seed: Optional. A seed to be passed to the model before generating a new stroke.
- options: Optional. An object describing the options of the model.
- callback: Optional. A function that will return a generated stroke. If no callback is provided, it will return a promise that will be resolved with a generated stroke.
📤 Outputs
- Object: an object with the x and y location, if the pen is down, up, or if it has ended
{s.dx, s.dy, down, up, end}
.
Examples
p5.js
p5 web editor
plain javascript
Demo
No demos yet - contribute one today!
Tutorials
No tutorials yet - contribute one today!
Acknowledgements
Contributors:
- Name 1
- Name 2
Credits:
- Paper Reference | Website URL | Github Repo | Book reference | etc