diff --git a/src/pages/local-detect.js b/src/pages/local-detect.js index dbac842..f9967d7 100644 --- a/src/pages/local-detect.js +++ b/src/pages/local-detect.js @@ -10,13 +10,18 @@ export default { }) }, async localDetect(imageData) { + console.time('pre-process') const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3); - const input = tf.tidy(() => { return tf.image.resizeBilinear(tf.browser.fromPixels(imageData), [modelWidth, modelHeight]).div(255.0).expandDims(0) }) + console.timeEnd('pre-process') + console.time('run prediction') const res = model.predict(input) + console.timeEnd('run prediction') + + console.time('post-process') const detectAttempts = res.shape[2] const outputSize = res.shape[1] const rawRes = tf.transpose(res,[0,2,1]).dataSync() @@ -69,6 +74,7 @@ export default { tf.dispose(res) tf.dispose(tBoxes) + console.timeEnd('post-process') return output }