From 934424ead52ad69a7ca716222dce4b63477ea661 Mon Sep 17 00:00:00 2001 From: Slater-Victoroff Date: Sun, 4 May 2014 22:43:56 -0400 Subject: [PATCH] All basic APIs working --- IndicoIo/images/facial_features.py | 7 +------ IndicoIo/images/fer.py | 12 ++++++++++++ IndicoIo/text/sentiment.py | 6 +----- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/IndicoIo/images/facial_features.py b/IndicoIo/images/facial_features.py index 0ac9775..c3f7c91 100644 --- a/IndicoIo/images/facial_features.py +++ b/IndicoIo/images/facial_features.py @@ -3,15 +3,10 @@ import json import requests import numpy as np -TEST_GOOD_FACE = np.linspace(0,50,48*48).reshape(48,48).tolist() -TEST_BAD_FACE = np.linspace(0,50,56*56).reshape(56,56).tolist() - -base_url = lambda c: "http://localhost/api/features/%s" % c +base_url = lambda c: "http://indico.io/api/features/%s" % c headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} def facial(face): data_dict = json.dumps({"datums": face}) response = requests.post(base_url("facial"), data=data_dict, headers=headers) return response.content - -print facial(TEST_BAD_FACE) diff --git a/IndicoIo/images/fer.py b/IndicoIo/images/fer.py index e69de29..7eb9dfb 100644 --- a/IndicoIo/images/fer.py +++ b/IndicoIo/images/fer.py @@ -0,0 +1,12 @@ +import json + +import requests +import numpy as np + +base_url = "http://indico.io/api/fer/classify" +headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} + +def fer(face): + data_dict = json.dumps({"image": face}) + response = requests.post(base_url, data=data_dict, headers=headers) + return response.content diff --git a/IndicoIo/text/sentiment.py b/IndicoIo/text/sentiment.py index 0fad602..899fd8e 100644 --- a/IndicoIo/text/sentiment.py +++ b/IndicoIo/text/sentiment.py @@ -1,7 +1,7 @@ import requests import json -base_url = lambda c: "http://localhost/api/sentiment/%s/classify" % c +base_url = lambda c: "http://indico.io/api/sentiment/%s/classify" % c headers = {'Content-type': 'application/json', 'Accept': 'text/plain'} def political(test_text): @@ -18,7 +18,3 @@ def sentiment(test_text): data_dict = json.dumps({'text': test_text}) response = requests.post(base_url("sentiment"), data=data_dict, headers=headers) return json.loads(response.content) - -print political("Guns don't kill people, people kill people.") -print spam("Get a Free Car!!") -print sentiment("Worst Car Ever.")