RichardErkhov commited on
Commit
be05b2d
1 Parent(s): c5e7f61

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +100 -0
README.md ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ anime-anything-promptgen-v2 - bnb 4bits
11
+ - Model creator: https://huggingface.co/FredZhang7/
12
+ - Original model: https://huggingface.co/FredZhang7/anime-anything-promptgen-v2/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ license: creativeml-openrail-m
20
+ language:
21
+ - en
22
+ widget:
23
+ - text: 1girl, fate
24
+ - text: 1boy, league of
25
+ - text: 1girl, genshin
26
+ - text: 1boy, national basketball association
27
+ - text: 1girl, spy x
28
+ - text: 1girl, absurdres
29
+ tags:
30
+ - stable-diffusion
31
+ - anime
32
+ - anything-v4
33
+ - art
34
+ - arxiv:2210.14140
35
+ datasets:
36
+ - FredZhang7/anime-prompts-180K
37
+ ---
38
+
39
+ ## Fast Anime PromptGen
40
+
41
+ This model was trained on a dataset of **80,000** safe anime prompts for 3 epochs. I fetched the prompts from the [Safebooru API endpoint](https://safebooru.donmai.us/posts/random.json), but only accepted unique prompts with **up_score ≥ 8** and without any [blacklisted tags](./blacklist.txt).
42
+ I didn't release the V1 model because it often generated gibberish prompts. After trying all means to correct that behavior, I eventually figured that the cause of the gibberish prompts is not from the pipeline params, model structure or training duration, but rather from the random usernames in the training data.
43
+ Here's the complete [prompt preprocessing algorithm](./preprocess.py).
44
+
45
+
46
+ ## Text-to-image Examples
47
+
48
+ Prefix *1girl* | [Generated *1girl* prompts](./anime_girl_settings.txt) | Model *Anything V4*
49
+
50
+ ![](./anime_girls.png)
51
+
52
+ Prefix *1boy*  | [Generated *1boy* prompts](./anime_boy_settings.txt) | Model *Anything V4*
53
+
54
+ ![](./anime_boys.png)
55
+
56
+ ## Contrastive Search
57
+ ```
58
+ pip install --upgrade transformers
59
+ ```
60
+ ```python
61
+ import torch
62
+ from transformers import GPT2Tokenizer, GPT2LMHeadModel, pipeline
63
+ tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
64
+ tokenizer.add_special_tokens({'pad_token': '[PAD]'})
65
+ model = GPT2LMHeadModel.from_pretrained('FredZhang7/anime-anything-promptgen-v2')
66
+
67
+ prompt = r'1girl, genshin'
68
+
69
+ # generate text using fine-tuned model
70
+ nlp = pipeline('text-generation', model=model, tokenizer=tokenizer)
71
+
72
+ # generate 10 samples using contrastive search
73
+ outs = nlp(prompt, max_length=76, num_return_sequences=10, do_sample=True, repetition_penalty=1.2, temperature=0.7, top_k=4, early_stopping=True)
74
+
75
+ print('\nInput:\n' + 100 * '-')
76
+ print('\033[96m' + prompt + '\033[0m')
77
+ print('\nOutput:\n' + 100 * '-')
78
+ for i in range(len(outs)):
79
+ # remove trailing commas and double spaces
80
+ outs[i] = str(outs[i]['generated_text']).replace(' ', '').rstrip(',')
81
+ print('\033[92m' + '\n\n'.join(outs) + '\033[0m\n')
82
+ ```
83
+
84
+ Output Example:
85
+
86
+ ![](./contrastive_search.png)
87
+
88
+ Please see [Fast GPT PromptGen](https://huggingface.co/FredZhang7/distilgpt2-stable-diffusion-v2) for more info on the pipeline parameters.
89
+
90
+
91
+ ## Awesome Tips
92
+
93
+ - If you feel like a generated anime character doesn't show emotions, try emoticons like `;o`, `:o`, `;p`, `:d`, `:p`, and `;d` in the prompt.
94
+ I also use `happy smirk`, `happy smile`, `laughing closed eyes`, etc. to make the characters more lively and expressive.
95
+
96
+ - Adding `absurdres`, instead of `highres` and `masterpiece`, to a prompt can drastically increase the sharpness and resolution of a generated image.
97
+
98
+ ## Danbooru
99
+ [Link to the Danbooru version](https://huggingface.co/FredZhang7/danbooru-tag-generator)
100
+