前提条件:创建已部署索引的批量视频仓库。
在控制台中搜索 Batch Video Warehouse 数据
控制台
打开 Gemini Enterprise Agent Platform Vision 信息中心的仓库标签页。
找到要搜索的索引端点,然后点击搜索资产。
您会看到一个视频列表(每个视频对应一个素材资源),以及顶部的搜索栏。您可以点击视频进行观看,也可以开始搜索视频。
如需开始搜索,请输入文字查询内容或上传图片作为搜索查询内容。您会在搜索结果页面的右侧看到一个视频片段列表,其中的每个视频片段都对应于媒体资源中的一个连续视频片段。 视频片段按与输入查询的相关性进行排名。
您可以使用搜索结果页面左侧的
Filters部分来优化搜索。每个过滤条件都包含一个数据架构键和您要搜索的注解值。指定过滤条件后,点击搜索以执行搜索。
使用命令行搜索 Batch Video Warehouse 数据
如需在语料库 (corpus) 中搜索视频 (assets),请在 searchIndexEndpoint
请求正文中填充您要查找的内容。
此类内容有多种不同的格式:
text_query或image_query:要搜索的查询。- 可选
criteria:用户提供的注释的过滤条件。
在以下示例中,假设有一个包含自然风光视频的语料库。如需检索与“海滩日落”相关且带有注解 "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"
}
]
}