This is the sample code for my talk about 'Add a computer vision model to your app without ML' from Innovate AI ML 2021
The aim was to teach beginners/intermediate developers how to add a computer vision model using the Rekognition APIs. I chose the content moderation example as most apps these days have some form of User Generated Content such as display pictures.
Note: In the talk, I showed the example of an Amplify App with the same backend code behind. For the purpose of this code sample I have stripped away the Amplify and front-end parts to keep it simple. Also, please use this code snippet for learning only :)
Instructions:
-
Download the repo
-
Run
npm install
in the root folder. This will install the dependencies listed inpackage.json
-
This example assumes you have stored a video file in an S3 bucket already. Check the bottom of the snippet for code on uploading a file to S3 programmatically
-
The
sample-image.js
works for content moderation on images only and is a good starting point if you are new to this. -
Fill in Region, Bucket Name, and File Name
-
Run
node sample-image.js
and you will see the moderation labels in the console -
The
sample.js
example shows how to implement content moderation for video. Create a SNS Topic, SQS Queue and an IAM Role and fill in these details. If you are unsure how to do these steps - View the talk linked above. You will have to sign up to view it. -
Run
node sample.js
. If the program stops at thesnooze()
function just runnode sample.js
again. There is a finite time for SQS to send out the messages.
To implement the same system in either Python or Java, check our documentation here