【问题标题】:using base64 for custom vision node js将base64用于自定义视觉节点js
【发布时间】:2019-05-15 16:47:36
【问题描述】:

目前我可以使用 url 作为我的分类图像 URL,但我想改用 base64string。但是当我尝试这样做时,我收到了 BadRequestImageFormat 错误消息。我该怎么办?

app.post('/predict', function(req, res){
const predictionKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const endPoint = "https://southcentralus.api.cognitive.microsoft.com"
const projectId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const publishedName = "AntiScam";
const PredictionApiClient = require("azure-cognitiveservices-customvision-prediction");
const predictor = new PredictionApiClient(predictionKey, endPoint);
var data2 = req.body.img;

tempData={ url: data2 };

predictor.classifyImageUrl(projectId, publishedName, tempData)
  .then((resultJSON) => {
       console.log("RESULT ######################")
       console.log(resultJSON);
             res.send(resultJSON);})

  .catch((error) => {
       console.log("ERROR #####################");
       console.log(error);}
);

});

【问题讨论】:

    标签: javascript node.js azure microsoft-custom-vision


    【解决方案1】:

    在此处查看 API 定义:https://southcentralus.dev.cognitive.microsoft.com/docs/services/Custom_Vision_Prediction_3.0/operations/5c82db60bf6a2b11a8247c15

    唯一受支持的请求是 multipart/form-data 或通过提供图像的 URL。所以不,似乎不支持 base64 字符串。

    【讨论】:

    • 我在 javascript 客户端做了一个,它可以将 base 64 转换为 blob,它会工作。有什么方法可以在节点 js 上将 base64 转换为 blob?
    • 您是否尝试过将 base64 转换为 multipart/form-data?喜欢这里stackoverflow.com/questions/4392690/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-10-17
    • 1970-01-01
    • 2017-11-19
    • 2021-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多