Machine Learning Test 2

by codingdude

HTML

<script src="https://unpkg.com/[email protected]/dist/ml5.min.js"></script>
<p><input type="text" class="input" placeholder="Input some text..."></p>
<p class="result"></p>

JavaScript

// Create the character level generator with a pre trained model
const rnn = ml5.charRNN('https://raw.githubusercontent.com/ml5js/ml5-data-and-models/master/models/lstm/bolano', modelLoaded);

document.querySelector(".input").onchange = function(){
	// Generete content
  console.log(this.value);
  rnn.generate({ seed: this.value }, function(err, results){
    document.querySelector(".result").innerText = JSON.stringify(results);
  });
}
// When the model is loaded
function modelLoaded() {
  console.log('Model Loaded!');
}