跳转到内容

CodeFormer

集成

模型 id codeformer
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/codeformer?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

与示例类似的文件: $0.009 9 API 积分 运行前会测量你的文件 在此页面运行

获取 API 密钥
Open model 图像编辑 #image-restoration#faces#utility

人脸修复模型,可修复模糊或失真的肖像,并可选人脸对齐和放大

Open model · 图像

你的第一个结果会显示在这里

在下方构建请求,并使用你的 API 密钥运行。输出会复制到我们的存储中,可永久保存,也可免费保存 7 天。

构建请求

控件根据模型架构生成。修改控件时,代码和价格会同步更新。

•必填 image_url
拖放文件,或

指向要重新打光的图像的 URL。

默认 2

放大期间应用的倍数。

高级 fidelity · seed · aligned · only_center_face · face_upscale
默认 0.5

分配给保真度因子的权重。

使生成结果可复现的随机种子。

POST /run/codeformer?wait=20 报价 → $0.009
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/codeformer?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

运行此请求

你的密钥会保留在此浏览器中:仅发送到 Doitong API;只有勾选“记住”后才会保存到 localStorage。 获取 API 密钥

关于 CodeFormer

修复通过 `image_url` 提供的损坏或模糊照片中的人脸。`fidelity` 平衡修复效果与原始面貌(默认 0.5),`upscale_factor` 放大输出(默认 2)。开关选项包括 `only_center_face`、`aligned` 和 `face_upscale`,`seed` 可使结果可重复。

参数

发送规范名称或原生名称之一,不要同时发送两者。 规范名称

名称类型 默认值允许值 描述
image_url必填 image
类型url · image
指向要重新打光的图像的 URL。
fidelity可选
类型number
默认值0.5
分配给保真度因子的权重。
upscale_factor可选
类型number
默认值2
≥ 1
放大期间应用的倍数。
aligned可选
类型boolean
默认值false
是否对齐面部和相似特征。
only_center_face可选
类型boolean
默认值false
修复是否仅限于中央面部。
face_upscale可选
类型boolean
默认值true
是否对面部应用放大。
seed可选
类型integer | null
使生成结果可复现的随机种子。
必填 规范名称,也可接受

文件参数接受公开的 https:// URL、最大 10 MB 的 data: URI,或上传文件的 file_url。 文件

输出

GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "codeformer",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 9,
    "usd": "0.009",
    "charged": 9,
    "refunded": 0
  },
  "input": {
    "image_url": "https://content.doitong.com/images/showcase/v3/gen_fox_cartoon.jpg"
  },
  "output": {
    "image": {
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_name": "0-output.jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768
    },
    "seed": 42
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
文件由你选择每个 outputs[].url 都是我们存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
所有模型的结构一致图像、视频和音频的字段均为 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
image
object {url, content_type, file_name, file_size, width, height}生成图像的文件信息。
seed
integer图像生成种子:如果输入未提供种子,则包含随机选择的值;否则重复使用所提供的值。

对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh-CN/developers/models/codeformer.md. 所有模型和指南: https://doitong.com/developers/llms.txt