Update README.md
Browse files
README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
---
|
| 2 |
language: en
|
| 3 |
tags:
|
| 4 |
-
- image-classification
|
| 5 |
-
- ai-detection
|
| 6 |
-
- vit
|
| 7 |
license: mit
|
| 8 |
---
|
| 9 |
|
|
@@ -39,4 +39,44 @@ def detect_image(image_path):
|
|
| 39 |
confidence = predictions[0][prediction_id].item() * 100
|
| 40 |
|
| 41 |
result = "AI Generated" if prediction_id == 1 else "Real Image"
|
| 42 |
-
return result, confidence
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
language: en
|
| 3 |
tags:
|
| 4 |
+
- image-classification
|
| 5 |
+
- ai-detection
|
| 6 |
+
- vit
|
| 7 |
license: mit
|
| 8 |
---
|
| 9 |
|
|
|
|
| 39 |
confidence = predictions[0][prediction_id].item() * 100
|
| 40 |
|
| 41 |
result = "AI Generated" if prediction_id == 1 else "Real Image"
|
| 42 |
+
return result, confidence
|
| 43 |
+
|
| 44 |
+
# Example usage
|
| 45 |
+
# result, confidence = detect_image("path/to/image.jpg")
|
| 46 |
+
# print(f"Result: {result} (Confidence: {confidence:.2f}%)")
|
| 47 |
+
Classes
|
| 48 |
+
The model classifies images into two categories:
|
| 49 |
+
|
| 50 |
+
Real Image (0)
|
| 51 |
+
AI Generated (1)
|
| 52 |
+
Technical Details
|
| 53 |
+
Model Architecture: Vision Transformer (ViT)
|
| 54 |
+
Input: Images (RGB)
|
| 55 |
+
Output: Binary classification with confidence score
|
| 56 |
+
Max Image Size: 224x224 (automatically resized)
|
| 57 |
+
Requirements
|
| 58 |
+
transformers>=4.30.0
|
| 59 |
+
torch>=2.0.0
|
| 60 |
+
Pillow>=9.0.0
|
| 61 |
+
Limitations
|
| 62 |
+
Best performance with clear, high-quality images
|
| 63 |
+
May have reduced accuracy with heavily edited photos
|
| 64 |
+
Designed for general image detection
|
| 65 |
+
Web Integration Example
|
| 66 |
+
javascript
|
| 67 |
+
CopyInsert
|
| 68 |
+
async function detectImage(imageFile) {
|
| 69 |
+
const formData = new FormData();
|
| 70 |
+
formData.append('image', imageFile);
|
| 71 |
+
|
| 72 |
+
const response = await fetch('YOUR_API_ENDPOINT', {
|
| 73 |
+
method: 'POST',
|
| 74 |
+
body: formData
|
| 75 |
+
});
|
| 76 |
+
|
| 77 |
+
return await response.json();
|
| 78 |
+
}
|
| 79 |
+
Developer
|
| 80 |
+
Created by: yaya36095
|
| 81 |
+
License: MIT
|
| 82 |
+
Repository: https://huggingface.co/yaya36095/ai-image-detector
|