| 37 | // Loads mobilenet and returns a model that returns the internal activation |
| 38 | // we'll use as input to our classifier model. |
| 39 | async function loadTruncatedMobileNet() { |
| 40 | const mobilenet = await tf.loadLayersModel( |
| 41 | 'https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json'); |
| 42 | |
| 43 | // Return a model that outputs an internal activation. |
| 44 | const layer = mobilenet.getLayer('conv_pw_13_relu'); |
| 45 | return tf.model({inputs: mobilenet.inputs, outputs: layer.output}); |
| 46 | } |
| 47 | |
| 48 | // When the UI buttons are pressed, read a frame from the webcam and associate |
| 49 | // it with the class label given by the button. up, down, left, right are |