获取识别结果 (JSON)
上传一张图片,返回详细的 JSON 格式识别数据。此接口支持按配置启用全局修正。
当前最大识别人脸数量: 50
POST
https://dio.jite.me/api/recognize
请求参数 (Body)
需要使用 multipart/form-data 格式发送请求。
| 参数名 | 类型 | 是否必填 | 说明 | 示例 |
|---|---|---|---|---|
file |
File | 必填 | 待识别的图片文件 | image.jpg |
use_correction |
boolean | "0" | "1" | "true" | "false" | 可选 | 是否强制启用全局识别修正。缺省时使用后端全局配置。 | 1 |
示例代码
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")}
data = {"use_correction": "1"}
resp = requests.post(url, files=files, data=data, 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)
.addFormDataPart("use_correction", "1")
.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);
fd.append('use_correction', '1');
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)
{
"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.123}
],
"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 | 候选结果列表(identity, name, anime, score)。 |