def test_descriptor_batch_low_threshold_aggregation(self): """ Test descriptor batch with low threshold warps with aggregation """ faceWarp = FaceWarpedImage.load(filename=BAD_THRESHOLD_WARP) for descriptorVersion in EFDVa: with self.subTest(planVersion=descriptorVersion): extractor = self.faceEngine.createFaceDescriptorEstimator(descriptorVersion) descriptorBatch = self.getBatch(descriptorVersion, 2, DescriptorType.face) _, descriptor = extractor.estimateDescriptorsBatch( [faceWarp] * 2, aggregate=1, descriptorBatch=descriptorBatch ) assert descriptor.garbageScore < 0.6, "Expected low gs"
def test_descriptor_batch_bad_threshold_aggregation(self): """ Test descriptor batch with bad threshold warps with aggregation """ faceWarp = FaceWarpedImage.load(filename=BAD_THRESHOLD_WARP) for descriptorVersion in [56]: with self.subTest(planVersion=descriptorVersion): extractor = self.faceEngine.createFaceDescriptorEstimator(descriptorVersion) descriptorBatch = self.getBatch(descriptorVersion, 2, DescriptorType.face) with pytest.raises(LunaSDKException) as exceptionInfo: extractor.estimateDescriptorsBatch([faceWarp] * 2, aggregate=1, descriptorBatch=descriptorBatch) self.assertLunaVlError( exceptionInfo, LunaVLError.BatchedInternalError.format( "Cant aggregate descriptors - all images'a GSs are less the threashold" ), )
from lunavl.sdk.image_utils.image import VLImage from tests.base import BaseTestClass from tests.detect_test_class import VLIMAGE_SMALL from tests.resources import WARP_WHITE_MAN, HUMAN_WARP, WARP_CLEAN_FACE, BAD_THRESHOLD_WARP EFDVa = EXISTENT_FACE_DESCRIPTOR_VERSION_ABUNDANCE = [46, 52, 54, 56] EHDVa = EXISTENT_HUMAN_DESCRIPTOR_VERSION_ABUNDANCE = [DHDV] class DescriptorType(Enum): face = "face" human = "human" faceWarp = FaceWarpedImage.load(filename=WARP_WHITE_MAN) faceWarps = [faceWarp] * 3 humanWarp = HumanWarpedImage.load(filename=HUMAN_WARP) humanWarps = [humanWarp] * 3 class DescriptorCase(NamedTuple): descriptor: BaseDescriptor aggregatedDescriptor: BaseDescriptor descriptorBatch: BaseDescriptorBatch type: DescriptorType estimator: Union[FaceDescriptorEstimator, HumanDescriptorEstimator] class ExtractorCase(NamedTuple): type: DescriptorType
def setUpClass(cls) -> None: """ Load warps. """ cls._warp = FaceWarpedImage.load(filename=WARP_ONE_FACE) cls._warp2 = FaceWarpedImage.load(filename=WARP_CLEAN_FACE)
FaceDescriptor, FaceDescriptorBatch, ) from lunavl.sdk.errors.errors import LunaVLError from lunavl.sdk.errors.exceptions import LunaSDKException from lunavl.sdk.estimators.face_estimators.facewarper import FaceWarpedImage from lunavl.sdk.indexes.base import IndexResult from lunavl.sdk.indexes.builder import IndexBuilder from lunavl.sdk.indexes.stored_index import DynamicIndex, DenseIndex, IndexType from lunavl.sdk.estimators.face_estimators.face_descriptor import FaceDescriptorEstimator from tests.base import BaseTestClass from tests.resources import WARP_WHITE_MAN, WARP_ONE_FACE, WARP_CLEAN_FACE EFDVa = EXISTENT_FACE_DESCRIPTOR_VERSION_ABUNDANCE = [54, 56, 57, 58] faceWarp = FaceWarpedImage.load(filename=WARP_WHITE_MAN) faceWarps = [FaceWarpedImage.load(filename=WARP_CLEAN_FACE), FaceWarpedImage.load(filename=WARP_ONE_FACE)] currDir = os.path.dirname(__file__) pathToStoredIndex = os.path.join(currDir, "data", "stored.index") nonDefaultDynamicIndex = os.path.join(currDir, "data", "descriptor57.index") class TestIndexFunctionality(BaseTestClass): """Test of indexes.""" descriptorVersion: int nonDefaultDescriptorVersion: int defaultFaceEstimator: FaceDescriptorEstimator faceDescriptor: FaceDescriptor nonDefaultFaceDescriptor: FaceDescriptor faceDescriptorBatch: FaceDescriptorBatch