Last active
May 24, 2019 17:02
-
-
Save selynna/8f5bce0a006d1af7ccb570ba2e4e74c0 to your computer and use it in GitHub Desktop.
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
// Train classifier | |
console.log("Training..."); | |
let trainingIteration = await trainer.trainProject(project.id); | |
console.log("Training started..."); | |
while (trainingIteration.status == "Training") { | |
await setTimeoutPromise(1000, null); | |
trainingIteration = await trainer.getIteration(project.id, trainingIteration.id) | |
} | |
console.log("Training status: " + trainingIteration.status); | |
// Publish the iteration to endpoint | |
await trainer.publishIteration(project.id, trainingIteration.id, publishIterationName, predictionResourceId); | |
const predictor = new PredictionApiClient(predictionKey, endpoint); | |
const testFile = fs.readFileSync(`${dataRoot}/test/maybe-pizza.jpeg`); | |
const results = await predictor.classifyImage(project.id, publishIterationName, testFile); | |
// Show results | |
console.log("Results:"); | |
results.predictions.forEach(predictedResult => { | |
console.log(`\t ${predictedResult.tagName}: ${(predictedResult.probability * 100.0).toFixed(2)}%`); | |
}); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment