https://azure.microsoft.com/ja-jp/services/cognitive-services/face/
2.では、まずWebそのまま利用で行きましょう。
(図1)
あれ、いきなり同一人物、、、だと。
https://westcentralus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236
まずは、test_consoleで。
Keyは、取り直し
(図2)
http://153.126.154.106/photo_check_20170731/files/
に
http://153.126.154.106/photo_check_20170731/files/IMG_15875604182662.jpeg
http://153.126.154.106/photo_check_20170731/files/1448158857484.jpg
http://153.126.154.106/photo_check_20170731/files/20110826oresama.JPG
まあ、なんか出たけど(北京でのビール片手)。。。2枚の比較ではないなあ・・・
apim-request-id: e0dc48de-9307-4c7e-9265-b397fb1c56dc
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Cache-Control: no-cache
Date: Mon, 31 Jul 2017 12:38:30 GMT
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Length: 1329
Content-Type: application/json; charset=utf-8
Expires: -1
https://westcentralus.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524b/console
apim-request-id: f7a884b5-110d-4748-b603-2794c9a9d7d5
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
Cache-Control: no-cache
Date: Mon, 31 Jul 2017 12:47:03 GMT
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Content-Length: 0
Expires: -1
ここからPython2.7 のコード
*********************************
#### Update or verify the following values. ###
###############################################
subscription_key = ’13hc77781f7e4b19b5fcdd72a8df7156′
#
# You must use the same region in your REST API call as you used to obtain your subscription keys.
# For example, if you obtained your subscription keys from the westus region, replace
# “westcentralus” in the URI below with “westus”.
#
# NOTE: Free trial subscription keys are generated in the westcentralus region, so if you are using
# a free trial subscription key, you should not need to change this region.
uri_base = ‘westcentralus.api.cognitive.microsoft.com’
headers = {
‘Content-Type’: ‘application/json’,
‘Ocp-Apim-Subscription-Key’: 91723b068b294bb7b1e78d8ba36914b9,
}
params = urllib.urlencode({
‘returnFaceId’: ‘true’,
‘returnFaceLandmarks’: ‘false’,
‘returnFaceAttributes’: ‘age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise’,
})
body = “{‘url’:’http://153.126.154.106/photo_check_20170731/files/20110826oresama.JPG’}”
# Execute the REST API call and get the response.
conn = httplib.HTTPSConnection(‘westcentralus.api.cognitive.microsoft.com’)
conn.request(“POST”, “/face/v1.0/detect?%s” % params, body, headers)
response = conn.getresponse()
data = response.read()
parsed = json.loads(data)
print (“Response:”)
print (json.dumps(parsed, sort_keys=True, indent=2))
conn.close()
print(“[Errno {0}] {1}”.format(e.errno, e.strerror))
ここまでPython2.7 のコード
*********************************
↓
*********************************
ここからResponse結果
*********************************
Response:
[
{
“faceAttributes”: {
“accessories”: [],
“age”: 34.9,
“blur”: {
“blurLevel”: “high”,
“value”: 0.98
},
“emotion”: {
“anger”: 0.0,
“contempt”: 0.001,
“disgust”: 0.0,
“fear”: 0.0,
“happiness”: 0.123,
“neutral”: 0.876,
“sadness”: 0.0,
“surprise”: 0.0
},
“exposure”: {
“exposureLevel”: “goodExposure”,
“value”: 0.59
},
“facialHair”: {
“beard”: 0.4,
“moustache”: 0.1,
“sideburns”: 0.2
},
“gender”: “male”,
“glasses”: “NoGlasses”,
“hair”: {
“bald”: 0.02,
“hairColor”: [
{
“color”: “brown”,
“confidence”: 1.0
},
{
“color”: “black”,
“confidence”: 0.76
},
{
“color”: “gray”,
“confidence”: 0.29
},
{
“color”: “other”,
“confidence”: 0.18
},
{
“color”: “blond”,
“confidence”: 0.09
},
{
“color”: “red”,
“confidence”: 0.07
}
],
“invisible”: false
},
“headPose”: {
“pitch”: 0.0,
“roll”: 1.2,
“yaw”: -6.3
},
“makeup”: {
“eyeMakeup”: false,
“lipMakeup”: true
},
“noise”: {
“noiseLevel”: “medium”,
“value”: 0.61
},
“occlusion”: {
“eyeOccluded”: false,
“foreheadOccluded”: false,
“mouthOccluded”: false
},
“smile”: 0.123
},
“faceId”: “3509””3-608a-4165-be27-b9e9″”””””2f7″,
“faceRectangle”: {
“height”: 406,
“left”: 863,
“top”: 151,
“width”: 406
}
}*********************************
ここまで結果
*********************************
Face API
***********************
写真に含まれる顔の検出、識別、分析、グループ化、タグ付け
30,000 トランザクション (1 分あたり 20 回)。
エンドポイント: https://westcentralus.api.cognitive.microsoft.com/face/v1.0
キー 1: 917*******************6914b9
キー 2: 192**********************2105ae
Emotion API
***********************
感情認識を使用してエクスペリエンスをパーソナライズする
30,000 トランザクション (1 分あたり 20 回)。
エンドポイント: https://westus.api.cognitive.microsoft.com/emotion/v1.0
キー 1: 2998″”””””””””””””””””””””””””””1866
キー 2: 229c””””””””””””””””””””””””””””3a093b