Image classification using TensorFlow.js

Image classification using TensorFlow.js

For Image Classification like label detection we're going to use MobileNet Model which is define in TensorFlow.js.

MobileNets are small, low-latency, low-power models parameterized to meet the resource constraints of a variety of use cases. They can be built upon for classification, detection, embeddings and segmentation similar to how other popular large scale models, such as Inception, are used.

MobileNets trade off between latency, size and accuracy while comparing favorably with popular models from the literature.

This TensorFlow.js model does not require you to know about machine learning. It can take as input any browser-based image elements (<img>, <video>, <canvas> elements, for example) and returns an array of most likely predictions and their confidences.

Usage

Load MobileNet model in your JavaScript project: via script tags.

via Script Tag

<!-- Load TensorFlow.js. This is required to use MobileNet. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script>
<!-- Load the MobileNet model. -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow-models/[email protected]"> </script>

<!-- Replace this with your image. Make sure CORS settings allow reading the image! -->
<img id="img" src="dog.jpg"></img>

<!-- Place your code in the script tag below. You can also use an external .js file -->
<script>
  // Notice there is no 'import' statement. 'mobilenet' and 'tf' is
  // available on the index-page because of the script tag above.

  const img = document.getElementById('img');

  // Load the model.
  mobilenet.load().then(model => {
    // Classify the image.
    model.classify(img).then(predictions => {
      console.log('Predictions: ');
      console.log(predictions);
    });
  });
</script>


要查看或添加评论,请登录

Vrijraj Singh的更多文章

  • Getting Started with TensorFlow.js

    Getting Started with TensorFlow.js

    TensorFlow.js is an open source WebGL-accelerated JavaScript library for machine intelligence.

  • Google’s Women Techmakers Empowers Women Globally

    Google’s Women Techmakers Empowers Women Globally

    Driven by the belief that a diversity of perspectives leads to better decision-making and more relevant products…

  • Pose Detection in the Browser: PoseNet Model Using TensorFlow.js

    Pose Detection in the Browser: PoseNet Model Using TensorFlow.js

    TensorFlow.js, an open-source library you can use to define, train, and run machine learning models entirely in the…

  • How to Become an Excellent Interaction Designer?

    How to Become an Excellent Interaction Designer?

    In recent years, with the rise of the Internet industry, designer quickly became a popular profession. The thriving…

  • IoT: The Internet of (Every)thing?

    IoT: The Internet of (Every)thing?

    Gone are the days when I had to get up out of my bed to turn the lights on. Now every morning my lights slowly turn on…

  • What is Udacity Nanodegrees Program?

    What is Udacity Nanodegrees Program?

    Udacity offers some great courses in their Nanodegree programs. If you don’t have the money, and/or just don’t want to…

    1 条评论
  • What is AMP and Who Actually Needs It?

    What is AMP and Who Actually Needs It?

    Accelerated Mobile Pages (AMP) is set to roll out within Google’s mobile search results in February 2016. Here we…

  • What is Microsoft Azure & Why Use It?

    What is Microsoft Azure & Why Use It?

    An In-Depth Look at the Cloud Services Platform from Microsoft Today plenty of businesses still have real concerns…

  • Google Developers :: Solve For India

    Google Developers :: Solve For India

    Google Developers :: Solve for India initiative aims to nurture developers, tech entrepreneurs and reach, support…

  • Google IO Extended 2017, GDG-Jalandhar

    Google IO Extended 2017, GDG-Jalandhar

    Google I/O is an annual developer festival held at the outdoor Shoreline Amphitheatre. This year's festival built lots…

社区洞察

其他会员也浏览了