必要條件:建立 Batch 影片倉庫,並部署索引。
在控制台中搜尋 Batch Video Warehouse 資料
控制台
開啟 Gemini Enterprise Agent Platform Vision 資訊主頁的「Warehouses」(倉庫) 分頁。
找出要搜尋的索引端點,然後按一下「搜尋資產」。
您會看到影片清單 (每部影片對應一項資產),以及頂端的搜尋列。你可以點選影片觀看,或開始搜尋影片。
如要開始搜尋,請輸入文字查詢,或上傳圖片做為搜尋查詢。搜尋結果頁面右側會列出短片,每個短片都對應到資產中的連續短片。短片會依與輸入查詢的關聯性排序。
您可以使用搜尋結果頁面左側的「
Filters」部分,縮小搜尋範圍。每項篩選條件都包含資料架構鍵和要搜尋的註解值。指定篩選條件後,按一下「Search」(搜尋) 即可執行搜尋。
使用指令列搜尋 Batch Video Warehouse 資料
如要搜尋語料庫 (corpus) 中的影片 (assets),請在 searchIndexEndpoint 要求主體中填入要尋找的內容。這類內容有幾種不同格式:
text_query或image_query:要搜尋的查詢。- 選用
criteria:使用者提供註解的篩選條件。
在以下範例中,假設語料庫包含自然風景影片。如要擷取與「sunset at beach」相關且標有 "state": "California" 註解的所有資產,請傳送下列要求:
REST 和指令列
使用任何要求資料之前,請先修改下列項目的值:
- REGIONALIZED_ENDPOINT:端點可能包含與
LOCATION_ID相符的前置字串,例如europe-west4-。進一步瞭解區域化端點。 - PROJECT_NUMBER:您的 Google Cloud專案編號。
- LOCATION_ID:使用 Agent Platform Vision 的區域。例如:
us-central1、europe-west4。查看可用區域。 - INDEX_ENDPOINT_ID:目標索引端點的 ID。
HTTP 方法和網址:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/indexEndpoints/INDEX_ENDPOINT_ID:searchIndexEndpoint
JSON 要求內文:
{
"text_query": "sunset at beach",
"criteria": [
{
"field": "state",
"text_array": {
"txt_values": [
"California"
]
}
}
]
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/indexEndpoints/INDEX_ENDPOINT_ID:searchIndexEndpoint"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/indexEndpoints/INDEX_ENDPOINT_ID:searchIndexEndpoint" | Select-Object -Expand Content
您應該會收到如下的 JSON 回覆:
{
"searchResultItems": [
{
"asset": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID_1"
},
{
"asset": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID_2"
}
]
}
如果您有海灘日落的圖片,也可以傳送下列要求 (輸入圖片為 Base64 編碼格式),將圖片做為搜尋查詢:
REST 和指令列
使用任何要求資料之前,請先修改下列項目的值:
- REGIONALIZED_ENDPOINT:端點可能包含與
LOCATION_ID相符的前置字串,例如europe-west4-。進一步瞭解區域化端點。 - PROJECT_NUMBER:您的 Google Cloud專案編號。
- LOCATION_ID:使用 Agent Platform Vision 的區域。例如:
us-central1、europe-west4。查看可用區域。 - INDEX_ENDPOINT_ID:目標索引端點的 ID。
HTTP 方法和網址:
POST https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/indexEndpoints/INDEX_ENDPOINT_ID:searchIndexEndpoint
JSON 要求內文:
{
"image_query": {
"input_image": "IMAGE_BYTES"
},
"criteria": [
{
"field": "state",
"text_array": {
"txt_values": [
"California"
]
}
}
]
}
如要傳送要求,請選擇以下其中一個選項:
curl
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/indexEndpoints/INDEX_ENDPOINT_ID:searchIndexEndpoint"
PowerShell
將要求主體儲存在名為 request.json 的檔案中,然後執行下列指令:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://warehouse-visionai.googleapis.com/v1/projects/PROJECT_NUMBER/locations/LOCATION_ID/indexEndpoints/INDEX_ENDPOINT_ID:searchIndexEndpoint" | Select-Object -Expand Content
您應該會收到如下的 JSON 回覆:
{
"searchResultItems": [
{
"asset": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID_1"
},
{
"asset": "projects/PROJECT_NUMBER/locations/LOCATION_ID/corpora/CORPUS_ID/assets/ASSET_ID_2"
}
]
}