Azure Cognitive Services:
Mood Analyzer
Hello!
I’m Sherry List
Azure Developer Technical Lead, Microsoft
You can find me at @SherrryLst
AI, ML, DL, ANN?
@Sherrrylst
Artificial Intelligence
AI is the simulation of human intelligence
processes by machines. These
processes include, reasoning,
remembering, learning and self-
correction.
@Sherrrylst
Machine Learning
@Sherrrylst
Machine learning is a field of computer
science that gives computers the ability
to learn without being explicitly
programmed.
Arthur Samuel, 1959
Machine learning techniques
@Sherrrylst
• Artificial Neural Networks
• Deep Learning
• Bayesian Networks
• Clustering
Artificial Intelligence (AI)
The bigger picture
Machine
Learning
Artificial Neural Networks
Deep Learning
Bayesian Networks
Clustering
@Sherrrylst
Machine
Learning 101
@Sherrrylst
Machine Learning 101
@Sherrrylst
Data
@Sherrrylst
Data
Patterns
Machine Learning 101
@Sherrrylst
Data
Patterns
Algorithm
(Deep learning, clustering, …)
Machine Learning 101
@Sherrrylst
Data
Patterns
Algorithm
(Deep learning, clustering, …)
Find patterns
Machine Learning 101
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns
Machine Learning 101
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns Recognizes patterns
Machine Learning 101
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns Recognizes patterns
Training
Machine Learning 101
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns Recognizes patterns Application
Training
Machine Learning 101
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns Recognizes patterns Application
Challenges
Data preparation
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns Recognizes patterns Application
Challenges
Data preparation Create and test algorithms
@Sherrrylst
Algorithm
(Deep learning, clustering, …)
Find patterns
Challenges
Create and test algorithms
Chihuahua or muffin?
@Sherrrylst
Data
Patterns
Model
Algorithm
(Deep learning, clustering, …)
Find patterns Recognizes patterns Application
Challenges
Data preparation Create and test algorithms Expose the model to app
Is there a better
way?
@Sherrrylst
Azure
Cognitive
Services
@Sherrrylst
@Sherrrylst
Application
The easier way
Azure Cognitive
Services
REST API
Azure Cognitive Services === machine-learning-as-a-service
@Sherrrylst
@Sherrrylst
Application
The easier way
Azure Cognitive
Services
REST API
Azure Cognitive Services
Decision Speech Language Search Vision
@Sherrrylst
Decision
(Cognitive Services)
@Sherrrylst
@Sherrrylst
• Content Moderator
Cognitive Services - Decision
@Sherrrylst
• Content Moderator
• Anomaly Detector (Preview)
Cognitive Services - Decision
@Sherrrylst
• Content Moderator
• Anomaly Detector (Preview)
• Personalizer(Preview)
Cognitive Services - Decision
Speech
(Cognitive Services)
@Sherrrylst
• Speech Services
• Speech to Text
• Text to Speech
• Business Scenario (Call center)
@Sherrrylst
Cognitive Services - Speech
• Speech Services
• Speaker recognition (Preview)
@Sherrrylst
Cognitive Services - Speech
@Sherrrylst
Language
(Cognitive Services)
• Language Understanding
@Sherrrylst
Cognitive Services - Language
• Language Understanding
• Bing Spell Check
@Sherrrylst
Cognitive Services - Language
• Language Understanding
• Bing Spell Check
• Translator Text
@Sherrrylst
Cognitive Services - Language
• Language Understanding
• Bing Spell Check
• Translator Text
• Text Analytics
@Sherrrylst
Cognitive Services - Language
• Language Understanding
• Bing Spell Check
• Translator Text
• Text Analytics
• QnA Maker
@Sherrrylst
Cognitive Services - Language
@Sherrrylst
Search
(Cognitive Services)
Cognitive Services - Search
@Sherrrylst
• Bing Custom Search
• Bing Web Search
• Bing Video Search
• Bing Image Search
• Bing Local Business Search (Preview)
• Bing Visual Search
• Bing Entity Search
• Bing News Search
• Bing Auto Suggest
@Sherrrylst
Vision
(Cognitive Services)
• Computer vision
@Sherrrylst
Cognitive Services - Vision
• Computer vision
• Video Indexer
@Sherrrylst
Cognitive Services - Vision
• Computer vision
• Video Indexer
• Face
@Sherrrylst
Cognitive Services - Vision
• Computer vision
• Video Indexer
• Face
• Custom Vision
@Sherrrylst
Cognitive Services - Vision
• Computer vision
• Video Indexer
• Face
• Custom Vision
• Ink Recognizer (Preview)
@Sherrrylst
Cognitive Services - Vision
• Computer vision
• Video Indexer
• Face
• Custom Vision
• Ink Recognizer (Preview)
• Form Recognizer (Preview)
@Sherrrylst
Cognitive Services - Vision
How to use it?
@Sherrrylst
How to use Cognitive Services?
1. Create service in Azure Portal
(https://portal.azure.com/)
@Sherrrylst
How to use Cognitive Services?
1. Create service in Azure Portal
(https://portal.azure.com/)
2. Customize and train model in the
portal (Optional)
@Sherrrylst
How to use Cognitive Services?
1. Create service in Azure Portal
(https://portal.azure.com/)
2. Customize and train model in the
portal (Optional)
3. Call the REST API from your app
@Sherrrylst
How to use Cognitive Services?
1. Create service in Azure Portal
(https://portal.azure.com/)
2. Customize and train model in the
portal (Optional)
3. Call the REST API from your app
4. Parse the JSON response
@Sherrrylst
Let’s do it!
@Sherrrylst
Create a Cognitive Services account in the
Azure portal
@Sherrrylst
@Sherrrylst
Cognitive Services account - Face
Face API
@Sherrrylst
Cognitive Services account
@Sherrrylst
• URL : {Endpoint}/face/v1.0/detect
• URI Parameters
• Location
• returnFaceLandmarks (Boolean)
• returnFaceAttributes
• age,gender,smile,glasses,emotion,facialHair
• Headers
• Content-Type: application/octet-stream | application/json
• Ocp-Apim-Subscription-Key
Face API - Detect
Face API Documentation
@Sherrrylst
Face API - Detect
Face API Documentation
<code />
@Sherrrylst Source code
{N} Playground
@Sherrrylst
@Sherrrylst
Face API – Mood Analyzer
async runFaceDetect() {
this.dataSource = [];
const imageAsset = await takePicture(
{
width: 300,
height: 500,
keepAspectRatio: true,
saveToGallery: false
});
const filePath = await this.getFilePath(imageAsset);
const imageFile = File.fromPath(filePath);
this.pictureFromCamera = imageAsset;
this.result = await this.sendRequest(imageFile);
this.dataSource = getEmotionData(this.result);
}
Source code
@Sherrrylst
Face API – Posting data (Part 1)
sendRequest(file: File): Promise<any> {
return new Promise((resolve, reject) => {
const ses = session('image-upload');
const request = {
url: this.faceUrl,
method: 'POST',
headers: {
'Content-Type': 'application/octet-stream',
'Ocp-Apim-Subscription-Key': '7d30f6357121430e91b3f8439b8205c6',
},
description: 'Uploading ' + file.name
};
const task = ses.uploadFile(file.path, request);
...
});
}
Source code
@Sherrrylst
Face API – Posting data (Part 2)
sendRequest(file: File): Promise<any> {
return new Promise((resolve, reject) => {
...
task.on('error',
e => reject('error ' + e.responseCode + ' code.')
)
task.on('responded',
e => {
const data = JSON.parse(e.data);
return resolve(data);
}
);
});
}
Source code
@Sherrrylst
Face API – Posting data
async runFaceDetect() {
this.dataSource = [];
const imageAsset = await takePicture(
{
width: 300,
height: 500,
keepAspectRatio: true,
saveToGallery: false
});
const filePath = await this.getFilePath(imageAsset);
const imageFile = File.fromPath(filePath);
this.pictureFromCamera = imageAsset;
this.result = await this.sendRequest(imageFile);
this.dataSource = getEmotionData(this.result);
}
Source code
@Sherrrylst
Demo
Source code
Scan the code
@Sherrrylst
AI.lab@Sherrrylst
Azure Cognitive Services re-cap
@Sherrrylst
• Easy to use (REST API)
• Easy to provision
• Provide pre-trained models
• Possibility to use custom data
• Free training resources
• Detailed documentation
• Create account for free
@sebawita
Thank you!
@Sherrrylst
Thank you!
https://aka.ms/dot-net-madrid
Sample code
@Sherrrylst
https://aka.ms/AA5bt1y
Resources
• Microsoft Azure Cognitive Services: The Big Picture
• The Mojifier (MS Learn)
• The Mojifier (Github)
• Azure Cognitive Services API - I need your clothes, boots and your motorcycle
• Add conversational intelligence to your apps by using LUIS (MS Learn)
• Discover sentiment in text with the Text Analytics API (MS Learn)
• Create Intelligent Bots with the Azure Bot Service (MS Learn)
• Getting started with Azure Cognitive Services

DotNet 2019 | Sherry List - Azure Cognitive Services with Native Script