🚀 开源深度伪造检测模型
开源深度伪造检测模型是一个基于视觉 - 语言编码器的模型,它在 siglip2-base-patch16-512
基础上进行微调,用于二分类图像分类任务。该模型使用 OpenDeepfake-Preview 数据集进行训练,能够检测图像是伪造的还是真实的。模型采用 SiglipForImageClassification
架构。

🚀 快速开始
安装依赖
pip install -q transformers torch pillow gradio hf_xet
推理代码
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch
model_name = "prithivMLmods/open-deepfake-detection"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
id2label = {
"0": "Fake",
"1": "Real"
}
def classify_image(image):
image = Image.fromarray(image).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
prediction = {
id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
}
return prediction
iface = gr.Interface(
fn=classify_image,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(num_top_classes=2, label="Deepfake Detection"),
title="open-deepfake-detection",
description="Upload an image to detect whether it is AI-generated (Fake) or a real photograph (Real), using the OpenDeepfake-Preview dataset."
)
if __name__ == "__main__":
iface.launch()
演示推理
⚠️ 重要提示
以下是真实图片示例:

⚠️ 重要提示
以下是伪造图片示例:

✨ 主要特性
分类报告
Classification Report:
precision recall f1-score support
Fake 0.9718 0.9155 0.9428 10000
Real 0.9201 0.9734 0.9460 9999
accuracy 0.9444 19999
macro avg 0.9459 0.9444 0.9444 19999
weighted avg 0.9459 0.9444 0.9444 19999
标签空间
模型将图像分为以下两类:
Class 0: 伪造
Class 1: 真实
预期用途
open-deepfake-detection
模型旨在用于以下场景:
- 深度伪造检测:识别由人工智能生成或经过篡改的图像。
- 内容审核:标记合成或伪造的视觉内容。
- 数据集整理:从混合数据集中移除合成样本。
- 视觉真实性验证:检查视觉媒体的完整性。
- 数字取证:支持图像来源验证和可追溯性。
相关论文
SigLIP 2: Multilingual Vision-Language Encoders with Improved Semantic Understanding, Localization, and Dense Features
https://arxiv.org/pdf/2502.14786
注意事项
⚠️ 重要提示
此为实验性模型。
📄 许可证
本项目采用 Apache-2.0 许可证。
📦 模型信息
属性 |
详情 |
模型类型 |
基于视觉 - 语言编码器的图像分类模型 |
训练数据 |
prithivMLmods/OpenDeepfake-Preview |
基础模型 |
google/siglip2-base-patch16-512 |
库名称 |
transformers |
标签 |
深度伪造、检测、SigLIP2、艺术、合成 |
任务类型 |
图像分类 |
