Views
No views yet
google/vit-base-patch16-224-in21k. The approach leverages the power of Vision Transformers (ViT) to classify images as real or fake.Fake, Real)

1from transformers import AutoImageProcessor, AutoModelForImageClassificationimport torch
2import torch
3from PIL import Image
4
5# Load the image_processor and model
6
7# Example usage
8image = Image.open('path of the image')
9inputs = image_processor(images=image, return_tensors="pt")
10outputs = model(**inputs)
11logits = outputs.logits
12pred = torch.argmax(logits, dim=1).item()
13label = 'Real' if pred == 1 else 'Fake'
14print(f"Predicted type: {Label}")
15
16