Detecting Domain Specific Content in the Images

Learn to detect the celebrities and landmarks present in the image using the Azure Computer Vision service.

Introduction

In this lesson, we’re going to use the domain specific functionality of computer vision service to extract the information related to a particular domain. The computer service has been trained on specialized datasets. Currently, the computer vision service provides specific image analysis on two domains:

  • Celebrity
  • Landmarks

We’ll use both models to understand how image analysis works with these special models trained with domain specific datasets.

We’ll use the analyze_image_by_domain() function from the ComputerVisionClient class. This function accepts the URL of an image and helps to extract features based on two domains: celebrity and landmark. This function also accepts a parameter of type string which denotes the domain on which features needs to be extracted. First, we’ll pass celebrity as the domain features to be extracted and then we will pass the landmark as the parameter to extract the landmark related features. The response is in JSON format and contains the features extracted from the image. If an error occurs on the computer vision end, this function will return an error code with an error message.

Similarly, we can also use the analyze_image_by_domain_in_stream() function if we are reading the image from the local machine and then pass the image in bytes format to this function as a parameter.

Implementation of celebrity detection

Now let’s implement this functionality.

Get hands-on with 1200+ tech skills courses.