Is there a way to use Googles AutoML with JavaScript?

只愿长相守 提交于 2021-01-29 07:41:09

问题


I trained a model using AutoML Natural Language on Googles Cloud Platform. Now i need to call the AI via JavaScript to do a sentiment analysis, using my own model.

My goal is to embed the whole thing into a website. There i'll have a input form to analyze text. That's all for now actually.

I wasn't able to find anything relating that use case when i did my research. Google provides a REST API but there is literally no tutorial on how to handle it.

Sorry, I know this might not meet the stackoverflow requirements for a question. But I'm totally puzzled.

This is what the REST API looks like:

export GOOGLE_APPLICATION_CREDENTIALS=key-file-path

curl -X POST \
  -H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
  -H "Content-Type: application/json" \
  https://automl.googleapis.com/v1beta1/projects/*myProjectID/locations/us-central1/models/*myModelID*:predict \
  -d '{
        "payload" : {
          "textSnippet": {
               "content": "YOUR TEXT HERE",
                "mime_type": "text/plain"
           },
        }
      }'

回答1:


Here you go! and please check the full repo.

https://github.com/googleapis/nodejs-vision/blob/master/samples/automl/automlVisionPredict.js



来源:https://stackoverflow.com/questions/53907340/is-there-a-way-to-use-googles-automl-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!