Created
July 26, 2018 13:04
-
-
Save MattKovtun/a56f10c9be13322e1eef37df0d5a86ac 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
let model; | |
const modelURL = 'http://localhost:5000/model'; | |
const preview = document.getElementById("preview"); | |
const predictButton = document.getElementById("predict"); | |
const clearButton = document.getElementById("clear"); | |
const numberOfFiles = document.getElementById("number-of-files"); | |
const fileInput = document.getElementById('file'); | |
const predict = async (modelURL) => { | |
if (!model) model = await tf.loadModel(modelURL); | |
const files = fileInput.files; | |
[...files].map(async (img) => { | |
const data = new FormData(); | |
data.append('file', img); | |
const processedImage = await fetch("/api/prepare", | |
{ | |
method: 'POST', | |
body: data | |
}).then(response => { | |
return response.json(); | |
}).then(result => { | |
return tf.tensor2d(result['image']); | |
}); | |
}) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment