mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-08-13 11:50:15 +08:00
Passing in a root_url variable and pulling config from environment variables
This commit is contained in:
committed by
Madison May
parent
a1621e8531
commit
6b9251f4f5
@@ -4,12 +4,13 @@ import requests
|
||||
import numpy as np
|
||||
|
||||
from indicoio.utils import image_preprocess, api_handler
|
||||
import indicoio.config as config
|
||||
|
||||
def facial_features(api_root, image, batch=False, auth=None, **kwargs):
|
||||
def facial_features(image, url_root=config.api_root, batch=False, auth=None, **kwargs):
|
||||
"""
|
||||
Given an grayscale input image of a face, returns a 48 dimensional feature vector explaining that face.
|
||||
Useful as a form of feature engineering for face oriented tasks.
|
||||
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:
|
||||
@@ -27,18 +28,18 @@ def facial_features(api_root, image, batch=False, auth=None, **kwargs):
|
||||
:type image: list of lists
|
||||
:rtype: List containing feature responses
|
||||
"""
|
||||
return api_handler(image, api_root + "facialfeatures", batch=batch, auth=auth, **kwargs)
|
||||
return api_handler(image, url_root + "facialfeatures", batch=batch, auth=auth, **kwargs)
|
||||
|
||||
def image_features(api_root, image, batch=False, auth=None, **kwargs):
|
||||
def image_features(image, url_root=config.api_root, batch=False, auth=None, **kwargs):
|
||||
"""
|
||||
Given an input image, returns a 2048 dimensional sparse feature vector explaining that image.
|
||||
Given an input image, returns a 2048 dimensional sparse feature vector explaining that image.
|
||||
Useful as a form of feature engineering for image oriented tasks.
|
||||
|
||||
* Input can be either grayscale or rgb color and should either be a numpy array or nested list format.
|
||||
* Input data should be either uint8 0-255 range values or floating point between 0 and 1.
|
||||
* Large images (i.e. 1024x768+) are much bigger than needed, resizing will be done internally to 64x64 if needed.
|
||||
* For ideal performance, images should be square aspect ratio but non-square aspect ratios are supported as well.
|
||||
|
||||
|
||||
Example usage:
|
||||
|
||||
.. code-block:: python
|
||||
@@ -60,4 +61,4 @@ def image_features(api_root, image, batch=False, auth=None, **kwargs):
|
||||
:rtype: List containing features
|
||||
"""
|
||||
image = image_preprocess(image, batch=batch)
|
||||
return api_handler(image, api_root + "imagefeatures", batch=batch, auth=auth, **kwargs)
|
||||
return api_handler(image, url_root + "imagefeatures", batch=batch, auth=auth, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user