Skip to content

Instantly share code, notes, and snippets.

@HassenIO
Created December 19, 2018 14:30
Show Gist options
  • Save HassenIO/34df3f3865be071f27f7a56248529eec to your computer and use it in GitHub Desktop.
Save HassenIO/34df3f3865be071f27f7a56248529eec to your computer and use it in GitHub Desktop.
Pre-processing script for AWS SageMaker Ground Truth
const ocrResults = require("./ocr-results.json");
const dataLocation = "<Data location in S3 bucket>";
exports.handler = async (event) => {
console.info(event);
const fileName = event.dataObject['source-ref'].substr(dataLocation.length);
const extracts = ocrResults[fileName] || {rekognition: "__error.rekognition__", gcVision: "__error.gcVision__"};
console.info(extracts);
const categories = [extracts["rekognition"], extracts["gcVision"], "Neither"];
const response = {
taskInput: {
taskObject: fileName,
categories
}
};
console.info(response);
return response;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment