Source code for luna_lambda_tools.public.clients.lrs

"""
Module contains luna-remote-sdk client adapted for usage in lambda
"""
from typing import Awaitable

from luna3.common.http_objs import BinaryImage, UrlForDetection
from luna3.common.luna_response import LunaResponse
from luna3.remote_sdk.remote_sdk import LunaRemoteSDKApi


[docs] class LRS: """Luna-remote-sdk client"""
[docs] def __init__(self, lrsClient: LunaRemoteSDKApi, accountId: str): self._accountId = accountId self._lrsClient = lrsClient
[docs] def getAddress(self) -> str: """Get luna-remote-sdk address""" return self._lrsClient.baseUri
[docs] def sdk( self, inputData: BinaryImage | list[BinaryImage] | list[UrlForDetection] | list[str], multifacePolicy: int = 1, detectFace: int | None = None, detectBody: int | None = None, estimateHeadPose: int | None = None, estimateLandmarks68: int | None = None, estimateLandmarks5: int | None = None, estimateQuality: int | None = None, estimateGaze: int | None = None, estimateEyesAttributes: int | None = None, estimateEmotions: int | None = None, estimateMouthAttributes: int | None = None, estimateMask: int | None = None, estimateGlasses: int | None = None, estimateLiveness: int | None = None, estimateFaceWarp: int | None = None, estimateBodyWarp: int | None = None, aggregateAttributes: int | None = None, estimateBasicAttributes: int | None = None, estimateBodyDescriptor: int | None = None, estimateFaceDescriptor: int | None = None, estimateUpperBody: int | None = None, estimateLowerBody: int | None = None, estimateBodyBasicAttributes: int | None = None, estimateAccessories: int | None = None, pitchThreshold: int | None = None, rollThreshold: int | None = None, yawThreshold: int | None = None, scoreThreshold: float = None, maskStates: list[int] | None = None, livenessStates: list[int] | None = None, imageType: int | None = None, useExifInfo: int | None = None, extractExif: int | None = None, raiseError: bool = True, **kwargs, ) -> Awaitable[LunaResponse] | LunaResponse: """ Detect faces on input images. Args: inputData: one of: - Single image or images list for extraction (supported formats "jpeg, png, tif, ppm, bmp"). - list of urls with images - list of images' ids multifacePolicy: multiple face detection policy: 0 - multiple face detection not allowed, 1 - multiple face detection allowed, 2 - get best detection from the image detectFace: detect faces detectBody: detect human bodies estimateHeadPose: Available values : 0, 1 estimateLandmarks5: Available values : 0, 1 estimateLandmarks68: Available values : 0, 1 estimateQuality: Available values : 0, 1 estimateGaze: Available values : 0, 1 estimateEyesAttributes: Available values : 0, 1 estimateMouthAttributes: Available values : 0, 1 estimateEmotions: Available values : 0, 1 estimateMask: Available values: 0, 1 estimateGlasses: Available values: 0, 1 estimateLiveness: Available values: 0, 1 estimateFaceDescriptor: Available values : 0, 1 estimateBodyDescriptor: Available values : 0, 1 estimateBasicAttributes: Available values : 0, 1 estimateBodyWarp: Available values : 0, 1 estimateFaceWarp: Available values : 0, 1 estimateUpperBody: Available values : 0, 1 estimateLowerBody: Available values : 0, 1 estimateBodyBasicAttributes: Available values : 0, 1 estimateAccessories: Available values : 0, 1 pitchThreshold: maximum deviation pitch angle from 0 rollThreshold: maximum deviation roll angle from 0 yawThreshold: maximum deviation yaw angle from 0 scoreThreshold: descriptor garbage score maskStates: Array of integer (filter by mask state) (Items Enum:1 2 3) livenessStates: Array of integer (filter by liveness state) (Items Enum:0 1 2) aggregateAttributes: Available values : 0, 1 imageType: image type (0 - raw image, 1 - face warped image, 2 - body warped image) useExifInfo: whether to use exif info for auto orientation extractExif: extract EXIF meta information from images raiseError: whether to raise LunaApiException in case of failure Returns: class:`~.LunaResponse` or *asyncio coroutine* with *LunaResponse*. In body of :class: `~.LunaResponse` json with samples, exif, filename for succeeded images and errors for failed images will be returned. """ return self._lrsClient.sdk( inputData=inputData, multifacePolicy=multifacePolicy, detectFace=detectFace, detectBody=detectBody, estimateHeadPose=estimateHeadPose, estimateLandmarks68=estimateLandmarks68, estimateLandmarks5=estimateLandmarks5, estimateQuality=estimateQuality, estimateGaze=estimateGaze, estimateEyesAttributes=estimateEyesAttributes, estimateEmotions=estimateEmotions, estimateMouthAttributes=estimateMouthAttributes, estimateMask=estimateMask, estimateGlasses=estimateGlasses, estimateLiveness=estimateLiveness, estimateFaceWarp=estimateFaceWarp, estimateBodyWarp=estimateBodyWarp, aggregateAttributes=aggregateAttributes, estimateBasicAttributes=estimateBasicAttributes, estimateBodyDescriptor=estimateBodyDescriptor, estimateFaceDescriptor=estimateFaceDescriptor, estimateUpperBody=estimateUpperBody, estimateLowerBody=estimateLowerBody, estimateBodyBasicAttributes=estimateBodyBasicAttributes, estimateAccessories=estimateAccessories, pitchThreshold=pitchThreshold, rollThreshold=rollThreshold, yawThreshold=yawThreshold, scoreThreshold=scoreThreshold, maskStates=maskStates, livenessStates=livenessStates, imageType=imageType, useExifInfo=useExifInfo, extractExif=extractExif, raiseError=raiseError, **kwargs, )