The Network Is The Computer: Celebrity Spotting! The Cloud becomes a bit more “human”

Computers have generally struggled to be human, as they often struggle to interpret our language and in analysing images. When we look at…

The Network Is The Computer: Celebrity Spotting! The Cloud becomes a bit more “human”

Computers have generally struggled to be human, as they often struggle to interpret our language and in analysing images. When we look at this we say “That’s Tiger Woods, playing golf, touching his cap, and with a nice blue shirt”.

But for a computer, it is not so easy, as they must try to mine the information based on a whole lot of pixels, and provide us with information that makes sense. “What is golf?”, “What is a shirt?” and “What is nice?”

So, I’ve been investigating a whole range of cognitive services within the Microsoft Cloud, and it feels like the Cloud is becoming a bit more human in its ‘thinking’. One of the new cognitive services is mining of information from images. This includes matching photos to people and famous landmarks, along with mining images and video for text.

So let’s integrate Microsoft’s Cognitive Service for image matching. First you have to register for the service:

and then run the code:

import httplib, urllib, base64
from pprint import pprint
import json
import sys
text='http://asecuritysite.com/log/till.jpg'
headers = {
# Request headers. Replace the key below with your subscription key.
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': 'KEY HERE',
}
params = urllib.urlencode({
# Request parameters. All of them are optional.
'visualFeatures': 'Categories',
'details': 'Celebrities',
'language': 'en',
})
body = "{'url':\'"+text+"\'}"
print body
try:
conn = httplib.HTTPSConnection('westus.api.cognitive.microsoft.com')
conn.request("POST", "/vision/v1.0/analyze?%s" % params, body, headers)
response = conn.getresponse()
data = response.read()
    conn.close()
d1=json.loads(data)
print
print 'Score: %3s \"%s\" \"%s\" ' % (d1['categories'][0]['score'],
d1['categories'][0]['name'],
d1['categories'][0]['detail']['celebrities'][0]['name'])
    print 
print 'Data:'
pprint(data)

and when run with a picture of Andy Murray, it spots him:

Loading:{'url':'http://asecuritysite.com/log/andy.jpg'}
Score: 0.87890625 "people_" "Andy Murray" 
Data:
{u'requestId': u'8af692d0-24c1-404a-b2f4-f0af931f510c', u'categories':
[{u'score': 0.87890625, u'name': u'people_', u'detail': {u'celebrities':
[{u'confidence': 1.0, u'faceRectangle':
{u'width': 140, u'top': 127, u'height': 140, u'left': 283},
u'name': u'Andy Murray'}]}}], u'metadata':
{u'width': 768, u'format': u'Jpeg', u'height': 432}}

So, you just can’t hide from the Cloud, it will spot you somewhere:

http://asecuritysite.com/comms/faceapi2

We are at the beginning of a great revolution, and where we will use the Cloud to make sense of our lives … the true start of the rise of intelligent machines!