Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
datasets:
|
3 |
+
- AdamCodd/Civitai-2m-prompts
|
4 |
+
metrics:
|
5 |
+
- accuracy
|
6 |
+
- f1
|
7 |
+
- precision
|
8 |
+
- recall
|
9 |
+
- roc_auc
|
10 |
+
inference: true
|
11 |
+
model-index:
|
12 |
+
- name: distilroberta-nsfw-prompt-stable-diffusion
|
13 |
+
results:
|
14 |
+
- task:
|
15 |
+
type: text-classification
|
16 |
+
name: Text Classification
|
17 |
+
metrics:
|
18 |
+
- type: loss
|
19 |
+
value: 0.3103
|
20 |
+
- type: accuracy
|
21 |
+
value: 0.8642
|
22 |
+
name: Accuracy
|
23 |
+
- type: f1
|
24 |
+
value: 0.8612
|
25 |
+
name: F1
|
26 |
+
- type: precision
|
27 |
+
value: 0.8805
|
28 |
+
name: Precision
|
29 |
+
- type: recall
|
30 |
+
value: 0.8427
|
31 |
+
name: Recall
|
32 |
+
- type: ROC_AUC
|
33 |
+
value: 0.9408
|
34 |
+
name: AUC
|
35 |
+
language:
|
36 |
+
- en
|
37 |
+
---
|
38 |
+
## DistilRoBERTa-nsfw-prompt-stable-diffusion
|
39 |
+
|
40 |
+
This model utilizes the [Distilroberta base](https://huggingface.co/distilroberta-base) architecture, which has been fine-tuned for a classification task on [AdamCodd/Civitai-2m-prompts](https://huggingface.co/datasets/AdamCodd/Civitai-2m-prompts) dataset, on the positive prompts.
|
41 |
+
It achieves the following results on the evaluation set:
|
42 |
+
* Loss: 0.3103
|
43 |
+
* Accuracy: 0.8642
|
44 |
+
* F1: 0.8612
|
45 |
+
* AUC: 0.9408
|
46 |
+
* Precision: 0.8805
|
47 |
+
* Recall: 0.8427
|
48 |
+
|
49 |
+
## Model description
|
50 |
+
|
51 |
+
This model was made to detect NSFW Stable-diffusion prompts by training it on 2M SFW and NSFW prompts (1043475 samples of each, perfectly balanced). One words prompts have been excluded to remove useless noise for the prediction.
|
52 |
+
|
53 |
+
## Usage
|
54 |
+
|
55 |
+
```python
|
56 |
+
from transformers import pipeline
|
57 |
+
|
58 |
+
prompt_detector = pipeline("text-classification", model="AdamCodd/distilroberta-nsfw-prompt-stable-diffusion")
|
59 |
+
|
60 |
+
predicted_class = prompt_detector("masterpiece, 1girl, yellow sundress, looking at viewer")
|
61 |
+
print(predicted_class)
|
62 |
+
#[{'label': 'SFW', 'score': 0.9983291029930115}]
|
63 |
+
```
|
64 |
+
|
65 |
+
## Training and evaluation data
|
66 |
+
|
67 |
+
More information needed
|
68 |
+
|
69 |
+
## Training procedure
|
70 |
+
|
71 |
+
### Training hyperparameters
|
72 |
+
|
73 |
+
The following hyperparameters were used during training:
|
74 |
+
- learning_rate: 3e-05
|
75 |
+
- train_batch_size: 32
|
76 |
+
- eval_batch_size: 32
|
77 |
+
- seed: 42
|
78 |
+
- optimizer: AdamW with betas=(0.9,0.999) and epsilon=1e-08
|
79 |
+
- lr_scheduler_type: linear
|
80 |
+
- lr_scheduler_warmup_steps: 150
|
81 |
+
- num_epochs: 1
|
82 |
+
- weight_decay: 0.01
|
83 |
+
|
84 |
+
### Training results
|
85 |
+
|
86 |
+
Metrics: Accuracy, F1, Precision, Recall, AUC
|
87 |
+
|
88 |
+
```
|
89 |
+
'eval_loss': 0.3103,
|
90 |
+
'eval_accuracy': 0.8642,
|
91 |
+
'eval_f1': 0.8612,
|
92 |
+
'eval_precision': 0.8805,
|
93 |
+
'eval_recall': 0.8427,
|
94 |
+
'eval_roc_auc': 0.9408,
|
95 |
+
```
|
96 |
+
|
97 |
+
[Confusion matrix](https://huggingface.co/AdamCodd/distilroberta-nsfw-prompt-stable-diffusion/resolve/main/Confusion_matrix.png):
|
98 |
+
|
99 |
+
[[184931 23859]
|
100 |
+
|
101 |
+
[32820 175780]]
|
102 |
+
|
103 |
+
### Framework versions
|
104 |
+
|
105 |
+
- Transformers 4.36.2
|
106 |
+
- Datasets 2.16.1
|
107 |
+
- Tokenizers 0.15.0
|
108 |
+
- Evaluate 0.4.1
|
109 |
+
|
110 |
+
If you want to support me, you can [here](https://ko-fi.com/adamcodd).
|