--- license: apache-2.0 widget: - text: "Converts a simple image description into a prompt. Prompts are formatted as multiple related tags separated by commas, plus you can use () to increase the weight, [] to decrease the weight, or use a number to specify the weight. You should add appropriate words to make the images described in the prompt more aesthetically pleasing, but make sure there is a correlation between the input and output.\n### Input: 1 girl\n### Output:" tags: - pytorch - transformers - text-generation --- # BeautifulPrompt-v2 ## 简介 Brief Introduction 我们开源了一个自动Prompt生成模型,您可以直接输入一个极其简单的Prompt,就可以得到经过语言模型优化过的Prompt,帮助您更简单地生成高颜值图像。相比[v1](https://huggingface.co/alibaba-pai/pai-bloom-1b1-text2prompt-sd), 我们提升了复杂场景下的表现以及增加了生成权重(配合sd-webui使用)的能力。 We release an automatic Prompt generation model, you can directly enter an extremely simple Prompt and get a Prompt optimized by the language model to help you generate more beautiful images simply. Compared with [v1](https://huggingface.co/alibaba-pai/pai-bloom-1b1-text2prompt-sd), we have improved the performance in complex scenarios and increased the ability to generate weights (use with sd-webui). * Github: [EasyNLP](https://github.com/alibaba/EasyNLP) ## 使用 Usage ```python from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained('alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2') model = AutoModelForCausalLM.from_pretrained('alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2').eval().cuda() raw_prompt = '1 girl' TEMPLATE_V2 = 'Converts a simple image description into a prompt. \ Prompts are formatted as multiple related tags separated by commas, plus you can use () to increase the weight, [] to decrease the weight, \ or use a number to specify the weight. You should add appropriate words to make the images described in the prompt more aesthetically pleasing, \ but make sure there is a correlation between the input and output.\n\ ### Input: {raw_prompt}\n### Output:' input = TEMPLATE_V2.format(raw_prompt=raw_prompt) input_ids = tokenizer.encode(input, return_tensors='pt').cuda() outputs = model.generate( input_ids, max_length=384, do_sample=True, temperature=0.9, top_k=50, top_p=0.95, repetition_penalty=1.1, num_return_sequences=5) prompts = tokenizer.batch_decode(outputs[:, input_ids.size(1):], skip_special_tokens=True) prompts = [p.strip() for p in prompts] print(prompts) ``` ## 作品展示 Gallery | Before | After | | ---------------------------------------- | ---------------------------------- | | prompt: a beautiful girl | prompt: (8k, RAW photo, best quality, masterpiece:1.2), (realistic, photo-realistic:1.37), octane render, ultra high res, photon mapping, radiosity, physically-based rendering, ue5, ((white dress)), ((long hair)), ((beautiful face)), ((light brown eyes)), ((smile))) extremely detailed CG unity 8k wallpaper, makeup, (glowing lips), (fantasy lining), (intricate details), light bokeh, (sharp focus) centered at the center of the face (wide angle:0.6), full body | | ![](imgs/2023-08-29_15-22-45_2442.png) ![](imgs/2023-08-29_15-23-01_7579.png) | ![](imgs/2023-08-29_15-28-21_2272.png) ![](imgs/2023-08-29_15-28-37_2750.png) | | Before | After | | ---------------------------------------- | ---------------------------------- | | prompt: Astronaut rides horse | prompt: (masterpiece), (best quality), astronaut on horseback, (rides horse), ( helmet ), (standing on horseback), panorama, looking ahead, detailed background, solo | | ![](imgs/2023-08-29_15-30-52_5812.png) ![](imgs/2023-08-29_15-31-08_8054.png) | ![](imgs/2023-08-29_15-33-31_7554.png) ![](imgs/2023-08-29_15-33-49_3184.png) | > generated by [sd-xl-1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) ## 使用须知 Notice for Use 使用上述模型需遵守[AIGC模型开源特别条款](https://terms.alicdn.com/legal-agreement/terms/common_platform_service/20230505180457947/20230505180457947.html)。 If you want to use this model, please read this [document](https://terms.alicdn.com/legal-agreement/terms/common_platform_service/20230505180457947/20230505180457947.html) carefully and abide by the terms.