SuperAPI AI 工具集

qwen-image-2-pro

设计与创作

查看项目

更新于 10-16 08:16

技能介绍

用途

Qwen-Image-2.0-Pro 是阿里巴巴推出的专业图像生成模型,通过 inference.sh CLI(belt)调用。它面向需要高质量文字渲染和复杂设计的图像生成任务,尤其适合海报、营销横幅等图文结合的场景。

主要能力

  • 专业文字渲染:支持多行和段落级文字,细节精细。
  • 细粒度写实:更好的纹理和照片级真实场景。
  • 更强的语义遵循:更准确地遵循复杂提示词。
  • 复杂设计:适合文字与图像组合的设计。
  • 图像编辑:支持风格迁移,例如让图 1 中的人物穿上图 2 的服装。
  • 多图生成:一次可生成 1-6 张图像。
  • 可复现生成:通过 seed 参数复现结果。

使用方式

需先安装 inference.sh CLI(belt):

npx skills add belt-sh/cli

登录:

belt login

基本文生图:

belt app run alibaba/qwen-image-2-pro --input '{"prompt": "A futuristic cityscape at sunset with flying cars"}'

文字密集海报示例:

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 string 必填。要生成或编辑的内容(最多 800 字符)
reference_images array 用于编辑的输入图像(1-3 张)
num_images integer 生成图像数量(1-6)
width integer 输出宽度(像素,512-2048)
height integer 输出高度(像素,512-2048)
watermark boolean 添加 "Qwen-Image" 水印
negative_prompt string 要避免的内容(最多 500 字符)
prompt_extend boolean 启用提示词重写(默认:true)
seed integer 用于复现的随机种子(0-2147483647)

尺寸约束:总像素必须在 512×512 到 2048×2048 之间。

输出

字段 类型 说明
images array 生成或编辑的图像(PNG 格式)
output_meta object 包含尺寸和数量的元数据

文字渲染技巧

  • 用引号包裹精确文字:"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

适用场景

  • 含多行文字的海报设计
  • 营销横幅与促销素材
  • 需要精确文字渲染的图文组合
  • 风格迁移与图像编辑
  • 需要批量生成多个变体的设计任务

限制

  • prompt 最多 800 字符,negative_prompt 最多 500 字符。
  • 输出尺寸总像素须在 512×512 到 2048×2048 之间。
  • reference_images 支持 1-3 张。
  • num_images 支持 1-6 张。
  • 需通过 inference.sh CLI(belt)调用,需登录。
  • 关于收费、价格、平台支持等信息暂未提供。