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

时间:2024-12-20 14:22:36

请求示例

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

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

  • 使用图片的BASE64编码,分析并识别用户上传的图像内容是否有敏感内容,事件类型为头像,检测场景为涉黄,暴恐。
    POST https://{endpoint}/v3/{project_id}/moderation/image
    
    {
      "event_type" : "head_image",
      "image" : "/9j/4AAQSkZJRgABAgEASABIAAD/4RFZRXhpZgAATU0AKgAAAAgABwESAAMAAAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAA...",
      "categories" : [ "porn", "terrorism" ],
      "image_text_config" : {
        "black_glossary_names" : [ "test" ]
      }
    }
  • 使用图片的url,分析并识别用户上传的图像内容是否有敏感内容,事件类型为头像,检测场景为涉黄,暴恐。
    POST https://{endpoint}/v3/{project_id}/moderation/image
    
    {
      "event_type" : "head_image",
      "url" : "https://bucketname.obs.myhwclouds.com/ObjectName1",
      "categories" : [ "porn", "terrorism" ],
      "image_text_config" : {
        "black_glossary_names" : [ "test" ]
      }
    }
  • 使用biz_type请求
    POST https://{endpoint}/v3/{project_id}/moderation/image
    
    {
      "url" : "https://bucketname.obs.myhwclouds.com/ObjectName1",
      "biz_type" : "test-type"
    }
support.huaweicloud.com/api-moderation/moderation_03_0086.html