()
| 178 | }); |
| 179 | |
| 180 | async function init() { |
| 181 | try { |
| 182 | webcam = await tfd.webcam(document.getElementById('webcam')); |
| 183 | } catch (e) { |
| 184 | console.log(e); |
| 185 | document.getElementById('no-webcam').style.display = 'block'; |
| 186 | } |
| 187 | truncatedMobileNet = await loadTruncatedMobileNet(); |
| 188 | |
| 189 | ui.init(); |
| 190 | |
| 191 | // Warm up the model. This uploads weights to the GPU and compiles the WebGL |
| 192 | // programs so the first time we collect data from the webcam it will be |
| 193 | // quick. |
| 194 | const screenShot = await webcam.capture(); |
| 195 | truncatedMobileNet.predict(screenShot.expandDims(0)); |
| 196 | screenShot.dispose(); |
| 197 | } |
| 198 | |
| 199 | // Initialize the application. |
| 200 | init(); |
no test coverage detected