Update README.md
Browse files
README.md
CHANGED
|
@@ -9,4 +9,22 @@ metrics:
|
|
| 9 |
tags:
|
| 10 |
- generative ai
|
| 11 |
- classification
|
| 12 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
tags:
|
| 10 |
- generative ai
|
| 11 |
- classification
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
Classification model used to classify real images and AI generated images.
|
| 15 |
+
The model used is swin-tiny-patch4-window7-224 finetued on aiornot dataset.
|
| 16 |
+
To use the model
|
| 17 |
+
```
|
| 18 |
+
from transformers import AutoFeatureExtractor, AutoModelForImageClassification
|
| 19 |
+
|
| 20 |
+
labels = ["Real", "AI"]
|
| 21 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained("Nahrawy/AIorNot")
|
| 22 |
+
model = AutoModelForImageClassification.from_pretrained("Nahrawy/AIorNot")
|
| 23 |
+
|
| 24 |
+
input = feature_extractor(image, return_tensors="pt")
|
| 25 |
+
with torch.no_grad():
|
| 26 |
+
outputs = model(**input)
|
| 27 |
+
logits = outputs.logits
|
| 28 |
+
prediction = logits.argmax(-1).item()
|
| 29 |
+
label = labels[prediction]
|
| 30 |
+
```
|