13518219792

建站动态

根据您的个性需求进行定制 先人一步 抢占小程序红利时代

创新互联百度小程序教程:swan.ai.imageAudit

swan.ai.imageAudit

解释 :自定义图像审核。
Web 态说明:受宿主环境限制,Web 态暂不支持 AI 能力相关接口。在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。

方法参数

Object object

object 参数说明

属性名 类型 默认值 必填 说明

image

String

图像资源地址

imgUrl

String

网图 URL 地址,以网图形式请求,图片 Url 需要做 UrlEncode,不能与 image 并存

success

Function

接口调用成功的回调函数

fail

Function

接口调用失败的回调函数

complete

Function

接口调用结束的回调函数(调用成功、失败都会执行)

success 返回参数说明

参数 类型 说明

log_id

Number

请求唯一 id

conclusion

String

审核结果描述,成功才返回,失败不返回

conclusionType

Number

审核结果标识,成功才返回,失败不返回

data

Array

审核项详细信息,响应成功并且 conclusion 为疑似或不合规时才返回,响应失败或 conclusion 为合规是不返回

data 返回值说明

参数 类型 说明

type

Number

审核类型,1:色情、2:性感、3:暴恐、4:恶心、5:水印码、6:二维码、7:条形码、8:政治人物、9:敏感词、10:自定义敏感词、11: 存在公众人物

msg

String

不合规项描述信息

probability

Number

不合规项置信度

words

String

审核不通过敏感词,仅在敏感词审核不通过时存在

stars

Array

政治人物列表数组,仅在政治人物审核不通过时存在

stars 返回值说明

参数 类型 说明

probability

Number

不合规项置信度

name

String

姓名

conclusion、conclusionType 参数说明

参数 说明

1

合规

2

不合规

3

疑似

4

审核失败

示例

跳转编辑工具

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

请使用百度APP扫码

图片示例

代码示例

 
 
 
  1. Page({
  2. swan.chooseImage({
  3. success: res => {
  4. let image = res.tempFilePaths[0];
  5. // AI系列的api有宿主使用限制,只可在百度App中使用,建议使用时加一层判断防止代码报未知错误
  6. let host = swan.getSystemInfoSync().host;
  7. if (host === 'baiduboxapp') {
  8. swan.ai.imageAudit({
  9. // 暂不支持识别网络图片
  10. image,
  11. success: res => {
  12. console.log('imageAudit res', res.conclusionType);
  13. },
  14. fail: err => {
  15. console.log('imageAudit err', err);
  16. }
  17. });
  18. }
  19. else {
  20. swan.showToast({
  21. title: '此api目前仅可在百度App上使用',
  22. icon: 'none'
  23. });
  24. }
  25. }
  26. })
  27. });

返回值示例

 
 
 
  1. {
  2. "log_id": $log_id,
  3. "conclusion": "不合规",
  4. "conclusionType": 2,
  5. "data": [
  6. {
  7. "msg": "存在色情内容",
  8. "probability": 0.94308,
  9. "type": 1
  10. },
  11. {
  12. "msg": "存在性感内容",
  13. "probability": 0.94308,
  14. "type": 2
  15. },
  16. {
  17. "msg": "存在暴恐内容",
  18. "probability": 0.94308,
  19. "type": 3
  20. },
  21. {
  22. "msg": "存在恶心内容",
  23. "probability": 0.9688154,
  24. "type": 4
  25. },
  26. {
  27. "msg": "存在政治敏感内容",
  28. "stars": [
  29. {
  30. "probability": 0.94308,
  31. "name": "习近平"
  32. },
  33. {
  34. "probability": 0.44308,
  35. "name": "彭丽媛"
  36. }
  37. ],
  38. "type": 8
  39. },
  40. {
  41. "msg": "存在二维码内容",
  42. "probability": 0.94308,
  43. "type": 6
  44. },
  45. {
  46. "msg": "存在水印码内容",
  47. "probability": 0.94308,
  48. "type": 5
  49. },
  50. {
  51. "msg": "存在条形码内容",
  52. "probability": 0.94308,
  53. "type": 7
  54. },
  55. {
  56. "msg": "包含联系方式",
  57. "probability": 0.94308,
  58. "words": "包含联系方式",
  59. "type": 8
  60. }
  61. ]
  62. }

当前名称:创新互联百度小程序教程:swan.ai.imageAudit
网站路径:http://cdbrznjsb.com/article/djdipdc.html

其他资讯

让你的专属顾问为你服务