###### tags: `阿瑜` # Day 12 ## Day 12: ML APIs | Google Cloud ### Practice #### Quest-`Integrate with Machine Learning APIs` ##### Lab-`Extract, Analyze, and Translate Text from Images with the Cloud ML APIs` - ID: **GSP075** - **Cloud Vision API**'s text detection method - 使用 OCR 從圖片提取文字 - **Translation API** - 翻譯文字 - **Natural Language API** - 分析文字 ###### Steps: ###### 1. Create an API Key - 在`Cloud Console`中,依序點選 **Navigation Menu > APIs & services > Credentials**  - 按 **+ Create Credentials** > 下拉選單選 API key  - **Copy key** 後按Close  - 把Key加入**環境變數** ```shell= export API_KEY=<YOUR_API_KEY> ```   ###### 2. Upload an `image` to a cloud storage bucket image: sign.jpg 為偵測目標 - Search Storage  - Create Bucket  - Setting  - Create - 上傳檔案到Cloud Stotage   - 設定檔案權限為公開    ###### 3. Create Vision API request  ```json= { "requests": [ { "image": { "source": { "gcsImageUri": "gs://my-bucket-name/sign.jpeg" } }, "features": [ { "type": "TEXT_DETECTION", "maxResults": 10 } ] } ] } ```  ###### 4. Call the Vision API's text detection method 在Cloud shell中,使用**curl** call the Vision API  ```shell= curl -s -X POST -H "Content-Type: application/json" --data-binary @ocr-request.json https://vision.googleapis.com/v1/images:annotate?key=${API_KEY} ``` 可以看到: [更正-my bucket name為project id]   由於輸出太長,可以輸出到文字檔內   ###### 5. Sending text from the image to the Translation API - 將圖片擷取的文字交由**Translation API**進行翻譯 - 建立translation-request.json  - 使用上一步驟輸出的文字擋xxxresponse.json  - Call the Translation API  ###### 6. Analyzing the image's text with the Natural Language API  ###### Summary: 上傳圖片到Cloud Storage, 使用`Vision API`擷取文字, 將擷取出來的文字存到文字檔(.json), 接著使用`Translation API`可以知道是哪國語言, 並翻譯成target(範例為en:english), 同樣地把翻譯好的結果存在文字檔, 建立`Natural Language API` 的request JSON檔, 將翻譯好的存檔輸入剛建的request, 再call api得每個word的分析(分類)。
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up