Created
December 19, 2018 14:31
-
-
Save HassenIO/13873cb5841980f75c9f6ff503e5cd9f to your computer and use it in GitHub Desktop.
Post-processing script for AWS SageMaker Ground Truth
This file contains 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
const AWS = require("aws-sdk"); | |
const s3 = new AWS.S3(); | |
exports.handler = async (event) => { | |
console.info(event); | |
try { | |
const consolidationRequestFile = await s3.getObject(event.payload.s3Uri); | |
const consolidationRequest = consolidationRequestFile.Body; | |
let consolidationLabels = []; | |
consolidationRequest.map(c => { | |
c.annotations.map(a => { | |
const label = JSON.parse(a.annotationData.content)['image-contains'].label; | |
console.info(`label= ${label}`); | |
const consolidationLabel = { | |
datasetObjectId: c.datasetObjectId, | |
consolidatedAnnotation: { | |
content: { | |
label: { | |
workerId: a.workerId, | |
imageSource: c.dataObject.s3Uri, | |
text: label, | |
} | |
} | |
} | |
} | |
console.info(consolidationLabel); | |
consolidationLabels.push(consolidationLabel); | |
}); | |
}); | |
return consolidationLabels; | |
} catch (err) { | |
console.error(err); | |
return err; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment