Views
No views yet

Deepfake-Detection-Exp-02-22 / vit_deepfake_detection is a minimalist, high-quality dataset trained on a ViT-based model for image classification, distinguishing between deepfake and real images. The model is based on Google's google/vit-base-patch32-224-in21k.1Mapping of IDs to Labels: {0: 'Deepfake', 1: 'Real'}
2
3Mapping of Labels to IDs: {'Deepfake': 0, 'Real': 1}1Classification report:
2
3 precision recall f1-score support
4
5 Deepfake 0.9833 0.9187 0.9499 1600
6 Real 0.9238 0.9844 0.9531 1600
7
8 accuracy 0.9516 3200
9 macro avg 0.9535 0.9516 0.9515 3200
10 weighted avg 0.9535 0.9516 0.9515 3200
1from transformers import pipeline
2
3# Load the model
4pipe = pipeline('image-classification', model="prithivMLmods/Deepfake-Detection-Exp-02-22", device=0)
5
6# Predict on an image
7result = pipe("path_to_image.jpg")
8print(result)1from transformers import ViTForImageClassification, ViTImageProcessor
2from PIL import Image
3import torch
4
5# Load the model and processor
6model = ViTForImageClassification.from_pretrained("strangerguardhf/vit_deepfake_detection")
7processor = ViTImageProcessor.from_pretrained("strangerguardhf/vit_deepfake_detection")
8
9# Load and preprocess the image
10image = Image.open("path_to_image.jpg").convert("RGB")
11inputs = processor(images=image, return_tensors="pt")
12
13# Perform inference
14with torch.no_grad():
15 outputs = model(**inputs)
16 logits = outputs.logits
17 predicted_class = torch.argmax(logits, dim=1).item()
18
19# Map class index to label
20label = model.config.id2label[predicted_class]
21print(f"Predicted Label: {label}")vit-base-patch32-224-in21k, it is optimized for 224x224 image resolution, which may limit its effectiveness on high-resolution images.