diff --git a/indicoio/images/features.py b/indicoio/images/features.py index 8ccb546..3c20010 100644 --- a/indicoio/images/features.py +++ b/indicoio/images/features.py @@ -24,6 +24,7 @@ def facial_features(image, cloud=None, batch=False, api_key=None, **kwargs): :type image: list of lists :rtype: List containing feature responses """ + image = image_preprocess(image, batch=batch) return api_handler(image, cloud=cloud, api="facialfeatures", batch=batch, api_key=api_key, **kwargs) def image_features(image, cloud=None, batch=False, api_key=None, **kwargs): diff --git a/indicoio/images/fer.py b/indicoio/images/fer.py index 1dfe1c5..642f086 100644 --- a/indicoio/images/fer.py +++ b/indicoio/images/fer.py @@ -1,6 +1,6 @@ import requests -from indicoio.utils import api_handler +from indicoio.utils import api_handler, image_preprocess import indicoio.config as config def fer(image, cloud=None, batch=False, api_key=None, **kwargs): @@ -26,5 +26,5 @@ def fer(image, cloud=None, batch=False, api_key=None, **kwargs): :type image: list of lists :rtype: Dictionary containing emotion probability pairs """ - + image = image_preprocess(image, batch=batch) return api_handler(image, cloud=cloud, api="fer", batch=batch, api_key=api_key, **kwargs) diff --git a/tests/test_remote.py b/tests/test_remote.py index 2e5c167..32f4b3f 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -46,6 +46,27 @@ class BatchAPIRun(unittest.TestCase): self.assertTrue(isinstance(response, list)) self.assertTrue(isinstance(response[0], dict)) + def test_batch_fer_bad_b64(self): + test_data = ["$bad#FI jeaf9(#0"] + self.assertRaises(ValueError, batch_fer, test_data, api_key=self.api_key) + + def test_batch_fer_good_b64(self): + test_data = ["iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAg5JREFUeNrEV4uNgzAMpegGyAgZgQ3KBscIjMAGx03QEdqbgG5AOwG3AWwAnSCXqLZkuUkwhfYsvaLm5xc7sZ1dIhdtUVjsLZRFTvp+LSaLq8UZ/s+KMSbZCcY5RV9E4QQKHG7QtgeCGv4PFt8WpzkCcztu3TiL0eJgkQmsVFn0MK+LzYkRKEGpG1GDyZdKRdaolhAoJewXnJsO1jtKCFDlChZAFxyJj2PnBRU20KZg7oMlOAENijpi8hwmGkKkZW2GzONtVLA/DxHAhTO2I7MCVBSQ6nGDlEBJDhyVYiUBHXBxzQm0wE4FzPYsGs856dA9SAAP2oENzFYqR6iAFQpHIAUzO/nxnOgthF/lM3w/3U8KYXTwxG/1IgIulF+wPQUXDMl75UoJZIHstRWpaGb8IGYqwBoKlG/lgpzoUEBoj50p8QtVrmHgaaXyC/H3BFC+e9kGFlCB0CtBF7FifQ8D9zjQQHj0pdOM3F1pUBoFKdxtqkMClScHJCSDlSxhHSNRT5K+FaZnHglrz+AGoxZLKNLYH6s3CkkuyJlp58wviZ4PuSCWDXl5hmjZtxcSCGbDUD3gK7EMOZBLCETrgVBF5K0lI5bIZ0wfrYh8NWHIAiNTPHpuTOKpCes1VTFaiNaFdGwPfdmaqlj6LmjJbgoSSfUW74K3voz+/W0oIeB7HWu2s+dfx3N+eLX8CTAAwUmKjK/dHS4AAAAASUVORK5CYII="] + response = batch_fer(test_data, api_key=self.api_key) + self.assertTrue(isinstance(response, list)) + self.assertTrue(isinstance(response[0], dict)) + + def test_batch_fer_filepath(self): + test_data = [os.path.normpath(os.path.join(DIR, "data/fear.png"))] + response = batch_fer(test_data, api_key=self.api_key) + self.assertTrue(isinstance(response, list)) + self.assertTrue(isinstance(response[0], dict)) + + def test_batch_fer_nonexistant_filepath(self): + test_data = ["data/unhappy.png"] + self.assertRaises(ValueError, batch_fer, test_data, api_key=self.api_key) + + def test_batch_facial_features(self): test_data = [generate_array((48,48))] response = batch_facial_features(test_data, api_key=self.api_key)