Skip to content

Instantly share code, notes, and snippets.

@pepetox
Created April 29, 2020 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pepetox/e6add7017c87007db5af52e766213902 to your computer and use it in GitHub Desktop.
Save pepetox/e6add7017c87007db5af52e766213902 to your computer and use it in GitHub Desktop.
tensoflow.js html
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow/tfjs-automl"></script>
<img id="daisy" crossorigin="anonymous" src="/hattori.jpeg">
<script>
async function run() {
const model = await tf.automl.loadImageClassification('model.json');
const image = document.getElementById('daisy');
const predictions = await model.classify(image);
console.log(predictions);
// Show the resulting object on the page.
const pre = document.createElement('pre');
pre.textContent = JSON.stringify(predictions, null, 2);
document.body.append(pre);
}
run();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment