mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-09-09 11:14:32 +08:00
Api standardization, feature importance folder
This commit is contained in:
@@ -3,8 +3,7 @@ import json
|
||||
import requests
|
||||
import numpy as np
|
||||
|
||||
from indicoio import JSON_HEADERS
|
||||
from indicoio.utils import image_preprocess
|
||||
from indicoio.utils import image_preprocess, api_handler
|
||||
|
||||
def facial_features(api_root, image):
|
||||
"""
|
||||
@@ -28,14 +27,7 @@ def facial_features(api_root, image):
|
||||
:type image: list of lists
|
||||
:rtype: List containing feature responses
|
||||
"""
|
||||
|
||||
data_dict = json.dumps({"face": image})
|
||||
response = requests.post(api_root + "facialfeatures", data=data_dict, headers=JSON_HEADERS)
|
||||
response_dict = response.json()
|
||||
if 'response' not in response_dict:
|
||||
raise ValueError(response_dict.values()[0])
|
||||
else:
|
||||
return response_dict['response']
|
||||
return api_handler(image, api_root + "facialfeatures")
|
||||
|
||||
def image_features(api_root, image):
|
||||
"""
|
||||
@@ -68,10 +60,4 @@ def image_features(api_root, image):
|
||||
:rtype: List containing features
|
||||
"""
|
||||
image = image_preprocess(image)
|
||||
data_dict = json.dumps({"image": image})
|
||||
response = requests.post(api_root + "imagefeatures", data=data_dict, headers=JSON_HEADERS)
|
||||
response_dict = response.json()
|
||||
if 'Features' not in response_dict:
|
||||
raise ValueError(response_dict.values()[0])
|
||||
else:
|
||||
return response_dict['Features']
|
||||
return api_handler(image, api_root + "imagefeatures")
|
||||
|
||||
Reference in New Issue
Block a user