I have a Gallery and Attachment models. A gallery has_many attachments and essentially all attachments are images referenced in the ':content' attribute of Attachment.
The images are uploaded using Carrierwave gem and are stored in Aws S3 via fog-aws gem. This works OK. However, I'd like to conduct image recognition to the uploaded images with Amazon Rekognition.
I've installed aws-sdk gem and I'm able to instantiate Rekognition without a problem until I call the detect_labels
method at which point I have been unable to use my attached images as arguments of this method.
So fat I've tried:
@attachement = Attachment.first
client = Aws::Rekognition::Client.new
resp = client.detect_labels(
image: @attachment
)
# I GET expected params[:image] to be a hash... and got class 'Attachment' instead
I've tried using:
client.detect_labels( image: { @attachment })
client.detect_labels( image: { @attachment.content.url })
client.detect_labels( image: { @attachment.content })
All with the same error. I wonder how can I fetch the s3 object form @attachment and, even if I could do that, how could I use it as an argument in detect_labels
.
I've tried also fetching directly the s3 object to try this last bit:
s3 = AWS:S3:Client.new
s3_object = s3.list_objects(bucket: 'my-bucket-name').contents[0]
# and then
client.detect_labels( image: { s3_object })
Still no success...
Any tips?
Aucun commentaire:
Enregistrer un commentaire