DEV Community

Cover image for Fun Project for getting started with AI: Rekognition DetectText
Veliswa_Boya ๐Ÿ‡ฟ๐Ÿ‡ฆ for AWS Heroes

Posted on • Updated on

Fun Project for getting started with AI: Rekognition DetectText

AWS offers a comprehensive set of services and APIs for Artificial Intelligence and Machine Learning.
What's awesome about this is that this set of services caters for both customers without ML skills and those looking for advanced functions.

I recently created an application that uses the Rekognition DetectText API.
Rekognition offers Image and Video APIs. The following Image APIs are available:

- Labels
- Custom Labels
- Content Moderation
- Face Detection and Analysis
- Face search and verification
- Celebrity Recognition
- Personal Protective Equipment (PPE) detection
- Text detection 
Enter fullscreen mode Exit fullscreen mode

I recently created what would be a back-end of an application that receives images which contain text. The back-end (Python) calls the Rekognition DetectText API which extracts the text, receives the extracted text and concatenates this text into a string. The string is then published to an SNS topic as a message where all those subscribed will receive this message.

The Architecture Design of the solution

Alt Text

SNS Topic: Create a topic accordingly, with the relevant subscriptions

S3 Bucket: Create an S3 bucket and grant the necessary permission.
If there needs to be public access, allow this through
the access control lists (ACLs), bucket policies, access point policies, etc.

Alt Text

Lambda Function: modify the Basic Lambda Execution role to include the following policies (in addition to the default policy assigned at role creation):
AmazonRekognitionReadOnlyAccess
AmazonS3ReadOnlyAccess
AmazonSNSFullAccess

Alt Text

Lastly, include the following resource-based policy, so that S3 can trigger the Lambda on PutObject of the image:

Alt Text

The complete code is available in my github repository and the sample is as below:

Alt Text

Conclusion

I hope this gets you started on AWS AI if you haven't already - and that you find your own use cases that will have you build even more fun (or useful :)) AI applications.

Top comments (0)