Deepfake Image Detector

This is a fine-tuned Vision Transformer (ViT) model for detecting deepfake images. It was trained on a dataset of misclassified images to classify them as 0_real or 1_fake.

Model Details

  • Base Model: google/vit-base-patch16-224
  • Classes: 0_real, 1_fake
  • Training Epochs: 8
  • Best Validation Accuracy: 91.00% at epoch 1
  • Test Accuracy: 97.84%

Files

  • checkpoints/: Contains model checkpoints (best_model_epoch_X.pth, final_model.pth)
  • training_plots.png: Training and validation loss/accuracy plots

Usage

from transformers import ViTForImageClassification, ViTFeatureExtractor
import torch
from PIL import Image

# Load model and feature extractor
model = ViTForImageClassification.from_pretrained('shivani1511/deepfake-image-detector')
feature_extractor = ViTFeatureExtractor.from_pretrained('shivani1511/deepfake-image-detector')
model.eval()

# Load and preprocess an image
image = Image.open("path_to_image.jpg").convert("RGB")
inputs = feature_extractor(images=image, return_tensors="pt")
outputs = model(**inputs).logits
probs = torch.softmax(outputs, dim=1)
predicted_class = '1_fake' if probs[0][1] > 0.5 else '0_real'
print(f"Predicted class: {predicted_class}")
Downloads last month
81
Safetensors
Model size
85.8M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support