内容审核 MODERATION-图像内容审核(V2):请求示例

时间:2024-11-04 10:07:10

请求示例

“endpoint”即调用API的请求地址,不同服务不同区域的endpoint不同,具体请参见终端节点

例如,服务部署在“华北-北京四”区域的“endpoint”“moderation.cn-north-4.myhuaweicloud.com”,请求URL为“https://moderation.cn-north-4.myhuaweicloud.com/v2/{project_id}/moderation/image”“project_id”为项目ID,获取方法请参见获取项目ID

  • 方式一:使用图片的BASE64编码,识别用户上传的图像内容是否有敏感内容,检测场景为涉黄,暴恐, 图像审核 规则为默认规则。
    POST https://{endpoint}/v2/{project_id}/moderation/image
    
    {
      "categories" : [ "porn", "terrorism" ],
      "moderation_rule" : "default",
      "url" : "",
      "image" : "/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA...",
      "threshold" : ""
    }
  • 方式二:使用图片的url,识别用户上传的图像内容是否有敏感内容,检测场景为涉黄,暴恐,图像审核规则为默认规则。
    POST https://{endpoint}/v2/{project_id}/moderation/image
    
    {
      "categories" : [ "porn", "terrorism" ],
      "moderation_rule" : "default",
      "url" : "https://BucketName.obs.myhuaweicloud.com/ObjectName",
      "image" : "",
      "threshold" : ""
    }
support.huaweicloud.com/api-moderation/moderation_03_0019.html