| | import torch |
| | from transformers import AutoModelForImageClassification, AutoFeatureExtractor |
| | from PIL import Image |
| |
|
| | |
| | model = AutoModelForImageClassification.from_pretrained("your-username/deepfake-recognition") |
| | feature_extractor = AutoFeatureExtractor.from_pretrained("your-username/deepfake-recognition") |
| |
|
| | |
| | image = Image.open("sample_image.jpg") |
| | inputs = feature_extractor(images=image, return_tensors="pt") |
| |
|
| | |
| | outputs = model(**inputs) |
| | predicted_class = torch.argmax(outputs.logits, dim=1).item() |
| |
|
| | print(f"Predicted Class: {'Deepfake' if predicted_class == 1 else 'Real'}") |
| |
|