mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-06-27 16:10:34 +08:00
All basic APIs working
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.")
|
||||
|
||||
Reference in New Issue
Block a user