Skip to content

Pipeline Reference

The UFME biometric pipeline is a sequence of pure, composable functions connected by async queues. Each stage declares the context keys it requires (reads) and produces (writes). The pipeline runner selects only the declared keys for each stage’s payload — stages never see the full context.

Optional stages (marked optional) are wired into the pipeline only when the corresponding ONNX model file is present at startup. Absent model = stage silently omitted.

[super_resolution] → receive → detect → align → [head_pose] →
pad → mad → [deepfake] → quality → extract → [age] → [face_attributes] →
route → respond

DELETE operations are routed directly from receive to route, bypassing all image-processing stages.


Model: realesrgan_x4plus.onnx

Upscales the raw probe image 4x before face detection. Intended for low-resolution surveillance captures where the face occupies fewer than ~80px. Uses tiled inference (512px tiles, 10px overlap blending) to bound peak memory.

Keys
Requiresimage_bytes
Producesimage_bytes (replaced with 4x upscaled JPEG)
GateNone — failures are non-fatal; original bytes passed through

Parses the inbound HTTP payload into a plain dict. Validates against XXE and billion-laughs patterns (64 KB prolog limit). Enforces a 50 MB payload size limit.

Keys
Requires— (reads from HTTP envelope)
Producesoperation, image_bytes, request_id, subject_id (when present), partition, metadata
GateDELETE → route_q; all others → detect_q (or sr_q when SR stage present)

Locates the face and five landmark points using SCRFD_10G. Returns a bounding box and landmark coordinates.

Keys
Requiresimage_bytes
Producesdetection (bounding box, score, 5-point landmarks)
GateNone (queue_out = align_q)
FailureNo face detected → {"ok": False, "error": "no_face"} → routed to respond_q

Applies an affine transform using the 5-point landmarks to produce a 112×112 pixel normalised face crop. Drops image_bytes from the context after this stage — raw imagery is never present downstream (privacy by structure).

Keys
Requiresimage_bytes, detection
Producescrop (112×112 RGB uint8)
Dropsimage_bytes
GateNone (queue_out = head_pose_q or pad_q)

Model: head_pose_resnet18.onnx

Estimates head orientation from the aligned crop using a ResNet-18 rotation matrix model. Outputs pitch, yaw, and roll in degrees. The yaw gate rejects extreme-profile faces that are unprocessable by downstream biometric stages.

Keys
Requirescrop
Produceshead_pose ({pitch, yaw, roll} in degrees)
Gate|yaw| > max_head_pose_yaw (default 45°) → respond_q; otherwise → pad_q

Model: MiniFASNetV2.onnx

Assesses whether the face is a physical or digital presentation attack. Measurement only — the gate is a separate pure function. ISO 30107-3 compliant for Level 1 print/replay attacks.

Keys
Requirescrop
Producespad ({spoof_score: float, attack_type: str})
Gatespoof_score > pad_spoof_score (default 0.85) → respond_q; otherwise → mad_q

Model: mad_selfmad_hrnet_w18.onnx (SelfMAD HRNet-W18)

Detects morphed document photos at enrolment. Measurement only — the gate is separate. Runs on the aligned crop (single-image, no reference required).

Keys
Requirescrop
Producesmorphing ({morph_score: float})
Gatemorph_score > mad_morph_score (default 0.75) → respond_q; otherwise → deepfake_q (or quality_q)

Model: deepfake_vit_q.onnx (ViT-base quantised)

Binary genuine/deepfake classifier. Produces a fake probability score. Measurement only — the gate is separate.

Keys
Requirescrop
Producesdeepfake ({fake_score: float})
Gatefake_score > deepfake_fake_score (default 0.50) → respond_q; otherwise → quality_q

Model: ediffiqa_tiny.onnx (eDifFIQA Tiny)

Measures face image quality using a MobileFaceNet-based model. ISO/IEC 29794-5 aligned. Measurement only — the gate is separate.

Keys
Requirescrop
Producesquality ({score: float})
Gatescore < quality_min_score (default 0.40) → respond_q; otherwise → extract_q

Model: w600k_r50.onnx (ArcFace ResNet-50, or w600k_mbf.onnx for mask-aware)

Produces a 512-dim L2-normalised face embedding. Drops crop from the context after this stage.

Keys
Requirescrop
Producesembedding (512-dim float32, L2-normalised), model_id
Dropscrop
GateNone (queue_out = age_q or route_q)

Model: genderage.onnx (InsightFace genderage, age head)

Produces an age estimate in years from the aligned crop.

Keys
Requirescrop
Producesage ({years: float})
GateNone — non-fatal; failures pass through silently

Model: genderage.onnx (InsightFace genderage, gender head)

Produces a gender classification from the aligned crop.

Keys
Requirescrop
Producesface_attributes ({gender: "male" | "female", gender_confidence: float})
GateNone — non-fatal; failures pass through silently

Dispatches to the operation-specific orchestrator queue based on the operation key.

Keys
Requiresoperation
Produces
GateSEARCHsearch_q; VERIFYverify_q; ENROLenrol_q; DELETEdelete_q

Formats the accumulated context into the outbound XML response. Serialises all present metadata fields (quality score, spoof score, age, head pose, attributes) into the response envelope.

Keys
Requiresresult, request_id, operation
Produces— (writes to HTTP response)
GateNone — terminal stage

GateThreshold keyReject conditionHTTP status
Head posethresholds.max_head_pose_yaw|yaw| > threshold422
PADthresholds.pad_spoof_scorespoof_score > threshold451
MADthresholds.mad_morph_scoremorph_score > threshold422
Deepfakethresholds.deepfake_fake_scorefake_score > threshold422
Qualitythresholds.quality_min_scorescore < threshold422

All thresholds are configurable in config.toml or via environment variables. See Configuration Reference.

KeyIntroduced byDropped byPresent in response
image_bytesreceivealignno
detectiondetectno
cropalignextractno
head_posehead_pose stageyes (optional)
padpad stageyes
morphingmad stageyes
deepfakedeepfake stageyes (optional)
qualityquality stageyes
embeddingextractno
ageage stageyes (optional)
face_attributesface_attributes stageyes (optional)
resultorchestratoryes