DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Azure AI and GPT-4: Real-World Applications and Best Practices
  • Zero to AI Hero, Part 3: Unleashing the Power of Agents in Semantic Kernel
  • Zero to AI Hero, Part 2: Understanding Plugins in Semantic Kernel, A Deep Dive With Examples
  • From Zero to AI Hero, Part 1: Jumpstart Your Journey With Semantic Kernel

Trending

  • Advancing Robot Vision and Control
  • A Guide to Auto-Tagging and Lineage Tracking With OpenMetadata
  • How To Introduce a New API Quickly Using Quarkus and ChatGPT
  • Software Delivery at Scale: Centralized Jenkins Pipeline for Optimal Efficiency
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Exploration on Azure Computer Vision Model To Build AI-Ready Web Applications

Exploration on Azure Computer Vision Model To Build AI-Ready Web Applications

This article explains how to integrate computer vision SDK with JavaScript to develop custom models or use pre-built models to build intelligent web applications.

By 
Naga Santhosh Reddy Vootukuri user avatar
Naga Santhosh Reddy Vootukuri
DZone Core CORE ·
May. 15, 24 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
763 Views

Join the DZone community and get the full member experience.

Join For Free

The Azure Computer Vision model is a powerful tool for building AI-ready web applications. This model enables developers to extract insights and meaning from visual data and can be used to build a wide range of applications, from image classification and object detection to facial recognition and natural language processing. In this article, we will explore the capabilities of the Azure Computer Vision model and how it can be used to build AI-ready web applications. We will also discuss the benefits of using this model and provide a step-by-step guide on how to get started.

Capabilities of Azure Computer Vision Model

The Azure Computer Vision model is a cloud-based API that enables developers to analyze and understand visual data. This model can be used to:

1. Classify Images Into Different Categories

Azure Computer Vision can classify images into different categories such as objects, scenes, and actions. 

Ex: for the below picture, it will classify into the category Animal_dog Image from Google

Image from Google

2. Detect Objects Within Images

Azure Computer Vision can detect objects within images, including people, animals, and objects.

Ex: The below picture will detect the object apple and provide the response in the JSON as shown below. 

Image from Google

Image from Google

JSON
 
{
   "objects":[
      {
         "rectangle":{
            "x":730,
            "y":66,
            "w":135,
            "h":85
         },
         "object":"Apple",
         "confidence":0.98
      }
}


3. Recognize Faces and Extract Facial Features

Azure Computer Vision can recognize faces and extract facial features such as age, gender, and emotions.

Image from Microsoft

Image from Microsoft

JSON
 
{
    "faces": [
        {
            "age": 11,
            "gender": "Male",
            "faceRectangle": {
                "top": 62,
                "left": 22,
                "width": 45,
                "height": 45
            }
        },
        {
            "age": 11,
            "gender": "Female",
            "faceRectangle": {
                "top": 127,
                "left": 240,
                "width": 42,
                "height": 42
            }
        },
        {
            "age": 37,
            "gender": "Female",
            "faceRectangle": {
                "top": 55,
                "left": 200,
                "width": 41,
                "height": 41
            }
        },
        {
            "age": 41,
            "gender": "Male",
            "faceRectangle": {
                "top": 45,
                "left": 103,
                "width": 39,
                "height": 39
            }
        }
    ],
    "requestId": "3a383cbe-1a05-4104-9ce7-1b5cf352b239",
    "metadata": {
        "height": 230,
        "width": 300,
        "format": "Png"
    }
}


4. Extract Text From Images

Azure Computer Vision can extract text from images, including handwritten and printed text.

5. Generate Image Descriptions

Azure Computer Vision can generate image descriptions, including captions and tags.

Benefits of Using Azure Computer Vision Model

Using the Azure Computer Vision model can bring numerous benefits to your web application, including:

  • Improved user experience: By analyzing visual data, you can provide users with a more personalized and engaging experience.
  • Increased efficiency: Automating image analysis can save time and reduce manual effort.
  • Enhanced security: Facial recognition and object detection can be used to enhance security and prevent fraud.
  • Better decision-making: Extracting insights from visual data can help businesses make informed decisions.

You can explore and play with Azure custom vision models by navigating to the Azure AI | Vision Studio.

Step-By-Step Guide To Building AI-Ready Web Applications With Azure Computer Vision Model

Here's a step-by-step guide to building AI-ready web applications with the Azure Computer Vision model:

  1. Sign up for Azure: Create an Azure account and subscribe to the Computer Vision service by navigating to the AI Vision studio link. Copy Key and Endpoint which is used later in code to call computer vision client SDK.
  2. Choose a programming language: Choose a programming language such as Python, Java, or C# to build your application. I have used NodeJS for the code example below.
  3. Install the Azure Computer Vision SDK: Install the Azure Computer Vision SDK for your chosen programming language.
  4. Upload images: Upload images to your Azure storage account which you can use in your code to analyze it
  5. Analyze images: Use the Azure Computer Vision API to analyze images and extract insights.
  6. Integrate with your web application: Integrate the extracted insights with your web application to provide a more personalized and engaging experience 

The code below is written using NodeJS where I have used the computer vision client SDK to analyze an image that contains fruits and vegetables and provide output about detected objects and the response. 

JavaScript
 
'use strict';
var http = require('http');
var port = process.env.PORT || 1337;

const { ComputerVisionClient } = require("@azure/cognitiveservices-computervision");
const { ApiKeyCredentials } = require("@azure/ms-rest-js");

const key = '<subscription Key>';
const endpoint = '<computervision endpoint>';

const credentials = new ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': key } });
const client = new ComputerVisionClient(credentials, endpoint);

http.createServer(async function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    //res.end('Hello World\n');

    // Define the URL of the image  uploaded to storage account which you want to analyze
    const imageUrl = '<imageUrl>';

    // Call the function to analyze the image
    const result = await analyzeImage(imageUrl, { visualFeatures: ['Objects'] });

    // Assuming 'result' is the response from the analyzeImage call
    if (result.objects && result.objects.length > 0) {
        const fruitsAndVeggies = result.objects.filter(obj => obj.object.toLowerCase().includes('fruit') || obj.object.toLowerCase().includes('vegetable'));
        console.log("Detected fruits and vegetables:", fruitsAndVeggies);
    } else {
        console.log("No fruits or vegetables detected.");
    }

    // Send the analysis result as the response
    res.end(`Image Analysis Result:\n${JSON.stringify(result, null, 2)}`);
}).listen(port);

async function analyzeImage(url) {
    try {
        const result = await client.analyzeImage(url, { visualFeatures: ['Categories', 'Description', 'Objects'] });
        console.log("Image analysis result:", result);
        return result;
    } catch (error) {
        console.error("An error occurred while analyzing the image:", error);
        return error;
    }
}


Conclusion

The Azure Computer Vision model is a powerful tool for building AI-ready web applications. By leveraging this model, developers can extract insights and meaning from visual data and provide users with a more personalized and engaging experience. With vast areas, numerous benefits, and ease of use, the Azure Computer Vision model is an ideal choice for businesses looking to build intelligent AI-ready web applications.

Visit here for more details about learning Azure Computer Vision.

Happy coding !!!

AI azure

Opinions expressed by DZone contributors are their own.

Related

  • Azure AI and GPT-4: Real-World Applications and Best Practices
  • Zero to AI Hero, Part 3: Unleashing the Power of Agents in Semantic Kernel
  • Zero to AI Hero, Part 2: Understanding Plugins in Semantic Kernel, A Deep Dive With Examples
  • From Zero to AI Hero, Part 1: Jumpstart Your Journey With Semantic Kernel

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!