图片检测

检测图片是否包含违法违规内容

接口地址

POST https://developer.toutiao.com/api/v2/tags/image/

⚠️ 注意

该接口请在开发者服务器端请求

参数

请求 Headers

属性说明
X-Token小程序 access_token,参考登录凭证检验

请求 Body

{
  "targets": ["ad", "porn"],
  "tasks": [
    {
      "image": "https://image.url"
    }
  ]
}
属性说明
targets图片检测服务类型,目前支持 porn、politics、ad、disgusting 四种
tasks检测任务列表
image检测的图片链接
image_data图片数据的 base64 格式,有 image 字段时,此字段无效

返回

正确返回的 JSON 如下:

{
  "log_id": "2019010320551501001001621510071",
  "data": [
    {
      "code": 0,
      "task_id": "d18197c4-0f56-11e9-99a5-0242ac110004",
      "data_id": null,
      "cached": false,
      "predicts": [
        {
          "prob": 1,
          "model_name": "image_ocr",
          "target": "ad"
        },
        {
          "prob": 0,
          "model_name": "image_qrcode",
          "target": "ad"
        }
      ],
      "msg": "ok"
    },
    {
      "code": 0,
      "task_id": "d1aedc02-0f56-11e9-99a5-0242ac110004",
      "data_id": null,
      "cached": false,
      "predicts": [
        {
          "prob": 0.0005013857153244317,
          "model_name": "image_porn",
          "target": "porn"
        },
        {
          "prob": 0.022131478413939476,
          "model_name": "image_vulgar",
          "target": "porn"
        }
      ],
      "msg": "ok"
    }
  ]
}
属性说明
log_id请求 id
data检测结果列表
code检测结果-状态码
msg检测结果-消息
data_id检测结果-数据 id
task_id检测结果-任务 id
predicts检测结果-置信度列表
target检测结果-置信度-服务/目标
model_name检测结果-置信度-模型/标签
prob检测结果-置信度-概率,值为 0 或者 1,当值为 1 时表示检测的图片有违法违规内容比如是广告

当 access_token 检验失败时会返回如下信息:

{
  "error_id": "dd60b2bef95f40d7a4ace0bf5130d2e7",
  "code": 401,
  "message": "Authentication credentials were not provided.",
  "exception": "Authentication credentials were not provided."
}
点击纠错