内容识别

快速入门

又拍云处理(内容识别)基于 CDN 或云存储服务,您在使用它之前,请确保您已经注册又拍云账号并完成实名验证,请确保您已经创建 CDN 服务云存储服务

收费方面,需要收费,详情请联系商务


开发者指南

图片

上传预处理

上传预处理

在上传图片时,提供预处理参数。待图片上传完成后,自动进行异步处理,处理完成后,回调通知用户处理结果。

支持的 API: FORM API

参数名是 apps,参数值是 JSON 字符串。一个 apps 最多只允许包含一个任务。

apps 参数结构

apps = [
    {
        "name": "imgaudit",                         // 异步任务名称,imgaudit 表示图片识别
        "notify_url": "<notify_url>"                // 回调地址,不填时使用上传参数中的 notify_url
    }
]

回调通知

任务处理完成后,向 notify_url 地址发送回调通知。详见「回调通知」。


已经存在云存储中的图片处理

请求方法

对已经存在云存储中的图片,以 POST 方法向 http://p0.api.upyun.com/pretreatment/ 提交处理任务,响应中返回任务 task_id。任务以异步的方式处理,处理完成后,回调通知用户处理结果。

curl -X POST \
    http://p0.api.upyun.com/pretreatment/ \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d "service=<service>" \
    -d "notify_url=<notify_url>" \
    -d "app_name=<app_name>" \
    -d "tasks=<base64 编码后的任务字符串>"

认证鉴权

Authorization 详见签名认证

请求参数

参数 类型 必选 说明
service string 图片所在的服务名
notify_url string 回调通知地址,详见回调通知
tasks string 任务信息,详见 tasks 参数说明
app_name string 处理功能,imgaudit 表示图片识别

tasks 参数说明

1. 按 JSON 格式组装任务,一次请求 tasks 最多可以提交 10 个任务。

[
    {
        "source": "/upyun.jpg",     // 需要审核的图片
    },
    …
]

2. 把 JSON 字符串 Base64 编码,得到 tasks

响应信息

[
    "35f0148d414a688a275bf915ba7cebb2",
    "98adbaa52b2f63d6d7f327a0ff223348",
    "c3103189fa906a5354d29bd807e8dc51",
    …
]

回调通知

任务处理完成后,向 notify_url 地址发送回调通知。详见「回调通知」。


回调通知

任务处理完成后,向 notify_url 发送 HTTP POST 请求,请求体是回调信息。

curl -X POST \
    <notify_url> \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d "service=<service>" \
    # 其他参数...

回调信息

回调信息为 JSON 字符串,参数名及说明如下:

参数 类型 说明
service string 图片所在的服务名
status_code integer 处理结果状态码,200 表示成功处理,详见状态码表
source string 图片路径
result json 识别结果集,包含 porn
porn json 鉴黄结果,包含 labelratereview
label integer 图片被判定的分类,可能值 010 表示正常,1 表示色情
rate float 图片被判定为某个分类的概率,介于 [0-1] 之间
review boolean 是否需要人工复审,true 表示需要,false 表示不需要
task_id string 任务对应的 task_id
error string 错误信息,空字符串表示无错误信息

回调签名

Authorization 详见签名认证

举例

{
    "service": "upyun-temp",
    "status_code": 200,
    "source": "upyun.jpg",
    "result": {
        "porn": {
            "label": 0,
            "rate": 0.9833183288574219,
            "review": false
        }
    },
    "task_id": "7b01610c7fa700b56cd7c80be5e08d5c",
    "error": ""
}

视频点播

上传预处理

上传预处理

在上传视频点播时,提供预处理参数。待视频上传完成后,自动进行异步处理,处理完成后,回调通知用户处理结果。

支持的 API: FORM API

参数名是 apps,参数值是 JSON 字符串。一个 apps 最多只允许包含一个任务。

apps 参数结构

apps = [
    {
        "name": "videoaudit",           // 异步任务名称,videoaudit 表示点播识别
        "notify_url": "<notify_url>"    // 回调地址,不填时使用上传参数中的 notify_url
        "interval": "10",                   // 截图间隔周期,非必填
        "save_as": "/foo_{index}.jpg",      // 截图保存路径,非必填
        "resize": "640x480",                // 截图保存尺寸,非必填
    }
]

