Fix preprocessing for batch image features

This commit is contained in:
Madison May
2014-12-20 17:16:50 -05:00
parent aa63a831c6
commit f58643868f
3 changed files with 37 additions and 2 deletions
+1 -1
View File
@@ -59,5 +59,5 @@ def image_features(api_root, image, batch=False, auth=None, **kwargs):
:type image: numpy.ndarray
:rtype: List containing features
"""
image = image_preprocess(image)
image = image_preprocess(image, batch=batch)
return api_handler(image, api_root + "imagefeatures", batch=batch, auth=auth, **kwargs)
+3 -1
View File
@@ -120,11 +120,13 @@ def normalize(array, distribution=1, norm_range=(0, 1), **kwargs):
return dict(zip(keys, norm_array))
return norm_array
def image_preprocess(image):
def image_preprocess(image, batch=False):
"""
Takes an image and prepares it for sending to the api including
resizing and image data/structure standardizing.
"""
if batch:
return [image_preprocess(img, batch=False) for img in image]
if isinstance(image,list):
image = np.asarray(image)
if type(image).__module__ != np.__name__: