Skip to content
Snippets Groups Projects
Commit 3096a84d authored by Olegs NIKISINS's avatar Olegs NIKISINS
Browse files

Added unit tests for quality checking preprocessor and patch reshape function

parent e4be7bfe
No related branches found
No related tags found
1 merge request!83Preprocessing and quality check
......@@ -48,6 +48,10 @@ from bob.bio.video.utils import FrameSelector
from ..preprocessor import BlockPatch
from bob.pad.face.config.preprocessor.face_feature_crop_quality_check import face_feature_0_128x128_crop_rgb
from bob.pad.face.utils.patch_utils import reshape_flat_patches
def test_detect_face_landmarks_in_image_mtcnn():
......@@ -309,6 +313,56 @@ def test_video_face_crop_align_block_patch():
assert data_preprocessed[1][1].shape == (9, 12288)
# =============================================================================
def test_preproc_with_quality_check():
"""
Test _Preprocessor cropping the face and checking the quality of the image
applying eye detection, and asserting if they are in the expected positions.
"""
# =========================================================================
# prepare the test data:
image = load(datafile('test_image.png', 'bob.pad.face.test'))
annotations = None
video, annotations = convert_image_to_video_data(image, annotations, 2)
# =========================================================================
# test the preprocessor:
data_preprocessed = face_feature_0_128x128_crop_rgb(video)
assert data_preprocessed is None
# =============================================================================
def test_reshape_flat_patches():
"""
Test reshape_flat_patches function.
"""
image = load(datafile('test_image.png', 'bob.pad.face.test'))
patch1 = image[0,0:10,0:10]
patch2 = image[1,0:10,0:10]
patches = np.stack([patch1.flatten(), patch2.flatten()])
patches_3d = reshape_flat_patches(patches, (10, 10))
assert np.all(patch1 == patches_3d[0])
assert np.all(patch2 == patches_3d[1])
# =========================================================================
patch1 = image[:,0:10,0:10]
patch2 = image[:,1:11,1:11]
patches = np.stack([patch1.flatten(), patch2.flatten()])
patches_3d = reshape_flat_patches(patches, (3, 10, 10))
assert np.all(patch1 == patches_3d[0])
assert np.all(patch2 == patches_3d[1])
#==============================================================================
def test_frame_difference():
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment