Siglip2 Custom
Collection
SiglipForImageClassification
•
5 items
•
Updated
•
3
Deepfake-Quality-Assess-Siglip2 is an image classification vision-language encoder model fine-tuned from google/siglip2-base-patch16-224 for a single-label classification task. It is designed to assess the quality of deepfake images using the SiglipForImageClassification architecture.
The model categorizes images into two classes:
!pip install -q transformers torch pillow gradio
import gradio as gr
from transformers import AutoImageProcessor
from transformers import SiglipForImageClassification
from transformers.image_utils import load_image
from PIL import Image
import torch
# Load model and processor
model_name = "prithivMLmods/Deepfake-Quality-Assess-Siglip2"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
def deepfake_detection(image):
"""Predicts deepfake probability scores for an 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()
labels = model.config.id2label
predictions = {labels[i]: round(probs[i], 3) for i in range(len(probs))}
return predictions
# Create Gradio interface
iface = gr.Interface(
fn=deepfake_detection,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(label="Prediction Scores"),
title="Deepfake Quality Detection",
description="Upload an image to check its deepfake probability scores."
)
# Launch the app
if __name__ == "__main__":
iface.launch()
The Deepfake-Quality-Assess-Siglip2 model is designed to evaluate the quality of deepfake images. It helps distinguish between high-quality deepfakes and those with noticeable issues. Potential use cases include:
Base model
google/siglip2-base-patch16-224