Azure Cognitive Services

Azure Cognitive Services is a collection of cloud-based APIs and services developed by Microsoft, designed to enable developers to add AI (Artificial Intelligence) capabilities to their applications without requiring deep expertise in AI or machine learning. These services cover a wide range of functionalities as follows:

  1. Computer Vision: This service allows applications to analyze and understand visual content in images and videos. It can perform tasks like image recognition, object detection, and image classification.
  1. Text Analytics: Text Analytics service enables sentiment analysis, key phrase extraction, language detection, and entity recognition in text data.
  1. Speech Services: Developers can integrate speech-to-text and text-to-speech capabilities into their applications, enabling voice recognition and synthesis.
  1. Language Understanding: Language Understanding Intelligence Service (LUIS) enables applications to understand and interpret user commands through natural language processing (NLP).
  1. Translator: This service offers text and speech translation in multiple languages, making it easier to create multilingual applications.
  1. Custom Vision: Developers can train custom machine learning models for image classification and object detection, tailored to their specific use cases.
  1. Anomaly Detector: This service helps in identifying anomalies and unusual patterns within data, which is useful for applications like fraud detection and predictive maintenance.
  1. Decision: The Decision service provides AI-powered recommendations and decision-making capabilities for various scenarios, aiding users in making informed choices.

Image Categorization and Text Extraction from Images

Step1:

Create a Computer Vision resource from create a resource on Azure Portal. Fill in the details to create a computer vision resource. The pricing tier of F0 which is a free tier is sufficient for this project.

Comprehensive Exploration of Azure Cognitive Services - Addend Analytics

Step2:

Create an Azure Data Lake Gen 2 storage account within it to create a container, while creating the container set its Public Access level to Container(anonymous read access for containers and blobs).

Upload images into the container. Upload different types of images so that we can have a large dataset for analysis.

Comprehensive Exploration of Azure Cognitive Services - Addend Analytics1

Step3:

Now in VScode create a .py file, then open a new terminal and install the following:

pip install azure-identity azure-storage-file-datalake requests

pip install azure-cognitiveservices-vision-computervision

write the code for image categorization and text extraction from images.

  • In the Python code various libraries are to imported which are going to be used for text extraction from image and image categorization.

from azure.cognitiveservices.vision.computervision import ComputerVisionClient

from azure.cognitiveservices.vision.computervision.models import OperationStatusCodes

from azure.cognitiveservices.vision.computervision.models import VisualFeatureTypes

  • In the code we need to give Computer Vision endpoint and subscription key.
  • We need to provide the data lake endpoint where the images are stored.
  • We need to specify the container name where the images are stored.
  • We use variables to store various values like blob name , container name and then we build a blob_url where we can pass these values to access the images stored in the container by using for loop.

Code snippet of Text Extraction from Image

Comprehensive Exploration of Azure Cognitive Services - Addend Analytics2

Code snippet of Image Categorization

Comprehensive Exploration of Azure Cognitive Services - Addend Analytics3

Step4:

Run the python code and you will get output as below.
Here, in the output we can see that for Image:carphoto.jpg we can see the various text that are extracted from image.

For the output of Categorize the images for image Landmark.jpg we can see the various categories of image.

Comprehensive Exploration of Azure Cognitive Services - Addend Analytics4

Addend Analytics is a Microsoft Gold Partner based in Mumbai, India, and a branch office in the U.S.

Addend has successfully implemented 100+ Microsoft Power BI and Business Central projects for 100+ clients across sectors like Financial Services, Banking, Insurance, Retail, Sales, Manufacturing, Real estate, Logistics, and Healthcare in countries like the US, Europe, Switzerland, and Australia.

Get a free consultation now by emailing us or contacting us.