"Update model card with complete documentation"
Browse files
README.md
CHANGED
|
@@ -1,16 +1,42 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
tags:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
library_name: transformers
|
| 8 |
-
model_type: vit
|
| 9 |
-
license: apache-2.0
|
| 10 |
-
datasets:
|
| 11 |
-
- custom-dataset
|
| 12 |
-
metrics:
|
| 13 |
-
- accuracy
|
| 14 |
-
- precision
|
| 15 |
-
- recall
|
| 16 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language: en
|
| 3 |
tags:
|
| 4 |
+
- image-classification
|
| 5 |
+
- ai-detection
|
| 6 |
+
- vit
|
| 7 |
+
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
+
|
| 10 |
+
# AI Image Detector
|
| 11 |
+
|
| 12 |
+
## Model Description
|
| 13 |
+
This model is designed to detect whether an image is real or AI-generated. It uses Vision Transformer (VIT) architecture to provide accurate classification.
|
| 14 |
+
|
| 15 |
+
## Model Usage
|
| 16 |
+
```python
|
| 17 |
+
from transformers import ViTImageProcessor, ViTForImageClassification
|
| 18 |
+
from PIL import Image
|
| 19 |
+
import torch
|
| 20 |
+
|
| 21 |
+
# Load model and processor
|
| 22 |
+
processor = ViTImageProcessor.from_pretrained("yaya36095/ai-image-detector")
|
| 23 |
+
model = ViTForImageClassification.from_pretrained("yaya36095/ai-image-detector")
|
| 24 |
+
|
| 25 |
+
def detect_image(image_path):
|
| 26 |
+
# Open image
|
| 27 |
+
image = Image.open(image_path)
|
| 28 |
+
|
| 29 |
+
# Process image
|
| 30 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 31 |
+
|
| 32 |
+
# Get predictions
|
| 33 |
+
with torch.no_grad():
|
| 34 |
+
outputs = model(**inputs)
|
| 35 |
+
predictions = outputs.logits.softmax(dim=-1)
|
| 36 |
+
|
| 37 |
+
# Get result
|
| 38 |
+
prediction_id = torch.argmax(predictions).item()
|
| 39 |
+
confidence = predictions[0][prediction_id].item() * 100
|
| 40 |
+
|
| 41 |
+
result = "AI Generated" if prediction_id == 1 else "Real Image"
|
| 42 |
+
return result, confidence
|