获取识别结果 (JSON)


上传一张图片,返回详细的 JSON 格式识别数据。此接口支持按配置启用全局修正。

当前最大识别人脸数量: 100

POST https://dio.jite.me/api/recognize
请求参数 (Body)

需要使用 multipart/form-data 格式发送请求。

参数名 类型 是否必填 说明 示例
file File 必填 待识别的图片文件 image.jpg
示例代码
import requests
import json

url = "https://dio.jite.me/api/recognize"
image_path = "path/to/your/image.jpg"

with open(image_path, "rb") as f:
    files = {"file": ("image.jpg", f, "image/jpeg")}
    resp = requests.post(url, files=files, timeout=30)
    print(resp.status_code)
    print(json.dumps(resp.json(), indent=2, ensure_ascii=False))
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("image/jpeg");
RequestBody fileBody = RequestBody.create(new File("path/to/your/image.jpg"), mediaType);

MultipartBody requestBody = new MultipartBody.Builder()
    .setType(MultipartBody.FORM)
    .addFormDataPart("file", "image.jpg", fileBody)
    .build();

Request request = new Request.Builder()
    .url("https://dio.jite.me/api/recognize")
    .post(requestBody)
    .build();

try (Response response = client.newCall(request).execute()) {
    System.out.println(response.code());
    System.out.println(response.body().string());
}
const url = 'https://dio.jite.me/api/recognize';
const fileInput = document.getElementById('fileInput');
const f = fileInput.files[0];
if (f) {
  const fd = new FormData();
  fd.append('file', f);
  fetch(url, { method:'POST', body: fd })
    .then(r => r.ok ? r.json() : r.json().then(e=>{throw e}))
    .then(data => console.log('OK', data))
    .catch(err => console.error('ERR', err));
}
成功响应 (JSON)
响应包含最终识别结果及候选结果,score 为最终置信度。
{
  "faces": [
    {
      "identity": "id_00001",
      "score": 0.987,
      "name": "角色A",
      "anime": "某部动漫",
      "first_class": 0,
      "bounding_box": [100.0, 150.0, 212.0, 262.0],
      "resolution": [112, 112],
      "top_k": [
        {"identity": "id_00001", "name": "角色A", "anime": "某部动漫", "score": 0.987},
        {"identity": "id_00002", "name": "角色B", "anime": "某部动漫", "score": 0.213}
      ],
      "is_corrected": true
    }
  ]
}
响应字段说明
字段名 类型 描述
identity String 最终识别出的角色ID。
name String 最终识别出的角色名称。
anime String 最终识别出的角色所属作品。
score Float 最终识别置信度 (0.0 - 1.0)。
bounding_box Array 权威人脸框坐标 [x1,y1,x2,y2]。
resolution Array 裁剪区域分辨率 [宽, 高]。
first_class Integer | Null 初步检测模型的分类结果。
is_corrected Boolean 是否经过全局修正。
top_k Array 候选结果列表,每项包含角色信息和对应的候选置信度 score。
accepted Boolean 是否接受该识别结果。
is_ambiguous Boolean 是否存在候选分数接近、需要人工确认的情况。
reject_reason String | Null 拒绝识别的原因;接受时为 null。