---
title: qwen-image-212
canonical_url: "https://www.modelscope.cn/studios/liudef07/qwen-image-212"
md_url: "https://www.modelscope.cn/studios/liudef07/qwen-image-212.md"
repository: liudef07/qwen-image-212
chinese_name: Qwen-Image-2.1
last_updated: 2026-10-19
sdk_type: gradio
sdk_version: 6.17.3
downloads: 0
stars: 9
---

# qwen-image-212

> qwen-image-212 - liudef07 在 ModelScope 创建的在线 Demo。Qwen-Image-2.1 text-to-image & multi-image editing demo with gradio_api

liudef07/qwen-image-212 是 ModelScope 魔搭社区上的在线可交互 Demo（创空间），基于 gradio 6.17.3 构建，中文名为「Qwen-Image-2.1」。

- **Repository**: liudef07/qwen-image-212
- **SDK**: gradio
- **SDK version**: 6.17.3
- **Downloads**: 0
- **Stars**: 9
- **Last updated**: 2026-10-19

Source: https://www.modelscope.cn/studios/liudef07/qwen-image-212

---

# Qwen-Image-2.1 文生图 / 图像编辑服务

基于 [Qwen/Qwen-Image-2.1](https://modelscope.cn/models/Qwen/Qwen-Image-2.1)（7B，bf16，Ada 48G 显存实例）的在线生成服务，支持：

- 文生图（7 种官方比例，最高 2752×1536）
- 图像编辑（上传 1 张参考图做指令式修改；上传多张做多图条件编辑）
- RGBA 透明图生成（Prompt 中描述透明背景即可）
- 案例库（26 个官方示例案例，含参考图与参考结果，一键填入；移植自 Qwen/Qwen-Image-2.1 官方创空间，Apache-2.0）

## HTTP API（Gradio REST）

远程调用统一走 **api-inference 域名**，请求头携带 SDK Token：

```
Authorization: Bearer ms-xxxx
```

### 1. 发起生成（同步拿 event_id）

```bash
curl -X POST "https://studio-liudef07-qwen-image-212.api-inference.modelscope.net/gradio_api/call/generate" \
  -H "Authorization: Bearer ms-xxxx" \
  -H "Content-Type: application/json" \
  --data-binary "@body.json"
```

`body.json`（`data` 数组顺序：prompt、负面提示词、比例、步数、CFG、种子、参考图列表、自定义宽、自定义高、透明图模式）：

```json
{ "data": ["一只戴宇航员头盔的橘猫，电影感打光", "", "1:1", 40, 1.0, -1, null, 0, 0, false] }
```

- 比例可选：`1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 16:9 / 9:16`，也可直接传自定义尺寸字符串如 `"1920×1080"`（自动对齐 32 的倍数，总像素超 4.3M 按比例缩小）
- 末三位：`custom_w / custom_h / transparent`；宽高同时 >0 时优先生效（编辑模式也适用），传 `0` 走比例档；`transparent=true` 自动在 prompt 前套官方 RGBA 透明图模板
- 种子传 `-1` 表示随机；`CFG > 1` 时负面提示词才生效
- 参考图位传 `null` 为文生图；图像编辑需先经 `/gradio_api/upload` 上传文件，再传入**文件对象数组**（1 张为单图编辑，最多 10 张多图编辑）；编辑模式与文生图统一按比例档/自定义尺寸出图

编辑模式 `body.json` 示例（两图编辑，`path` 为上传接口返回的服务端路径；Gallery 要求每项包一层 `image`）：

```json
{ "data": ["把第一张图的主角放进第二张图的场景里", "", "1:1", 40, 1.0, -1,
  [{"image": {"path": "/tmp/gradio/xxx/a.png", "meta": {"_type": "gradio.FileData"}}},
   {"image": {"path": "/tmp/gradio/xxx/b.png", "meta": {"_type": "gradio.FileData"}}}], 0, 0, false] }
```

返回：

```json
{ "event_id": "..." }
```

### 2. 轮询结果（SSE）

```bash
curl -N "https://studio-liudef07-qwen-image-212.api-inference.modelscope.net/gradio_api/call/generate/<event_id>" \
  -H "Authorization: Bearer ms-xxxx" -H "Accept: text/event-stream"
```

成功时返回 `event: complete`，`data` 中为结果图片的临时 URL（`/gradio_api/file=...`）与实际种子。

> 页面域名 `https://liudef07-qwen-image-212.ms.show` 供浏览器访问；SDK Token 调 API 一律走 api-inference 域名。
