SadraCoding commited on
Commit
bd289c2
·
1 Parent(s): 270c326

README Update

Browse files
Files changed (1) hide show
  1. README.md +55 -21
README.md CHANGED
@@ -12,54 +12,88 @@ base_model: Organika/sdxl-detector
12
 
13
  # Spatial–Frequency Hybrid Detector for Synthetic Face Images
14
 
15
- This repository contains a fine-tuned checkpoint for binary image classification. Given an input image, the model predicts one of two labels: `artificial` or `human`.
16
 
17
- > **Experimental research model.** This classifier is not an authenticity or provenance verifier. Its predictions reflect its training data and preprocessing; they do not establish who created an image, whether a face is real, or whether an image was manipulated. Do not use it as the sole basis for high-impact decisions.
18
 
19
- ## Links
20
 
21
- - **GitHub source, scripts, report, and protocol:** [SadraCoding/SDXL-Deepfake-Detector](https://github.com/SadraCoding/SDXL-Deepfake-Detector)
22
- - **Live demo:** [sdxldd.ir](https://sdxldd.ir)
23
- - **Base checkpoint:** [Organika/sdxl-detector](https://huggingface.co/Organika/sdxl-detector)
24
- - **Dataset referenced by the project:** [140k Real and Fake Faces](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces)
 
 
25
 
26
  ## Model details
27
 
28
- The model starts from the Swin image-classification checkpoint `Organika/sdxl-detector`. It combines pooled spatial features from Swin with a learned encoding of the input's centered 2D Fourier log-magnitude. A fusion classifier predicts the final label, and an auxiliary classifier is trained on the Swin features.
29
 
30
- The image processor resizes inputs to 224 × 224, rescales pixel values, and applies ImageNet channel normalization. The class mapping stored with this checkpoint is:
31
-
32
- | ID | Label |
33
  | --- | --- |
34
  | 0 | `artificial` |
35
  | 1 | `human` |
36
 
37
- An optional adaptive inference path predicts first from the Swin features and runs the frequency branch for samples below a confidence threshold. The checkpoint's default threshold is 0.90. Softmax confidence should not be interpreted as calibrated probability unless calibration has been evaluated separately.
38
 
39
  ## Intended use and limitations
40
 
41
- The project references the Kaggle 140k Real and Fake Faces collection, a face-image dataset commonly described as containing real and StyleGAN-generated images. This is a narrow benchmark domain. It does not establish performance on unseen generators, face swaps, video, current text-to-image systems, or arbitrary images in the wild. Dataset version, split construction, and complete run provenance are not included with the checkpoint.
 
 
 
 
42
 
43
- The project's checked-in metrics artifact reports 93.27% clean accuracy on one run of 10,905 images. Split provenance and other details needed to reproduce or independently interpret this result are incomplete; treat it as a historical result, not a generalization claim. The Hugging Face model page's previously reported 97% accuracy has different or undocumented evaluation details and should not be compared directly with that artifact.
 
 
 
 
 
 
44
 
45
- Potential dataset shortcuts, distribution shift, image compression, preprocessing, identity overlap, and generator-specific artifacts can affect predictions. The project has not established that the frequency branch improves performance over a matched Swin-only baseline. See the GitHub [research report](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/REVISED_PROJECT_REPORT.md) and [research protocol](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/docs/research_protocol.md) for details.
 
 
46
 
47
  ## Using the checkpoint
48
 
49
- This checkpoint uses a custom architecture (`SwinFrequencyHybridDetector`), so the model implementation and inference scripts are provided in the GitHub repository. Follow its [installation and quick-start instructions](https://github.com/SadraCoding/SDXL-Deepfake-Detector#installation). In brief, clone the source, install the requirements and a compatible PyTorch build, then run the prediction script from `model/`:
50
 
51
  ```bash
 
 
 
 
52
  python scripts/predict.py --image /path/to/image.jpg
53
  ```
54
 
55
- The script selects CUDA when available and otherwise uses CPU. It reports the predicted class, confidence, adaptive-path status, measured model-call latency, and descriptive image diagnostics. Only process images you have permission to use.
 
 
 
 
56
 
57
- ## Training data
58
 
59
- The dataset is not included in this repository. The source project describes downloading it separately from [Kaggle](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces) and arranging it into `train/{fake,real}`, `val/{fake,real}`, and `test/{fake,real}` directories. Review the dataset's current access terms and image rights before use. Dataset terms are separate from the code license.
 
 
60
 
61
  ## License and attribution
62
 
63
- The project declares MIT for its original code. The initialized upstream model, derived checkpoint, and dataset may have separate terms. The upstream `Organika/sdxl-detector` card identifies a CC BY-NC 3.0 license and non-commercial restrictions; review its current terms before using or redistributing this checkpoint. The MIT license does not grant rights to third-party weights or dataset images.
 
 
 
 
 
 
 
 
 
 
64
 
65
- Please cite the [source project](https://github.com/SadraCoding/SDXL-Deepfake-Detector), the [base model](https://huggingface.co/Organika/sdxl-detector), and the [dataset](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces) as relevant to your work.
 
 
 
12
 
13
  # Spatial–Frequency Hybrid Detector for Synthetic Face Images
14
 
15
+ This repository contains a fine-tuned checkpoint for binary image classification. It predicts whether an input image belongs to the `artificial` or `human` class. The project combines a Swin image-classification backbone with a learned representation of the image's centered two-dimensional Fourier log-magnitude spectrum.
16
 
17
+ > **Experimental research model.** This is a classifier, not an authenticity or provenance verifier. Its output does not establish who created an image, whether a face is real, whether an image was manipulated, or whether a person consented to its use. Do not use it as the sole basis for consequential decisions.
18
 
19
+ ## Project links
20
 
21
+ - [GitHub source, training and evaluation scripts](https://github.com/SadraCoding/SDXL-Deepfake-Detector)
22
+ - [Technical report](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/REVISED_PROJECT_REPORT.md)
23
+ - [Research protocol](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/docs/research_protocol.md)
24
+ - [Live demo](https://sdxldd.ir)
25
+ - [Base checkpoint: Organika/sdxl-detector](https://huggingface.co/Organika/sdxl-detector)
26
+ - [Dataset cited by the project: 140k Real and Fake Faces](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces)
27
 
28
  ## Model details
29
 
30
+ The model uses pooled spatial features from the Swin backbone and a 128-dimensional feature vector learned from the centered FFT log-magnitude representation. It concatenates these features and classifies them with a fusion head. An auxiliary classifier on the Swin features is trained with an additional loss. The checkpoint's class mapping is:
31
 
32
+ | Class ID | Label |
 
 
33
  | --- | --- |
34
  | 0 | `artificial` |
35
  | 1 | `human` |
36
 
37
+ The image processor resizes images to 224 × 224, rescales pixel values, and applies ImageNet channel normalization. The checkpoint also includes an optional confidence-based early-exit path: with adaptive inference enabled, predictions at or above the configured confidence threshold (default 0.90) use the auxiliary Swin head; less confident samples use the full spatial–frequency path. A softmax score is not a calibrated probability unless calibration has been measured separately.
38
 
39
  ## Intended use and limitations
40
 
41
+ The project references the Kaggle 140k Real and Fake Faces collection, commonly described as real face images and StyleGAN-generated faces. This is a narrow face-image domain. It does not establish performance on face swaps, video, SDXL or other unseen generators, or arbitrary images in the wild. The checkpoint does not include enough dataset version, split construction, and run provenance to reproduce or independently validate its reported result.
42
+
43
+ The checked-in GitHub metrics artifact reports one evaluation on 10,905 images. It reports 93.27% clean accuracy for both full and adaptive inference. These are historical results from a run with incomplete provenance, not evidence of generalization. The project Hugging Face page has also displayed a self-reported 97% accuracy; the evaluation details do not establish that it is directly comparable to the checked-in metrics. Do not combine or compare those figures as if they came from the same protocol.
44
+
45
+ The metrics artifact reports the following accuracy and weighted F1 for its clean test set and four synthetic corruption variants:
46
 
47
+ | Evaluation variant | Accuracy (full / adaptive) | Weighted F1 |
48
+ | --- | ---: | ---: |
49
+ | Clean | 93.27% / 93.27% | 93.26% |
50
+ | JPEG quality 50 | 91.30% / 91.30% | 91.25% |
51
+ | 5 × 5 Gaussian blur | 92.86% / 92.86% | 92.85% |
52
+ | Half resolution, resized back | 92.11% / 92.11% | 92.11% |
53
+ | Gaussian noise, σ = 15 | 91.24% / 91.24% | 91.23% |
54
 
55
+ These controlled degradations are not a comprehensive robustness test. The metrics artifact omits the dataset revision, split construction, per-source support, GPU model, software versions, checkpoint hash, and threshold-selection procedure. Adaptive and full modes had the same reported labels for these variants; the recorded adaptive early-exit rates were approximately 98.4–99.1%. The repository has not demonstrated that frequency fusion improves performance over a matched Swin-only baseline.
56
+
57
+ Potential dataset shortcuts, identity or duplicate overlap, source-specific artifacts, compression, preprocessing, demographic coverage, and distribution shift can affect predictions. The project is not a universal deepfake detector. See the linked [technical report](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/REVISED_PROJECT_REPORT.md) and [research protocol](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/docs/research_protocol.md) for detailed caveats and recommendations for controlled evaluation.
58
 
59
  ## Using the checkpoint
60
 
61
+ This checkpoint uses the project's custom `SwinFrequencyHybridDetector` architecture; it cannot be loaded as a standard `AutoModelForImageClassification` without the custom model code. Clone the GitHub repository, install the dependencies and a PyTorch/torchvision build for your platform, then run inference from the `model/` directory:
62
 
63
  ```bash
64
+ git clone https://github.com/SadraCoding/SDXL-Deepfake-Detector.git
65
+ cd SDXL-Deepfake-Detector
66
+ python -m pip install -r model/scripts/requirements.txt
67
+ cd model
68
  python scripts/predict.py --image /path/to/image.jpg
69
  ```
70
 
71
+ The script loads the bundled fine-tuned checkpoint from `model/SDXL-Deepfake-Detector/`, selects CUDA when available (otherwise CPU), and reports the predicted label, confidence, adaptive-path status, model-call latency, and descriptive image-quality measurements. Adaptive inference is off by default. Enable it with `--adaptive`; optionally set `--confidence_threshold` to a value in `(0, 1]`. The threshold should be selected on validation data and frozen before test evaluation.
72
+
73
+ To evaluate a class-folder test set, use `python scripts/evaluate.py --test_dir ./dataset/test` from `model/`. The evaluator reports full and adaptive results and applies the synthetic corruption procedures described above. For training, arrange data in `dataset/train/{fake,real}/` and `dataset/val/{fake,real}/`, then run `python scripts/train.py --train_dir ./dataset/train --val_dir ./dataset/val`. The scripts do not download or arrange the dataset, validate split integrity, or establish that a split is leakage-free. Consult the GitHub README for complete options and defaults.
74
+
75
+ The dataset is not included. The GitHub project describes obtaining it separately from Kaggle and arranging it into `train/{fake,real}`, `val/{fake,real}`, and `test/{fake,real}` directories (`fake → artificial`, `real → human`). Review the current dataset terms, image rights, and privacy requirements before use. Keep credentials, restricted data, and identifiable examples out of public repositories.
76
 
77
+ ## Training and evaluation context
78
 
79
+ The reported training hardware is one NVIDIA RTX 3060 with 12 GB VRAM. The repository's training defaults are 10 epochs, batch size 32, learning rate `2e-5`, weight decay 0.01, preprocessing chunk size 20,000, seed 42, and confidence threshold 0.90. Training uses horizontal flips, rotations up to 15 degrees, and brightness/contrast jitter; validation preprocessing is deterministic. These are implementation defaults, not tuned or statistically validated settings. The requirements specify minimum package versions rather than a locked environment.
80
+
81
+ For research use, preserve the exact code revision, checkpoint and processor hashes, dataset revision and split manifest, commands, resolved software versions, hardware, seeds, and threshold-selection procedure. Prefer identity/source-aware splits, check for duplicates and leakage, keep test data untouched during model and threshold selection, compare against a matched Swin-only baseline, and report uncertainty and per-class metrics. The [research protocol](https://github.com/SadraCoding/SDXL-Deepfake-Detector/blob/main/docs/research_protocol.md) provides a fuller checklist.
82
 
83
  ## License and attribution
84
 
85
+ The project declares MIT for its original code. That license does not grant rights to third-party model weights or dataset images. The upstream [`Organika/sdxl-detector`](https://huggingface.co/Organika/sdxl-detector) model card identifies a CC BY-NC 3.0 license and non-commercial restrictions; review its current terms before using or redistributing this derived checkpoint. The Kaggle dataset has separate terms and upstream image-rights considerations. Face data may also be subject to privacy, consent, and institutional requirements.
86
+
87
+ Suggested attribution:
88
+
89
+ - SadraCoding, [SDXL-Deepfake-Detector](https://github.com/SadraCoding/SDXL-Deepfake-Detector), source code and research artifacts.
90
+ - Organika, [SDXL Detector](https://huggingface.co/Organika/sdxl-detector), upstream checkpoint.
91
+ - xhlulu, [140k Real and Fake Faces](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces), Kaggle dataset.
92
+
93
+ For formal work, record immutable model revisions and access dates, and cite the relevant dataset and model documentation.
94
+
95
+ ## References
96
 
97
+ 1. Liu, Z. et al. (2021). “Swin Transformer: Hierarchical Vision Transformer using Shifted Windows.” *ICCV*. [DOI](https://doi.org/10.1109/ICCV48922.2021.00986).
98
+ 2. Frank, J. et al. (2020). “Leveraging Frequency Analysis for Deep Fake Image Recognition.” [arXiv:2003.08685](https://arxiv.org/abs/2003.08685).
99
+ 3. Byun, J. Y. et al. (2026). “Adaptive Inference for Medical Vision Transformers: Token Reduction or Early Exit?” *Proceedings of the 9th International Conference on Medical Imaging with Deep Learning*, PMLR 315:2171–2191. [Proceedings](https://proceedings.mlr.press/v315/byun26b.html). This provides methodological context; its medical-dataset findings are not directly comparable to this project.