yaya36095 commited on
Commit
0ad0fb4
·
verified ·
1 Parent(s): f2475cd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -30
README.md CHANGED
@@ -15,33 +15,37 @@ This model is designed to detect whether an image is real or AI-generated. It us
15
  ## Model Usage
16
 
17
  ```python
18
- from transformers import ViTImageProcessor, ViTForImageClassification
19
- from PIL import Image
20
- import torch
21
-
22
- # Load model and processor
23
- processor = ViTImageProcessor.from_pretrained("yaya36095/ai-image-detector")
24
- model = ViTForImageClassification.from_pretrained("yaya36095/ai-image-detector")
25
-
26
- def detect_image(image_path):
27
- # Open image
28
- image = Image.open(image_path)
29
-
30
- # Process image
31
- inputs = processor(images=image, return_tensors="pt")
32
-
33
- # Get predictions
34
- with torch.no_grad():
35
- outputs = model(**inputs)
36
- predictions = outputs.logits.softmax(dim=-1)
37
-
38
- # Get result
39
- prediction_id = torch.argmax(predictions).item()
40
- confidence = predictions[0][prediction_id].item() * 100
41
-
42
- result = "AI Generated" if prediction_id == 1 else "Real Image"
43
- return result, confidence
44
-
45
- # Example usage
46
- # result, confidence = detect_image("path/to/image.jpg")
47
- # print(f"Result: {result} (Confidence: {confidence:.2f}%)")
 
 
 
 
 
15
  ## Model Usage
16
 
17
  ```python
18
+ ## Classes
19
+ The model classifies images into two categories:
20
+ - Real Image (0)
21
+ - AI Generated (1)
22
+
23
+ ## Technical Details
24
+ - Model Architecture: Vision Transformer (ViT)
25
+ - Input: Images (RGB)
26
+ - Output: Binary classification with confidence score
27
+ - Max Image Size: 224x224 (automatically resized)
28
+
29
+ ## Requirements
30
+ - transformers>=4.30.0
31
+ - torch>=2.0.0
32
+ - Pillow>=9.0.0
33
+
34
+ ## Limitations
35
+ - Best performance with clear, high-quality images
36
+ - May have reduced accuracy with heavily edited photos
37
+ - Designed for general image detection
38
+
39
+ ## Web Integration Example
40
+ ```javascript
41
+ async function detectImage(imageFile) {
42
+ const formData = new FormData();
43
+ formData.append('image', imageFile);
44
+
45
+ const response = await fetch('YOUR_API_ENDPOINT', {
46
+ method: 'POST',
47
+ body: formData
48
+ });
49
+
50
+ return await response.json();
51
+ }