Rails主动存储 AWS Rekognition detect_labels:过滤标签



我正在尝试使AWS重新认知与Rails 6 RC3一起使用,并通过Active Storage存储在S3中的照片。

Aws.config.update({
      region: 'us-west-2',
      credentials: Aws::Credentials.new(Rails.application.credentials.aws[:access_key], Rails.application.credentials.aws[:secret_access_key])
    })
    rekognition = Aws::Rekognition::Client.new(region: Aws.config[:region], credentials: Aws.config[:credentials])
    @uri = @user.avatar.service_url
    @dir = @uri.split("/").fourth
    @key = @dir.split("?").first
    response = rekognition.detect_labels(
      {image:
        {s3_object:
          {bucket: 'bucket',
            name: @key,
          },
        },
        max_labels: 5,
        min_confidence: 70
      }
    )
    puts response
    @user.update(notes: response)

但是,响应中的标签显示"过滤"

{:labels=>[{:name=>"[FILTERED]", :confidence=>99.28252410888672, :instances=>[], :parents=>[{:name=>"[FILTERED]"}

通过AWS-CLI做同样的事情显示标签。为什么显示"过滤",我该如何显示标签?

通过response对象循环并打印标签字段,如果您想看到它们未经过滤:

response.labels.each { |label| puts(label.name) }

相关内容

  • 没有找到相关文章

最新更新