初始化项目,由ModelHub XC社区提供模型
Model: FredZhang7/distilgpt2-stable-diffusion-v2 Source: Original Platform
This commit is contained in:
34
.gitattributes
vendored
Normal file
34
.gitattributes
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
91
README.md
Normal file
91
README.md
Normal file
@@ -0,0 +1,91 @@
|
||||
---
|
||||
license: creativeml-openrail-m
|
||||
tags:
|
||||
- stable-diffusion
|
||||
- prompt-generator
|
||||
- arxiv:2210.14140
|
||||
widget:
|
||||
- text: "amazing"
|
||||
- text: "a photo of"
|
||||
- text: "a sci-fi"
|
||||
- text: "a portrait of"
|
||||
- text: "a person standing"
|
||||
- text: "a boy watching"
|
||||
datasets:
|
||||
- FredZhang7/stable-diffusion-prompts-2.47M
|
||||
- poloclub/diffusiondb
|
||||
- Gustavosta/Stable-Diffusion-Prompts
|
||||
- bartman081523/stable-diffusion-discord-prompts
|
||||
---
|
||||
# Fast GPT2 PromptGen
|
||||
|
||||
<style>
|
||||
.container {
|
||||
padding-left: 20px;
|
||||
border-left: 5px solid gray;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<p><strong><a href="https://huggingface.co/FredZhang7/anime-anything-promptgen-v2">Fast Anime PromptGen</a></strong> generates descriptive safebooru and danbooru tags for anime text-to-image models.</p>
|
||||
</div>
|
||||
|
||||
|
||||
This model was trained on 2,470,000 descriptive stable diffusion prompts on the [FredZhang7/distilgpt2-stable-diffusion](https://huggingface.co/FredZhang7/distilgpt2-stable-diffusion) checkpoint for another 4,270,000 steps.
|
||||
|
||||
Compared to other prompt generation models using GPT2, this one runs with 50% faster forwardpropagation and 40% less disk space & RAM.
|
||||
|
||||
Major improvements from v1 are:
|
||||
- 25% more variations
|
||||
- faster and more fluent prompt generation
|
||||
- cleaned training data
|
||||
* removed prompts that generate images with nsfw scores > 0.5
|
||||
* removed duplicates, including prompts that differ by capitalization and punctuations
|
||||
* removed punctuations at random places
|
||||
* removed prompts shorter than 15 characters
|
||||
|
||||
|
||||
## Live WebUI Demo
|
||||
See the Prompt Generator tab of [Paint Journey Demo](https://huggingface.co/spaces/FredZhang7/paint-journey-demo).
|
||||
|
||||
|
||||
## Contrastive Search
|
||||
|
||||
```bash
|
||||
pip install --upgrade transformers
|
||||
```
|
||||
|
||||
```python
|
||||
from transformers import GPT2Tokenizer, GPT2LMHeadModel
|
||||
tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
|
||||
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
|
||||
model = GPT2LMHeadModel.from_pretrained('FredZhang7/distilgpt2-stable-diffusion-v2')
|
||||
|
||||
prompt = r'a cat sitting' # the beginning of the prompt
|
||||
temperature = 0.9 # a higher temperature will produce more diverse results, but with a higher risk of less coherent text
|
||||
top_k = 8 # the number of tokens to sample from at each step
|
||||
max_length = 80 # the maximum number of tokens for the output of the model
|
||||
repitition_penalty = 1.2 # the penalty value for each repetition of a token
|
||||
num_return_sequences=5 # the number of results to generate
|
||||
|
||||
# generate the result with contrastive search
|
||||
input_ids = tokenizer(prompt, return_tensors='pt').input_ids
|
||||
output = model.generate(input_ids, do_sample=True, temperature=temperature, top_k=top_k, max_length=max_length, num_return_sequences=num_return_sequences, repetition_penalty=repitition_penalty, penalty_alpha=0.6, no_repeat_ngram_size=1, early_stopping=True)
|
||||
|
||||
print('\nInput:\n' + 100 * '-')
|
||||
print('\033[96m' + prompt + '\033[0m')
|
||||
print('\nOutput:\n' + 100 * '-')
|
||||
for i in range(len(output)):
|
||||
print('\033[92m' + tokenizer.decode(output[i], skip_special_tokens=True) + '\033[0m\n')
|
||||
```
|
||||
|
||||
No comma style:
|
||||

|
||||
|
||||
|
||||
To bring back the commas, assign output without `penalty_alpha` and `no_repeat_ngram_size`:
|
||||
```python
|
||||
output = model.generate(input_ids, do_sample=True, temperature=temperature, top_k=top_k, max_length=max_length, num_return_sequences=num_return_sequences, repetition_penalty=repitition_penalty, early_stopping=True)
|
||||
```
|
||||
|
||||

|
||||
51
config.json
Normal file
51
config.json
Normal file
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"_name_or_path": "distilgpt2",
|
||||
"_num_labels": 1,
|
||||
"activation_function": "gelu_new",
|
||||
"architectures": [
|
||||
"GPT2LMHeadModel"
|
||||
],
|
||||
"attn_pdrop": 0.1,
|
||||
"bos_token_id": 50256,
|
||||
"embd_pdrop": 0.1,
|
||||
"eos_token_id": 50256,
|
||||
"id2label": {
|
||||
"0": "LABEL_0"
|
||||
},
|
||||
"initializer_range": 0.02,
|
||||
"label2id": {
|
||||
"LABEL_0": 0
|
||||
},
|
||||
"layer_norm_epsilon": 1e-05,
|
||||
"model_type": "gpt2",
|
||||
"n_ctx": 1024,
|
||||
"n_embd": 768,
|
||||
"n_head": 12,
|
||||
"n_inner": null,
|
||||
"n_layer": 6,
|
||||
"n_positions": 1024,
|
||||
"pad_token_id": 50256,
|
||||
"reorder_and_upcast_attn": false,
|
||||
"resid_pdrop": 0.1,
|
||||
"scale_attn_by_inverse_layer_idx": false,
|
||||
"scale_attn_weights": true,
|
||||
"summary_activation": null,
|
||||
"summary_first_dropout": 0.1,
|
||||
"summary_proj_to_labels": true,
|
||||
"summary_type": "cls_index",
|
||||
"summary_use_proj": true,
|
||||
"task_specific_params": {
|
||||
"text-generation": {
|
||||
"do_sample": true,
|
||||
"max_length": 76,
|
||||
"temperature": 0.7,
|
||||
"top_k": 4,
|
||||
"repetition_penalty": 1.2,
|
||||
"early_stopping": true
|
||||
}
|
||||
},
|
||||
"torch_dtype": "float32",
|
||||
"transformers_version": "4.21.2",
|
||||
"use_cache": true,
|
||||
"vocab_size": 50257
|
||||
}
|
||||
BIN
constrastive_search.png
Normal file
BIN
constrastive_search.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
BIN
contrastive_comma_style.png
Normal file
BIN
contrastive_comma_style.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
3
model.safetensors
Normal file
3
model.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:e03360bc4c5d7fe24eff02a265fbb9b97e84c752a20366bbfc5b2fc7ccd5e557
|
||||
size 333950622
|
||||
3
pytorch_model.bin
Normal file
3
pytorch_model.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2f54520576e1012e0b9f620631732e32c7cf827e020bae142e886c1f9500e371
|
||||
size 333969117
|
||||
1
tokenizer.json
Normal file
1
tokenizer.json
Normal file
File diff suppressed because one or more lines are too long
3
training_args.bin
Normal file
3
training_args.bin
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:2e929da9add7e721ae081565ee200a8fa3a1c95320080adb428ab0da5e45963b
|
||||
size 3311
|
||||
Reference in New Issue
Block a user