Real-ESRGAN Upscaler API
图片超分辨率服务,支持 2x / 4x 放大,CPU 推理。
Endpoints
GET /health
健康检查,确认服务在线。
{
"status": "ok",
"supported_scales": [2, 4],
"note": "CPU inference, 512x512 → x4 takes ~30-60s"
}
POST /upscale
上传图片进行超分辨率放大。
参数(Query):
scale:放大倍数,2或4(默认 4)output_format:输出格式,png或jpeg(默认 png)
Body: multipart/form-data,字段名 image
返回: 图片二进制(png 或 jpeg)
响应 Headers:
X-Input-Size:原始尺寸,如512x512X-Output-Size:放大后尺寸,如2048x2048X-Elapsed-Seconds:推理耗时
/ui
Gradio 可视化界面,直接浏览器操作。
调用示例
import requests
with open("input.png", "rb") as f:
resp = requests.post(
"https://your-space.hf.space/upscale?scale=4&output_format=png",
files={"image": ("input.png", f, "image/png")},
timeout=180,
)
with open("output.png", "wb") as f:
f.write(resp.content)
print(resp.headers.get("X-Elapsed-Seconds"), "秒")
限制
- 输入图片最大 1024×1024(约 1MP),超过会报 400
- CPU 推理,512×512 图约需 30-60 秒
- 48小时无活动会自动休眠,调用前先 GET /health 唤醒
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support