我有一个网站,我想在通过点击按钮后使用Azure Custom Vision在经过训练的模型上显示测试图像的结果。
示例我想通过Shark image对其进行分类,并获得具有最高概率的输出标签。
我只是熟悉JavaScript / AJAX,所以我做了这段代码。
<script>
$(document).ready(function(){
$("#yalla").click(function(){
$.ajax({
url: "https://westeurope.api.cognitive.microsoft.com/customvision/v3.0/Prediction/MyPredictionKey/classify/iterations/Classify%20Iteration/url",
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Prediction-Key","MyPredictionKey");
xhrObj.setRequestHeader("Content-Type","application/json");
},
type: "POST",
// Request body
data: {"Url": "https://i.imgsafe.org/66/66f4494ce5.jpeg"},
})
.done(function(data) {
alert("success");
})
.fail(function() {
//THIS WHAT CODE RESULTS IN
alert("Error");
});
});
});
</script>
但如果有帮助,这也可以在Azure API Console中使用。
POST https://westeurope.api.cognitive.microsoft.com/customvision/v3.0/Prediction/MyPredictionKey/classify/iterations/Classify%20Iteration/url HTTP/1.1
Host: westeurope.api.cognitive.microsoft.com
Prediction-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Type: application/json
{
"url": "https://i.imgsafe.org/66/66f4494ce5.jpeg"
}
可以帮忙吗?