intervalsave_asresize 参数解释说明,见 tasks 参数说明

回调通知

任务处理完成后,向 notify_url 地址发送回调通知。详见「回调通知」。


已经存在云存储中的视频点播处理

请求方法

对已经存在云存储中的视频点播,以 POST 方法向 http://p0.api.upyun.com/pretreatment/ 提交处理任务,响应中返回任务 task_id。任务以异步的方式处理,处理完成后,回调通知用户处理结果。

curl -X POST \
    http://p0.api.upyun.com/pretreatment/ \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d "service=<service>" \
    -d "notify_url=<notify_url>" \
    -d "app_name=<app_name>" \
    -d "tasks=<base64 编码后的任务字符串>"

认证鉴权

Authorization 详见签名认证

请求参数

参数 类型 必选 说明
service string 视频点播所在的服务名
notify_url string 回调通知地址,详见回调通知
tasks string 任务信息,详见 tasks 参数说明
app_name string 处理功能,videoaudit 表示点播识别

tasks 参数说明

参数 类型 必选 说明
source string 视频点播的路径
interval string 截图间隔时间,默认 10,单位秒
save_as string 截图保存路径,默认不保存截图
支持动态参数{index}(必填),后缀作为截图格式,支持 jpgpng
resize string 截图保存尺寸,默认原图大小,格式宽x高,如 640x480

1. 按 JSON 格式组装任务,一次请求 tasks 最多可以提交 10 个任务。

[
    {
        "source": "/upyun.mp4",
        "save_as": "/foo_{index}.jpg",   // {index} 表示第几张截图,第一张是 /foo_1.jpg,第二张是 /foo_2.jpg
    },
    …
]

2. 把 JSON 字符串 Base64 编码,得到 tasks

响应信息

[
    "35f0148d414a688a275bf915ba7cebb2",
    …
]

回调通知

任务处理完成后,向 notify_url 地址发送回调通知。详见「回调通知」。


回调通知

任务处理完成后,向 notify_url 发送 HTTP POST 请求,请求体是回调信息。

curl -X POST \
    <notify_url> \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d "service=<service>" \
    # 其他参数...

回调信息

回调信息为 JSON 字符串,参数名及说明如下:

参数 类型 说明
service string 视频点播所在的服务名
status_code integer 处理结果状态码,200 表示成功处理,详见状态码表
filelist json 截图集
source string 截图保存路径,如果请求参数中未设置 save_as,不存在
shot_time string 截图时间点
result json 识别结果集,包含 porn
porn json 鉴黄结果,包含 labelratereview
label integer 图片被判定的分类,可能值 010 表示正常,1 表示色情
rate float 图片被判定为某个分类的概率,介于 [0-1] 之间
review boolean 是否需要人工复审,true 表示需要,false 表示不需要
task_id string 任务对应的 task_id
error string 错误信息,空字符串表示无错误信息

回调签名

Authorization 详见签名认证

举例

{
    "service": "upyun-temp",
    "status_code": 200,
    "source": "upyun.mp4",
    "filelist": [
        {
            "result": {
                    "porn": {
                    "label": 0,
                    "rate": 0.9833183288574219,
                    "review": false
                }
            },
            "shot_time": 0,
            "save_as": "foo_1.jpg"
        }
    ],
    "task_id": "7b01610c7fa700b56cd7c80be5e08d5c",
    "error": ""
}

视频直播

创建任务

直播任务处理流程

POST 方法向 http://p1.api.upyun.com/<service>/liveaudit/create 提交任务,服务收到请求后创建定时任务,获取流最近关键帧,识别并返回结果。特别地,<service> 需替换为具体的服务名。

curl -X POST \
    http://p1.api.upyun.com/<service>/liveaudit/create \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d '{"service": "<service>", "source": "<source>", "save_as": "<save_as>", "notify_url": "<notify_url>"}'

认证鉴权

Authorization 详见签名认证

请求参数

参数 类型 必选 说明
service string 图片存储的服务名
source string RTMP 流地址,必须以 rtmp:// 开头
save_as string 截图保存地址,支持动态参数,后缀作为截图格式,支持 jpgpng
notify_url string 回调通知地址,详见回调通知
interval string 截图间隔时间,默认 10,单位秒
resize string 截图保存尺寸,默认原图大小,格式宽x高,如 640x480

