# varshinipinnu8/face-detection-and-recognition architecture

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

- Interactive diagram: https://gitdiagram.com/varshinipinnu8/face-detection-and-recognition
- Repository: https://github.com/varshinipinnu8/face-detection-and-recognition

## Overview

This Streamlit application lets users either detect faces in one uploaded image or verify whether two uploaded images show the same person. Detection returns an annotated image and face count; verification detects and crops faces, creates FaceNet embeddings, compares them, and presents similarity, distance, and a prediction. The graph follows the documented features and the inspected app.py and utils.py; model and library nodes represent external dependencies, not repository modules.

Main entry points: [`utils.py`](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py) (Verify faces), [`app.py`](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py) (Streamlit app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_detection["Face detection"]
  node_detect_flow["Detection handler<br/>[app.py]"]
  node_process_detection["Process detection<br/>[utils.py]"]
  node_detect_faces["Detect faces<br/>[utils.py]"]
  node_draw_faces["Draw boxes<br/>[utils.py]"]
  node_mtcnn["MTCNN detector"]
  node_opencv["OpenCV"]
end

subgraph group_verification["Face verification"]
  node_verify_flow["Verification handler<br/>[app.py]"]
  node_verify_faces["Verify faces<br/>[utils.py]"]
  node_extract_face["Extract face<br/>[utils.py]"]
  node_get_embedding["Generate embedding<br/>[utils.py]"]
  node_cosine_similarity["Cosine similarity<br/>[utils.py]"]
  node_euclidean_distance["Euclidean distance<br/>[utils.py]"]
  node_facenet["FaceNet embedder"]
  node_scipy["SciPy distance"]
end

node_user(("User"))

node_user -->|"uploads images"| node_app
node_app -->|"routes detection"| node_detect_flow
node_detect_flow -->|"calls"| node_process_detection
node_process_detection -->|"calls"| node_detect_faces
node_process_detection -->|"calls"| node_draw_faces
node_detect_faces -->|"detects faces"| node_mtcnn
node_detect_faces -->|"resizes images"| node_opencv
node_draw_faces -->|"draws annotations"| node_opencv
node_app -->|"routes verification"| node_verify_flow
node_verify_flow -->|"calls"| node_verify_faces
node_verify_faces -->|"calls twice"| node_extract_face
node_extract_face -->|"detects face"| node_mtcnn
node_extract_face -->|"resizes crops"| node_opencv
node_verify_faces -->|"calls twice"| node_get_embedding
node_get_embedding -->|"generates embedding"| node_facenet
node_verify_faces -->|"compares embeddings"| node_cosine_similarity
node_cosine_similarity -->|"computes distance"| node_scipy
node_verify_faces -->|"compares embeddings"| node_euclidean_distance
node_app -->|"displays results"| node_user

click node_app "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py"
click node_detect_flow "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py"
click node_process_detection "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_detect_faces "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_draw_faces "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_verify_flow "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py"
click node_verify_faces "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_extract_face "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_get_embedding "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_cosine_similarity "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py"
click node_euclidean_distance "https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.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,node_user toneBlue
class node_detect_flow,node_process_detection,node_detect_faces,node_draw_faces,node_mtcnn,node_opencv toneAmber
class node_verify_flow,node_verify_faces,node_extract_face,node_get_embedding,node_cosine_similarity,node_euclidean_distance,node_facenet,node_scipy toneMint
```

## Components

### User interface

- [Streamlit app](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py): `app.py`

### Face detection

- [Detection handler](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py): `app.py`
- [Process detection](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- [Detect faces](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- [Draw boxes](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- **MTCNN detector**
- **OpenCV**

### Face verification

- [Verification handler](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/app.py): `app.py`
- [Verify faces](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- [Extract face](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- [Generate embedding](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- [Cosine similarity](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- [Euclidean distance](https://github.com/varshinipinnu8/face-detection-and-recognition/blob/main/utils.py): `utils.py`
- **FaceNet embedder**
- **SciPy distance**

### Other components

- **User**

## Connections

- User → Streamlit app: uploads images
- Streamlit app → Detection handler: routes detection
- Detection handler → Process detection: calls
- Process detection → Detect faces: calls
- Process detection → Draw boxes: calls
- Detect faces → MTCNN detector: detects faces
- Detect faces → OpenCV: resizes images
- Draw boxes → OpenCV: draws annotations
- Streamlit app → Verification handler: routes verification
- Verification handler → Verify faces: calls
- Verify faces → Extract face: calls twice
- Extract face → MTCNN detector: detects face
- Extract face → OpenCV: resizes crops
- Verify faces → Generate embedding: calls twice
- Generate embedding → FaceNet embedder: generates embedding
- Verify faces → Cosine similarity: compares embeddings
- Cosine similarity → SciPy distance: computes distance
- Verify faces → Euclidean distance: compares embeddings
- Streamlit app → User: displays results
