def test_constructor_sets_instrumentation_key(self): face = Client.face('key') vision = Client.vision('key') emotion = Client.emotion('key') self.assertIsNotNone(face) self.assertIsNotNone(vision) self.assertIsNotNone(emotion)
def test_constructor_sets_instrumentation_key(self): face = Client.face('key') vision = Client.vision('key') emotion = Client.emotion('key') self.assertIsNotNone(face) self.assertIsNotNone(vision) self.assertIsNotNone(emotion)
def setUpClass(cls): # set up self.client for tests cls.client = Client.face(os.environ['OXFORD_FACE_API_KEY']) # detect two faces cls.knownFaceIds = []; cls.localFilePrefix = os.path.join(rootDirectory, 'tests', 'images') face1 = cls.client.detect({'path': os.path.join(cls.localFilePrefix, 'face1.jpg')}) face2 = cls.client.detect({'path': os.path.join(cls.localFilePrefix, 'face2.jpg')}) cls.knownFaceIds.append(face1[0]['faceId']) cls.knownFaceIds.append(face2[0]['faceId'])
def setUpClass(cls): # set up self.client for tests cls.client = Client.face(os.environ['OXFORD_FACE_API_KEY']) # detect two faces cls.knownFaceIds = [] cls.localFilePrefix = os.path.join(rootDirectory, 'tests', 'images') face1 = cls.client.detect( {'path': os.path.join(cls.localFilePrefix, 'face1.jpg')}) face2 = cls.client.detect( {'path': os.path.join(cls.localFilePrefix, 'face2.jpg')}) cls.knownFaceIds.append(face1[0]['faceId']) cls.knownFaceIds.append(face2[0]['faceId'])
def setUpClass(cls): # set up client for tests cls.client = Client.face(os.environ['OXFORD_FACE_API_KEY']) # detect two faces cls.knownFaceIds = []; localFilePrefix = os.path.join(rootDirectory, 'tests', 'images') face1 = cls.client.detect({'path': os.path.join(localFilePrefix, 'face1.jpg')}) face2 = cls.client.detect({'path': os.path.join(localFilePrefix, 'face2.jpg')}) cls.knownFaceIds.append(face1[0]['faceId']) cls.knownFaceIds.append(face2[0]['faceId']) # create a person group cls.personGroupId = str(uuid.uuid4()) cls.client.personGroup.create(cls.personGroupId, 'test-person-group')
def setUpClass(cls): # set up client for tests cls.client = Client.face(os.environ['OXFORD_FACE_API_KEY']) # detect two faces cls.knownFaceIds = [] localFilePrefix = os.path.join(rootDirectory, 'tests', 'images') face1 = cls.client.detect( {'path': os.path.join(localFilePrefix, 'face1.jpg')}) face2 = cls.client.detect( {'path': os.path.join(localFilePrefix, 'face2.jpg')}) cls.knownFaceIds.append(face1[0]['faceId']) cls.knownFaceIds.append(face2[0]['faceId']) # create a person group cls.personGroupId = str(uuid.uuid4()) cls.client.personGroup.create(cls.personGroupId, 'test-person-group')
def setUpClass(cls): # set up self.client for tests cls.client = Client.face(os.environ['OXFORD_FACE_API_KEY']) # detect two faces cls.knownFaceIds = []; cls.localFilePrefix = os.path.join(rootDirectory, 'tests', 'images') face1 = cls.client.detect({'path': os.path.join(cls.localFilePrefix, 'face1.jpg')}) face2 = cls.client.detect({'path': os.path.join(cls.localFilePrefix, 'face2.jpg')}) cls.knownFaceIds.append(face1[0]['faceId']) cls.knownFaceIds.append(face2[0]['faceId']) # set common detect options cls.detectOptions = { 'analyzesFaceLandmarks': True, 'analyzesAge': True, 'analyzesGender': True, 'analyzesHeadPose': True }
def setUpClass(cls): # set up self.client for tests cls.client = Client.face(os.environ['OXFORD_FACE_API_KEY']) # detect two faces cls.knownFaceIds = [] cls.localFilePrefix = os.path.join(rootDirectory, 'tests', 'images') face1 = cls.client.detect( {'path': os.path.join(cls.localFilePrefix, 'face1.jpg')}) face2 = cls.client.detect( {'path': os.path.join(cls.localFilePrefix, 'face2.jpg')}) cls.knownFaceIds.append(face1[0]['faceId']) cls.knownFaceIds.append(face2[0]['faceId']) # set common detect options cls.detectOptions = { 'analyzesFaceLandmarks': True, 'analyzesAge': True, 'analyzesGender': True, 'analyzesHeadPose': True }
''' This program should do two things: 1. Add all of the people from the db.json into Project Oxford's API 2. Train the mlb person group ''' from projectoxford.Client import Client from projectoxford.Person import Person from projectoxford.PersonGroup import PersonGroup import json import time client = Client() faceClient = client.face('9defe6b7bd8045eea6cccb8e4b8d5ddd') personClient = Person('9defe6b7bd8045eea6cccb8e4b8d5ddd') def getJSONfromDB(path): # readDB :: String -> JSON ''' Gets the JSON from the file at the inputted path and returns it as a string''' json_data = open(path).read() with open(path) as data_file: data = json.load(data_file) return data #pprint.PrettyPrinter(indent=4).pprint(data) def addPerson(name, url, personGroup): # addPerson :: String -> String -> String -> () ''' Creates a person based in an inputted name and image url before adding it to the inputted personGroup in Project Oxford's API''' # Detect face from image result = faceClient.detect({'url': url})
userName = '******' # Define subreddit to troll sub = 'whoisdat' ##### # Define user agent user_agent = 'User-Agent: windows:WhoDat:v0.0.1 (by /u/' + userName + ')' # Create initial praw object r = praw.Reddit(user_agent) subreddit = r.get_subreddit('whoisdat') # Configure Project Oxford API client = Client() faceClient = client.face( sys.argv[1] ) # The API key is retrieved from the first command line argument # This will hold all submissions that have been dealt with submissions = [] def getAppropriateComment(result): # JSON -> JSON ''' Returns the appropriate comment to post given a result from Project Oxford''' # Name, debut date, draft date, position print "response \n\n" print result if result[0]['candidates'] == []: comment = "I couldn't figure out who this is. Sorry!" return comment else: conf = result[0]['candidates'][0]['confidence']
def test_face_return_throws_for_bad_request(self): client = Client.face('key') self.assertRaises(Exception, client.detect, {'url': 'http://bing.com'})
userName = '******' # Define subreddit to troll sub = 'whoisdat' ##### # Define user agent user_agent = 'User-Agent: windows:WhoDat:v0.0.1 (by /u/' + userName + ')' # Create initial praw object r = praw.Reddit(user_agent) subreddit = r.get_subreddit('whoisdat') # Configure Project Oxford API client = Client() faceClient = client.face(sys.argv[1]) # The API key is retrieved from the first command line argument # This will hold all submissions that have been dealt with submissions = [] def getAppropriateComment(result): # JSON -> JSON ''' Returns the appropriate comment to post given a result from Project Oxford''' # Name, debut date, draft date, position print "response \n\n" print result if result[0]['candidates'] == []: comment = "I couldn't figure out who this is. Sorry!" return comment else: conf = result[0]['candidates'][0]['confidence'] person = faceClient.person.get('mlb', result[0]['candidates'][0]['personId']) identitySentence = "**WhoDatBot:**\nI'm " + str(conf * 100) + "% certain that this is " + person['name'] + "."
def test_face_return_throws_for_bad_request(self): client = Client.face('key') self.assertRaises(Exception, client.detect, {'url': 'http://bing.com'});