Deepfake Classification 022025
Collection
based on recent dataset
β’
8 items
β’
Updated
β’
11
AI-vs-Deepfake-vs-Real is an image classification model for differentiating between artificial, deepfake, and real images. It is based on Google's ViT model (google/vit-base-patch32-224-in21k
).
A reasonable number of training samples were used to achieve good efficiency in the final training process and its efficiency metrics. Since this task involves classifying images into three categories (artificial, deepfake, and real), the model was trained accordingly. Future improvements will be made based on the complexity of the task.
id2label: {
"0": "Artificial",
"1": "Deepfake",
"2": "Real"
}
Classification report:
precision recall f1-score support
Artificial 0.9897 0.9347 0.9614 1333
Deepfake 0.9409 0.9910 0.9653 1333
Real 0.9970 0.9993 0.9981 1334
accuracy 0.9750 4000
macro avg 0.9759 0.9750 0.9749 4000
weighted avg 0.9759 0.9750 0.9750 4000
from transformers import pipeline
# Load the model
pipe = pipeline('image-classification', model="prithivMLmods/AI-vs-Deepfake-vs-Real", device=0)
# Predict on an image
result = pipe("path_to_image.jpg")
print(result)
from transformers import ViTForImageClassification, ViTImageProcessor
from PIL import Image
import torch
# Load the model and processor
model = ViTForImageClassification.from_pretrained("prithivMLmods/AI-vs-Deepfake-vs-Real")
processor = ViTImageProcessor.from_pretrained("prithivMLmods/AI-vs-Deepfake-vs-Real")
# Load and preprocess the image
image = Image.open("path_to_image.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
# Perform inference
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
predicted_class = torch.argmax(logits, dim=1).item()
# Map class index to label
label = model.config.id2label[predicted_class]
print(f"Predicted Label: {label}")
Base model
google/vit-base-patch16-224-in21k