响应信息

{
    "service": "upyun-temp",
    "status_code": 200,
    "source": "upyun.jpg",
    "result": {
        "porn": {
            "label": 0,
            "rate": 0.9833183288574219,
            "review": false
        }
    },
    "task_id": "7b01610c7fa700b56cd7c80be5e08d5c"
    "error": ""
}

周期性处理

之后,系统会周期去获取流,并提取最近关键帧进行识别,识别结果向 notify_url 发送 HTTP POST 请求,请求体是回调信息。

curl -X POST \
    <notify_url> \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d "service=<service>" \
    # 其他参数...

回调信息

回调信息为 JSON 字符串,参数名及说明如下:

参数 类型 说明
service string 图片存储的服务名
status_code integer 处理结果状态码,200 表示成功处理,详见状态码表
source string 图片路径
result json 识别结果集,包含 porn
porn json 鉴黄结果,包含 labelratereview
label integer 图片被判定的分类,可能值 010 表示正常,1 表示色情
rate float 图片被判定为某个分类的概率,介于 [0-1] 之间
review boolean 是否需要人工复审,true 表示需要,false 表示不需要
task_id string 任务对应的 task_id
error string 错误信息,空字符串表示无错误信息

回调签名

Authorization 详见签名认证

举例

{
    "service": "upyun-temp",
    "status_code": 200,
    "source": "upyun.jpg",
    "result": {
        "porn": {
            "label": 0,
            "rate": 0.9833183288574219,
            "review": false
        }
    },
    "task_id": "7b01610c7fa700b56cd7c80be5e08d5c"
    "error": ""
}

取消任务

POST 方法向 http://p1.api.upyun.com/<service>/liveaudit/cancel 提交任务。特别地,<service> 需替换为具体的服务名。

curl -X POST \
    http://p1.api.upyun.com/<service>/liveaudit/cancel \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d '{"service": <service>, "task_id": <task_id>}'

认证鉴权

Authorization 详见签名认证

请求参数

参数 类型 必选 说明
service string 图片存储的服务名
task_id string 任务 ID, 任务创建时系统返回的任务 ID

响应信息

{"status": 200}


文本

文本检测

POST 方法向 http://p1.api.upyun.com/<service>/textaudit/detect 提交任务。特别地,<service> 需替换为具体的服务名。

curl -X POST \
    http://p1.api.upyun.com/<service>/textaudit/detect \
    -H "Authorization: UPYUN <Operator>:<Signature>" \
    -H "Date: <Wed, 29 Oct 2014 02:26:58 GMT>" \
    -H "Content-MD5: <Content-MD5>" \
    -d '{"text": "<text>"}' 

认证鉴权

Authorization 详见签名认证

请求参数

参数 类型 必选 说明
text string 文本内容,最大支持64k

响应信息

响应信息为 JSON 字符串,参数名及说明如下:

参数 类型 说明
status integer 处理结果状态码,200 表示成功处理,详见状态码表
task_id string 任务对应的 task_id
label integer 文本被判定的分类,可能值 0120 表示正常文本,1 表示违规文本,2 表示可疑文本
review boolean 是否需要人工复审,true 表示需要,false 表示不需要
spam float 文本被判定为违规的概率,介于 [0-1] 之间
normal float 文本被判定为正常的概率,介于 [0-1] 之间
{
    "status":200,
    "task_id":"6583350f99b2a2fa569c53081aa91a4f",
    "label":1,
    "review":false,
    "spam":0.99,
    "normal":0.01
}

状态码表

状态码 说明
200 处理成功
400 缺失必填参数,ErrMissingRequiredArgument
400 参数类型错误,ErrType
400 interval 参数错误,ErrInterval
403 任务已存在,ErrRepeat
404 文件不存在/直播流不存在/任务不存在
405 请求方法不允许
413 文件大小超过 10M
415 文件不是图片
5xx 服务端错误。如遇此类错误,请反馈给售后或您的商务经理

准确率

从某业务系统随机抽取 24 万张图片,先进行机器审核,再对结果进行人工复查两遍,最终确定准确率是 99.68%。即 99.68% 的机器判断是准确的,类似于人工审核的准确率,可以代替人工进行审核。


智能鉴黄

图片

视频点播

视频直播

文本


如有疑问请 联系我们