commit 4ffc24dc3e2ffcefd39b1ab3a615133c56b3042b Author: ModelHub XC Date: Sat Apr 25 17:58:52 2026 +0800 初始化项目,由ModelHub XC社区提供模型 Model: pai/pai-bloom-1b1-text2prompt-sd-v2 Source: Original Platform diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..21b3632 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,49 @@ +*.7z filter=lfs diff=lfs merge=lfs -text +*.arrow filter=lfs diff=lfs merge=lfs -text +*.bin filter=lfs diff=lfs merge=lfs -text +*.bin.* filter=lfs diff=lfs merge=lfs -text +*.bz2 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 +*.model filter=lfs diff=lfs merge=lfs -text +*.msgpack 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 +*.pt filter=lfs diff=lfs merge=lfs -text +*.pth filter=lfs diff=lfs merge=lfs -text +*.rar 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 +*.xz filter=lfs diff=lfs merge=lfs -text +*.zip filter=lfs diff=lfs merge=lfs -text +*.zstandard filter=lfs diff=lfs merge=lfs -text +*.tfevents* filter=lfs diff=lfs merge=lfs -text +*.db* filter=lfs diff=lfs merge=lfs -text +*.ark* filter=lfs diff=lfs merge=lfs -text +**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text +**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text +**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text +*.safetensors filter=lfs diff=lfs merge=lfs -text +*.ckpt filter=lfs diff=lfs merge=lfs -text +*.gguf* filter=lfs diff=lfs merge=lfs -text +*.ggml filter=lfs diff=lfs merge=lfs -text +*.llamafile* filter=lfs diff=lfs merge=lfs -text +*.pt2 filter=lfs diff=lfs merge=lfs -text +*.mlmodel filter=lfs diff=lfs merge=lfs -text +*.npy filter=lfs diff=lfs merge=lfs -text +*.npz filter=lfs diff=lfs merge=lfs -text +*.pickle filter=lfs diff=lfs merge=lfs -text +*.pkl filter=lfs diff=lfs merge=lfs -text +*.tar filter=lfs diff=lfs merge=lfs -text +*.wasm filter=lfs diff=lfs merge=lfs -text +*.zst filter=lfs diff=lfs merge=lfs -text +*tfevents* filter=lfs diff=lfs merge=lfs -text + +tokenizer.json filter=lfs diff=lfs merge=lfs -text \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e3f7a5b --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ +--- +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_new_tokens=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. + + +## Paper Citation + + +If you find the model useful, please consider cite the paper: + +``` +@inproceedings{emnlp2023a, + author = {Tingfeng Cao and + Chengyu Wang and + Bingyan Liu and + Ziheng Wu and + Jinhui Zhu and + Jun Huang}, + title = {BeautifulPrompt: Towards Automatic Prompt Engineering for Text-to-Image Synthesis}, + booktitle = {Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing: Industry Track}, + pages = {1--11}, + year = {2023} +} +``` \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..9e7c9b8 --- /dev/null +++ b/config.json @@ -0,0 +1,32 @@ +{ + "_name_or_path": "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2", + "apply_residual_connection_post_layernorm": false, + "architectures": [ + "BloomForCausalLM" + ], + "attention_dropout": 0.0, + "attention_softmax_in_fp32": true, + "bias_dropout_fusion": true, + "bos_token_id": 1, + "eos_token_id": 2, + "hidden_dropout": 0.0, + "hidden_size": 1536, + "initializer_range": 0.02, + "layer_norm_epsilon": 1e-05, + "masked_softmax_fusion": true, + "model_type": "bloom", + "n_head": 16, + "n_inner": null, + "n_layer": 24, + "offset_alibi": 100, + "pad_token_id": 3, + "pretraining_tp": 1, + "skip_bias_add": true, + "skip_bias_add_qkv": false, + "slow_but_exact": false, + "torch_dtype": "float16", + "transformers_version": "4.30.0", + "unk_token_id": 0, + "use_cache": true, + "vocab_size": 250880 +} diff --git a/configuration.json b/configuration.json new file mode 100644 index 0000000..bbeeda1 --- /dev/null +++ b/configuration.json @@ -0,0 +1 @@ +{"framework": "pytorch", "task": "text-generation", "allow_remote": true} \ No newline at end of file diff --git a/generation_config.json b/generation_config.json new file mode 100644 index 0000000..ca5f79d --- /dev/null +++ b/generation_config.json @@ -0,0 +1,7 @@ +{ + "_from_model_config": true, + "bos_token_id": 1, + "eos_token_id": 2, + "pad_token_id": 3, + "transformers_version": "4.30.0" +} diff --git a/imgs/2023-08-29_15-22-45_2442.png b/imgs/2023-08-29_15-22-45_2442.png new file mode 100644 index 0000000..817c01a Binary files /dev/null and b/imgs/2023-08-29_15-22-45_2442.png differ diff --git a/imgs/2023-08-29_15-23-01_7579.png b/imgs/2023-08-29_15-23-01_7579.png new file mode 100644 index 0000000..6aa55c2 Binary files /dev/null and b/imgs/2023-08-29_15-23-01_7579.png differ diff --git a/imgs/2023-08-29_15-28-21_2272.png b/imgs/2023-08-29_15-28-21_2272.png new file mode 100644 index 0000000..e56a8a7 Binary files /dev/null and b/imgs/2023-08-29_15-28-21_2272.png differ diff --git a/imgs/2023-08-29_15-28-37_2750.png b/imgs/2023-08-29_15-28-37_2750.png new file mode 100644 index 0000000..a247e7d Binary files /dev/null and b/imgs/2023-08-29_15-28-37_2750.png differ diff --git a/imgs/2023-08-29_15-30-52_5812.png b/imgs/2023-08-29_15-30-52_5812.png new file mode 100644 index 0000000..d8a80b1 Binary files /dev/null and b/imgs/2023-08-29_15-30-52_5812.png differ diff --git a/imgs/2023-08-29_15-31-08_8054.png b/imgs/2023-08-29_15-31-08_8054.png new file mode 100644 index 0000000..ee49a5e Binary files /dev/null and b/imgs/2023-08-29_15-31-08_8054.png differ diff --git a/imgs/2023-08-29_15-33-31_7554.png b/imgs/2023-08-29_15-33-31_7554.png new file mode 100644 index 0000000..39f0ca4 Binary files /dev/null and b/imgs/2023-08-29_15-33-31_7554.png differ diff --git a/imgs/2023-08-29_15-33-49_3184.png b/imgs/2023-08-29_15-33-49_3184.png new file mode 100644 index 0000000..da06780 Binary files /dev/null and b/imgs/2023-08-29_15-33-49_3184.png differ diff --git a/model.safetensors b/model.safetensors new file mode 100644 index 0000000..3c5e92b --- /dev/null +++ b/model.safetensors @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:928872c6f117499bb96dbceb5fc72e709423ab6e9bc0647400c9b2657f3b51ca +size 2130662600 diff --git a/pytorch_model.bin b/pytorch_model.bin new file mode 100644 index 0000000..92f46a4 --- /dev/null +++ b/pytorch_model.bin @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f73c5c8902bd384c6f77ef2857a124a782e2ce79ea1eda6868d50505a7136f36 +size 2130723617 diff --git a/special_tokens_map.json b/special_tokens_map.json new file mode 100644 index 0000000..fdafe48 --- /dev/null +++ b/special_tokens_map.json @@ -0,0 +1,6 @@ +{ + "bos_token": "", + "eos_token": "", + "pad_token": "", + "unk_token": "" +} diff --git a/tokenizer.json b/tokenizer.json new file mode 100644 index 0000000..d371465 --- /dev/null +++ b/tokenizer.json @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6c9597d88490e2d1215db6f35ebc1ed6ef1294a7ee829e36078b74c0a8ddaadf +size 14500723 diff --git a/tokenizer_config.json b/tokenizer_config.json new file mode 100644 index 0000000..612d97d --- /dev/null +++ b/tokenizer_config.json @@ -0,0 +1,11 @@ +{ + "add_prefix_space": false, + "bos_token": "", + "clean_up_tokenization_spaces": false, + "eos_token": "", + "model_max_length": 1000000000000000019884624838656, + "pad_token": "", + "padding_side": "left", + "tokenizer_class": "BloomTokenizer", + "unk_token": "" +}