Files
2026-03-08 16:02:37 +00:00

109 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# change_app.py API 文档
## 1. GET /
返回主页静态文件 `index.html`
---
## 2. POST /change_cloth
**推荐入口**,带 Redis 队列排队,避免并发冲突。
### 请求参数(JSON
| 参数 | 类型 | 必选 | 说明 |
|------|------|------|------|
| human_url | string | 是 | 人物图片 URL |
| cloth_url | string | 是 | 服装图片 URL |
| output_format | string | 是 | 输出格式,包含 `"base64"` 则返回 base64,否则返回 URL |
| no2 | bool | 否 | true=跳过第一步(脱衣/生成写真),直接换衣;默认 false |
| tuodi | bool | 否 | true=使用拖地款工作流;默认 false |
| kuzi | bool | 否 | 是否同时换裤子(配合 kuzi_url);默认 false |
| cloth_len | string | 否 | 手动指定服装长度(如"膝盖""拖地"等),不传则 AI 自动判断 |
| suit | bool | 否 | true=使用 Gemini 模型换装(套装模式);默认 false |
### 响应
```json
// 成功(URL 模式)
{
"ret": 0,
"state": 0,
"msg": "success",
"url": "https://xiangsilian.oss-cn-beijing.aliyuncs.com/xxx.jpg",
"second_url": "换衣前中间步骤图 URL",
"first_url": "第一步(脱衣/写真)图 URL",
"is_girl": true
}
// 成功(base64 模式)
{
"ret": 0,
"state": 0,
"msg": "success",
"data": "data:image/jpeg;base64,...",
"second_step_data": "...",
"first_step_data": "...",
"is_girl": true
}
// 失败
{ "ret": -1, "state": -1, "msg": "错误信息" }
```
---
## 3. POST /change_cloth_base64
`/change_cloth` 功能相同,图片以 Base64 格式传入。
### 请求参数(JSON
| 参数 | 类型 | 必选 | 说明 |
|------|------|------|------|
| human_img | string | 是 | 人物图片 base64(带 data: 头,如 `data:image/jpeg;base64,...` |
| cloth_img | string | 是 | 服装图片 base64 |
| output_format | string | 是 | 同上 |
| kuzi_img | string | 否 | 裤子图片 base64 |
| no2 | bool | 否 | 同上 |
| tuodi | bool | 否 | 同上 |
| suit | bool | 否 | 同上 |
| cloth_len | string | 否 | 同上 |
### 响应
`/change_cloth`
---
## 4. POST /do_change_cloth
**直接调用**,无队列保护,通常由内部或 `/change_cloth_base64` 调用,不建议外部直接使用。
### 请求参数(JSON
| 参数 | 类型 | 必选 | 说明 |
|------|------|------|------|
| human_url | string | 是 | 人物图片 URL |
| cloth_url | string | 是 | 服装图片 URL |
| output_format | string | 是 | 同上 |
| no2 | bool | 否 | 同上 |
| tuodi | bool | 否 | 同上 |
| kuzi_url | string | 否 | 裤子图片 URL |
| cloth_len | string | 否 | 同上 |
| suit | bool | 否 | 同上 |
### 响应
`/change_cloth`
---
## 备注
- `cloth_len` 可选值:`胸、腰、跨、大腿、膝盖、小腿、脚踝、拖地、裤子、难以辨认`
- 若服装图片中检测到人物,`cloth_len` 自动设为 `拖地`
- 结果图片同时上传至阿里云 OSS(bucket: `xiangsilian`region: 北京)
- 服务默认监听端口由 `config.py` 中的 `base64_test_port` 决定