Skip to content

Instantly share code, notes, and snippets.

@risenW
Created June 21, 2020 16:03
Show Gist options
  • Save risenW/31f4cc51131149d458a4e7d63d5b9b4a to your computer and use it in GitHub Desktop.
Save risenW/31f4cc51131149d458a4e7d63d5b9b4a to your computer and use it in GitHub Desktop.
let base_net,webcam;
const webcamElement = document.getElementById('webcam');
const classifier = knnClassifier.create();
async function addExample(classId) {
// Capture an image from the web camera.
const img = await webcam.capture();
// Get the intermediate activation of MobileNet
const activation = base_net.infer(img, true);
// Pass the intermediate activation to the classifier.
classifier.addExample(activation, classId);
// Dispose the tensor to release the memory.
img.dispose();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment