Amazon Rekognition Node Issue

Hi team,

AWS Rekognition - Detect Labels returns empty results.

This is the result of n8n node:

This is the result of Postman request:

Also, I’ve tested to send incorrect data to both bucket and object name the result was same empty result.

Thank you for your help.

n8n setup details

  • n8n version: 0.181.2
  • Database you’re using: MySQL & Redis → Queue Mode
  • Running n8n with the execution process: own
  • Running n8n via: Docker

Hi @samaritan, I am very sorry to hear you’re having trouble with the node. I was able to reproduce the problem and have added it to our backlog for a closer look. We’ll keep you updated on the progress.

Hi @samaritan. How is going?

Did you solve or work around this issue?
I have the same problem.

Thank you

Hi @Jeferson_Zimmermann,

I coded a Lambda function that can be triggered via API, and I’m using HTTP Request to process my images. If this work around is ok for you, I can share my code.

Thanks

Thak you @samaritan

Yes work for me. If you can share i will thankful.

Best reguards

Perhaps @sirdavidoff can share an also share an update on where we are with the bugfix, seeing peeps keep running into this?

Hi,

This is the code I’m using in Lambda. Please don’t forget to set Lambda roles for accessing S3 bucket and Rekognition service.

#Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-custom-labels-developer-guide/blob/master/LICENSE-SAMPLECODE.)

import boto3
import io
from decimal import Decimal
import json
import urllib.request
import urllib.parse
import urllib.error

def show_custom_labels(model,bucket,photo, min_confidence):
    client=boto3.client('rekognition')

    response = client.detect_custom_labels(Image={'S3Object': {'Bucket': bucket, 'Name': photo}},
        MinConfidence=min_confidence,
        ProjectVersionArn=model)

    return response['CustomLabels']

def lambda_handler(event,context):

    req = json.loads(event['body'])
  
    bucket = req['bucketName']
    key = req['object']

    photo=key
    model='<<YOUR MODEL ARN>>'
    min_confidence=10

    try: 
        label_count=show_custom_labels(model,bucket,photo, min_confidence)
        
        return {
        'statusCode': 200,
        'headers': {'Content-Type': 'application/json'},
        'body': json.dumps(label_count)
        }
    
    except Exception as err:
      
        return {
        'statusCode': 200,
        'headers': {'Content-Type': 'application/json'},
        'body': json.dumps(str(err))
        }

if __name__ == "__main__":
    main()
2 Likes

Thank you a lot @samaritan

i’ll implement and return were to share with you my result.

Best Reguards

Hi @samaritan

I adapted your code to Detect Moderation Labels and work fine.

Thank you again

#Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#PDX-License-Identifier: MIT-0 (For details, see https://github.com/awsdocs/amazon-rekognition-custom-labels-developer-guide/blob/master/LICENSE-SAMPLECODE.)

import boto3
import io
from decimal import Decimal
import json
import urllib.request
import urllib.parse
import urllib.error

def shows_detect_moderation_labels(bucket,photo, min_confidence):
    client=boto3.client('rekognition')

    response = client.detect_moderation_labels(Image={'S3Object': {'Bucket': bucket, 'Name': photo}},
        MinConfidence=min_confidence)

    return response['ModerationLabels']

def lambda_handler(event,context):

    bucket = event.get('bucketName')
    key = event.get('object')
    

    photo=key
    min_confidence=50

    try: 
        label_count=shows_detect_moderation_labels(bucket,photo, min_confidence)
        
        return {
        'statusCode': 200,
        'headers': {'Content-Type': 'application/json'},
        'body': (label_count)
        #'body': json.dumps(label_count)
        }
    
    except Exception as err:
      
        return {
        'statusCode': 400,
        'headers': {'Content-Type': 'application/json'},
        'body': json.dumps(str(err))
        }

if __name__ == "__main__":
    main()
2 Likes

New version [email protected] got released which includes the GitHub PR 6136.

1 Like