# seungmin0625/photo-ai-detector-v32 architecture

> Architecture diagram of the GitHub repository seungmin0625/photo-ai-detector-v32, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/seungmin0625/photo-ai-detector-v32
- Repository: https://github.com/seungmin0625/photo-ai-detector-v32

## Overview

This repository develops and serves a single-image detector for AI-generated secondhand-market photos. The user workflow is upload or provide an image, select a detector by file format, score it, and return a three-level result; high-resolution JPEG/PNG receives an additional resized-image check. The graph also shows the model-training and robustness-evaluation work that supports the shipped detector. The README documents the main inference stages; some unsampled implementation details and links to the team DDA code are therefore represented only where documented.

Main entry points: [`detector_v32.py`](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v32.py) (Format and hires routing), [`views_v31.py`](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/views_v31.py) (v3.1 image views), [`detector_v3.py`](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v3.py) (Three-head detector), [`finetune_v31.py`](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_v31.py) (v3.1 fine-tuning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inference["Serving and inference"]
  node_personal_app["Personal app server<br/>[server_v32.py]"]
  node_v32_router["Format and hires routing<br/>[detector_v32.py]"]
  node_result["Three-level result<br/>[detector_v3.py]"]
end

subgraph group_models["Detector models"]
  node_v3_detector["Three-head detector<br/>[detector_v3.py]"]
  node_v31_views["v3.1 image views<br/>[views_v31.py]"]
  node_dda["DDA backbone"]
end

subgraph group_training["Training and features"]
  node_feature_extraction["Feature extraction"]
  node_lora_training["LoRA fine-tuning<br/>[finetune_lora.py]"]
  node_v3_training["v3 fine-tuning<br/>[finetune_v3.py]"]
  node_v31_training["v3.1 fine-tuning<br/>[finetune_v31.py]"]
  node_head_selection["Head selection"]
end

subgraph group_evaluation["Evaluation and robustness"]
  node_evaluation["Feature evaluation<br/>[evaluate.py]"]
  node_demo_benchmark["Demo benchmark<br/>[demo_benchmark.py]"]
  node_stress["Upload stress tests<br/>[stress_v31.py]"]
  node_team_eval["Team-style evaluation<br/>[team_style_eval.py]"]
end

node_user(("Image user"))

node_user -->|"uploads image"| node_personal_app
node_personal_app -->|"uses detector"| node_v32_router
node_v32_router -->|"routes non-WEBP"| node_v3_detector
node_v32_router -->|"routes WEBP"| node_v31_views
node_v32_router -->|"checks hires copy"| node_v32_router
node_v3_detector -->|"scores image"| node_dda
node_v3_detector -->|"returns tier"| node_result
node_v31_views -->|"prepares model views"| node_dda
node_feature_extraction -->|"extracts features"| node_dda
node_lora_training -->|"fine-tunes adapters"| node_dda
node_v3_training -->|"fine-tunes adapters"| node_dda
node_v31_training -->|"uses augmentations"| node_v31_views
node_v31_training -->|"fine-tunes adapters"| node_dda
node_head_selection -->|"compares candidates"| node_evaluation
node_evaluation -->|"evaluates cached features"| node_feature_extraction
node_demo_benchmark -->|"compares recipes"| node_head_selection
node_stress -->|"tests image conditions"| node_v31_views
node_team_eval -->|"reuses stress fusion"| node_stress
node_team_eval -->|"applies upload conditions"| node_v31_views

click node_personal_app "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/personal_app/server_v32.py"
click node_v32_router "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v32.py"
click node_v3_detector "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v3.py"
click node_v31_views "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/views_v31.py"
click node_result "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v3.py"
click node_feature_extraction "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/extract_features.py"
click node_lora_training "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_lora.py"
click node_v3_training "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_v3.py"
click node_v31_training "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_v31.py"
click node_head_selection "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/final_candidates.py"
click node_evaluation "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/evaluate.py"
click node_demo_benchmark "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/demo_benchmark.py"
click node_stress "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/stress_v31.py"
click node_team_eval "https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/team_style_eval.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_personal_app,node_v32_router,node_result,node_user toneBlue
class node_v3_detector,node_v31_views,node_dda toneAmber
class node_feature_extraction,node_lora_training,node_v3_training,node_v31_training,node_head_selection toneMint
class node_evaluation,node_demo_benchmark,node_stress,node_team_eval toneRose
```

## Components

### Serving and inference

- [Personal app server](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/personal_app/server_v32.py): `personal_app/server_v32.py`
- [Format and hires routing](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v32.py): `detector_v32.py`
- [Three-level result](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v3.py): `detector_v3.py`

### Detector models

- [Three-head detector](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/detector_v3.py): `detector_v3.py`
- [v3.1 image views](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/views_v31.py): `views_v31.py`
- **DDA backbone**

### Training and features

- [Feature extraction](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/extract_features.py): `extract_features.py`
- [LoRA fine-tuning](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_lora.py): `finetune_lora.py`
- [v3 fine-tuning](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_v3.py): `finetune_v3.py`
- [v3.1 fine-tuning](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/finetune_v31.py): `finetune_v31.py`
- [Head selection](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/final_candidates.py): `final_candidates.py`

### Evaluation and robustness

- [Feature evaluation](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/evaluate.py): `evaluate.py`
- [Demo benchmark](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/demo_benchmark.py): `demo_benchmark.py`
- [Upload stress tests](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/stress_v31.py): `stress_v31.py`
- [Team-style evaluation](https://github.com/seungmin0625/photo-ai-detector-v32/blob/main/team_style_eval.py): `team_style_eval.py`

### Other components

- **Image user**

## Connections

- Image user → Personal app server: uploads image (evidence: `README.md`)
- Personal app server → Format and hires routing: uses detector (evidence: `personal_app/server_v32.py`)
- Format and hires routing → Three-head detector: routes non-WEBP (evidence: `README.md`)
- Format and hires routing → v3.1 image views: routes WEBP (evidence: `README.md`)
- Format and hires routing → Format and hires routing: checks hires copy (evidence: `README.md`)
- Three-head detector → DDA backbone: scores image (evidence: `README.md`)
- Three-head detector → Three-level result: returns tier (evidence: `README.md`)
- v3.1 image views → DDA backbone: prepares model views (evidence: `views_v31.py`)
- Feature extraction → DDA backbone: extracts features (evidence: `extract_features.py`)
- LoRA fine-tuning → DDA backbone: fine-tunes adapters (evidence: `finetune_lora.py`)
- v3 fine-tuning → DDA backbone: fine-tunes adapters (evidence: `finetune_v3.py`)
- v3.1 fine-tuning → v3.1 image views: uses augmentations (evidence: `finetune_v31.py`)
- v3.1 fine-tuning → DDA backbone: fine-tunes adapters (evidence: `finetune_v31.py`)
- Head selection → Feature evaluation: compares candidates (evidence: `final_candidates.py`)
- Feature evaluation → Feature extraction: evaluates cached features (evidence: `evaluate.py`)
- Demo benchmark → Head selection: compares recipes (evidence: `demo_benchmark.py`)
- Upload stress tests → v3.1 image views: tests image conditions (evidence: `stress_v31.py`)
- Team-style evaluation → Upload stress tests: reuses stress fusion (evidence: `team_style_eval.py`)
- Team-style evaluation → v3.1 image views: applies upload conditions (evidence: `team_style_eval.py`)
