Appearance
图片相似度
比较两张图片的相似度,返回浮点数结果。
接口信息
| 项目 | 值 |
|---|---|
| 地址 | /api/compare/similarity |
| 方法 | POST |
| Content-Type | application/json |
| 认证 | 需要 Bearer Token |
| 扣点 | 普通用户扣点,管理员不扣点 |
请求体
json
{
"img1_base64": "base64-image",
"img2_base64": "base64-image"
}| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
img1_base64 | string | 是 | 第一张图片 Base64 字符串 |
img2_base64 | string | 是 | 第二张图片 Base64 字符串 |
curl 示例
bash
curl -X POST "$BASE_URL/api/compare/similarity" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{
\"img1_base64\": \"$IMG1_BASE64\",
\"img2_base64\": \"$IMG2_BASE64\"
}"返回示例
json
{
"result": 0.98
}后端会将 AntiCAP 返回值转换为 float。
错误码
| 状态码 | 说明 |
|---|---|
401 | Token 无效或过期 |
402 | 余额不足 |
后端调用
python
Atc.Compare_Image_Similarity(
image1_base64=data.img1_base64,
image2_base64=data.img2_base64
)