How to use

Here is how to use this model to classify an image of the AIorNot dataset into one of the 2 classes:

from transformers import AutoImageProcessor, AutoModelForImageClassification
import torch
from datasets import load_dataset

dataset = load_dataset("competitions/aiornot")
image = dataset["test"][0]["image"]

processor = AutoImageProcessor.from_pretrained("microsoft/resnet-50")
model = AutoModelForImageClassification.from_pretrained("arnolfokam/ai-generated-image-detector", trust_remote_code=True)

inputs = processor(image, return_tensors="pt")

with torch.no_grad():
    logits = model(**inputs).logits

# model predicts one of the 2 classes
predicted_label = logits.argmax(-1).item()
print(model.config.id2label[predicted_label])