Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- Gustavosta/Stable-Diffusion-Prompts
|
5 |
+
- bartman081523/stable-diffusion-discord-prompts
|
6 |
+
language:
|
7 |
+
- en
|
8 |
+
library_name: transformers
|
9 |
+
pipeline_tag: text-generation
|
10 |
+
tags:
|
11 |
+
- art
|
12 |
+
- code
|
13 |
+
---
|
14 |
+
|
15 |
+
# Stable Diffusion Prompt Generator
|
16 |
+
|
17 |
+
TODO: Complete me next time
|
18 |
+
|
19 |
+
## Introcude
|
20 |
+
|
21 |
+
...
|
22 |
+
|
23 |
+
```python
|
24 |
+
from transformers import pipeline
|
25 |
+
|
26 |
+
pipe = pipeline('text-generation', model_id='Ar4ikov/gpt2-650k-stable-diffusion-prompt-generator')
|
27 |
+
|
28 |
+
|
29 |
+
def get_valid_prompt(text: str) -> str:
|
30 |
+
dot_split = text.split('.')[0]
|
31 |
+
n_split = text.split('\n')[0]
|
32 |
+
|
33 |
+
return {
|
34 |
+
len(dot_split) < len(n_split): dot_split,
|
35 |
+
len(n_split) > len(dot_split): n_split,
|
36 |
+
len(n_split) == len(dot_split): dot_split
|
37 |
+
}[True]
|
38 |
+
|
39 |
+
|
40 |
+
prompt = 'A Tokio town landscape, sunset, by'
|
41 |
+
|
42 |
+
valid_prompt = get_valid_prompt(pipe(prompt, max_length=77)[0]['generated_text'])
|
43 |
+
print(valid_prompt)
|
44 |
+
# >>> A Tokio town landscape, sunset, by Greg Rutkowski,Artgerm,trending on Behance,light effect,high detail,3d sculpture,golden ratio,dramatic,dramatic background,digital art
|
45 |
+
```
|