Add performance tracking to local detection
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -10,13 +10,18 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
async localDetect(imageData) {
|
async localDetect(imageData) {
|
||||||
|
console.time('pre-process')
|
||||||
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3);
|
const [modelWidth, modelHeight] = model.inputs[0].shape.slice(1, 3);
|
||||||
|
|
||||||
const input = tf.tidy(() => {
|
const input = tf.tidy(() => {
|
||||||
return tf.image.resizeBilinear(tf.browser.fromPixels(imageData), [modelWidth, modelHeight]).div(255.0).expandDims(0)
|
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)
|
const res = model.predict(input)
|
||||||
|
console.timeEnd('run prediction')
|
||||||
|
|
||||||
|
console.time('post-process')
|
||||||
const detectAttempts = res.shape[2]
|
const detectAttempts = res.shape[2]
|
||||||
const outputSize = res.shape[1]
|
const outputSize = res.shape[1]
|
||||||
const rawRes = tf.transpose(res,[0,2,1]).dataSync()
|
const rawRes = tf.transpose(res,[0,2,1]).dataSync()
|
||||||
@@ -69,6 +74,7 @@ export default {
|
|||||||
|
|
||||||
tf.dispose(res)
|
tf.dispose(res)
|
||||||
tf.dispose(tBoxes)
|
tf.dispose(tBoxes)
|
||||||
|
console.timeEnd('post-process')
|
||||||
|
|
||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user