Last active
March 7, 2022 02:45
-
-
Save B046090010/4d2d95b69b465fa6eff2e43db9f92aa8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://unpkg.com/@tensorflow/tfjs"></script> | |
<script src="https://unpkg.com/@tensorflow/tfjs-automl"></script> | |
<p><input type="file" accept="image/*" name="image" id="file" onchange="loadFile(event)" style="display: none;"></p> | |
<p><label for="file" style="cursor: pointer;">Upload Image</label></p> | |
<p><img id="output" width="200" /></p> | |
<p><pre id = "result"></pre></p> | |
<script> | |
async function run() { | |
const model = await tf.automl.loadImageClassification('api_list/model.json'); | |
const image = document.getElementById('output'); | |
const predictions = await model.classify(image); | |
console.log(predictions); | |
// Show the resulting object on the page. | |
const result = document.getElementById('result'); | |
result.textContent = JSON.stringify(predictions, null, 2); | |
} | |
var loadFile = function(event) { | |
var image = document.getElementById('output'); | |
image.src = URL.createObjectURL(event.target.files[0]); | |
run(); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment