Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function init() {
try {
// await webcam.setup();
webcamDataset = tfd.webcam(
document.getElementById('webcam') as HTMLVideoElement,
{frameRate: 10, width: 224, height: 224});
await webcamDataset.init();
} catch (e) {
document.getElementById('no-webcam').style.display = 'block';
}
truncatedMobileNet = await loadTruncatedMobileNet();
// Warm up the model. This uploads weights to the GPU and compiles the WebGL
// programs so the first time we collect data from the webcam it will be
// quick.
const screenShot = await webcamDataset.capture();
truncatedMobileNet.predict(screenShot.expandDims(0));
screenShot.dispose();
ui.init();