Created
April 28, 2026 17:22
-
-
Save LucioD3v/fac9ffef895a31769515a442718d3c85 to your computer and use it in GitHub Desktop.
Código fuente para la función AWS Lambda utilizada en la charla "Crea tu Fábrica de IA con Amazon Rekognition" de Cúcuta-Cloud.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| def lambda_handler(event, context): | |
| rekognition = boto3.client('rekognition') | |
| s3 = boto3.client('s3') | |
| # Obtener el nombre del bucket y la foto del evento | |
| bucket = event['Records'][0]['s3']['bucket']['name'] | |
| key = event['Records'][0]['s3']['object']['key'] | |
| print(f"Analizando imagen: {key} en el bucket: {bucket}") | |
| # Llamada a la IA (Amazon Rekognition) | |
| response = rekognition.detect_labels( | |
| Image={'S3Object': {'Bucket': bucket, 'Name': key}}, | |
| MaxLabels=5, | |
| MinConfidence=80 | |
| ) | |
| print("--- RESULTADOS DE LA IA ---") | |
| for label in response['Labels']: | |
| print(f"Detectado: {label['Name']} con {label['Confidence']:.2f}% de certeza") | |
| return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment