File size: 3,277 Bytes
635278d
 
 
 
5fd509c
 
 
 
 
1dd6766
 
635278d
83f11b6
635278d
875c761
83f11b6
 
 
 
 
 
 
 
 
f669322
 
1805c93
 
83f11b6
 
37a1a79
83f11b6
 
635278d
 
83f11b6
635278d
f1dd802
 
7b9d6f3
 
1dd6766
635278d
 
2a98d07
 
635278d
206f6de
 
 
 
 
770d173
206f6de
770d173
875c761
 
 
770d173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37a1a79
 
770d173
 
635278d
 
 
7b9d6f3
635278d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
license: apache-2.0
tags:
- generated_from_trainer
- stable diffusion
- diffusion
- text2image
- prompt augment
- prompt engineering
datasets:
- Gustavosta/Stable-Diffusion-Prompts
model-index:
- name: distilgpt2-magicprompt-SD
  results: []
thumbnail: https://i.ibb.co/WkmTnZD/image.png
widget:
 - text: "morning sun over Jakarta"
   example_title: "morning sun"
 - text: "WARNING: pip is"
   example_title: "pip"
 - text: "sentient cheese"
   example_title: "sentient cheese"
 - text: "cheeps are"
   example_title: "cheeps"
 - text: "avocado armchair"
   example_title: "creative prompt"
 - text: "Landscape of"
   example_title: "landscape"
parameters:
  min_length: 16
  max_new_tokens: 24
  no_repeat_ngram_size: 1
  do_sample: True
---

# distilgpt2-magicprompt-SD

[![colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/pszemraj/bdddf9c3fe92d1ac2654730016d64c80/demo-distilgpt2-magicprompt.ipynb)

Generate/augment your prompt, stable diffusion style.

This model is a fine-tuned version of [distilgpt2](https://huggingface.co/distilgpt2) on the Gustavosta/Stable-Diffusion-Prompts dataset.
It achieves the following results on the evaluation set:
- Loss: 1.3089
- eval_steps_per_second   =     17.201
- perplexity              =     3.7022

## example


Results in (_DALL-E, but you get the idea_):

![example](https://i.ibb.co/WkmTnZD/image.png)


<br>

this `distilgpt2` version is probably small/fast enough to be used locally on CPU!

## basic usage

install transformers as needed:

```bash
pip install -U transformers
```

load and query through a `pipeline` object:

```python
from transformers import pipeline

model_tag = "pszemraj/distilgpt2-magicprompt-SD"
generator = pipeline(
    "text-generation",
    model=model_tag,
)

prompt = "The Answer to Why"
result = generator(
    prompt,
    max_new_tokens=24,
)  # generate, adjust/add kwargs as needed
print(result[0]["generated_text"])
```

## Training and evaluation data

refer to the `Gustavosta/Stable-Diffusion-Prompts` dataset.

## Training procedure

### Training hyperparameters

The following hyperparameters were used during training:
- learning_rate: 0.001
- train_batch_size: 16
- eval_batch_size: 2
- seed: 42
- distributed_type: multi-GPU
- num_devices: 2
- gradient_accumulation_steps: 8
- total_train_batch_size: 256
- total_eval_batch_size: 4
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: cosine
- lr_scheduler_warmup_ratio: 0.05
- num_epochs: 10.0

### Training results

| Training Loss | Epoch | Step | Validation Loss |
|:-------------:|:-----:|:----:|:---------------:|
| 2.7061        | 0.99  | 33   | 2.5859          |
| 2.08          | 1.99  | 66   | 1.9965          |
| 1.7623        | 2.99  | 99   | 1.7248          |
| 1.5408        | 3.99  | 132  | 1.5449          |
| 1.4147        | 4.99  | 165  | 1.4437          |
| 1.3593        | 5.99  | 198  | 1.3768          |
| 1.2703        | 6.99  | 231  | 1.3362          |
| 1.2528        | 7.99  | 264  | 1.3175          |
| 1.1981        | 8.99  | 297  | 1.3091          |
| 1.2117        | 9.99  | 330  | 1.3089          |


### Framework versions

- Transformers 4.25.0.dev0
- Pytorch 1.13.0+cu117
- Datasets 2.6.1
- Tokenizers 0.13.1