Google News
logo
ml5.js - Interview Questions
How to Using Promises in ml5.js?
ml5.js also supports Promises. If no callback is provided to any asynchronous function then a Promise is returned.
 
With Promises, the image classification example can be used in the following way :
// No callback needs to be passed to use Promises.
ml5
  .imageClassifier('MobileNet')
  .then(classifier => classifier.predict(image))
  .then((results) => {
    // Do something with the results
  });
Advertisement