--- tags: - image-classification - computer-vision - deepfake-detection - fine-tuned license: mit datasets: - 140k-real-and-fake-faces metrics: - accuracy --- # 🎭 SDXL-Deepfake-Detector **A high-performance deep learning model for binary classification of real versus synthetically generated (deepfake) human faces.** Developed by **[Sadra Milani Moghaddam](https://sadramilani.ir/)**, this model is designed to detect faces generated by state-of-the-art synthesis models—including those based on SDXL and similar architectures—while maintaining strong generalization across diverse image sources. ## 🚀 Model Overview **SDXL-Deepfake-Detector** is a fine-tuned image classification model built using transfer learning. It leverages a pre-trained vision backbone and is optimized specifically for distinguishing authentic human faces from AI-generated forgeries. ### Key Features - **Task**: Binary image classification (Real = 0, Deepfake = 1) - **Training Dataset**: [140k Real and Fake Faces (Kaggle)](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces) - **Test Accuracy**: **91%** on an independent hold-out test set - **Hardware Used for Training**: NVIDIA RTX 3060 (12GB VRAM) - **License**: [MIT](https://opensource.org/licenses/MIT) This model is suitable for integration into media forensics pipelines, content moderation systems, or any application requiring reliable deepfake detection at the image level. --- ## 💻 Usage You can easily load and run inference with this model using the Hugging Face `transformers` library. ### Installation ```bash pip install transformers torch pillow ``` ```python import argparse from transformers import AutoModelForImageClassification, AutoFeatureExtractor from PIL import Image import torch def main(): parser = argparse.ArgumentParser( description="Classify an image as 'Real' or 'Deepfake' using the SDXL-Deepfake-Detector." ) parser.add_argument("--image", type=str, required=True, help="Path to the input image file") args = parser.parse_args() model_name = "SADRACODING/SDXL-Deepfake-Detector" model = AutoModelForImageClassification.from_pretrained(model_name) feature_extractor = AutoFeatureExtractor.from_pretrained(model_name) device = torch.device("cuda" if torch.cuda.is_available() else "cpu") model.to(device) model.eval() image = Image.open(args.image).convert("RGB") inputs = feature_extractor(images=image, return_tensors="pt").to(device) with torch.no_grad(): outputs = model(**inputs) logits = outputs.logits predicted_class_idx = logits.argmax(-1).item() predicted_label = model.config.id2label[predicted_class_idx] print(f"Predicted class index: {predicted_class_idx}") print(f"Predicted label: {predicted_label}") if __name__ == "__main__": main() ``` ```bash python predict.py --image path/to/face_image.jpg ``` ## 📄 License This model is released under the [MIT License](https://opensource.org/licenses/MIT), allowing for both commercial and non-commercial use with proper attribution. ## 🙌 Acknowledgements - **Dataset**: [140k Real and Fake Faces](https://www.kaggle.com/datasets/xhlulu/140k-real-and-fake-faces) by xhlulu - **Framework**: [Hugging Face Transformers](https://huggingface.co/docs/transformers) - **Github**: [SDXL-Deepfake-Detector](https://github.com/SadraCoding/SDXL-Deepfake-Detector) - **Developer**: [Sadra Milani Moghaddam](https://sadramilani.ir/)