license: creativeml-openrail-m
language:
- en
widget:
- text: 1girl, fate
- text: 1boy, league of legends
- text: 1girl, genshin impact
- text: 1boy, national basketball association
- text: 1girl, spy x
- text: 1girl, absurdres
tags:
- stable-diffusion
- anime
- anything-v4
- art
- arxiv:2210.14140
datasets:
- FredZhang7/anime-prompts-180K
Fast Anime PromptGen
pytorch_model
is trained on 80K anime tags, all with up_score
greater than 8 and without "greyscale","girls","boys", and "others", fetched from the Safebooru API.
I didn't release the V1 model because it only 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 model or training duration, but rather from the random usernames present in the training data.
Here's the complete prompt preprocessing.
Todo:
- upload Danbooru model
Text-to-image Examples
Prefix 1girl | Generated 1girl prompts | Model Anything V4
Prefix 1boy | Generated 1boy prompts | Model Anything V4
Contrastive Search
pip install --upgrade transformers
import torch
from transformers import GPT2Tokenizer, GPT2LMHeadModel, pipeline
tokenizer = GPT2Tokenizer.from_pretrained('distilgpt2')
tokenizer.add_special_tokens({'pad_token': '[PAD]'})
model = GPT2LMHeadModel.from_pretrained('FredZhang7/anime-anything-promptgen')
prompt = r'1girl, genshin'
# generate text using fine-tuned model
nlp = pipeline('text-generation', model=model, tokenizer=tokenizer)
# generate 10 samples using greedy search
outs = nlp(prompt, max_length=76, num_return_sequences=10, do_sample=True, repetition_penalty=1.1, temperature=0.7, top_k=4, early_stopping=True)
print('\nInput:\n' + 100 * '-')
print('\033[96m' + prompt + '\033[0m')
print('\nOutput:\n' + 100 * '-')
for i in range(len(outs)):
# remove trailing commas and double spaces
outs[i] = str(outs[i]['generated_text']).replace(' ', '').rstrip(',')
print('\033[92m' + '\n\n'.join(outs) + '\033[0m\n')
Output Example:
Please see Fast GPT PromptGen for more info on the pipeline parameters.
Tips
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. I often usehappy smirk
,happy smile
,laughing closed eyes
, etc. to make the characters more lively and expressive.Adding
absurdres
, instead ofhighres
andmasterpiece
, to a prompt tends to increase the sharpness of a generated image.