Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
tags:
|
| 4 |
+
- image-classification
|
| 5 |
+
- ai-detection
|
| 6 |
+
- cnn
|
| 7 |
+
- pytorch
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# AI Detection CNN Model
|
| 11 |
+
|
| 12 |
+
This model detects AI-generated images using spatial features extracted from Qwen2.5-VL.
|
| 13 |
+
|
| 14 |
+
## Model Description
|
| 15 |
+
|
| 16 |
+
- **Architecture**: 1D CNN with 3 convolutional layers
|
| 17 |
+
- **Task**: Binary classification (AI-generated vs Real images)
|
| 18 |
+
- **Feature Extractor**: Qwen2.5-VL-3B-Instruct
|
| 19 |
+
- **Framework**: PyTorch
|
| 20 |
+
|
| 21 |
+
## Usage
|
| 22 |
+
|
| 23 |
+
```python
|
| 24 |
+
from inference import test_image
|
| 25 |
+
|
| 26 |
+
# Test an image
|
| 27 |
+
result = test_image(
|
| 28 |
+
"path/to/image.jpg",
|
| 29 |
+
hf_repo_id="nahid112376/ai-detection-cnn",
|
| 30 |
+
threshold=0.5
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
print(f"Label: {result['label']}")
|
| 34 |
+
print(f"Confidence: {result['confidence']*100:.2f}%")
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
## Model Details
|
| 38 |
+
|
| 39 |
+
- Input: Spatial features from Qwen2.5-VL (shape: [num_patches, hidden_dim])
|
| 40 |
+
- Output: Single regression score (0-1, threshold at 0.5)
|
| 41 |
+
- Training: Trained on demectai dataset
|
| 42 |
+
|
| 43 |
+
## Installation
|
| 44 |
+
|
| 45 |
+
```bash
|
| 46 |
+
pip install torch transformers huggingface_hub pillow numpy
|
| 47 |
+
pip install qwen-vl-utils
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
## Files
|
| 51 |
+
|
| 52 |
+
- `cnn_regression_model.pth`: Trained model weights
|
| 53 |
+
- `inference.py`: Inference script
|
| 54 |
+
- `extract_features.py`: Feature extraction script
|
| 55 |
+
|
| 56 |
+
## Citation
|
| 57 |
+
|
| 58 |
+
If you use this model, please cite:
|
| 59 |
+
|
| 60 |
+
```bibtex
|
| 61 |
+
@misc{ai-detection-cnn,
|
| 62 |
+
author = {bartazable},
|
| 63 |
+
title = {AI Detection CNN Model},
|
| 64 |
+
year = {2026},
|
| 65 |
+
publisher = {Hugging Face},
|
| 66 |
+
howpublished = {\url{https://huggingface.co/nahid112376/ai-detection-cnn}}
|
| 67 |
+
}
|
| 68 |
+
```
|