我正在尝试使AWS Rekognition与通过Active Storage存储在S3中的照片一起用于Rails 6 rc3。
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上执行相同的操作会显示标签。为什么它显示“已过滤”,我如何显示标签?
答案 0 :(得分:0)
如果要查看未过滤的标签,请遍历response
对象并打印标签字段:
response.labels.each { |label| puts(label.name) }