Passing in a root_url variable and pulling config from environment variables

This commit is contained in:
Anne Carlson
2015-02-27 16:32:32 -05:00
committed by Madison May
parent a1621e8531
commit 6b9251f4f5
7 changed files with 39 additions and 37 deletions
+9 -7
View File
@@ -2,12 +2,14 @@ import json
import requests
import numpy as np
from indicoio.utils import api_handler
def fer(api_root, image, batch=False, auth=None, **kwargs):
from indicoio.utils import api_handler
import indicoio.config as config
def fer(image, url_root=config.api_root, batch=False, auth=None, **kwargs):
"""
Given a grayscale input image of a face, returns a probability distribution over emotional state.
Input should be in a list of list format, resizing will be attempted internally but for best
Input should be in a list of list format, resizing will be attempted internally but for best
performance, images should be already sized at 48x48 pixels..
Example usage:
@@ -19,13 +21,13 @@ def fer(api_root, image, batch=False, auth=None, **kwargs):
>>> face = np.zeros((48,48)).tolist()
>>> emotions = fer(face)
>>> emotions
{u'Angry': 0.6340586827229989, u'Sad': 0.1764309536057839,
u'Neutral': 0.05582989039191157, u'Surprise': 0.0072685938275375344,
{u'Angry': 0.6340586827229989, u'Sad': 0.1764309536057839,
u'Neutral': 0.05582989039191157, u'Surprise': 0.0072685938275375344,
u'Fear': 0.08523385724298838, u'Happy': 0.04117802220878012}
:param image: The image to be analyzed.
:type image: list of lists
:rtype: Dictionary containing emotion probability pairs
"""
return api_handler(image, api_root + "fer", batch=batch, auth=auth, **kwargs)
return api_handler(image, url_root + "fer", batch=batch, auth=auth, **kwargs)