Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
lw0404 committed Nov 11, 2024
2 parents 0739582 + 235bee9 commit c1ef533
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 3 deletions.
34 changes: 32 additions & 2 deletions api/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ class TaskQueue(BaseModel):

class FaceSpecBQAT(str, Enum):
ipd = "Inter-pupillary distance."
confidence = "Confidence level of face dectection (not quality score)."
face_detection = "Confidence level of face dectection (not quality score)."
bbox_left = "Left border of the face bounding box coordinates in pixels."
bbox_right = "Right border of the face bounding box coordinates in pixels."
bbox_upper = "Upper border of the face bounding box coordinates in pixels."
Expand All @@ -662,7 +662,37 @@ class FaceSpecBQAT(str, Enum):
roll_pose = "Roll in head pose direction."
roll_degree = "Roll in head pose degree."
smile = "Smile detected or not."
glassed = "Glasses detected or not."
glasses = "Eyeglasses/Spectacles detected or not."
face_ratio = "Ratio of face area to whole image."
brightness = "Average brightness of the image."
dynamic_range = "Dynamic range of the image."
sharpness = "Shaphness of the image."
contrast = "Contrast of the image."
face_offset_x = "Horizontal offset of the face from image centre."
face_offset_y = "Vertical offset of the face from image centre."
background_colour_name = "Background colour name."
background_colour_rgb = "Background colour rgb values."
background_uniformity = "Background colour uniformity."
hair_coverage = "Ratio of detected hair area to whole face bounding box."
blur_lap_var = "Laplacian variance of image as a indicator of blurriness"
blurriness = "Blur effect metric. A estimate strength of perceptual blurriness."
gaze_right_x = "Right eyeball gazing direction offset percentage horizontal."
gaze_right_y = "Right eyeball gazing direction offset percentage vertical."
gaze_left_x = "Left eyeball gazing direction offset percentage horizontal."
gaze_left_y = "Left eyeball gazing direction offset percentage vertical."
pupil_colour_right_name = "Right pupil colour name."
pupil_colour_right_rgb = "Right pupil colour rgb values."
pupil_colour_left_name = "Left pupil colour name."
pupil_colour_left_rgb = "Left pupil colour rgb values."
brisque_quality = "Blind/Referenceless Image Spatial Quality Evaluator (BRISQUE) no-reference image quality score"
age = "Estimation of age."
gender = "Estimation of gender."
ethnicity = "Estimation of ethnicity."
emotion = "Estimation of emotions."
is_hologram = "Hologram effect detected or not."
holograms = "Hologram area detected."
is_glare = "Glare/Reflection on the image detected or not."
glares = "Glare area detected."


class FaceSpecOFIQ(str, Enum):
Expand Down
65 changes: 64 additions & 1 deletion api/routes/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@
from PIL import Image as PILImage

from api.config import Settings
from api.config.models import ImageRequest
from api.config.models import (
FaceSpecBIQT,
FaceSpecBQAT,
FaceSpecOFIQ,
FingerprintSpecDefault,
ImageRequest,
IrisSpecDefault,
Modality,
SpeechSpecDefault,
)
from api.utils import ensure_base64_padding, extend, get_info

router = APIRouter()
Expand Down Expand Up @@ -216,3 +225,57 @@ async def delete_dataset(
)
async def get_version_info():
return JSONResponse(status_code=status.HTTP_200_OK, content=get_info())


@router.get(
"/specification",
response_description="Output descriptions retrieved",
description="Fetches output columns descriptions.",
)
async def get_description(modality: Modality, engine: str = "default"):
match modality:
case Modality.face:
match engine:
case "bqat" | "default":
return {item.name: item.value for item in FaceSpecBQAT}
case "ofiq":
return {item.name: item.value for item in FaceSpecOFIQ}
case "biqt":
return {item.name: item.value for item in FaceSpecBIQT}
case _:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid engine specified.",
)
case Modality.fingerprint:
match engine:
case "default":
return {item.name: item.value for item in FingerprintSpecDefault}
case _:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid engine specified.",
)
case Modality.iris:
match engine:
case "default":
return {item.name: item.value for item in IrisSpecDefault}
case _:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid engine specified.",
)
case Modality.speech:
match engine:
case "default":
return {item.name: item.value for item in SpeechSpecDefault}
case _:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid engine specified.",
)
case _:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Invalid modality specified.",
)
23 changes: 23 additions & 0 deletions api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ async def run_report_tasks(
{
"mode": dataset_log["options"].get("mode"),
"engine": dataset_log["options"].get("engine"),
"fusion": dataset_log["options"].get("fusion"),
}
)

Expand Down Expand Up @@ -1581,6 +1582,28 @@ def generate_report(data, **options):
metadata = {
"description": "Face image dataset, processed by BIQT engine."
}
case "fusion":
descriptions = {}
engines = []
fusion_code = options.get("fusion", 0)
if fusion_code & 4 == 4:
descriptions.update(
{item.name: item.value for item in FaceSpecBQAT}
)
engines.append("BQAT")
if fusion_code & 2 == 2:
descriptions.update(
{item.name: item.value for item in FaceSpecOFIQ}
)
engines.append("OFIQ")
if fusion_code & 1 == 1:
descriptions.update(
{item.name: item.value for item in FaceSpecBIQT}
)
engines.append("BIQT")
metadata = {
"description": f"Folder of face images, processed by fusion engine{' (' + ', '.join(engines) + ')' if engines else ''}."
}
case _:
descriptions = {}
metadata = {"description": "Face image dataset."}
Expand Down

0 comments on commit c1ef533

Please sign in to comment.