# parthsavaliya01/liveliness-ditection architecture

> Architecture diagram of the GitHub repository parthsavaliya01/liveliness-ditection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/parthsavaliya01/liveliness-ditection
- Repository: https://github.com/parthsavaliya01/liveliness-ditection

## Overview

Face Liveness Detection is a Streamlit anti-spoofing application with a separate dataset-evaluation workflow. The main user flow accepts a camera capture or uploaded image, decodes and previews it, runs single-image inference, then displays a live/spoof result with confidence and timing. Internally, inference detects and crops a face before scoring it with an ONNX model. The README also documents webcam and CLI workflows; their implementation details are not fully sampled, so the graph focuses on the evidenced application and evaluator paths.

Main entry points: [`src/evaluate.py`](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/evaluate.py) (Dataset evaluator), [`src/detector.py`](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/detector.py) (Face detection), [`app.py`](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app.py) (App entry), [`src/selfie_liveness.py`](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/selfie_liveness.py) (Single-image analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Streamlit application"]
  node_app_entry["App entry<br/>[app.py]"]
  node_ui["UI rendering<br/>[ui.py]"]
  node_components["UI components<br/>[components.py]"]
  node_image_utils["Image handling<br/>[utils.py]"]
  node_services["Inference service<br/>[services.py]"]
end

subgraph group_infer["Liveness inference"]
  node_selfie["Single-image analysis<br/>[selfie_liveness.py]"]
  node_face["Face detection<br/>[detector.py]"]
  node_geometry["Face preprocessing<br/>[utils.py]"]
  node_predictor["ONNX predictor<br/>[detector.py]"]
  node_config["Inference configuration<br/>[config.py]"]
end

subgraph group_evaluation["Dataset evaluation"]
  node_evaluator["Dataset evaluator<br/>[evaluate.py]"]
  node_dataset["Evaluation samples"]
  node_results["Evaluation report"]
end

node_user(("User"))
node_insightface["InsightFace"]
node_onnx["ONNX Runtime"]

node_user -->|"uses app"| node_app_entry
node_app_entry -->|"renders interface"| node_ui
node_ui -->|"renders components"| node_components
node_app_entry -->|"validates and decodes"| node_image_utils
node_app_entry -->|"requests analysis"| node_services
node_services -->|"analyzes image"| node_selfie
node_selfie -->|"detects face"| node_face
node_face -->|"detects faces"| node_insightface
node_face -->|"aligns and crops"| node_geometry
node_selfie -->|"scores face crops"| node_predictor
node_predictor -->|"runs inference"| node_onnx
node_face -->|"uses thresholds"| node_config
node_selfie -->|"uses thresholds"| node_config
node_predictor -->|"uses model settings"| node_config
node_user -.->|"runs evaluation"| node_evaluator
node_evaluator -->|"reads samples"| node_dataset
node_evaluator -->|"detects faces"| node_face
node_evaluator -->|"scores crops"| node_predictor
node_evaluator -->|"collects media, computes metrics"| node_geometry
node_evaluator -->|"uses dataset settings"| node_config
node_evaluator -->|"writes report"| node_results

click node_app_entry "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app.py"
click node_ui "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/ui.py"
click node_components "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/components.py"
click node_image_utils "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/utils.py"
click node_services "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/services.py"
click node_selfie "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/selfie_liveness.py"
click node_face "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/detector.py"
click node_geometry "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/utils.py"
click node_predictor "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/detector.py"
click node_evaluator "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/evaluate.py"
click node_dataset "https://github.com/parthsavaliya01/liveliness-ditection/tree/main/dataset"
click node_results "https://github.com/parthsavaliya01/liveliness-ditection/tree/main/results"
click node_config "https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/config.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app_entry,node_ui,node_components,node_image_utils,node_services,node_user toneBlue
class node_selfie,node_face,node_geometry,node_predictor,node_config toneAmber
class node_evaluator,node_dataset,node_results toneMint
class node_insightface,node_onnx toneIndigo
```

## Components

### Streamlit application

- [App entry](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app.py): `app.py`
- [UI rendering](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/ui.py): `app/ui.py`
- [UI components](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/components.py): `app/components.py`
- [Image handling](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/utils.py): `app/utils.py`
- [Inference service](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/app/services.py): `app/services.py`

### Liveness inference

- [Single-image analysis](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/selfie_liveness.py): `src/selfie_liveness.py`
- [Face detection](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/detector.py): `src/detector.py`
- [Face preprocessing](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/utils.py): `src/utils.py`
- [ONNX predictor](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/detector.py): `src/detector.py`
- [Inference configuration](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/config.py): `src/config.py`

### Dataset evaluation

- [Dataset evaluator](https://github.com/parthsavaliya01/liveliness-ditection/blob/main/src/evaluate.py): `src/evaluate.py`
- [Evaluation samples](https://github.com/parthsavaliya01/liveliness-ditection/tree/main/dataset): `dataset`
- [Evaluation report](https://github.com/parthsavaliya01/liveliness-ditection/tree/main/results): `results`

### Other components

- **User**
- **InsightFace**
- **ONNX Runtime**

## Connections

- User → App entry: uses app
- App entry → UI rendering: renders interface
- UI rendering → UI components: renders components
- App entry → Image handling: validates and decodes
- App entry → Inference service: requests analysis
- Inference service → Single-image analysis: analyzes image
- Single-image analysis → Face detection: detects face
- Face detection → InsightFace: detects faces
- Face detection → Face preprocessing: aligns and crops
- Single-image analysis → ONNX predictor: scores face crops
- ONNX predictor → ONNX Runtime: runs inference
- Face detection → Inference configuration: uses thresholds
- Single-image analysis → Inference configuration: uses thresholds
- ONNX predictor → Inference configuration: uses model settings
- User → Dataset evaluator: runs evaluation
- Dataset evaluator → Evaluation samples: reads samples
- Dataset evaluator → Face detection: detects faces
- Dataset evaluator → ONNX predictor: scores crops
- Dataset evaluator → Face preprocessing: collects media, computes metrics
- Dataset evaluator → Inference configuration: uses dataset settings
- Dataset evaluator → Evaluation report: writes report
