Skip to content

Instantly share code, notes, and snippets.

@smzn
Created August 12, 2022 13:59
Show Gist options
  • Save smzn/f941eb66671706174a6ebcf709c78ca6 to your computer and use it in GitHub Desktop.
Save smzn/f941eb66671706174a6ebcf709c78ca6 to your computer and use it in GitHub Desktop.
import boto3
BUCKET = 'bucket name'
KEY = 'file name'
REGION = 'region'
def detect_labels(bucket, key, max_labels=10, min_confidence=90, region=REGION):
rekognition = boto3.client("rekognition", region)
response = rekognition.detect_labels(
Image={
"S3Object": {
"Bucket": bucket,
"Name": key,
}
},
MaxLabels=max_labels,
MinConfidence=min_confidence,
)
return response['Labels']
for label in detect_labels(BUCKET, KEY):
print("{Name} - {Confidence}%".format(**label))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment