用途
Qwen-Image-2.0-Pro 是阿里巴巴推出的专业图像生成模型,通过 inference.sh CLI(belt)调用。它面向需要高质量文字渲染和复杂设计的场景,官方描述其优势为:专业文字渲染、细粒度写实、更强的语义遵循,适合文字与图像结合的设计任务。
主要能力
- 专业文字渲染:支持多行及段落级文字,细节精细。
- 细粒度写实:更好的纹理与照片级场景表现。
- 更强的语义遵循:更准确地执行复杂提示词。
- 复杂设计:适合文字与图像组合的设计。
- 支持图像编辑(如风格迁移)、多图变体生成、可复现生成(通过 seed)。
使用方式
需先安装 inference.sh CLI(belt),安装命令为 npx skills add belt-sh/cli,随后登录:
belt login
基本调用示例:
belt app run alibaba/qwen-image-2-pro --input '{"prompt": "Poster with title \"Welcome!\" in bold blue text"}'
文字密集海报示例:
belt app run alibaba/qwen-image-2-pro --input '{
"prompt": "Healing-style hand-drawn poster featuring three puppies playing with a ball. The main title \"Come Play Ball!\" is prominently displayed at the top in bold, blue cartoon font. Below, the subtitle \"Join the Fun!\" appears in green font.",
"width": 1024,
"height": 1536,
"prompt_extend": false
}'
营销横幅示例:
belt app run alibaba/qwen-image-2-pro --input '{
"prompt": "Professional marketing banner for summer sale. Large text \"SUMMER SALE\" in white on gradient sunset background. \"50% OFF\" in yellow below. Clean, modern design.",
"width": 1920,
"height": 1080,
"prompt_extend": false,
"negative_prompt": "blurry text, distorted text, low quality"
}'
多图变体示例:
belt app run alibaba/qwen-image-2-pro --input '{
"prompt": "Minimalist logo design for a coffee shop called \"Bean & Brew\"",
"num_images": 4
}'
图像编辑(风格迁移)示例:
belt app run alibaba/qwen-image-2-pro --input '{
"prompt": "Make the person from Image 1 wear the outfit from Image 2",
"reference_images": [
{"uri": "https://example.com/person.jpg"},
{"uri": "https://example.com/outfit.jpg"}
],
"num_images": 2
}'
可复现生成示例:
belt app run alibaba/qwen-image-2-pro --input '{
"prompt": "Abstract geometric art in blue and gold",
"seed": 12345
}'
输入参数
- prompt:字符串,必填,生成或编辑内容(最多 800 字符)。
- reference_images:数组,用于编辑的输入图像(1-3 张)。
- num_images:整数,生成图像数量(1-6)。
- width:整数,输出宽度像素(512-2048)。
- height:整数,输出高度像素(512-2048)。
- watermark:布尔值,添加 "Qwen-Image" 水印。
- negative_prompt:字符串,需避免的内容(最多 500 字符)。
- prompt_extend:布尔值,启用提示词重写(默认 true)。
- seed:整数,随机种子用于复现(0-2147483647)。
尺寸约束:总像素须在 512×512 与 2048×2048 之间。
输出
- images:数组,生成或编辑后的图像(PNG 格式)。
- output_meta:对象,包含尺寸和数量的元数据。
文字渲染技巧
- 用引号包裹精确文字:"Title: "Hello World!""。
- 指定字体细节:颜色、样式、大小、位置。
- 关闭 prompt_extend:设置 prompt_extend: false 以精确控制。
- 使用负向提示词:"blurry text, distorted text, low quality"。
推荐提示词结构示例:
Poster with the title "GRAND OPENING" in large red serif font at the top center.
Below, the date "March 15, 2024" in smaller black text.
Background: elegant gold and white gradient.
Style: professional, clean, modern.
推荐负向提示词:
{
"negative_prompt": "low resolution, low quality, deformed limbs, deformed fingers, oversaturated, waxy, no facial details, overly smooth, AI-like, chaotic composition, blurry text, distorted text"
}
示例工作流
# 1. 生成示例输入以查看所有选项
belt app sample alibaba/qwen-image-2-pro --save input.json
# 2. 编辑提示词
# 3. 运行
belt app run alibaba/qwen-image-2-pro --input input.json
Python SDK
from inferencesh import inference
client = inference()
# 文字密集海报
result = client.run({
"app": "alibaba/qwen-image-2-pro",
"input": {
"prompt": "Poster with title \"Welcome!\" in bold blue text at top",
"width": 1024,
"height": 1536,
"prompt_extend": False
}
})
print(result["output"])
# 流式实时更新
for update in client.run({
"app": "alibaba/qwen-image-2-pro",
"input": {
"prompt": "Professional product photography of a watch"
}
}, stream=True):
if update.get("progress"):
print(f"progress: {update['progress']}%")
if update.get("output"):
print(f"output: {update['output']}")
相关技能
# 标准 Qwen-Image(更快,通用)
npx skills add inference-sh/skills@qwen-image
# 完整平台技能(所有应用)
npx skills add inference-sh/skills@infsh-cli
# 所有图像生成模型
npx skills add inference-sh/skills@ai-image-generation
# 浏览所有图像应用
belt app list --category image
适用场景
- 含多行或段落级文字的海报、横幅、营销物料设计。
- 需要照片级写实纹理的场景。
- 需要精确遵循复杂提示词的设计任务。
- 图像编辑与风格迁移(如换装)。
- 需要批量生成变体或可复现结果的创作。
限制
- 提示词最多 800 字符,负向提示词最多 500 字符。
- 参考图像 1-3 张,生成数量 1-6 张。
- 输出宽高各在 512-2048 像素之间,总像素须在 512×512 与 2048×2048 之间。
- 需通过 inference.sh CLI(belt)或 Python SDK 调用,需登录。
- 关于收费、价格、平台支持范围等信息,资料暂未提供。