Page 14 - MSDN Magazine, December 15, 2017
P. 14
stream from the kiosk camera. It then uses Cognitive Services to assign each visitor an anonymous unique identifier, so it can count the number of unique visitors to the kiosk. The software uses facial recognition to determine the age and gender of visitors, as well as recognize displayed emotion. Figure 3 shows the solution in action.
Azure Machine Learning services is an integrated, end-to-end data science and advanced analytics solution for professional data scientists to prepare data, develop experiments and deploy models at cloud scale.
Once you’ve downloaded the sample code, you’ll learn how to extract key frames from the camera at one frame per second (fps), sending each frame to the Cognitive Services Computer Vision APIs to identify the age, gender and emotion of people present in each frame in the file RealTimeDemo.xaml.cs (bit.ly/2hZZDFF). Lines 160 and 161 of this file show how you can invoke the methods for
emotion and face identification (specifically, DetectEmotionAsync and DetectFacesAsync). Various face attributes, such as bounding box, age and gender are returned by Cognitive Services.
As you explore the code, you’ll find the image analysis methods in the file ImageAnalyzer.cs. ImageAnalyzer further leverages helper classes (like FaceServiceHelper and EmotionServiceHelper) to leverage Cognitive Services for face and emotion detection. In FaceServiceHelper, you’ll see how you can use the FaceServiceClient provided by Cognitive Services to instantiate the faceClient that’s used for face detection.
private static void InitializeFaceServiceClient() { faceClient = ApiKeyRegion != null ?
new FaceServiceClient(ApiKey, string.Format("https://{0}.api.cognitive.microsoft.com/face/v1.0", ApiKeyRegion)) : new FaceServiceClient(ApiKey);
}
You’ll find that this is a common pattern used when working with Cognitive Services. Each of the Cognitive Services provides REST APIs, as well as an SDK that makes it easy to use Cognitive Services from any application. The SDK lets you quickly get started devel- oping AI applications using C#, Java, JavaScript, PHP, Python and Ruby. You can also use Curl to directly access the Cognitive Services APIs. Learn more about the APIs at aka.ms/msdn/cognitiveservices/restapi and the Cognitive Services SDK at aka.ms/msdn/cognitiveservices/sdk.
The API key for Cognitive Services can be obtained from the Azure portal after the Cognitive Service you need has been created. When you create a Cognitive Service using the Azure portal, you need to specify the API type that you require—for example, Computer Vision. When developing applications, use the API Key
to instantiate each service client. Figure 4 shows how you can cre- ate a Computer Vision Cognitive Service using the Azure portal, and
then obtain the API key.
Inside Azure
Machine Learning
Azure Machine Learning services is an integrated, end-to-end data science and advanced analytics solution for professional data scientists to prepare data, develop experiments and deploy models at cloud scale. The package enables data science teams to have an environment that enables them to be productive, and amplifies the data science work that they do each day.
When developing custom ma- chine learning and deep learning models, there are lots of choices in the toolkits. Azure Machine Learn- ing lets you use the toolkits you’re familiar with—Cognitive Toolkit (CNTK), Tensorflow, Caffe and more. In addition, Azure Machine Learning can deploy, manage and
Artificial Intelligence
Figure 5 Azure Machine Learning Workbench 10 msdn magazine