Instructions to use alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2")# Load model directly 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") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2
- SGLang
How to use alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2 with Docker Model Runner:
docker model run hf.co/alibaba-pai/pai-bloom-1b1-text2prompt-sd-v2
BeautifulPrompt-v2
简介 Brief Introduction
我们开源了一个自动Prompt生成模型,您可以直接输入一个极其简单的Prompt,就可以得到经过语言模型优化过的Prompt,帮助您更简单地生成高颜值图像。相比v1, 我们提升了复杂场景下的表现以及增加了生成权重(配合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, we have improved the performance in complex scenarios and increased the ability to generate weights (use with sd-webui).
- Github: EasyNLP
使用 Usage
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
generated by sd-xl-1.0
使用须知 Notice for Use
使用上述模型需遵守AIGC模型开源特别条款。
If you want to use this model, please read this document 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}
}
- Downloads last month
- 5







