mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-08-04 12:33:47 +08:00
ADD: basic min axis content resizing
This commit is contained in:
committed by
Madison May
parent
1d42d6defe
commit
d00b669a16
@@ -336,6 +336,11 @@ class FullAPIRun(unittest.TestCase):
|
||||
response = content_filtering(test_face)
|
||||
self.assertTrue(response < 0.5)
|
||||
|
||||
def test_resize_content_filtering(self):
|
||||
test_face = os.path.normpath(os.path.join(DIR, "data/happy.png"))
|
||||
response = content_filtering(test_face)
|
||||
self.assertTrue(isinstance(response, float))
|
||||
|
||||
def test_good_facial_features(self):
|
||||
test_face = os.path.normpath(os.path.join(DIR, "data/48by48.png"))
|
||||
response = facial_features(test_face)
|
||||
@@ -551,6 +556,11 @@ class NumpyImagesRun(FullAPIRun):
|
||||
test_image = np.random.randint(255, 300, size=(48,48, 5))
|
||||
self.assertRaises(IndicoError, image_features, test_image)
|
||||
|
||||
def test_resize_content_filtering_numpy_arrays(self):
|
||||
test_image = np.random.randint(0, 255, size=(480,248, 3))
|
||||
response = content_filtering(test_image)
|
||||
self.assertTrue(isinstance(response, float))
|
||||
|
||||
def flatten(container):
|
||||
for i in container:
|
||||
if isinstance(i, list) or isinstance(i, tuple):
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
from indicoio.utils.image import image_preprocess
|
||||
from PIL import Image
|
||||
import os, unittest, base64, StringIO
|
||||
|
||||
DIR = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
class ResizeTests(unittest.TestCase):
|
||||
"""
|
||||
test image resizing
|
||||
"""
|
||||
def test_min_axis_resize(self):
|
||||
test_image = os.path.normpath(os.path.join(DIR, "data/fear.png"))
|
||||
resized_image = image_preprocess(test_image, min_axis=360)
|
||||
image_string = StringIO.StringIO(base64.b64decode(resized_image))
|
||||
image = Image.open(image_string)
|
||||
self.assertEqual(image.size, (360.0, 360.0))
|
||||
Reference in New Issue
Block a user