Created
May 10, 2018 21:27
-
-
Save yavuzKomecoglu/2146977a86e4b5ca2907fc95929c525e 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
$('#upload-file-btn').click(function () { | |
$('.loader').show(); | |
$("#results").html(''); | |
var form_data = new FormData($('#upload-file')[0]); | |
$.ajax({ | |
type: 'POST', | |
url: '/predict', | |
data: form_data, | |
contentType: false, | |
cache: false, | |
processData: false, | |
async: false, | |
success: function (data) { | |
console.log(data.success); | |
$('.loader').hide(); | |
$.each(data.predictions, function (i, item) { | |
console.log(item); | |
label = item["label"]; | |
prob = item["probability"].toFixed(2); | |
percent = prob * 100; | |
$("#results").append('<label>' + percent + '% ' + label + '</label><div class="progress"><div class="progress-bar" role="progressbar" aria-valuenow="' + percent + '" aria-valuemin="0" aria-valuemax="100" style="width:' + percent + '%"></div></div>'); | |
}); | |
}, | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment