Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
datasets:
|
| 3 |
+
- ideepankarsharma2003/ImageClassificationStableDiffusion_small
|
| 4 |
+
- ideepankarsharma2003/Midjourney_v6_Classification_small_shuffled
|
| 5 |
+
- ideepankarsharma2003/AIGeneratedImages_Midjourney
|
| 6 |
+
tags:
|
| 7 |
+
- image-classification
|
| 8 |
+
- ai-gen-images
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
# Model Card for AI Image Classification - Midjourney V6 & SDXL
|
| 13 |
+
|
| 14 |
+
## Model Details
|
| 15 |
+
|
| 16 |
+
### Model Description
|
| 17 |
+
|
| 18 |
+
This model is a **Swin Transformer-based classifier** designed to distinguish between **AI-generated** and **human-created** images, specifically focusing on outputs from **Midjourney V6** and **Stable Diffusion XL (SDXL)**. It has been trained on a curated dataset of AI-generated images.
|
| 19 |
+
|
| 20 |
+
- **Developed by:** Deepankar Sharma
|
| 21 |
+
- **Model type:** Image Classification (Swin Transformer)
|
| 22 |
+
- **Finetuned from model:** SwinForImageClassification
|
| 23 |
+
|
| 24 |
+
### Model Sources
|
| 25 |
+
|
| 26 |
+
- **Repository:** [Hugging Face Model Repository](https://huggingface.co/ideepankarsharma2003/AI_ImageClassification_MidjourneyV6_SDXL)
|
| 27 |
+
|
| 28 |
+
## Uses
|
| 29 |
+
|
| 30 |
+
### Direct Use
|
| 31 |
+
|
| 32 |
+
This model can be used for **detecting AI-generated images** from Midjourney V6 and SDXL. It is useful for content moderation, fact-checking, and detecting synthetic media.
|
| 33 |
+
|
| 34 |
+
### Out-of-Scope Use
|
| 35 |
+
|
| 36 |
+
- The model is **not designed** for detecting AI-generated images from all generative models.
|
| 37 |
+
- It **may not perform well** on heavily edited AI-generated images or images mixed with human elements.
|
| 38 |
+
- It is **not intended for forensic-level deepfake detection**.
|
| 39 |
+
|
| 40 |
+
## Bias, Risks, and Limitations
|
| 41 |
+
|
| 42 |
+
This model is trained specifically on **Midjourney V6** and **Stable Diffusion XL** datasets. It may not generalize well to images generated by other AI models. Additionally, biases in the dataset could lead to **false positives** (flagging real images as AI-generated) or **false negatives** (failing to detect AI-generated content).
|
| 43 |
+
|
| 44 |
+
### Recommendations
|
| 45 |
+
|
| 46 |
+
Users should verify results with additional tools and **not solely rely on this model** for high-stakes decisions. Model performance should be tested on domain-specific datasets before deployment.
|
| 47 |
+
|
| 48 |
+
## How to Get Started with the Model
|
| 49 |
+
|
| 50 |
+
You can use this model with the 🤗 Transformers library:
|
| 51 |
+
|
| 52 |
+
```python
|
| 53 |
+
from transformers import AutoModelForImageClassification, AutoFeatureExtractor
|
| 54 |
+
from PIL import Image
|
| 55 |
+
import torch
|
| 56 |
+
|
| 57 |
+
# Load model and feature extractor
|
| 58 |
+
model_name = "ideepankarsharma2003/AI_ImageClassification_MidjourneyV6_SDXL"
|
| 59 |
+
model = AutoModelForImageClassification.from_pretrained(model_name)
|
| 60 |
+
feature_extractor = AutoFeatureExtractor.from_pretrained(model_name)
|
| 61 |
+
|
| 62 |
+
# Load and preprocess image
|
| 63 |
+
image = Image.open("path_to_image.jpg")
|
| 64 |
+
inputs = feature_extractor(images=image, return_tensors="pt")
|
| 65 |
+
|
| 66 |
+
# Perform inference
|
| 67 |
+
with torch.no_grad():
|
| 68 |
+
outputs = model(**inputs)
|
| 69 |
+
logits = outputs.logits
|
| 70 |
+
predicted_label = logits.argmax(-1).item()
|
| 71 |
+
|
| 72 |
+
# Label Mapping
|
| 73 |
+
id2label = {0: "ai_gen", 1: "human"}
|
| 74 |
+
print("Predicted label:", id2label[predicted_label])
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Training Details
|
| 78 |
+
|
| 79 |
+
### Training Data
|
| 80 |
+
|
| 81 |
+
The model was trained on the following datasets:
|
| 82 |
+
|
| 83 |
+
- [ImageClassificationStableDiffusion_small](https://huggingface.co/datasets/ideepankarsharma2003/ImageClassificationStableDiffusion_small)
|
| 84 |
+
- [Midjourney_v6_Classification_small_shuffled](https://huggingface.co/datasets/ideepankarsharma2003/Midjourney_v6_Classification_small_shuffled)
|
| 85 |
+
- [AIGeneratedImages_Midjourney](https://huggingface.co/datasets/ideepankarsharma2003/AIGeneratedImages_Midjourney)
|
| 86 |
+
|
| 87 |
+
### Training Procedure
|
| 88 |
+
|
| 89 |
+
- **Image Size:** 224x224
|
| 90 |
+
- **Patch Size:** 4
|
| 91 |
+
- **Embedding Dimension:** 128
|
| 92 |
+
- **Layers:** 4
|
| 93 |
+
- **Attention Heads per Stage:** [4, 8, 16, 32]
|
| 94 |
+
- **Dropout Rates:**
|
| 95 |
+
- Attention: 0.0
|
| 96 |
+
- Hidden: 0.0
|
| 97 |
+
- Drop Path: 0.1
|
| 98 |
+
- **Activation Function:** GeLU
|
| 99 |
+
- **Optimizer:** AdamW
|
| 100 |
+
- **Learning Rate Scheduler:** Cosine Annealing
|
| 101 |
+
- **Precision:** float32
|
| 102 |
+
- **Training Steps:** 3414
|
| 103 |
+
|
| 104 |
+
## Evaluation
|
| 105 |
+
|
| 106 |
+
### Testing Data, Factors & Metrics
|
| 107 |
+
|
| 108 |
+
#### Testing Data
|
| 109 |
+
|
| 110 |
+
The model was evaluated on a separate validation split from the training datasets.
|
| 111 |
+
|
| 112 |
+
#### Metrics
|
| 113 |
+
|
| 114 |
+
- **Accuracy**
|
| 115 |
+
- **Precision & Recall**
|
| 116 |
+
- **F1 Score**
|
| 117 |
+
|
| 118 |
+
### Summary
|
| 119 |
+
|
| 120 |
+
The model effectively distinguishes between AI-generated and human-created images, but its performance may be affected by dataset biases and out-of-distribution examples.
|
| 121 |
+
|
| 122 |
+
## Citation
|
| 123 |
+
|
| 124 |
+
If you use this model, please cite:
|
| 125 |
+
|
| 126 |
+
```bibtex
|
| 127 |
+
@misc{ai_image_classification,
|
| 128 |
+
author = {Deepankar Sharma},
|
| 129 |
+
title = {AI Image Classification - Midjourney V6 & SDXL},
|
| 130 |
+
year = {2024},
|
| 131 |
+
publisher = {Hugging Face},
|
| 132 |
+
howpublished = {\url{https://huggingface.co/ideepankarsharma2003/AI_ImageClassification_MidjourneyV6_SDXL}}
|
| 133 |
+
}
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
## Model Card Authors
|
| 137 |
+
|
| 138 |
+
- **Author:** Deepankar Sharma
|
| 139 |
+
|
| 140 |
+
---
|