Readme updated
Browse files
README.md
CHANGED
|
@@ -4,6 +4,12 @@ tags:
|
|
| 4 |
model-index:
|
| 5 |
- name: diffusion-detection
|
| 6 |
results: []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
|
| 9 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
@@ -11,21 +17,32 @@ should probably proofread and complete it, then remove this comment. -->
|
|
| 11 |
|
| 12 |
# diffusion-detection
|
| 13 |
|
| 14 |
-
This model was trained from
|
| 15 |
|
| 16 |
-
## Model
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
## Training and evaluation data
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
### Training hyperparameters
|
| 31 |
|
|
@@ -44,4 +61,4 @@ The following hyperparameters were used during training:
|
|
| 44 |
- Transformers 4.29.2
|
| 45 |
- Pytorch 1.11.0+cu113
|
| 46 |
- Datasets 2.12.0
|
| 47 |
-
- Tokenizers 0.13.3
|
|
|
|
| 4 |
model-index:
|
| 5 |
- name: diffusion-detection
|
| 6 |
results: []
|
| 7 |
+
license: apache-2.0
|
| 8 |
+
datasets:
|
| 9 |
+
- imagenet-1k
|
| 10 |
+
metrics:
|
| 11 |
+
- accuracy
|
| 12 |
+
pipeline_tag: image-classification
|
| 13 |
---
|
| 14 |
|
| 15 |
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
|
|
|
| 17 |
|
| 18 |
# diffusion-detection
|
| 19 |
|
| 20 |
+
This model was trained to distinguish real world images (negative) from machine generated ones (postive).
|
| 21 |
|
| 22 |
+
## Model usage
|
| 23 |
|
| 24 |
+
```python
|
| 25 |
+
from transformers import BeitImageProcessor, BeitForImageClassification
|
| 26 |
+
from PIL import Image
|
| 27 |
|
| 28 |
+
processor = BeitImageProcessor.from_pretrained('TimKond/diffusion-detection')
|
| 29 |
+
model = BeitForImageClassification.from_pretrained('TimKond/diffusion-detection')
|
| 30 |
|
| 31 |
+
image = Image.open("2980_saltshaker.jpg")
|
| 32 |
+
|
| 33 |
+
inputs = processor(images=image, return_tensors="pt")
|
| 34 |
+
outputs = model(**inputs)
|
| 35 |
+
logits = outputs.logits
|
| 36 |
+
|
| 37 |
+
predicted_class_idx = logits.argmax(-1).item()
|
| 38 |
+
print("Predicted class:", model.config.id2label[predicted_class_idx])
|
| 39 |
+
```
|
| 40 |
|
| 41 |
## Training and evaluation data
|
| 42 |
|
| 43 |
+
[BEiT-base-patch16-224-pt22k](https://huggingface.co/microsoft/beit-base-patch16-224-pt22k) was loaded as a base model for further fine tuning:
|
| 44 |
|
| 45 |
+
As negatives a subsample of 10.000 images from [imagenet-1k](https://huggingface.co/datasets/imagenet-1k) was used. Complementary 10.000 positive images were generated using [Realistic_Vision_V1.4](https://huggingface.co/SG161222/Realistic_Vision_V1.4).
|
| 46 |
|
| 47 |
### Training hyperparameters
|
| 48 |
|
|
|
|
| 61 |
- Transformers 4.29.2
|
| 62 |
- Pytorch 1.11.0+cu113
|
| 63 |
- Datasets 2.12.0
|
| 64 |
+
- Tokenizers 0.13.3
|