File size: 2,607 Bytes
248f7de e9fefd7 248f7de |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
---
license: apache-2.0
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- deepfake
- Real
---
# **Fake-Real-Class-Siglip2**
**Fake-Real-Class-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 **classify images as either Fake or Real** using the **SiglipForImageClassification** architecture.
The model categorizes images into two classes:
- **Class 0:** "Fake" – The image is detected as AI-generated, manipulated, or synthetic.
- **Class 1:** "Real" – The image is classified as authentic and unaltered.
```python
!pip install -q transformers torch pillow gradio
```
```python
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-Real-Class-Siglip2"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
def classify_image(image):
"""Classifies an image as Fake or Real."""
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=classify_image,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(label="Classification Result"),
title="Fake vs Real Image Classification",
description="Upload an image to determine if it is Fake or Real."
)
# Launch the app
if __name__ == "__main__":
iface.launch()
```
# **Intended Use:**
The **Fake-Real-Class-Siglip2** model is designed to classify images into two categories: **Fake or Real**. It helps in detecting AI-generated or manipulated images.
### Potential Use Cases:
- **Fake Image Detection:** Identifying AI-generated or altered images.
- **Content Verification:** Assisting platforms in filtering misleading media.
- **Forensic Analysis:** Supporting research in detecting synthetic media.
- **Authenticity Checks:** Helping journalists and investigators verify image credibility. |