mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
27 lines
755 B
JavaScript
27 lines
755 B
JavaScript
classifier = ml5.imageClassifier('MobileNet', function() {
|
|
console.log('Model Loaded!');
|
|
});
|
|
|
|
// Takes in the ID of the image, and returns labels and confidences
|
|
function upload() {
|
|
classifier.predict(document.getElementById('invisible_img'), function(err,
|
|
results) {
|
|
if (!results) {
|
|
return
|
|
}
|
|
console.log(results)
|
|
var output = {
|
|
'label': results[0].className,
|
|
'confidences': [
|
|
{'label': results[0].className,
|
|
'confidence': results[0].probability.toFixed(4)},
|
|
{'label': results[1].className,
|
|
'confidence': results[1].probability.toFixed(4)},
|
|
{'label': results[2].className,
|
|
'confidence': results[2].probability.toFixed(4)},
|
|
]
|
|
}
|
|
loadData(output);
|
|
});
|
|
}
|